worldorbit 3.0.7 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/browser/core/dist/atlas-edit.js +5 -1
  2. package/dist/browser/core/dist/atlas-validate.js +1 -1
  3. package/dist/browser/core/dist/draft-parse.js +14 -9
  4. package/dist/browser/core/dist/draft.d.ts +1 -0
  5. package/dist/browser/core/dist/draft.js +4 -2
  6. package/dist/browser/core/dist/format.js +5 -3
  7. package/dist/browser/core/dist/load.js +3 -2
  8. package/dist/browser/core/dist/normalize.js +36 -0
  9. package/dist/browser/core/dist/parse.js +54 -0
  10. package/dist/browser/core/dist/scene.js +1 -0
  11. package/dist/browser/core/dist/types.d.ts +21 -1
  12. package/dist/unpkg/core/dist/atlas-edit.js +5 -1
  13. package/dist/unpkg/core/dist/atlas-validate.js +1 -1
  14. package/dist/unpkg/core/dist/draft-parse.js +14 -9
  15. package/dist/unpkg/core/dist/draft.d.ts +1 -0
  16. package/dist/unpkg/core/dist/draft.js +4 -2
  17. package/dist/unpkg/core/dist/format.js +5 -3
  18. package/dist/unpkg/core/dist/load.js +3 -2
  19. package/dist/unpkg/core/dist/normalize.js +36 -0
  20. package/dist/unpkg/core/dist/parse.js +54 -0
  21. package/dist/unpkg/core/dist/scene.js +1 -0
  22. package/dist/unpkg/core/dist/types.d.ts +21 -1
  23. package/dist/unpkg/worldorbit-core.min.js +9 -9
  24. package/dist/unpkg/worldorbit-editor.min.js +206 -206
  25. package/dist/unpkg/worldorbit-markdown.min.js +19 -19
  26. package/dist/unpkg/worldorbit-viewer.min.js +203 -203
  27. package/dist/unpkg/worldorbit.js +112 -14
  28. package/dist/unpkg/worldorbit.min.js +191 -191
  29. package/package.json +1 -1
  30. package/packages/core/dist/atlas-edit.js +5 -1
  31. package/packages/core/dist/atlas-validate.js +1 -1
  32. package/packages/core/dist/draft-parse.js +14 -9
  33. package/packages/core/dist/draft.d.ts +1 -0
  34. package/packages/core/dist/draft.js +4 -2
  35. package/packages/core/dist/format.js +5 -3
  36. package/packages/core/dist/load.js +3 -2
  37. package/packages/core/dist/normalize.js +36 -0
  38. package/packages/core/dist/parse.js +54 -0
  39. package/packages/core/dist/scene.js +1 -0
  40. package/packages/core/dist/types.d.ts +21 -1
@@ -1,4 +1,4 @@
1
- "use strict";var WorldOrbitViewer=(()=>{var _u=Object.defineProperty;var ky=Object.getOwnPropertyDescriptor;var By=Object.getOwnPropertyNames;var zy=Object.prototype.hasOwnProperty;var Vy=(n,e)=>()=>(n&&(e=n(n=0)),e);var Jf=(n,e)=>{for(var t in e)_u(n,t,{get:e[t],enumerable:!0})},Hy=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of By(e))!zy.call(n,r)&&r!==t&&_u(n,r,{get:()=>e[r],enumerable:!(i=ky(e,r))||i.enumerable});return n};var Gy=n=>Hy(_u({},"__esModule",{value:!0}),n);var fy={};Jf(fy,{ACESFilmicToneMapping:()=>x0,AddEquation:()=>Ai,AddOperation:()=>m0,AdditiveAnimationBlendMode:()=>Nf,AdditiveBlending:()=>Rd,AgXToneMapping:()=>b0,AlphaFormat:()=>T0,AlwaysCompare:()=>W0,AlwaysDepth:()=>l0,AlwaysStencilFunc:()=>ah,AmbientLight:()=>Zc,AnimationAction:()=>au,AnimationClip:()=>vr,AnimationLoader:()=>Nh,AnimationMixer:()=>Qh,AnimationObjectGroup:()=>Kh,AnimationUtils:()=>aT,ArcCurve:()=>pc,ArrayCamera:()=>ec,ArrowHelper:()=>wf,AttachedBindMode:()=>Dd,Audio:()=>ru,AudioAnalyser:()=>Zh,AudioContext:()=>eo,AudioListener:()=>Yh,AudioLoader:()=>jh,AxesHelper:()=>Mf,BackSide:()=>jt,BasicDepthPacking:()=>N0,BasicShadowMap:()=>kb,BatchedMesh:()=>cc,Bone:()=>Ua,BooleanKeyframeTrack:()=>oi,Box2:()=>cf,Box3:()=>Dt,Box3Helper:()=>_f,BoxGeometry:()=>cr,BoxHelper:()=>xf,BufferAttribute:()=>tt,BufferGeometry:()=>Xe,BufferGeometryLoader:()=>nu,ByteType:()=>S0,Cache:()=>ei,Camera:()=>hs,CameraHelper:()=>vf,CanvasTexture:()=>Ph,CapsuleGeometry:()=>_c,CatmullRomCurve3:()=>mc,CineonToneMapping:()=>v0,CircleGeometry:()=>bc,ClampToEdgeWrapping:()=>gn,Clock:()=>iu,Color:()=>we,ColorKeyframeTrack:()=>Za,ColorManagement:()=>at,CompressedArrayTexture:()=>Ch,CompressedCubeTexture:()=>Rh,CompressedTexture:()=>gs,CompressedTextureLoader:()=>Fh,ConeGeometry:()=>wc,ConstantAlphaFactor:()=>s0,ConstantColorFactor:()=>i0,CubeCamera:()=>Kl,CubeReflectionMapping:()=>si,CubeRefractionMapping:()=>Ti,CubeTexture:()=>ur,CubeTextureLoader:()=>kh,CubeUVReflectionMapping:()=>xs,CubicBezierCurve:()=>Fa,CubicBezierCurve3:()=>gc,CubicInterpolant:()=>Gc,CullFaceBack:()=>Cd,CullFaceFront:()=>Vg,CullFaceFrontBack:()=>Fb,CullFaceNone:()=>zg,Curve:()=>an,CurvePath:()=>xc,CustomBlending:()=>Gg,CustomToneMapping:()=>_0,CylinderGeometry:()=>vs,Cylindrical:()=>lf,Data3DTexture:()=>Ta,DataArrayTexture:()=>cs,DataTexture:()=>On,DataTextureLoader:()=>Bh,DataUtils:()=>Ww,DecrementStencilOp:()=>qb,DecrementWrapStencilOp:()=>Jb,DefaultLoadingManager:()=>dy,DepthFormat:()=>ar,DepthStencilFormat:()=>os,DepthTexture:()=>Pa,DetachedBindMode:()=>M0,DirectionalLight:()=>qc,DirectionalLightHelper:()=>yf,DiscreteInterpolant:()=>$c,DisplayP3ColorSpace:()=>cu,DodecahedronGeometry:()=>Mc,DoubleSide:()=>Pn,DstAlphaFactor:()=>Kg,DstColorFactor:()=>e0,DynamicCopyUsage:()=>hw,DynamicDrawUsage:()=>aw,DynamicReadUsage:()=>cw,EdgesGeometry:()=>Sc,EllipseCurve:()=>ys,EqualCompare:()=>V0,EqualDepth:()=>u0,EqualStencilFunc:()=>tw,EquirectangularReflectionMapping:()=>pa,EquirectangularRefractionMapping:()=>ma,Euler:()=>rn,EventDispatcher:()=>En,ExtrudeGeometry:()=>Ac,FileLoader:()=>Tn,Float16BufferAttribute:()=>mh,Float32BufferAttribute:()=>Te,FloatType:()=>yn,Fog:()=>nc,FogExp2:()=>tc,FramebufferTexture:()=>Ih,FrontSide:()=>ri,Frustum:()=>dr,GLBufferAttribute:()=>rf,GLSL1:()=>pw,GLSL3:()=>oh,GreaterCompare:()=>H0,GreaterDepth:()=>h0,GreaterEqualCompare:()=>$0,GreaterEqualDepth:()=>d0,GreaterEqualStencilFunc:()=>sw,GreaterStencilFunc:()=>iw,GridHelper:()=>mf,Group:()=>Ei,HalfFloatType:()=>no,HemisphereLight:()=>jc,HemisphereLightHelper:()=>pf,IcosahedronGeometry:()=>Ec,ImageBitmapLoader:()=>Wh,ImageLoader:()=>xr,ImageUtils:()=>Zl,IncrementStencilOp:()=>Yb,IncrementWrapStencilOp:()=>Zb,InstancedBufferAttribute:()=>Ci,InstancedBufferGeometry:()=>tu,InstancedInterleavedBuffer:()=>nf,InstancedMesh:()=>lc,Int16BufferAttribute:()=>fh,Int32BufferAttribute:()=>ph,Int8BufferAttribute:()=>uh,IntType:()=>Cf,InterleavedBuffer:()=>ms,InterleavedBufferAttribute:()=>hr,Interpolant:()=>mr,InterpolateDiscrete:()=>va,InterpolateLinear:()=>xa,InterpolateSmooth:()=>Xl,InvertStencilOp:()=>Kb,KeepStencilOp:()=>Qi,KeyframeTrack:()=>on,LOD:()=>sc,LatheGeometry:()=>Ha,Layers:()=>us,LessCompare:()=>z0,LessDepth:()=>c0,LessEqualCompare:()=>Ff,LessEqualDepth:()=>fa,LessEqualStencilFunc:()=>nw,LessStencilFunc:()=>ew,Light:()=>kn,LightProbe:()=>Qc,Line:()=>Fn,Line3:()=>uf,LineBasicMaterial:()=>Ot,LineCurve:()=>ka,LineCurve3:()=>yc,LineDashedMaterial:()=>Hc,LineLoop:()=>hc,LineSegments:()=>vn,LinearDisplayP3ColorSpace:()=>io,LinearFilter:()=>bt,LinearInterpolant:()=>qa,LinearMipMapLinearFilter:()=>Hb,LinearMipMapNearestFilter:()=>Vb,LinearMipmapLinearFilter:()=>Ln,LinearMipmapNearestFilter:()=>la,LinearSRGBColorSpace:()=>ci,LinearToneMapping:()=>g0,LinearTransfer:()=>ba,Loader:()=>Ht,LoaderUtils:()=>Qa,LoadingManager:()=>Ja,LoopOnce:()=>D0,LoopPingPong:()=>U0,LoopRepeat:()=>O0,LuminanceAlphaFormat:()=>R0,LuminanceFormat:()=>C0,MOUSE:()=>Ub,Material:()=>Lt,MaterialLoader:()=>eu,MathUtils:()=>Pw,Matrix3:()=>Ve,Matrix4:()=>Ne,MaxEquation:()=>Xg,Mesh:()=>yt,MeshBasicMaterial:()=>Nn,MeshDepthMaterial:()=>La,MeshDistanceMaterial:()=>Da,MeshLambertMaterial:()=>zc,MeshMatcapMaterial:()=>Vc,MeshNormalMaterial:()=>Bc,MeshPhongMaterial:()=>Fc,MeshPhysicalMaterial:()=>Nc,MeshStandardMaterial:()=>Ya,MeshToonMaterial:()=>kc,MinEquation:()=>jg,MirroredRepeatWrapping:()=>ya,MixOperation:()=>p0,MultiplyBlending:()=>Ld,MultiplyOperation:()=>to,NearestFilter:()=>Rt,NearestMipMapLinearFilter:()=>zb,NearestMipMapNearestFilter:()=>Bb,NearestMipmapLinearFilter:()=>ts,NearestMipmapNearestFilter:()=>Tf,NeutralToneMapping:()=>w0,NeverCompare:()=>B0,NeverDepth:()=>o0,NeverStencilFunc:()=>Qb,NoBlending:()=>ti,NoColorSpace:()=>Zn,NoToneMapping:()=>ni,NormalAnimationBlendMode:()=>lu,NormalBlending:()=>sr,NotEqualCompare:()=>G0,NotEqualDepth:()=>f0,NotEqualStencilFunc:()=>rw,NumberKeyframeTrack:()=>gr,Object3D:()=>it,ObjectLoader:()=>$h,ObjectSpaceNormalMap:()=>k0,OctahedronGeometry:()=>ja,OneFactor:()=>qg,OneMinusConstantAlphaFactor:()=>a0,OneMinusConstantColorFactor:()=>r0,OneMinusDstAlphaFactor:()=>Qg,OneMinusDstColorFactor:()=>t0,OneMinusSrcAlphaFactor:()=>ql,OneMinusSrcColorFactor:()=>Jg,OrthographicCamera:()=>ps,P3Primaries:()=>Ma,PCFShadowMap:()=>Ef,PCFSoftShadowMap:()=>Hg,PMREMGenerator:()=>Ra,Path:()=>fr,PerspectiveCamera:()=>At,Plane:()=>Rn,PlaneGeometry:()=>fs,PlaneHelper:()=>bf,PointLight:()=>Yc,PointLightHelper:()=>ff,Points:()=>fc,PointsMaterial:()=>Na,PolarGridHelper:()=>gf,PolyhedronGeometry:()=>Ri,PositionalAudio:()=>qh,PropertyBinding:()=>st,PropertyMixer:()=>su,QuadraticBezierCurve:()=>Ba,QuadraticBezierCurve3:()=>za,Quaternion:()=>Vt,QuaternionKeyframeTrack:()=>Pi,QuaternionLinearInterpolant:()=>Wc,RED_GREEN_RGTC2_Format:()=>rh,RED_RGTC1_Format:()=>L0,REVISION:()=>Ob,RGBADepthPacking:()=>F0,RGBAFormat:()=>en,RGBAIntegerFormat:()=>Uf,RGBA_ASTC_10x10_Format:()=>Kd,RGBA_ASTC_10x5_Format:()=>qd,RGBA_ASTC_10x6_Format:()=>Zd,RGBA_ASTC_10x8_Format:()=>Jd,RGBA_ASTC_12x10_Format:()=>Qd,RGBA_ASTC_12x12_Format:()=>eh,RGBA_ASTC_4x4_Format:()=>Vd,RGBA_ASTC_5x4_Format:()=>Hd,RGBA_ASTC_5x5_Format:()=>Gd,RGBA_ASTC_6x5_Format:()=>$d,RGBA_ASTC_6x6_Format:()=>Wd,RGBA_ASTC_8x5_Format:()=>jd,RGBA_ASTC_8x6_Format:()=>Xd,RGBA_ASTC_8x8_Format:()=>Yd,RGBA_BPTC_Format:()=>jl,RGBA_ETC2_EAC_Format:()=>zd,RGBA_PVRTC_2BPPV1_Format:()=>Fd,RGBA_PVRTC_4BPPV1_Format:()=>Nd,RGBA_S3TC_DXT1_Format:()=>Gl,RGBA_S3TC_DXT3_Format:()=>$l,RGBA_S3TC_DXT5_Format:()=>Wl,RGBFormat:()=>I0,RGB_BPTC_SIGNED_Format:()=>th,RGB_BPTC_UNSIGNED_Format:()=>nh,RGB_ETC1_Format:()=>kd,RGB_ETC2_Format:()=>Bd,RGB_PVRTC_2BPPV1_Format:()=>Ud,RGB_PVRTC_4BPPV1_Format:()=>Od,RGB_S3TC_DXT1_Format:()=>Hl,RGFormat:()=>P0,RGIntegerFormat:()=>Of,RawShaderMaterial:()=>Uc,Ray:()=>Ii,Raycaster:()=>sf,Rec709Primaries:()=>wa,RectAreaLight:()=>Jc,RedFormat:()=>Lf,RedIntegerFormat:()=>Df,ReinhardToneMapping:()=>y0,RenderTarget:()=>Jl,RepeatWrapping:()=>ga,ReplaceStencilOp:()=>Xb,ReverseSubtractEquation:()=>Wg,RingGeometry:()=>Tc,SIGNED_RED_GREEN_RGTC2_Format:()=>sh,SIGNED_RED_RGTC1_Format:()=>ih,SRGBColorSpace:()=>mn,SRGBTransfer:()=>ut,Scene:()=>ic,ShaderChunk:()=>$e,ShaderLib:()=>An,ShaderMaterial:()=>sn,ShadowMaterial:()=>Oc,Shape:()=>ii,ShapeGeometry:()=>Ic,ShapePath:()=>Sf,ShapeUtils:()=>Un,ShortType:()=>A0,Skeleton:()=>oc,SkeletonHelper:()=>hf,SkinnedMesh:()=>ac,Source:()=>Kn,Sphere:()=>Pt,SphereGeometry:()=>Xa,Spherical:()=>of,SphericalHarmonics3:()=>Kc,SplineCurve:()=>Va,SpotLight:()=>Xc,SpotLightHelper:()=>df,Sprite:()=>rc,SpriteMaterial:()=>Oa,SrcAlphaFactor:()=>Yl,SrcAlphaSaturateFactor:()=>n0,SrcColorFactor:()=>Zg,StaticCopyUsage:()=>dw,StaticDrawUsage:()=>Sa,StaticReadUsage:()=>lw,StereoCamera:()=>Xh,StreamCopyUsage:()=>fw,StreamDrawUsage:()=>ow,StreamReadUsage:()=>uw,StringKeyframeTrack:()=>li,SubtractEquation:()=>$g,SubtractiveBlending:()=>Pd,TOUCH:()=>Nb,TangentSpaceNormalMap:()=>Li,TetrahedronGeometry:()=>Cc,Texture:()=>wt,TextureLoader:()=>zh,TorusGeometry:()=>Rc,TorusKnotGeometry:()=>Pc,Triangle:()=>Qn,TriangleFanDrawMode:()=>Wb,TriangleStripDrawMode:()=>$b,TrianglesDrawMode:()=>Gb,TubeGeometry:()=>Lc,UVMapping:()=>ou,Uint16BufferAttribute:()=>Ia,Uint32BufferAttribute:()=>Ca,Uint8BufferAttribute:()=>dh,Uint8ClampedBufferAttribute:()=>hh,Uniform:()=>ef,UniformsGroup:()=>tf,UniformsLib:()=>ye,UniformsUtils:()=>J0,UnsignedByteType:()=>ai,UnsignedInt248Type:()=>_s,UnsignedInt5999Type:()=>E0,UnsignedIntType:()=>lr,UnsignedShort4444Type:()=>Rf,UnsignedShort5551Type:()=>Pf,UnsignedShortType:()=>If,VSMShadowMap:()=>Cn,Vector2:()=>te,Vector3:()=>R,Vector4:()=>ot,VectorKeyframeTrack:()=>yr,VideoTexture:()=>Th,WebGL3DRenderTarget:()=>ch,WebGLArrayRenderTarget:()=>lh,WebGLCoordinateSystem:()=>Dn,WebGLCubeRenderTarget:()=>Ql,WebGLMultipleRenderTargets:()=>Af,WebGLRenderTarget:()=>nn,WebGLRenderer:()=>Sh,WebGLUtils:()=>ry,WebGPUCoordinateSystem:()=>Aa,WireframeGeometry:()=>Dc,WrapAroundEnding:()=>_a,ZeroCurvatureEnding:()=>nr,ZeroFactor:()=>Yg,ZeroSlopeEnding:()=>ir,ZeroStencilOp:()=>jb,createCanvasElement:()=>X0});function tn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(kt[n&255]+kt[n>>8&255]+kt[n>>16&255]+kt[n>>24&255]+"-"+kt[e&255]+kt[e>>8&255]+"-"+kt[e>>16&15|64]+kt[e>>24&255]+"-"+kt[t&63|128]+kt[t>>8&255]+"-"+kt[t>>16&255]+kt[t>>24&255]+kt[i&255]+kt[i>>8&255]+kt[i>>16&255]+kt[i>>24&255]).toLowerCase()}function gt(n,e,t){return Math.max(e,Math.min(t,n))}function kf(n,e){return(n%e+e)%e}function mw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function gw(n,e,t){return n!==e?(t-n)/(e-n):0}function ca(n,e,t){return(1-t)*n+t*e}function yw(n,e,t,i){return ca(n,e,1-Math.exp(-t*i))}function vw(n,e=1){return e-Math.abs(kf(n,e*2)-e)}function xw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function _w(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function bw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function ww(n,e){return n+Math.random()*(e-n)}function Mw(n){return n*(.5-Math.random())}function Sw(n){n!==void 0&&(lm=n);let e=lm+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Aw(n){return n*or}function Ew(n){return n*ls}function Tw(n){return(n&n-1)===0&&n!==0}function Iw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Cw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Rw(n,e,t,i,r){let s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),u=a((e+i)/2),d=s((e-i)/2),h=a((e-i)/2),f=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*u,l*d,l*h,o*c);break;case"YZY":n.set(l*h,o*u,l*d,o*c);break;case"ZXZ":n.set(l*d,l*h,o*u,o*c);break;case"XZX":n.set(o*u,l*m,l*f,o*c);break;case"YXY":n.set(l*f,o*u,l*m,o*c);break;case"ZYZ":n.set(l*m,l*f,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Wt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function He(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function j0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ns(n,e){return new Lw[n](e)}function Ea(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function X0(){let n=Ea("canvas");return n.style.display="block",n}function Y0(n){n in cm||(cm[n]=!0,console.warn(n))}function ss(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function ju(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Xu(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Zl.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function qu(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Hi.fromArray(n,s);let o=r.x*Math.abs(Hi.x)+r.y*Math.abs(Hi.y)+r.z*Math.abs(Hi.z),l=e.dot(Hi),c=t.dot(Hi),u=i.dot(Hi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}function sd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function $w(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}let s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Yt(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=gt(n,-65504,65504),Jn.floatView[0]=n;let e=Jn.uint32View[0],t=e>>23&511;return Jn.baseTable[t]+((e&8388607)>>Jn.shiftTable[t])}function aa(n){let e=n>>10;return Jn.uint32View[0]=Jn.mantissaTable[Jn.offsetTable[e]+(n&1023)]+Jn.exponentTable[e],Jn.floatView[0]}function Xw(n,e,t,i,r,s,a,o){let l;if(e.side===jt?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===ri,o),l===null)return null;hl.copy(o),hl.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(hl);return c<t.near||c>t.far?null:{distance:c,point:hl.clone(),object:n}}function fl(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,Gr),n.getVertexPosition(l,$r),n.getVertexPosition(c,Wr);let u=Xw(n,e,t,i,Gr,$r,Wr,dl);if(u){r&&(ll.fromBufferAttribute(r,o),cl.fromBufferAttribute(r,l),ul.fromBufferAttribute(r,c),u.uv=Qn.getInterpolation(dl,Gr,$r,Wr,ll,cl,ul,new te)),s&&(ll.fromBufferAttribute(s,o),cl.fromBufferAttribute(s,l),ul.fromBufferAttribute(s,c),u.uv1=Qn.getInterpolation(dl,Gr,$r,Wr,ll,cl,ul,new te)),a&&(Mm.fromBufferAttribute(a,o),Sm.fromBufferAttribute(a,l),Am.fromBufferAttribute(a,c),u.normal=Qn.getInterpolation(dl,Gr,$r,Wr,Mm,Sm,Am,new R),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a:o,b:l,c,normal:new R,materialIndex:0};Qn.getNormal(Gr,$r,Wr,d.normal),u.face=d}return u}function ds(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function $t(n){let e={};for(let t=0;t<n.length;t++){let i=ds(n[t]);for(let r in i)e[r]=i[r]}return e}function Yw(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Z0(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:at.workingColorSpace}function K0(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function Qw(n){let e=new WeakMap;function t(o,l){let c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){let u=l.array,d=l._updateRange,h=l.updateRanges;if(n.bindBuffer(c,o),d.count===-1&&h.length===0&&n.bufferSubData(c,0,u),h.length!==0){for(let f=0,m=h.length;f<m;f++){let y=h[f];n.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(c,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isGLBufferAttribute){let u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}o.isInterleavedBufferAttribute&&(o=o.data);let c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}function O1(n,e,t,i,r,s,a){let o=new we(0),l=s===!0?0:1,c,u,d=null,h=0,f=null;function m(x){let v=x.isScene===!0?x.background:null;return v&&v.isTexture&&(v=(x.backgroundBlurriness>0?t:e).get(v)),v}function y(x){let v=!1,b=m(x);b===null?p(o,l):b&&b.isColor&&(p(b,1),v=!0);let L=n.xr.getEnvironmentBlendMode();L==="additive"?i.buffers.color.setClear(0,0,0,1,a):L==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(x,v){let b=m(v);b&&(b.isCubeTexture||b.mapping===xs)?(u===void 0&&(u=new yt(new cr(1,1,1),new sn({name:"BackgroundCubeMaterial",uniforms:ds(An.backgroundCube.uniforms),vertexShader:An.backgroundCube.vertexShader,fragmentShader:An.backgroundCube.fragmentShader,side:jt,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(L,A,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Wi.copy(v.backgroundRotation),Wi.x*=-1,Wi.y*=-1,Wi.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Wi.y*=-1,Wi.z*=-1),u.material.uniforms.envMap.value=b,u.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(D1.makeRotationFromEuler(Wi)),u.material.toneMapped=at.getTransfer(b.colorSpace)!==ut,(d!==b||h!==b.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=b,h=b.version,f=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new yt(new fs(2,2),new sn({name:"BackgroundMaterial",uniforms:ds(An.background.uniforms),vertexShader:An.background.vertexShader,fragmentShader:An.background.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=at.getTransfer(b.colorSpace)!==ut,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(d!==b||h!==b.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,d=b,h=b.version,f=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function p(x,v){x.getRGB(ml,Z0(n)),i.buffers.color.setClear(ml.r,ml.g,ml.b,v,a)}return{getClearColor:function(){return o},setClearColor:function(x,v=1){o.set(x),l=v,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,p(o,l)},render:y,addToRenderList:g}}function U1(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,a=!1;function o(w,T,U,I,B){let W=!1,F=d(I,U,T);s!==F&&(s=F,c(s.object)),W=f(w,I,U,B),W&&m(w,I,U,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,b(w,T,U,I),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(w){return n.bindVertexArray(w)}function u(w){return n.deleteVertexArray(w)}function d(w,T,U){let I=U.wireframe===!0,B=i[w.id];B===void 0&&(B={},i[w.id]=B);let W=B[T.id];W===void 0&&(W={},B[T.id]=W);let F=W[I];return F===void 0&&(F=h(l()),W[I]=F),F}function h(w){let T=[],U=[],I=[];for(let B=0;B<t;B++)T[B]=0,U[B]=0,I[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:T,enabledAttributes:U,attributeDivisors:I,object:w,attributes:{},index:null}}function f(w,T,U,I){let B=s.attributes,W=T.attributes,F=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let se=B[k],ve=W[k];if(ve===void 0&&(k==="instanceMatrix"&&w.instanceMatrix&&(ve=w.instanceMatrix),k==="instanceColor"&&w.instanceColor&&(ve=w.instanceColor)),se===void 0||se.attribute!==ve||ve&&se.data!==ve.data)return!0;F++}return s.attributesNum!==F||s.index!==I}function m(w,T,U,I){let B={},W=T.attributes,F=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let se=W[k];se===void 0&&(k==="instanceMatrix"&&w.instanceMatrix&&(se=w.instanceMatrix),k==="instanceColor"&&w.instanceColor&&(se=w.instanceColor));let ve={};ve.attribute=se,se&&se.data&&(ve.data=se.data),B[k]=ve,F++}s.attributes=B,s.attributesNum=F,s.index=I}function y(){let w=s.newAttributes;for(let T=0,U=w.length;T<U;T++)w[T]=0}function g(w){p(w,0)}function p(w,T){let U=s.newAttributes,I=s.enabledAttributes,B=s.attributeDivisors;U[w]=1,I[w]===0&&(n.enableVertexAttribArray(w),I[w]=1),B[w]!==T&&(n.vertexAttribDivisor(w,T),B[w]=T)}function x(){let w=s.newAttributes,T=s.enabledAttributes;for(let U=0,I=T.length;U<I;U++)T[U]!==w[U]&&(n.disableVertexAttribArray(U),T[U]=0)}function v(w,T,U,I,B,W,F){F===!0?n.vertexAttribIPointer(w,T,U,B,W):n.vertexAttribPointer(w,T,U,I,B,W)}function b(w,T,U,I){y();let B=I.attributes,W=U.getAttributes(),F=T.defaultAttributeValues;for(let X in W){let k=W[X];if(k.location>=0){let re=B[X];if(re===void 0&&(X==="instanceMatrix"&&w.instanceMatrix&&(re=w.instanceMatrix),X==="instanceColor"&&w.instanceColor&&(re=w.instanceColor)),re!==void 0){let se=re.normalized,ve=re.itemSize,Le=e.get(re);if(Le===void 0)continue;let Je=Le.buffer,Z=Le.type,q=Le.bytesPerElement,pe=Z===n.INT||Z===n.UNSIGNED_INT||re.gpuType===Cf;if(re.isInterleavedBufferAttribute){let ne=re.data,Fe=ne.stride,_e=re.offset;if(ne.isInstancedInterleavedBuffer){for(let H=0;H<k.locationSize;H++)p(k.location+H,ne.meshPerAttribute);w.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let H=0;H<k.locationSize;H++)g(k.location+H);n.bindBuffer(n.ARRAY_BUFFER,Je);for(let H=0;H<k.locationSize;H++)v(k.location+H,ve/k.locationSize,Z,se,Fe*q,(_e+ve/k.locationSize*H)*q,pe)}else{if(re.isInstancedBufferAttribute){for(let ne=0;ne<k.locationSize;ne++)p(k.location+ne,re.meshPerAttribute);w.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let ne=0;ne<k.locationSize;ne++)g(k.location+ne);n.bindBuffer(n.ARRAY_BUFFER,Je);for(let ne=0;ne<k.locationSize;ne++)v(k.location+ne,ve/k.locationSize,Z,se,ve*q,ve/k.locationSize*ne*q,pe)}}else if(F!==void 0){let se=F[X];if(se!==void 0)switch(se.length){case 2:n.vertexAttrib2fv(k.location,se);break;case 3:n.vertexAttrib3fv(k.location,se);break;case 4:n.vertexAttrib4fv(k.location,se);break;default:n.vertexAttrib1fv(k.location,se)}}}}x()}function L(){D();for(let w in i){let T=i[w];for(let U in T){let I=T[U];for(let B in I)u(I[B].object),delete I[B];delete T[U]}delete i[w]}}function A(w){if(i[w.id]===void 0)return;let T=i[w.id];for(let U in T){let I=T[U];for(let B in I)u(I[B].object),delete I[B];delete T[U]}delete i[w.id]}function E(w){for(let T in i){let U=i[T];if(U[w.id]===void 0)continue;let I=U[w.id];for(let B in I)u(I[B].object),delete I[B];delete U[w.id]}}function D(){M(),a=!0,s!==r&&(s=r,c(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:D,resetDefaultState:M,dispose:L,releaseStatesOfGeometry:A,releaseStatesOfProgram:E,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function N1(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,d){d!==0&&(n.drawArraysInstanced(i,c,u,d),t.update(u,i,d))}function o(c,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(c[f],u[f]);else{h.multiDrawArraysWEBGL(i,c,0,u,0,d);let f=0;for(let m=0;m<d;m++)f+=u[m];t.update(f,i,1)}}function l(c,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<c.length;m++)a(c[m],u[m],h[m]);else{f.multiDrawArraysInstancedWEBGL(i,c,0,u,0,h,0,d);let m=0;for(let y=0;y<d;y++)m+=u[y];for(let y=0;y<h.length;y++)t.update(m,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function F1(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){return!(A!==en&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){let E=A===no&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==ai&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==yn&&!E)}function l(A){if(A==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),p=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),x=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=f>0,L=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:m,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:p,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:b,maxSamples:L}}function k1(n){let e=this,t=null,i=0,r=!1,s=!1,a=new Rn,o=new Ve,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let m=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,p=n.get(d);if(!r||m===null||m.length===0||s&&!g)s?u(null):c();else{let x=s?0:i,v=x*4,b=p.clippingState||null;l.value=b,b=u(m,h,v,f);for(let L=0;L!==v;++L)b[L]=t[L];p.clippingState=b,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,m){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=l.value,m!==!0||g===null){let p=f+y*4,x=h.matrixWorldInverse;o.getNormalMatrix(x),(g===null||g.length<p)&&(g=new Float32Array(p));for(let v=0,b=f;v!==y;++v,b+=4)a.copy(d[v]).applyMatrix4(x,o),a.normal.toArray(g,b),g[b+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function B1(n){let e=new WeakMap;function t(a,o){return o===pa?a.mapping=si:o===ma&&(a.mapping=Ti),a}function i(a){if(a&&a.isTexture){let o=a.mapping;if(o===pa||o===ma)if(e.has(a)){let l=e.get(a).texture;return t(l,a.mapping)}else{let l=a.image;if(l&&l.height>0){let c=new Ql(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){let o=a.target;o.removeEventListener("dispose",r);let l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function z1(n){let e=[],t=[],i=[],r=n,s=n-is+1+Im.length;for(let a=0;a<s;a++){let o=Math.pow(2,r);t.push(o);let l=1/o;a>n-is?l=Im[a-n+is-1]:a===0&&(l=0),i.push(l);let c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,m=6,y=3,g=2,p=1,x=new Float32Array(y*m*f),v=new Float32Array(g*m*f),b=new Float32Array(p*m*f);for(let A=0;A<f;A++){let E=A%3*2/3-1,D=A>2?0:-1,M=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];x.set(M,y*m*A),v.set(h,g*m*A);let w=[A,A,A,A,A,A];b.set(w,p*m*A)}let L=new Xe;L.setAttribute("position",new tt(x,y)),L.setAttribute("uv",new tt(v,g)),L.setAttribute("faceIndex",new tt(b,p)),e.push(L),r>is&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Pm(n,e,t){let i=new nn(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function gl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function V1(n,e,t){let i=new Float32Array(tr),r=new R(0,1,0);return new sn({name:"SphericalGaussianBlur",defines:{n:tr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Bf(),fragmentShader:`
1
+ "use strict";var WorldOrbitViewer=(()=>{var _u=Object.defineProperty;var By=Object.getOwnPropertyDescriptor;var zy=Object.getOwnPropertyNames;var Vy=Object.prototype.hasOwnProperty;var Hy=(n,e)=>()=>(n&&(e=n(n=0)),e);var Jf=(n,e)=>{for(var t in e)_u(n,t,{get:e[t],enumerable:!0})},Gy=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of zy(e))!Vy.call(n,r)&&r!==t&&_u(n,r,{get:()=>e[r],enumerable:!(i=By(e,r))||i.enumerable});return n};var $y=n=>Gy(_u({},"__esModule",{value:!0}),n);var py={};Jf(py,{ACESFilmicToneMapping:()=>_0,AddEquation:()=>Ai,AddOperation:()=>g0,AdditiveAnimationBlendMode:()=>Nf,AdditiveBlending:()=>Rd,AgXToneMapping:()=>w0,AlphaFormat:()=>I0,AlwaysCompare:()=>j0,AlwaysDepth:()=>c0,AlwaysStencilFunc:()=>oh,AmbientLight:()=>Zc,AnimationAction:()=>ou,AnimationClip:()=>vr,AnimationLoader:()=>Nh,AnimationMixer:()=>Qh,AnimationObjectGroup:()=>Kh,AnimationUtils:()=>cT,ArcCurve:()=>pc,ArrayCamera:()=>ec,ArrowHelper:()=>wf,AttachedBindMode:()=>Dd,Audio:()=>ru,AudioAnalyser:()=>Zh,AudioContext:()=>ta,AudioListener:()=>Yh,AudioLoader:()=>jh,AxesHelper:()=>Mf,BackSide:()=>jt,BasicDepthPacking:()=>F0,BasicShadowMap:()=>Vb,BatchedMesh:()=>cc,Bone:()=>No,BooleanKeyframeTrack:()=>ai,Box2:()=>cf,Box3:()=>Dt,Box3Helper:()=>_f,BoxGeometry:()=>cr,BoxHelper:()=>xf,BufferAttribute:()=>tt,BufferGeometry:()=>Xe,BufferGeometryLoader:()=>nu,ByteType:()=>A0,Cache:()=>ei,Camera:()=>hs,CameraHelper:()=>vf,CanvasTexture:()=>Ph,CapsuleGeometry:()=>_c,CatmullRomCurve3:()=>mc,CineonToneMapping:()=>x0,CircleGeometry:()=>bc,ClampToEdgeWrapping:()=>gn,Clock:()=>iu,Color:()=>we,ColorKeyframeTrack:()=>Jo,ColorManagement:()=>ot,CompressedArrayTexture:()=>Ch,CompressedCubeTexture:()=>Rh,CompressedTexture:()=>gs,CompressedTextureLoader:()=>Fh,ConeGeometry:()=>wc,ConstantAlphaFactor:()=>o0,ConstantColorFactor:()=>r0,CubeCamera:()=>Kl,CubeReflectionMapping:()=>si,CubeRefractionMapping:()=>Ti,CubeTexture:()=>ur,CubeTextureLoader:()=>kh,CubeUVReflectionMapping:()=>xs,CubicBezierCurve:()=>ko,CubicBezierCurve3:()=>gc,CubicInterpolant:()=>Gc,CullFaceBack:()=>Cd,CullFaceFront:()=>Hg,CullFaceFrontBack:()=>zb,CullFaceNone:()=>Vg,Curve:()=>on,CurvePath:()=>xc,CustomBlending:()=>$g,CustomToneMapping:()=>b0,CylinderGeometry:()=>vs,Cylindrical:()=>lf,Data3DTexture:()=>Io,DataArrayTexture:()=>cs,DataTexture:()=>On,DataTextureLoader:()=>Bh,DataUtils:()=>Yw,DecrementStencilOp:()=>Kb,DecrementWrapStencilOp:()=>ew,DefaultLoadingManager:()=>hy,DepthFormat:()=>or,DepthStencilFormat:()=>as,DepthTexture:()=>Lo,DetachedBindMode:()=>S0,DirectionalLight:()=>qc,DirectionalLightHelper:()=>yf,DiscreteInterpolant:()=>$c,DisplayP3ColorSpace:()=>cu,DodecahedronGeometry:()=>Mc,DoubleSide:()=>Pn,DstAlphaFactor:()=>Qg,DstColorFactor:()=>t0,DynamicCopyUsage:()=>mw,DynamicDrawUsage:()=>cw,DynamicReadUsage:()=>hw,EdgesGeometry:()=>Sc,EllipseCurve:()=>ys,EqualCompare:()=>H0,EqualDepth:()=>d0,EqualStencilFunc:()=>rw,EquirectangularReflectionMapping:()=>mo,EquirectangularRefractionMapping:()=>go,Euler:()=>rn,EventDispatcher:()=>En,ExtrudeGeometry:()=>Ac,FileLoader:()=>Tn,Float16BufferAttribute:()=>mh,Float32BufferAttribute:()=>Te,FloatType:()=>yn,Fog:()=>nc,FogExp2:()=>tc,FramebufferTexture:()=>Ih,FrontSide:()=>ri,Frustum:()=>dr,GLBufferAttribute:()=>rf,GLSL1:()=>yw,GLSL3:()=>ah,GreaterCompare:()=>G0,GreaterDepth:()=>f0,GreaterEqualCompare:()=>W0,GreaterEqualDepth:()=>h0,GreaterEqualStencilFunc:()=>lw,GreaterStencilFunc:()=>ow,GridHelper:()=>mf,Group:()=>Ei,HalfFloatType:()=>ia,HemisphereLight:()=>jc,HemisphereLightHelper:()=>pf,IcosahedronGeometry:()=>Ec,ImageBitmapLoader:()=>Wh,ImageLoader:()=>xr,ImageUtils:()=>Zl,IncrementStencilOp:()=>Jb,IncrementWrapStencilOp:()=>Qb,InstancedBufferAttribute:()=>Ci,InstancedBufferGeometry:()=>tu,InstancedInterleavedBuffer:()=>nf,InstancedMesh:()=>lc,Int16BufferAttribute:()=>fh,Int32BufferAttribute:()=>ph,Int8BufferAttribute:()=>uh,IntType:()=>Cf,InterleavedBuffer:()=>ms,InterleavedBufferAttribute:()=>hr,Interpolant:()=>mr,InterpolateDiscrete:()=>xo,InterpolateLinear:()=>_o,InterpolateSmooth:()=>Xl,InvertStencilOp:()=>tw,KeepStencilOp:()=>Qi,KeyframeTrack:()=>an,LOD:()=>sc,LatheGeometry:()=>Go,Layers:()=>us,LessCompare:()=>V0,LessDepth:()=>u0,LessEqualCompare:()=>Ff,LessEqualDepth:()=>po,LessEqualStencilFunc:()=>sw,LessStencilFunc:()=>iw,Light:()=>kn,LightProbe:()=>Qc,Line:()=>Fn,Line3:()=>uf,LineBasicMaterial:()=>Ot,LineCurve:()=>Bo,LineCurve3:()=>yc,LineDashedMaterial:()=>Hc,LineLoop:()=>hc,LineSegments:()=>vn,LinearDisplayP3ColorSpace:()=>ra,LinearFilter:()=>bt,LinearInterpolant:()=>Zo,LinearMipMapLinearFilter:()=>Wb,LinearMipMapNearestFilter:()=>$b,LinearMipmapLinearFilter:()=>Ln,LinearMipmapNearestFilter:()=>lo,LinearSRGBColorSpace:()=>ci,LinearToneMapping:()=>y0,LinearTransfer:()=>wo,Loader:()=>Ht,LoaderUtils:()=>ea,LoadingManager:()=>Ko,LoopOnce:()=>O0,LoopPingPong:()=>N0,LoopRepeat:()=>U0,LuminanceAlphaFormat:()=>P0,LuminanceFormat:()=>R0,MOUSE:()=>kb,Material:()=>Lt,MaterialLoader:()=>eu,MathUtils:()=>Ow,Matrix3:()=>Ve,Matrix4:()=>Ne,MaxEquation:()=>Yg,Mesh:()=>yt,MeshBasicMaterial:()=>Nn,MeshDepthMaterial:()=>Do,MeshDistanceMaterial:()=>Oo,MeshLambertMaterial:()=>zc,MeshMatcapMaterial:()=>Vc,MeshNormalMaterial:()=>Bc,MeshPhongMaterial:()=>Fc,MeshPhysicalMaterial:()=>Nc,MeshStandardMaterial:()=>qo,MeshToonMaterial:()=>kc,MinEquation:()=>Xg,MirroredRepeatWrapping:()=>vo,MixOperation:()=>m0,MultiplyBlending:()=>Ld,MultiplyOperation:()=>na,NearestFilter:()=>Rt,NearestMipMapLinearFilter:()=>Gb,NearestMipMapNearestFilter:()=>Hb,NearestMipmapLinearFilter:()=>ts,NearestMipmapNearestFilter:()=>Tf,NeutralToneMapping:()=>M0,NeverCompare:()=>z0,NeverDepth:()=>l0,NeverStencilFunc:()=>nw,NoBlending:()=>ti,NoColorSpace:()=>Zn,NoToneMapping:()=>ni,NormalAnimationBlendMode:()=>lu,NormalBlending:()=>sr,NotEqualCompare:()=>$0,NotEqualDepth:()=>p0,NotEqualStencilFunc:()=>aw,NumberKeyframeTrack:()=>gr,Object3D:()=>it,ObjectLoader:()=>$h,ObjectSpaceNormalMap:()=>B0,OctahedronGeometry:()=>Xo,OneFactor:()=>Zg,OneMinusConstantAlphaFactor:()=>a0,OneMinusConstantColorFactor:()=>s0,OneMinusDstAlphaFactor:()=>e0,OneMinusDstColorFactor:()=>n0,OneMinusSrcAlphaFactor:()=>ql,OneMinusSrcColorFactor:()=>Kg,OrthographicCamera:()=>ps,P3Primaries:()=>So,PCFShadowMap:()=>Ef,PCFSoftShadowMap:()=>Gg,PMREMGenerator:()=>Po,Path:()=>fr,PerspectiveCamera:()=>At,Plane:()=>Rn,PlaneGeometry:()=>fs,PlaneHelper:()=>bf,PointLight:()=>Yc,PointLightHelper:()=>ff,Points:()=>fc,PointsMaterial:()=>Fo,PolarGridHelper:()=>gf,PolyhedronGeometry:()=>Ri,PositionalAudio:()=>qh,PropertyBinding:()=>st,PropertyMixer:()=>su,QuadraticBezierCurve:()=>zo,QuadraticBezierCurve3:()=>Vo,Quaternion:()=>Vt,QuaternionKeyframeTrack:()=>Pi,QuaternionLinearInterpolant:()=>Wc,RED_GREEN_RGTC2_Format:()=>rh,RED_RGTC1_Format:()=>D0,REVISION:()=>Fb,RGBADepthPacking:()=>k0,RGBAFormat:()=>en,RGBAIntegerFormat:()=>Uf,RGBA_ASTC_10x10_Format:()=>Kd,RGBA_ASTC_10x5_Format:()=>qd,RGBA_ASTC_10x6_Format:()=>Zd,RGBA_ASTC_10x8_Format:()=>Jd,RGBA_ASTC_12x10_Format:()=>Qd,RGBA_ASTC_12x12_Format:()=>eh,RGBA_ASTC_4x4_Format:()=>Vd,RGBA_ASTC_5x4_Format:()=>Hd,RGBA_ASTC_5x5_Format:()=>Gd,RGBA_ASTC_6x5_Format:()=>$d,RGBA_ASTC_6x6_Format:()=>Wd,RGBA_ASTC_8x5_Format:()=>jd,RGBA_ASTC_8x6_Format:()=>Xd,RGBA_ASTC_8x8_Format:()=>Yd,RGBA_BPTC_Format:()=>jl,RGBA_ETC2_EAC_Format:()=>zd,RGBA_PVRTC_2BPPV1_Format:()=>Fd,RGBA_PVRTC_4BPPV1_Format:()=>Nd,RGBA_S3TC_DXT1_Format:()=>Gl,RGBA_S3TC_DXT3_Format:()=>$l,RGBA_S3TC_DXT5_Format:()=>Wl,RGBFormat:()=>C0,RGB_BPTC_SIGNED_Format:()=>th,RGB_BPTC_UNSIGNED_Format:()=>nh,RGB_ETC1_Format:()=>kd,RGB_ETC2_Format:()=>Bd,RGB_PVRTC_2BPPV1_Format:()=>Ud,RGB_PVRTC_4BPPV1_Format:()=>Od,RGB_S3TC_DXT1_Format:()=>Hl,RGFormat:()=>L0,RGIntegerFormat:()=>Of,RawShaderMaterial:()=>Uc,Ray:()=>Ii,Raycaster:()=>sf,Rec709Primaries:()=>Mo,RectAreaLight:()=>Jc,RedFormat:()=>Lf,RedIntegerFormat:()=>Df,ReinhardToneMapping:()=>v0,RenderTarget:()=>Jl,RepeatWrapping:()=>yo,ReplaceStencilOp:()=>Zb,ReverseSubtractEquation:()=>jg,RingGeometry:()=>Tc,SIGNED_RED_GREEN_RGTC2_Format:()=>sh,SIGNED_RED_RGTC1_Format:()=>ih,SRGBColorSpace:()=>mn,SRGBTransfer:()=>ut,Scene:()=>ic,ShaderChunk:()=>$e,ShaderLib:()=>An,ShaderMaterial:()=>sn,ShadowMaterial:()=>Oc,Shape:()=>ii,ShapeGeometry:()=>Ic,ShapePath:()=>Sf,ShapeUtils:()=>Un,ShortType:()=>E0,Skeleton:()=>ac,SkeletonHelper:()=>hf,SkinnedMesh:()=>oc,Source:()=>Kn,Sphere:()=>Pt,SphereGeometry:()=>Yo,Spherical:()=>af,SphericalHarmonics3:()=>Kc,SplineCurve:()=>Ho,SpotLight:()=>Xc,SpotLightHelper:()=>df,Sprite:()=>rc,SpriteMaterial:()=>Uo,SrcAlphaFactor:()=>Yl,SrcAlphaSaturateFactor:()=>i0,SrcColorFactor:()=>Jg,StaticCopyUsage:()=>pw,StaticDrawUsage:()=>Ao,StaticReadUsage:()=>dw,StereoCamera:()=>Xh,StreamCopyUsage:()=>gw,StreamDrawUsage:()=>uw,StreamReadUsage:()=>fw,StringKeyframeTrack:()=>li,SubtractEquation:()=>Wg,SubtractiveBlending:()=>Pd,TOUCH:()=>Bb,TangentSpaceNormalMap:()=>Li,TetrahedronGeometry:()=>Cc,Texture:()=>wt,TextureLoader:()=>zh,TorusGeometry:()=>Rc,TorusKnotGeometry:()=>Pc,Triangle:()=>Qn,TriangleFanDrawMode:()=>Yb,TriangleStripDrawMode:()=>Xb,TrianglesDrawMode:()=>jb,TubeGeometry:()=>Lc,UVMapping:()=>au,Uint16BufferAttribute:()=>Co,Uint32BufferAttribute:()=>Ro,Uint8BufferAttribute:()=>dh,Uint8ClampedBufferAttribute:()=>hh,Uniform:()=>ef,UniformsGroup:()=>tf,UniformsLib:()=>ye,UniformsUtils:()=>K0,UnsignedByteType:()=>oi,UnsignedInt248Type:()=>_s,UnsignedInt5999Type:()=>T0,UnsignedIntType:()=>lr,UnsignedShort4444Type:()=>Rf,UnsignedShort5551Type:()=>Pf,UnsignedShortType:()=>If,VSMShadowMap:()=>Cn,Vector2:()=>te,Vector3:()=>R,Vector4:()=>at,VectorKeyframeTrack:()=>yr,VideoTexture:()=>Th,WebGL3DRenderTarget:()=>ch,WebGLArrayRenderTarget:()=>lh,WebGLCoordinateSystem:()=>Dn,WebGLCubeRenderTarget:()=>Ql,WebGLMultipleRenderTargets:()=>Af,WebGLRenderTarget:()=>nn,WebGLRenderer:()=>Sh,WebGLUtils:()=>sy,WebGPUCoordinateSystem:()=>Eo,WireframeGeometry:()=>Dc,WrapAroundEnding:()=>bo,ZeroCurvatureEnding:()=>nr,ZeroFactor:()=>qg,ZeroSlopeEnding:()=>ir,ZeroStencilOp:()=>qb,createCanvasElement:()=>Y0});function tn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(kt[n&255]+kt[n>>8&255]+kt[n>>16&255]+kt[n>>24&255]+"-"+kt[e&255]+kt[e>>8&255]+"-"+kt[e>>16&15|64]+kt[e>>24&255]+"-"+kt[t&63|128]+kt[t>>8&255]+"-"+kt[t>>16&255]+kt[t>>24&255]+kt[i&255]+kt[i>>8&255]+kt[i>>16&255]+kt[i>>24&255]).toLowerCase()}function gt(n,e,t){return Math.max(e,Math.min(t,n))}function kf(n,e){return(n%e+e)%e}function vw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function xw(n,e,t){return n!==e?(t-n)/(e-n):0}function co(n,e,t){return(1-t)*n+t*e}function _w(n,e,t,i){return co(n,e,1-Math.exp(-t*i))}function bw(n,e=1){return e-Math.abs(kf(n,e*2)-e)}function ww(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Mw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Sw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Aw(n,e){return n+Math.random()*(e-n)}function Ew(n){return n*(.5-Math.random())}function Tw(n){n!==void 0&&(cm=n);let e=cm+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Iw(n){return n*ar}function Cw(n){return n*ls}function Rw(n){return(n&n-1)===0&&n!==0}function Pw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Lw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Dw(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+i)/2),u=o((e+i)/2),d=s((e-i)/2),h=o((e-i)/2),f=s((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":n.set(a*u,l*d,l*h,a*c);break;case"YZY":n.set(l*h,a*u,l*d,a*c);break;case"ZXZ":n.set(l*d,l*h,a*u,a*c);break;case"XZX":n.set(a*u,l*p,l*f,a*c);break;case"YXY":n.set(l*f,a*u,l*p,a*c);break;case"ZYZ":n.set(l*p,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Wt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function He(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function X0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ns(n,e){return new Uw[n](e)}function To(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Y0(){let n=To("canvas");return n.style.display="block",n}function q0(n){n in um||(um[n]=!0,console.warn(n))}function ss(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function ju(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Xu(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Zl.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function qu(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Hi.fromArray(n,s);let a=r.x*Math.abs(Hi.x)+r.y*Math.abs(Hi.y)+r.z*Math.abs(Hi.z),l=e.dot(Hi),c=t.dot(Hi),u=i.dot(Hi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}function sd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function Xw(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function Yt(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=gt(n,-65504,65504),Jn.floatView[0]=n;let e=Jn.uint32View[0],t=e>>23&511;return Jn.baseTable[t]+((e&8388607)>>Jn.shiftTable[t])}function oo(n){let e=n>>10;return Jn.uint32View[0]=Jn.mantissaTable[Jn.offsetTable[e]+(n&1023)]+Jn.exponentTable[e],Jn.floatView[0]}function Zw(n,e,t,i,r,s,o,a){let l;if(e.side===jt?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===ri,a),l===null)return null;hl.copy(a),hl.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(hl);return c<t.near||c>t.far?null:{distance:c,point:hl.clone(),object:n}}function fl(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Gr),n.getVertexPosition(l,$r),n.getVertexPosition(c,Wr);let u=Zw(n,e,t,i,Gr,$r,Wr,dl);if(u){r&&(ll.fromBufferAttribute(r,a),cl.fromBufferAttribute(r,l),ul.fromBufferAttribute(r,c),u.uv=Qn.getInterpolation(dl,Gr,$r,Wr,ll,cl,ul,new te)),s&&(ll.fromBufferAttribute(s,a),cl.fromBufferAttribute(s,l),ul.fromBufferAttribute(s,c),u.uv1=Qn.getInterpolation(dl,Gr,$r,Wr,ll,cl,ul,new te)),o&&(Sm.fromBufferAttribute(o,a),Am.fromBufferAttribute(o,l),Em.fromBufferAttribute(o,c),u.normal=Qn.getInterpolation(dl,Gr,$r,Wr,Sm,Am,Em,new R),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new R,materialIndex:0};Qn.getNormal(Gr,$r,Wr,d.normal),u.face=d}return u}function ds(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function $t(n){let e={};for(let t=0;t<n.length;t++){let i=ds(n[t]);for(let r in i)e[r]=i[r]}return e}function Jw(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function J0(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ot.workingColorSpace}function Q0(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function nM(n){let e=new WeakMap;function t(a,l){let c=a.array,u=a.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),a.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,l,c){let u=l.array,d=l._updateRange,h=l.updateRanges;if(n.bindBuffer(c,a),d.count===-1&&h.length===0&&n.bufferSubData(c,0,u),h.length!==0){for(let f=0,p=h.length;f<p;f++){let y=h[f];n.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(c,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),l.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.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.");i(c.buffer,a,l),c.version=a.version}}return{get:r,remove:s,update:o}}function F1(n,e,t,i,r,s,o){let a=new we(0),l=s===!0?0:1,c,u,d=null,h=0,f=null;function p(x){let v=x.isScene===!0?x.background:null;return v&&v.isTexture&&(v=(x.backgroundBlurriness>0?t:e).get(v)),v}function y(x){let v=!1,b=p(x);b===null?m(a,l):b&&b.isColor&&(m(b,1),v=!0);let L=n.xr.getEnvironmentBlendMode();L==="additive"?i.buffers.color.setClear(0,0,0,1,o):L==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(x,v){let b=p(v);b&&(b.isCubeTexture||b.mapping===xs)?(u===void 0&&(u=new yt(new cr(1,1,1),new sn({name:"BackgroundCubeMaterial",uniforms:ds(An.backgroundCube.uniforms),vertexShader:An.backgroundCube.vertexShader,fragmentShader:An.backgroundCube.fragmentShader,side:jt,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(L,A,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Wi.copy(v.backgroundRotation),Wi.x*=-1,Wi.y*=-1,Wi.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Wi.y*=-1,Wi.z*=-1),u.material.uniforms.envMap.value=b,u.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(N1.makeRotationFromEuler(Wi)),u.material.toneMapped=ot.getTransfer(b.colorSpace)!==ut,(d!==b||h!==b.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=b,h=b.version,f=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new yt(new fs(2,2),new sn({name:"BackgroundMaterial",uniforms:ds(An.background.uniforms),vertexShader:An.background.vertexShader,fragmentShader:An.background.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=ot.getTransfer(b.colorSpace)!==ut,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(d!==b||h!==b.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,d=b,h=b.version,f=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function m(x,v){x.getRGB(ml,J0(n)),i.buffers.color.setClear(ml.r,ml.g,ml.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),l=v,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,m(a,l)},render:y,addToRenderList:g}}function k1(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(w,T,U,I,B){let W=!1,F=d(I,U,T);s!==F&&(s=F,c(s.object)),W=f(w,I,U,B),W&&p(w,I,U,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,b(w,T,U,I),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(w){return n.bindVertexArray(w)}function u(w){return n.deleteVertexArray(w)}function d(w,T,U){let I=U.wireframe===!0,B=i[w.id];B===void 0&&(B={},i[w.id]=B);let W=B[T.id];W===void 0&&(W={},B[T.id]=W);let F=W[I];return F===void 0&&(F=h(l()),W[I]=F),F}function h(w){let T=[],U=[],I=[];for(let B=0;B<t;B++)T[B]=0,U[B]=0,I[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:T,enabledAttributes:U,attributeDivisors:I,object:w,attributes:{},index:null}}function f(w,T,U,I){let B=s.attributes,W=T.attributes,F=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let se=B[k],ve=W[k];if(ve===void 0&&(k==="instanceMatrix"&&w.instanceMatrix&&(ve=w.instanceMatrix),k==="instanceColor"&&w.instanceColor&&(ve=w.instanceColor)),se===void 0||se.attribute!==ve||ve&&se.data!==ve.data)return!0;F++}return s.attributesNum!==F||s.index!==I}function p(w,T,U,I){let B={},W=T.attributes,F=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let se=W[k];se===void 0&&(k==="instanceMatrix"&&w.instanceMatrix&&(se=w.instanceMatrix),k==="instanceColor"&&w.instanceColor&&(se=w.instanceColor));let ve={};ve.attribute=se,se&&se.data&&(ve.data=se.data),B[k]=ve,F++}s.attributes=B,s.attributesNum=F,s.index=I}function y(){let w=s.newAttributes;for(let T=0,U=w.length;T<U;T++)w[T]=0}function g(w){m(w,0)}function m(w,T){let U=s.newAttributes,I=s.enabledAttributes,B=s.attributeDivisors;U[w]=1,I[w]===0&&(n.enableVertexAttribArray(w),I[w]=1),B[w]!==T&&(n.vertexAttribDivisor(w,T),B[w]=T)}function x(){let w=s.newAttributes,T=s.enabledAttributes;for(let U=0,I=T.length;U<I;U++)T[U]!==w[U]&&(n.disableVertexAttribArray(U),T[U]=0)}function v(w,T,U,I,B,W,F){F===!0?n.vertexAttribIPointer(w,T,U,B,W):n.vertexAttribPointer(w,T,U,I,B,W)}function b(w,T,U,I){y();let B=I.attributes,W=U.getAttributes(),F=T.defaultAttributeValues;for(let X in W){let k=W[X];if(k.location>=0){let re=B[X];if(re===void 0&&(X==="instanceMatrix"&&w.instanceMatrix&&(re=w.instanceMatrix),X==="instanceColor"&&w.instanceColor&&(re=w.instanceColor)),re!==void 0){let se=re.normalized,ve=re.itemSize,Le=e.get(re);if(Le===void 0)continue;let Je=Le.buffer,Z=Le.type,q=Le.bytesPerElement,pe=Z===n.INT||Z===n.UNSIGNED_INT||re.gpuType===Cf;if(re.isInterleavedBufferAttribute){let ne=re.data,Fe=ne.stride,_e=re.offset;if(ne.isInstancedInterleavedBuffer){for(let H=0;H<k.locationSize;H++)m(k.location+H,ne.meshPerAttribute);w.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let H=0;H<k.locationSize;H++)g(k.location+H);n.bindBuffer(n.ARRAY_BUFFER,Je);for(let H=0;H<k.locationSize;H++)v(k.location+H,ve/k.locationSize,Z,se,Fe*q,(_e+ve/k.locationSize*H)*q,pe)}else{if(re.isInstancedBufferAttribute){for(let ne=0;ne<k.locationSize;ne++)m(k.location+ne,re.meshPerAttribute);w.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let ne=0;ne<k.locationSize;ne++)g(k.location+ne);n.bindBuffer(n.ARRAY_BUFFER,Je);for(let ne=0;ne<k.locationSize;ne++)v(k.location+ne,ve/k.locationSize,Z,se,ve*q,ve/k.locationSize*ne*q,pe)}}else if(F!==void 0){let se=F[X];if(se!==void 0)switch(se.length){case 2:n.vertexAttrib2fv(k.location,se);break;case 3:n.vertexAttrib3fv(k.location,se);break;case 4:n.vertexAttrib4fv(k.location,se);break;default:n.vertexAttrib1fv(k.location,se)}}}}x()}function L(){D();for(let w in i){let T=i[w];for(let U in T){let I=T[U];for(let B in I)u(I[B].object),delete I[B];delete T[U]}delete i[w]}}function A(w){if(i[w.id]===void 0)return;let T=i[w.id];for(let U in T){let I=T[U];for(let B in I)u(I[B].object),delete I[B];delete T[U]}delete i[w.id]}function E(w){for(let T in i){let U=i[T];if(U[w.id]===void 0)continue;let I=U[w.id];for(let B in I)u(I[B].object),delete I[B];delete U[w.id]}}function D(){M(),o=!0,s!==r&&(s=r,c(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:D,resetDefaultState:M,dispose:L,releaseStatesOfGeometry:A,releaseStatesOfProgram:E,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function B1(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function o(c,u,d){d!==0&&(n.drawArraysInstanced(i,c,u,d),t.update(u,i,d))}function a(c,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(c[f],u[f]);else{h.multiDrawArraysWEBGL(i,c,0,u,0,d);let f=0;for(let p=0;p<d;p++)f+=u[p];t.update(f,i,1)}}function l(c,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<c.length;p++)o(c[p],u[p],h[p]);else{f.multiDrawArraysInstancedWEBGL(i,c,0,u,0,h,0,d);let p=0;for(let y=0;y<d;y++)p+=u[y];for(let y=0;y<h.length;y++)t.update(p,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function z1(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){return!(A!==en&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let E=A===ia&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==oi&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==yn&&!E)}function l(A){if(A==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),m=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),x=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=f>0,L=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:m,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:b,maxSamples:L}}function V1(n){let e=this,t=null,i=0,r=!1,s=!1,o=new Rn,a=new Ve,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let p=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,m=n.get(d);if(!r||p===null||p.length===0||s&&!g)s?u(null):c();else{let x=s?0:i,v=x*4,b=m.clippingState||null;l.value=b,b=u(p,h,v,f);for(let L=0;L!==v;++L)b[L]=t[L];m.clippingState=b,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=l.value,p!==!0||g===null){let m=f+y*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,b=f;v!==y;++v,b+=4)o.copy(d[v]).applyMatrix4(x,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function H1(n){let e=new WeakMap;function t(o,a){return a===mo?o.mapping=si:a===go&&(o.mapping=Ti),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===mo||a===go)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new Ql(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",r),t(c.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function G1(n){let e=[],t=[],i=[],r=n,s=n-is+1+Cm.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let l=1/a;o>n-is?l=Cm[o-n+is-1]:o===0&&(l=0),i.push(l);let c=1/(a-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,y=3,g=2,m=1,x=new Float32Array(y*p*f),v=new Float32Array(g*p*f),b=new Float32Array(m*p*f);for(let A=0;A<f;A++){let E=A%3*2/3-1,D=A>2?0:-1,M=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];x.set(M,y*p*A),v.set(h,g*p*A);let w=[A,A,A,A,A,A];b.set(w,m*p*A)}let L=new Xe;L.setAttribute("position",new tt(x,y)),L.setAttribute("uv",new tt(v,g)),L.setAttribute("faceIndex",new tt(b,m)),e.push(L),r>is&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Lm(n,e,t){let i=new nn(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function gl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function $1(n,e,t){let i=new Float32Array(tr),r=new R(0,1,0);return new sn({name:"SphericalGaussianBlur",defines:{n:tr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Bf(),fragmentShader:`
2
2
 
3
3
  precision mediump float;
4
4
  precision mediump int;
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  }
61
- `,blending:ti,depthTest:!1,depthWrite:!1})}function Lm(){return new sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Bf(),fragmentShader:`
61
+ `,blending:ti,depthTest:!1,depthWrite:!1})}function Dm(){return new sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Bf(),fragmentShader:`
62
62
 
63
63
  precision mediump float;
64
64
  precision mediump int;
@@ -77,7 +77,7 @@
77
77
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
78
78
 
79
79
  }
80
- `,blending:ti,depthTest:!1,depthWrite:!1})}function Dm(){return new sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Bf(),fragmentShader:`
80
+ `,blending:ti,depthTest:!1,depthWrite:!1})}function Om(){return new sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Bf(),fragmentShader:`
81
81
 
82
82
  precision mediump float;
83
83
  precision mediump int;
@@ -148,15 +148,15 @@
148
148
  gl_Position = vec4( position, 1.0 );
149
149
 
150
150
  }
151
- `}function H1(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){let l=o.mapping,c=l===pa||l===ma,u=l===si||l===Ti;if(c||u){let d=e.get(o),h=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==h)return t===null&&(t=new Ra(n)),d=c?t.fromEquirectangular(o,d):t.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),d.texture;if(d!==void 0)return d.texture;{let f=o.image;return c&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new Ra(n)),d=c?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",s),d.texture):null}}}return o}function r(o){let l=0,c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){let l=o.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function G1(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function $1(n,e,t,i){let r={},s=new WeakMap;function a(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let m in h.attributes)e.remove(h.attributes[m]);for(let m in h.morphAttributes){let y=h.morphAttributes[m];for(let g=0,p=y.length;g<p;g++)e.remove(y[g])}h.removeEventListener("dispose",a),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(d,h){return r[h.id]===!0||(h.addEventListener("dispose",a),r[h.id]=!0,t.memory.geometries++),h}function l(d){let h=d.attributes;for(let m in h)e.update(h[m],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let m in f){let y=f[m];for(let g=0,p=y.length;g<p;g++)e.update(y[g],n.ARRAY_BUFFER)}}function c(d){let h=[],f=d.index,m=d.attributes.position,y=0;if(f!==null){let x=f.array;y=f.version;for(let v=0,b=x.length;v<b;v+=3){let L=x[v+0],A=x[v+1],E=x[v+2];h.push(L,A,A,E,E,L)}}else if(m!==void 0){let x=m.array;y=m.version;for(let v=0,b=x.length/3-1;v<b;v+=3){let L=v+0,A=v+1,E=v+2;h.push(L,A,A,E,E,L)}}else return;let g=new(j0(h)?Ca:Ia)(h,1);g.version=y;let p=s.get(d);p&&e.remove(p),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:u}}function W1(n,e,t){let i;function r(h){i=h}let s,a;function o(h){s=h.type,a=h.bytesPerElement}function l(h,f){n.drawElements(i,f,s,h*a),t.update(f,i,1)}function c(h,f,m){m!==0&&(n.drawElementsInstanced(i,f,s,h*a,m),t.update(f,i,m))}function u(h,f,m){if(m===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<m;g++)this.render(h[g]/a,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,m);let g=0;for(let p=0;p<m;p++)g+=f[p];t.update(g,i,1)}}function d(h,f,m,y){if(m===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let p=0;p<h.length;p++)c(h[p]/a,f[p],y[p]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,m);let p=0;for(let x=0;x<m;x++)p+=f[x];for(let x=0;x<y.length;x++)t.update(p,i,y[x])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function j1(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function X1(n,e,t){let i=new WeakMap,r=new ot;function s(a,o,l){let c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(o);if(h===void 0||h.count!==d){let w=function(){D.dispose(),i.delete(o),o.removeEventListener("dispose",w)};var f=w;h!==void 0&&h.texture.dispose();let m=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],v=o.morphAttributes.color||[],b=0;m===!0&&(b=1),y===!0&&(b=2),g===!0&&(b=3);let L=o.attributes.position.count*b,A=1;L>e.maxTextureSize&&(A=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);let E=new Float32Array(L*A*4*d),D=new cs(E,L,A,d);D.type=yn,D.needsUpdate=!0;let M=b*4;for(let T=0;T<d;T++){let U=p[T],I=x[T],B=v[T],W=L*A*4*T;for(let F=0;F<U.count;F++){let X=F*M;m===!0&&(r.fromBufferAttribute(U,F),E[W+X+0]=r.x,E[W+X+1]=r.y,E[W+X+2]=r.z,E[W+X+3]=0),y===!0&&(r.fromBufferAttribute(I,F),E[W+X+4]=r.x,E[W+X+5]=r.y,E[W+X+6]=r.z,E[W+X+7]=0),g===!0&&(r.fromBufferAttribute(B,F),E[W+X+8]=r.x,E[W+X+9]=r.y,E[W+X+10]=r.z,E[W+X+11]=B.itemSize===4?r.w:1)}}h={count:d,texture:D,size:new te(L,A)},i.set(o,h),o.addEventListener("dispose",w)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let m=0;for(let g=0;g<c.length;g++)m+=c[g];let y=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(n,"morphTargetBaseInfluence",y),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function Y1(n,e,t,i){let r=new WeakMap;function s(l){let c=i.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==c&&(e.update(d),r.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){let h=l.skeleton;r.get(h)!==c&&(h.update(),r.set(h,c))}return d}function a(){r=new WeakMap}function o(l){let c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}function bs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Om[r];if(s===void 0&&(s=new Float32Array(r),Om[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function Et(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Tt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function uu(n,e){let t=Um[e];t===void 0&&(t=new Int32Array(e),Um[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function q1(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Z1(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2fv(this.addr,e),Tt(t,e)}}function J1(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Et(t,e))return;n.uniform3fv(this.addr,e),Tt(t,e)}}function K1(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4fv(this.addr,e),Tt(t,e)}}function Q1(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;km.set(i),n.uniformMatrix2fv(this.addr,!1,km),Tt(t,i)}}function eA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;Fm.set(i),n.uniformMatrix3fv(this.addr,!1,Fm),Tt(t,i)}}function tA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;Nm.set(i),n.uniformMatrix4fv(this.addr,!1,Nm),Tt(t,i)}}function nA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function iA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2iv(this.addr,e),Tt(t,e)}}function rA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;n.uniform3iv(this.addr,e),Tt(t,e)}}function sA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4iv(this.addr,e),Tt(t,e)}}function aA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function oA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2uiv(this.addr,e),Tt(t,e)}}function lA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;n.uniform3uiv(this.addr,e),Tt(t,e)}}function cA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4uiv(this.addr,e),Tt(t,e)}}function uA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?ey:Q0;t.setTexture2D(e||s,r)}function dA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||ny,r)}function hA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||iy,r)}function fA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||ty,r)}function pA(n){switch(n){case 5126:return q1;case 35664:return Z1;case 35665:return J1;case 35666:return K1;case 35674:return Q1;case 35675:return eA;case 35676:return tA;case 5124:case 35670:return nA;case 35667:case 35671:return iA;case 35668:case 35672:return rA;case 35669:case 35673:return sA;case 5125:return aA;case 36294:return oA;case 36295:return lA;case 36296:return cA;case 35678:case 36198:case 36298:case 36306:case 35682:return uA;case 35679:case 36299:case 36307:return dA;case 35680:case 36300:case 36308:case 36293:return hA;case 36289:case 36303:case 36311:case 36292:return fA}}function mA(n,e){n.uniform1fv(this.addr,e)}function gA(n,e){let t=bs(e,this.size,2);n.uniform2fv(this.addr,t)}function yA(n,e){let t=bs(e,this.size,3);n.uniform3fv(this.addr,t)}function vA(n,e){let t=bs(e,this.size,4);n.uniform4fv(this.addr,t)}function xA(n,e){let t=bs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function _A(n,e){let t=bs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function bA(n,e){let t=bs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function wA(n,e){n.uniform1iv(this.addr,e)}function MA(n,e){n.uniform2iv(this.addr,e)}function SA(n,e){n.uniform3iv(this.addr,e)}function AA(n,e){n.uniform4iv(this.addr,e)}function EA(n,e){n.uniform1uiv(this.addr,e)}function TA(n,e){n.uniform2uiv(this.addr,e)}function IA(n,e){n.uniform3uiv(this.addr,e)}function CA(n,e){n.uniform4uiv(this.addr,e)}function RA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Q0,s[a])}function PA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||ny,s[a])}function LA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||iy,s[a])}function DA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||ty,s[a])}function OA(n){switch(n){case 5126:return mA;case 35664:return gA;case 35665:return yA;case 35666:return vA;case 35674:return xA;case 35675:return _A;case 35676:return bA;case 5124:case 35670:return wA;case 35667:case 35671:return MA;case 35668:case 35672:return SA;case 35669:case 35673:return AA;case 5125:return EA;case 36294:return TA;case 36295:return IA;case 36296:return CA;case 35678:case 36198:case 36298:case 36306:case 35682:return RA;case 35679:case 36299:case 36307:return PA;case 35680:case 36300:case 36308:case 36293:return LA;case 36289:case 36303:case 36311:case 36292:return DA}}function Bm(n,e){n.seq.push(e),n.map[e.id]=e}function UA(n,e,t){let i=n.name,r=i.length;for(pd.lastIndex=0;;){let s=pd.exec(i),a=pd.lastIndex,o=s[1],l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Bm(t,c===void 0?new gh(o,n,e):new yh(o,n,e));break}else{let d=t.map[o];d===void 0&&(d=new vh(o),Bm(t,d)),t=d}}}function zm(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function kA(n,e){let t=n.split(`
152
- `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){let o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
153
- `)}function BA(n){let e=at.getPrimaries(at.workingColorSpace),t=at.getPrimaries(n),i;switch(e===t?i="":e===Ma&&t===wa?i="LinearDisplayP3ToLinearSRGB":e===wa&&t===Ma&&(i="LinearSRGBToLinearDisplayP3"),n){case ci:case io:return[i,"LinearTransferOETF"];case mn:case cu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function Vm(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let a=parseInt(s[1]);return t.toUpperCase()+`
151
+ `}function W1(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===mo||l===go,u=l===si||l===Ti;if(c||u){let d=e.get(a),h=d!==void 0?d.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new Po(n)),d=c?t.fromEquirectangular(a,d):t.fromCubemap(a,d),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),d.texture;if(d!==void 0)return d.texture;{let f=a.image;return c&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new Po(n)),d=c?t.fromEquirectangular(a):t.fromCubemap(a),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),a.addEventListener("dispose",s),d.texture):null}}}return a}function r(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function j1(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function X1(n,e,t,i){let r={},s=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let p in h.attributes)e.remove(h.attributes[p]);for(let p in h.morphAttributes){let y=h.morphAttributes[p];for(let g=0,m=y.length;g<m;g++)e.remove(y[g])}h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return r[h.id]===!0||(h.addEventListener("dispose",o),r[h.id]=!0,t.memory.geometries++),h}function l(d){let h=d.attributes;for(let p in h)e.update(h[p],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let p in f){let y=f[p];for(let g=0,m=y.length;g<m;g++)e.update(y[g],n.ARRAY_BUFFER)}}function c(d){let h=[],f=d.index,p=d.attributes.position,y=0;if(f!==null){let x=f.array;y=f.version;for(let v=0,b=x.length;v<b;v+=3){let L=x[v+0],A=x[v+1],E=x[v+2];h.push(L,A,A,E,E,L)}}else if(p!==void 0){let x=p.array;y=p.version;for(let v=0,b=x.length/3-1;v<b;v+=3){let L=v+0,A=v+1,E=v+2;h.push(L,A,A,E,E,L)}}else return;let g=new(X0(h)?Ro:Co)(h,1);g.version=y;let m=s.get(d);m&&e.remove(m),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&c(d)}else c(d);return s.get(d)}return{get:a,update:l,getWireframeAttribute:u}}function Y1(n,e,t){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function l(h,f){n.drawElements(i,f,s,h*o),t.update(f,i,1)}function c(h,f,p){p!==0&&(n.drawElementsInstanced(i,f,s,h*o,p),t.update(f,i,p))}function u(h,f,p){if(p===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<p;g++)this.render(h[g]/o,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];t.update(g,i,1)}}function d(h,f,p,y){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<h.length;m++)c(h[m]/o,f[m],y[m]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,p);let m=0;for(let x=0;x<p;x++)m+=f[x];for(let x=0;x<y.length;x++)t.update(m,i,y[x])}}this.setMode=r,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function q1(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function Z1(n,e,t){let i=new WeakMap,r=new at;function s(o,a,l){let c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let w=function(){D.dispose(),i.delete(a),a.removeEventListener("dispose",w)};var f=w;h!==void 0&&h.texture.dispose();let p=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],x=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],b=0;p===!0&&(b=1),y===!0&&(b=2),g===!0&&(b=3);let L=a.attributes.position.count*b,A=1;L>e.maxTextureSize&&(A=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);let E=new Float32Array(L*A*4*d),D=new cs(E,L,A,d);D.type=yn,D.needsUpdate=!0;let M=b*4;for(let T=0;T<d;T++){let U=m[T],I=x[T],B=v[T],W=L*A*4*T;for(let F=0;F<U.count;F++){let X=F*M;p===!0&&(r.fromBufferAttribute(U,F),E[W+X+0]=r.x,E[W+X+1]=r.y,E[W+X+2]=r.z,E[W+X+3]=0),y===!0&&(r.fromBufferAttribute(I,F),E[W+X+4]=r.x,E[W+X+5]=r.y,E[W+X+6]=r.z,E[W+X+7]=0),g===!0&&(r.fromBufferAttribute(B,F),E[W+X+8]=r.x,E[W+X+9]=r.y,E[W+X+10]=r.z,E[W+X+11]=B.itemSize===4?r.w:1)}}h={count:d,texture:D,size:new te(L,A)},i.set(a,h),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let g=0;g<c.length;g++)p+=c[g];let y=a.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",y),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function J1(n,e,t,i){let r=new WeakMap;function s(l){let c=i.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==c&&(e.update(d),r.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){let h=l.skeleton;r.get(h)!==c&&(h.update(),r.set(h,c))}return d}function o(){r=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}function bs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Um[r];if(s===void 0&&(s=new Float32Array(r),Um[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Et(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Tt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function uu(n,e){let t=Nm[e];t===void 0&&(t=new Int32Array(e),Nm[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function K1(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Q1(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2fv(this.addr,e),Tt(t,e)}}function eA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Et(t,e))return;n.uniform3fv(this.addr,e),Tt(t,e)}}function tA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4fv(this.addr,e),Tt(t,e)}}function nA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;Bm.set(i),n.uniformMatrix2fv(this.addr,!1,Bm),Tt(t,i)}}function iA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;km.set(i),n.uniformMatrix3fv(this.addr,!1,km),Tt(t,i)}}function rA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Et(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,i))return;Fm.set(i),n.uniformMatrix4fv(this.addr,!1,Fm),Tt(t,i)}}function sA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function oA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2iv(this.addr,e),Tt(t,e)}}function aA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;n.uniform3iv(this.addr,e),Tt(t,e)}}function lA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4iv(this.addr,e),Tt(t,e)}}function cA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function uA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;n.uniform2uiv(this.addr,e),Tt(t,e)}}function dA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;n.uniform3uiv(this.addr,e),Tt(t,e)}}function hA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Et(t,e))return;n.uniform4uiv(this.addr,e),Tt(t,e)}}function fA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?ty:ey;t.setTexture2D(e||s,r)}function pA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||iy,r)}function mA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||ry,r)}function gA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||ny,r)}function yA(n){switch(n){case 5126:return K1;case 35664:return Q1;case 35665:return eA;case 35666:return tA;case 35674:return nA;case 35675:return iA;case 35676:return rA;case 5124:case 35670:return sA;case 35667:case 35671:return oA;case 35668:case 35672:return aA;case 35669:case 35673:return lA;case 5125:return cA;case 36294:return uA;case 36295:return dA;case 36296:return hA;case 35678:case 36198:case 36298:case 36306:case 35682:return fA;case 35679:case 36299:case 36307:return pA;case 35680:case 36300:case 36308:case 36293:return mA;case 36289:case 36303:case 36311:case 36292:return gA}}function vA(n,e){n.uniform1fv(this.addr,e)}function xA(n,e){let t=bs(e,this.size,2);n.uniform2fv(this.addr,t)}function _A(n,e){let t=bs(e,this.size,3);n.uniform3fv(this.addr,t)}function bA(n,e){let t=bs(e,this.size,4);n.uniform4fv(this.addr,t)}function wA(n,e){let t=bs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function MA(n,e){let t=bs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function SA(n,e){let t=bs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function AA(n,e){n.uniform1iv(this.addr,e)}function EA(n,e){n.uniform2iv(this.addr,e)}function TA(n,e){n.uniform3iv(this.addr,e)}function IA(n,e){n.uniform4iv(this.addr,e)}function CA(n,e){n.uniform1uiv(this.addr,e)}function RA(n,e){n.uniform2uiv(this.addr,e)}function PA(n,e){n.uniform3uiv(this.addr,e)}function LA(n,e){n.uniform4uiv(this.addr,e)}function DA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||ey,s[o])}function OA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||iy,s[o])}function UA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||ry,s[o])}function NA(n,e,t){let i=this.cache,r=e.length,s=uu(t,r);Et(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||ny,s[o])}function FA(n){switch(n){case 5126:return vA;case 35664:return xA;case 35665:return _A;case 35666:return bA;case 35674:return wA;case 35675:return MA;case 35676:return SA;case 5124:case 35670:return AA;case 35667:case 35671:return EA;case 35668:case 35672:return TA;case 35669:case 35673:return IA;case 5125:return CA;case 36294:return RA;case 36295:return PA;case 36296:return LA;case 35678:case 36198:case 36298:case 36306:case 35682:return DA;case 35679:case 36299:case 36307:return OA;case 35680:case 36300:case 36308:case 36293:return UA;case 36289:case 36303:case 36311:case 36292:return NA}}function zm(n,e){n.seq.push(e),n.map[e.id]=e}function kA(n,e,t){let i=n.name,r=i.length;for(pd.lastIndex=0;;){let s=pd.exec(i),o=pd.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){zm(t,c===void 0?new gh(a,n,e):new yh(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new vh(a),zm(t,d)),t=d}}}function Vm(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function VA(n,e){let t=n.split(`
152
+ `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
153
+ `)}function HA(n){let e=ot.getPrimaries(ot.workingColorSpace),t=ot.getPrimaries(n),i;switch(e===t?i="":e===So&&t===Mo?i="LinearDisplayP3ToLinearSRGB":e===Mo&&t===So&&(i="LinearSRGBToLinearDisplayP3"),n){case ci:case ra:return[i,"LinearTransferOETF"];case mn:case cu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function Hm(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
154
154
 
155
155
  `+r+`
156
156
 
157
- `+kA(n.getShaderSource(e),a)}else return r}function zA(n,e){let t=BA(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function VA(n,e){let t;switch(e){case g0:t="Linear";break;case y0:t="Reinhard";break;case v0:t="OptimizedCineon";break;case x0:t="ACESFilmic";break;case b0:t="AgX";break;case w0:t="Neutral";break;case _0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function HA(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(oa).join(`
158
- `)}function GA(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
159
- `)}function $A(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),a=s.name,o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function oa(n){return n!==""}function Hm(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Gm(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function xh(n){return n.replace(WA,XA)}function XA(n,e){let t=$e[e];if(t===void 0){let i=jA.get(e);if(i!==void 0)t=$e[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return xh(t)}function $m(n){return n.replace(YA,qA)}function qA(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Wm(n){let e=`precision ${n.precision} float;
157
+ `+VA(n.getShaderSource(e),o)}else return r}function GA(n,e){let t=HA(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function $A(n,e){let t;switch(e){case y0:t="Linear";break;case v0:t="Reinhard";break;case x0:t="OptimizedCineon";break;case _0:t="ACESFilmic";break;case w0:t="AgX";break;case M0:t="Neutral";break;case b0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function WA(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ao).join(`
158
+ `)}function jA(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
159
+ `)}function XA(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),o=s.name,a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function ao(n){return n!==""}function Gm(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function $m(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function xh(n){return n.replace(YA,ZA)}function ZA(n,e){let t=$e[e];if(t===void 0){let i=qA.get(e);if(i!==void 0)t=$e[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return xh(t)}function Wm(n){return n.replace(JA,KA)}function KA(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function jm(n){let e=`precision ${n.precision} float;
160
160
  precision ${n.precision} int;
161
161
  precision ${n.precision} sampler2D;
162
162
  precision ${n.precision} samplerCube;
@@ -176,32 +176,32 @@
176
176
  `;return n.precision==="highp"?e+=`
177
177
  #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
178
178
  #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
179
- #define LOW_PRECISION`),e}function ZA(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Ef?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Hg?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Cn&&(e="SHADOWMAP_TYPE_VSM"),e}function JA(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case si:case Ti:e="ENVMAP_TYPE_CUBE";break;case xs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function KA(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Ti&&(e="ENVMAP_MODE_REFRACTION"),e}function QA(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case to:e="ENVMAP_BLENDING_MULTIPLY";break;case p0:e="ENVMAP_BLENDING_MIX";break;case m0:e="ENVMAP_BLENDING_ADD";break}return e}function eE(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function tE(n,e,t,i){let r=n.getContext(),s=t.defines,a=t.vertexShader,o=t.fragmentShader,l=ZA(t),c=JA(t),u=KA(t),d=QA(t),h=eE(t),f=HA(t),m=GA(s),y=r.createProgram(),g,p,x=t.glslVersion?"#version "+t.glslVersion+`
180
- `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(oa).join(`
179
+ #define LOW_PRECISION`),e}function QA(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Ef?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Gg?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Cn&&(e="SHADOWMAP_TYPE_VSM"),e}function eE(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case si:case Ti:e="ENVMAP_TYPE_CUBE";break;case xs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function tE(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Ti&&(e="ENVMAP_MODE_REFRACTION"),e}function nE(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case na:e="ENVMAP_BLENDING_MULTIPLY";break;case m0:e="ENVMAP_BLENDING_MIX";break;case g0:e="ENVMAP_BLENDING_ADD";break}return e}function iE(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function rE(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=QA(t),c=eE(t),u=tE(t),d=nE(t),h=iE(t),f=WA(t),p=jA(s),y=r.createProgram(),g,m,x=t.glslVersion?"#version "+t.glslVersion+`
180
+ `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(ao).join(`
181
181
  `),g.length>0&&(g+=`
182
- `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(oa).join(`
183
- `),p.length>0&&(p+=`
184
- `)):(g=[Wm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
185
- `].filter(oa).join(`
186
- `),p=[Wm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ni?"#define TONE_MAPPING":"",t.toneMapping!==ni?$e.tonemapping_pars_fragment:"",t.toneMapping!==ni?VA("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,zA("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
187
- `].filter(oa).join(`
188
- `)),a=xh(a),a=Hm(a,t),a=Gm(a,t),o=xh(o),o=Hm(o,t),o=Gm(o,t),a=$m(a),o=$m(o),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
182
+ `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(ao).join(`
183
+ `),m.length>0&&(m+=`
184
+ `)):(g=[jm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
185
+ `].filter(ao).join(`
186
+ `),m=[jm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ni?"#define TONE_MAPPING":"",t.toneMapping!==ni?$e.tonemapping_pars_fragment:"",t.toneMapping!==ni?$A("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,GA("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
187
+ `].filter(ao).join(`
188
+ `)),o=xh(o),o=Gm(o,t),o=$m(o,t),a=xh(a),a=Gm(a,t),a=$m(a,t),o=Wm(o),a=Wm(a),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
189
189
  `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
190
190
  `)+`
191
- `+g,p=["#define varying in",t.glslVersion===oh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===oh?"":"#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(`
191
+ `+g,m=["#define varying in",t.glslVersion===ah?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ah?"":"#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(`
192
192
  `)+`
193
- `+p);let v=x+g+a,b=x+p+o,L=zm(r,r.VERTEX_SHADER,v),A=zm(r,r.FRAGMENT_SHADER,b);r.attachShader(y,L),r.attachShader(y,A),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function E(T){if(n.debug.checkShaderErrors){let U=r.getProgramInfoLog(y).trim(),I=r.getShaderInfoLog(L).trim(),B=r.getShaderInfoLog(A).trim(),W=!0,F=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(W=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,L,A);else{let X=Vm(r,L,"vertex"),k=Vm(r,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
193
+ `+m);let v=x+g+o,b=x+m+a,L=Vm(r,r.VERTEX_SHADER,v),A=Vm(r,r.FRAGMENT_SHADER,b);r.attachShader(y,L),r.attachShader(y,A),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function E(T){if(n.debug.checkShaderErrors){let U=r.getProgramInfoLog(y).trim(),I=r.getShaderInfoLog(L).trim(),B=r.getShaderInfoLog(A).trim(),W=!0,F=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(W=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,L,A);else{let X=Hm(r,L,"vertex"),k=Hm(r,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
194
194
 
195
195
  Material Name: `+T.name+`
196
196
  Material Type: `+T.type+`
197
197
 
198
198
  Program Info Log: `+U+`
199
199
  `+X+`
200
- `+k)}else U!==""?console.warn("THREE.WebGLProgram: Program Info Log:",U):(I===""||B==="")&&(F=!1);F&&(T.diagnostics={runnable:W,programLog:U,vertexShader:{log:I,prefix:g},fragmentShader:{log:B,prefix:p}})}r.deleteShader(L),r.deleteShader(A),D=new as(r,y),M=$A(r,y)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let M;this.getAttributes=function(){return M===void 0&&E(this),M};let w=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return w===!1&&(w=r.getProgramParameter(y,NA)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=FA++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=L,this.fragmentShader=A,this}function iE(n,e,t,i,r,s,a){let o=new us,l=new _h,c=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,w,T,U,I){let B=U.fog,W=I.geometry,F=M.isMeshStandardMaterial?U.environment:null,X=(M.isMeshStandardMaterial?t:e).get(M.envMap||F),k=X&&X.mapping===xs?X.image.height:null,re=m[M.type];M.precision!==null&&(f=r.getMaxPrecision(M.precision),f!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",f,"instead."));let se=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,ve=se!==void 0?se.length:0,Le=0;W.morphAttributes.position!==void 0&&(Le=1),W.morphAttributes.normal!==void 0&&(Le=2),W.morphAttributes.color!==void 0&&(Le=3);let Je,Z,q,pe;if(re){let et=An[re];Je=et.vertexShader,Z=et.fragmentShader}else Je=M.vertexShader,Z=M.fragmentShader,l.update(M),q=l.getVertexShaderID(M),pe=l.getFragmentShaderID(M);let ne=n.getRenderTarget(),Fe=I.isInstancedMesh===!0,_e=I.isBatchedMesh===!0,H=!!M.map,Ue=!!M.matcap,J=!!X,ce=!!M.aoMap,K=!!M.lightMap,de=!!M.bumpMap,le=!!M.normalMap,he=!!M.displacementMap,Ae=!!M.emissiveMap,P=!!M.metalnessMap,S=!!M.roughnessMap,j=M.anisotropy>0,ee=M.clearcoat>0,ae=M.dispersion>0,ie=M.iridescence>0,Ce=M.sheen>0,me=M.transmission>0,ge=j&&!!M.anisotropyMap,ke=ee&&!!M.clearcoatMap,fe=ee&&!!M.clearcoatNormalMap,Re=ee&&!!M.clearcoatRoughnessMap,We=ie&&!!M.iridescenceMap,Pe=ie&&!!M.iridescenceThicknessMap,Me=Ce&&!!M.sheenColorMap,De=Ce&&!!M.sheenRoughnessMap,qe=!!M.specularMap,ht=!!M.specularColorMap,Ge=!!M.specularIntensityMap,z=me&&!!M.transmissionMap,oe=me&&!!M.thicknessMap,Q=!!M.gradientMap,xe=!!M.alphaMap,be=M.alphaTest>0,Se=!!M.alphaHash,Ke=!!M.extensions,lt=ni;M.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(lt=n.toneMapping);let ft={shaderID:re,shaderType:M.type,shaderName:M.name,vertexShader:Je,fragmentShader:Z,defines:M.defines,customVertexShaderID:q,customFragmentShaderID:pe,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:f,batching:_e,instancing:Fe,instancingColor:Fe&&I.instanceColor!==null,instancingMorph:Fe&&I.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ne===null?n.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:ci,alphaToCoverage:!!M.alphaToCoverage,map:H,matcap:Ue,envMap:J,envMapMode:J&&X.mapping,envMapCubeUVHeight:k,aoMap:ce,lightMap:K,bumpMap:de,normalMap:le,displacementMap:h&&he,emissiveMap:Ae,normalMapObjectSpace:le&&M.normalMapType===k0,normalMapTangentSpace:le&&M.normalMapType===Li,metalnessMap:P,roughnessMap:S,anisotropy:j,anisotropyMap:ge,clearcoat:ee,clearcoatMap:ke,clearcoatNormalMap:fe,clearcoatRoughnessMap:Re,dispersion:ae,iridescence:ie,iridescenceMap:We,iridescenceThicknessMap:Pe,sheen:Ce,sheenColorMap:Me,sheenRoughnessMap:De,specularMap:qe,specularColorMap:ht,specularIntensityMap:Ge,transmission:me,transmissionMap:z,thicknessMap:oe,gradientMap:Q,opaque:M.transparent===!1&&M.blending===sr&&M.alphaToCoverage===!1,alphaMap:xe,alphaTest:be,alphaHash:Se,combine:M.combine,mapUv:H&&y(M.map.channel),aoMapUv:ce&&y(M.aoMap.channel),lightMapUv:K&&y(M.lightMap.channel),bumpMapUv:de&&y(M.bumpMap.channel),normalMapUv:le&&y(M.normalMap.channel),displacementMapUv:he&&y(M.displacementMap.channel),emissiveMapUv:Ae&&y(M.emissiveMap.channel),metalnessMapUv:P&&y(M.metalnessMap.channel),roughnessMapUv:S&&y(M.roughnessMap.channel),anisotropyMapUv:ge&&y(M.anisotropyMap.channel),clearcoatMapUv:ke&&y(M.clearcoatMap.channel),clearcoatNormalMapUv:fe&&y(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&y(M.clearcoatRoughnessMap.channel),iridescenceMapUv:We&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:Pe&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&y(M.sheenRoughnessMap.channel),specularMapUv:qe&&y(M.specularMap.channel),specularColorMapUv:ht&&y(M.specularColorMap.channel),specularIntensityMapUv:Ge&&y(M.specularIntensityMap.channel),transmissionMapUv:z&&y(M.transmissionMap.channel),thicknessMapUv:oe&&y(M.thicknessMap.channel),alphaMapUv:xe&&y(M.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(le||j),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!W.attributes.uv&&(H||xe),fog:!!B,useFog:M.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:I.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:Le,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&T.length>0,shadowMapType:n.shadowMap.type,toneMapping:lt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:H&&M.map.isVideoTexture===!0&&at.getTransfer(M.map.colorSpace)===ut,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Pn,flipSided:M.side===jt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Ke&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Ke&&M.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return ft.vertexUv1s=c.has(1),ft.vertexUv2s=c.has(2),ft.vertexUv3s=c.has(3),c.clear(),ft}function p(M){let w=[];if(M.shaderID?w.push(M.shaderID):(w.push(M.customVertexShaderID),w.push(M.customFragmentShaderID)),M.defines!==void 0)for(let T in M.defines)w.push(T),w.push(M.defines[T]);return M.isRawShaderMaterial===!1&&(x(w,M),v(w,M),w.push(n.outputColorSpace)),w.push(M.customProgramCacheKey),w.join()}function x(M,w){M.push(w.precision),M.push(w.outputColorSpace),M.push(w.envMapMode),M.push(w.envMapCubeUVHeight),M.push(w.mapUv),M.push(w.alphaMapUv),M.push(w.lightMapUv),M.push(w.aoMapUv),M.push(w.bumpMapUv),M.push(w.normalMapUv),M.push(w.displacementMapUv),M.push(w.emissiveMapUv),M.push(w.metalnessMapUv),M.push(w.roughnessMapUv),M.push(w.anisotropyMapUv),M.push(w.clearcoatMapUv),M.push(w.clearcoatNormalMapUv),M.push(w.clearcoatRoughnessMapUv),M.push(w.iridescenceMapUv),M.push(w.iridescenceThicknessMapUv),M.push(w.sheenColorMapUv),M.push(w.sheenRoughnessMapUv),M.push(w.specularMapUv),M.push(w.specularColorMapUv),M.push(w.specularIntensityMapUv),M.push(w.transmissionMapUv),M.push(w.thicknessMapUv),M.push(w.combine),M.push(w.fogExp2),M.push(w.sizeAttenuation),M.push(w.morphTargetsCount),M.push(w.morphAttributeCount),M.push(w.numDirLights),M.push(w.numPointLights),M.push(w.numSpotLights),M.push(w.numSpotLightMaps),M.push(w.numHemiLights),M.push(w.numRectAreaLights),M.push(w.numDirLightShadows),M.push(w.numPointLightShadows),M.push(w.numSpotLightShadows),M.push(w.numSpotLightShadowsWithMaps),M.push(w.numLightProbes),M.push(w.shadowMapType),M.push(w.toneMapping),M.push(w.numClippingPlanes),M.push(w.numClipIntersection),M.push(w.depthPacking)}function v(M,w){o.disableAll(),w.supportsVertexTextures&&o.enable(0),w.instancing&&o.enable(1),w.instancingColor&&o.enable(2),w.instancingMorph&&o.enable(3),w.matcap&&o.enable(4),w.envMap&&o.enable(5),w.normalMapObjectSpace&&o.enable(6),w.normalMapTangentSpace&&o.enable(7),w.clearcoat&&o.enable(8),w.iridescence&&o.enable(9),w.alphaTest&&o.enable(10),w.vertexColors&&o.enable(11),w.vertexAlphas&&o.enable(12),w.vertexUv1s&&o.enable(13),w.vertexUv2s&&o.enable(14),w.vertexUv3s&&o.enable(15),w.vertexTangents&&o.enable(16),w.anisotropy&&o.enable(17),w.alphaHash&&o.enable(18),w.batching&&o.enable(19),w.dispersion&&o.enable(20),M.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.skinning&&o.enable(4),w.morphTargets&&o.enable(5),w.morphNormals&&o.enable(6),w.morphColors&&o.enable(7),w.premultipliedAlpha&&o.enable(8),w.shadowMapEnabled&&o.enable(9),w.useLegacyLights&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.alphaToCoverage&&o.enable(20),M.push(o.mask)}function b(M){let w=m[M.type],T;if(w){let U=An[w];T=J0.clone(U.uniforms)}else T=M.uniforms;return T}function L(M,w){let T;for(let U=0,I=u.length;U<I;U++){let B=u[U];if(B.cacheKey===w){T=B,++T.usedTimes;break}}return T===void 0&&(T=new tE(n,w,M,s),u.push(T)),T}function A(M){if(--M.usedTimes===0){let w=u.indexOf(M);u[w]=u[u.length-1],u.pop(),M.destroy()}}function E(M){l.remove(M)}function D(){l.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:b,acquireProgram:L,releaseProgram:A,releaseShaderCache:E,programs:u,dispose:D}}function rE(){let n=new WeakMap;function e(s){let a=n.get(s);return a===void 0&&(a={},n.set(s,a)),a}function t(s){n.delete(s)}function i(s,a,o){n.get(s)[a]=o}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function sE(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function jm(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Xm(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(d,h,f,m,y,g){let p=n[e];return p===void 0?(p={id:d.id,object:d,geometry:h,material:f,groupOrder:m,renderOrder:d.renderOrder,z:y,group:g},n[e]=p):(p.id=d.id,p.object=d,p.geometry=h,p.material=f,p.groupOrder=m,p.renderOrder=d.renderOrder,p.z=y,p.group=g),e++,p}function o(d,h,f,m,y,g){let p=a(d,h,f,m,y,g);f.transmission>0?i.push(p):f.transparent===!0?r.push(p):t.push(p)}function l(d,h,f,m,y,g){let p=a(d,h,f,m,y,g);f.transmission>0?i.unshift(p):f.transparent===!0?r.unshift(p):t.unshift(p)}function c(d,h){t.length>1&&t.sort(d||sE),i.length>1&&i.sort(h||jm),r.length>1&&r.sort(h||jm)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:u,sort:c}}function aE(){let n=new WeakMap;function e(i,r){let s=n.get(i),a;return s===void 0?(a=new Xm,n.set(i,[a])):r>=s.length?(a=new Xm,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function oE(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new we};break;case"SpotLight":t={position:new R,direction:new R,color:new we,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new we,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new we,groundColor:new we};break;case"RectAreaLight":t={color:new we,position:new R,halfWidth:new R,halfHeight:new R};break}return n[e.id]=t,t}}}function lE(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function uE(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function dE(n){let e=new oE,t=lE(),i={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 c=0;c<9;c++)i.probe.push(new R);let r=new R,s=new Ne,a=new Ne;function o(c,u){let d=0,h=0,f=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let m=0,y=0,g=0,p=0,x=0,v=0,b=0,L=0,A=0,E=0,D=0;c.sort(uE);let M=u===!0?Math.PI:1;for(let T=0,U=c.length;T<U;T++){let I=c[T],B=I.color,W=I.intensity,F=I.distance,X=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=B.r*W*M,h+=B.g*W*M,f+=B.b*W*M;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],W);D++}else if(I.isDirectionalLight){let k=e.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*M),I.castShadow){let re=I.shadow,se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,i.directionalShadow[m]=se,i.directionalShadowMap[m]=X,i.directionalShadowMatrix[m]=I.shadow.matrix,v++}i.directional[m]=k,m++}else if(I.isSpotLight){let k=e.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(B).multiplyScalar(W*M),k.distance=F,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[g]=k;let re=I.shadow;if(I.map&&(i.spotLightMap[A]=I.map,A++,re.updateMatrices(I),I.castShadow&&E++),i.spotLightMatrix[g]=re.matrix,I.castShadow){let se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,i.spotShadow[g]=se,i.spotShadowMap[g]=X,L++}g++}else if(I.isRectAreaLight){let k=e.get(I);k.color.copy(B).multiplyScalar(W),k.halfWidth.set(I.width*.5,0,0),k.halfHeight.set(0,I.height*.5,0),i.rectArea[p]=k,p++}else if(I.isPointLight){let k=e.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*M),k.distance=I.distance,k.decay=I.decay,I.castShadow){let re=I.shadow,se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,se.shadowCameraNear=re.camera.near,se.shadowCameraFar=re.camera.far,i.pointShadow[y]=se,i.pointShadowMap[y]=X,i.pointShadowMatrix[y]=I.shadow.matrix,b++}i.point[y]=k,y++}else if(I.isHemisphereLight){let k=e.get(I);k.skyColor.copy(I.color).multiplyScalar(W*M),k.groundColor.copy(I.groundColor).multiplyScalar(W*M),i.hemi[x]=k,x++}}p>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ye.LTC_FLOAT_1,i.rectAreaLTC2=ye.LTC_FLOAT_2):(i.rectAreaLTC1=ye.LTC_HALF_1,i.rectAreaLTC2=ye.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let w=i.hash;(w.directionalLength!==m||w.pointLength!==y||w.spotLength!==g||w.rectAreaLength!==p||w.hemiLength!==x||w.numDirectionalShadows!==v||w.numPointShadows!==b||w.numSpotShadows!==L||w.numSpotMaps!==A||w.numLightProbes!==D)&&(i.directional.length=m,i.spot.length=g,i.rectArea.length=p,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=L,i.spotShadowMap.length=L,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=L+A-E,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=E,i.numLightProbes=D,w.directionalLength=m,w.pointLength=y,w.spotLength=g,w.rectAreaLength=p,w.hemiLength=x,w.numDirectionalShadows=v,w.numPointShadows=b,w.numSpotShadows=L,w.numSpotMaps=A,w.numLightProbes=D,i.version=cE++)}function l(c,u){let d=0,h=0,f=0,m=0,y=0,g=u.matrixWorldInverse;for(let p=0,x=c.length;p<x;p++){let v=c[p];if(v.isDirectionalLight){let b=i.directional[d];b.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),d++}else if(v.isSpotLight){let b=i.spot[f];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),b.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let b=i.rectArea[m];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),a.identity(),s.copy(v.matrixWorld),s.premultiply(g),a.extractRotation(s),b.halfWidth.set(v.width*.5,0,0),b.halfHeight.set(0,v.height*.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),m++}else if(v.isPointLight){let b=i.point[h];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let b=i.hemi[y];b.direction.setFromMatrixPosition(v.matrixWorld),b.direction.transformDirection(g),y++}}}return{setup:o,setupView:l,state:i}}function Ym(n){let e=new dE(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(u){e.setup(t,u)}function l(u){e.setupView(t,u)}let c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function hE(n){let e=new WeakMap;function t(r,s=0){let a=e.get(r),o;return a===void 0?(o=new Ym(n),e.set(r,[o])):s>=a.length?(o=new Ym(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}function mE(n,e,t){let i=new dr,r=new te,s=new te,a=new ot,o=new La({depthPacking:F0}),l=new Da,c={},u=t.maxTextureSize,d={[ri]:jt,[jt]:ri,[Pn]:Pn},h=new sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:fE,fragmentShader:pE}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Xe;m.setAttribute("position",new tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new yt(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ef;let p=this.type;this.render=function(A,E,D){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||A.length===0)return;let M=n.getRenderTarget(),w=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),U=n.state;U.setBlending(ti),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let I=p!==Cn&&this.type===Cn,B=p===Cn&&this.type!==Cn;for(let W=0,F=A.length;W<F;W++){let X=A[W],k=X.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",X,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);let re=k.getFrameExtents();if(r.multiply(re),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/re.x),r.x=s.x*re.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/re.y),r.y=s.y*re.y,k.mapSize.y=s.y)),k.map===null||I===!0||B===!0){let ve=this.type!==Cn?{minFilter:Rt,magFilter:Rt}:{};k.map!==null&&k.map.dispose(),k.map=new nn(r.x,r.y,ve),k.map.texture.name=X.name+".shadowMap",k.camera.updateProjectionMatrix()}n.setRenderTarget(k.map),n.clear();let se=k.getViewportCount();for(let ve=0;ve<se;ve++){let Le=k.getViewport(ve);a.set(s.x*Le.x,s.y*Le.y,s.x*Le.z,s.y*Le.w),U.viewport(a),k.updateMatrices(X,ve),i=k.getFrustum(),b(E,D,k.camera,X,this.type)}k.isPointLightShadow!==!0&&this.type===Cn&&x(k,D),k.needsUpdate=!1}p=this.type,g.needsUpdate=!1,n.setRenderTarget(M,w,T)};function x(A,E){let D=e.update(y);h.defines.VSM_SAMPLES!==A.blurSamples&&(h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new nn(r.x,r.y)),h.uniforms.shadow_pass.value=A.map.texture,h.uniforms.resolution.value=A.mapSize,h.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(E,null,D,h,y,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value=A.mapSize,f.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(E,null,D,f,y,null)}function v(A,E,D,M){let w=null,T=D.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(T!==void 0)w=T;else if(w=D.isPointLight===!0?l:o,n.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){let U=w.uuid,I=E.uuid,B=c[U];B===void 0&&(B={},c[U]=B);let W=B[I];W===void 0&&(W=w.clone(),B[I]=W,E.addEventListener("dispose",L)),w=W}if(w.visible=E.visible,w.wireframe=E.wireframe,M===Cn?w.side=E.shadowSide!==null?E.shadowSide:E.side:w.side=E.shadowSide!==null?E.shadowSide:d[E.side],w.alphaMap=E.alphaMap,w.alphaTest=E.alphaTest,w.map=E.map,w.clipShadows=E.clipShadows,w.clippingPlanes=E.clippingPlanes,w.clipIntersection=E.clipIntersection,w.displacementMap=E.displacementMap,w.displacementScale=E.displacementScale,w.displacementBias=E.displacementBias,w.wireframeLinewidth=E.wireframeLinewidth,w.linewidth=E.linewidth,D.isPointLight===!0&&w.isMeshDistanceMaterial===!0){let U=n.properties.get(w);U.light=D}return w}function b(A,E,D,M,w){if(A.visible===!1)return;if(A.layers.test(E.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&w===Cn)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,A.matrixWorld);let I=e.update(A),B=A.material;if(Array.isArray(B)){let W=I.groups;for(let F=0,X=W.length;F<X;F++){let k=W[F],re=B[k.materialIndex];if(re&&re.visible){let se=v(A,re,M,w);A.onBeforeShadow(n,A,E,D,I,se,k),n.renderBufferDirect(D,null,I,se,A,k),A.onAfterShadow(n,A,E,D,I,se,k)}}}else if(B.visible){let W=v(A,B,M,w);A.onBeforeShadow(n,A,E,D,I,W,null),n.renderBufferDirect(D,null,I,W,A,null),A.onAfterShadow(n,A,E,D,I,W,null)}}let U=A.children;for(let I=0,B=U.length;I<B;I++)b(U[I],E,D,M,w)}function L(A){A.target.removeEventListener("dispose",L);for(let D in c){let M=c[D],w=A.target.uuid;w in M&&(M[w].dispose(),delete M[w])}}}function gE(n){function e(){let z=!1,oe=new ot,Q=null,xe=new ot(0,0,0,0);return{setMask:function(be){Q!==be&&!z&&(n.colorMask(be,be,be,be),Q=be)},setLocked:function(be){z=be},setClear:function(be,Se,Ke,lt,ft){ft===!0&&(be*=lt,Se*=lt,Ke*=lt),oe.set(be,Se,Ke,lt),xe.equals(oe)===!1&&(n.clearColor(be,Se,Ke,lt),xe.copy(oe))},reset:function(){z=!1,Q=null,xe.set(-1,0,0,0)}}}function t(){let z=!1,oe=null,Q=null,xe=null;return{setTest:function(be){be?pe(n.DEPTH_TEST):ne(n.DEPTH_TEST)},setMask:function(be){oe!==be&&!z&&(n.depthMask(be),oe=be)},setFunc:function(be){if(Q!==be){switch(be){case o0:n.depthFunc(n.NEVER);break;case l0:n.depthFunc(n.ALWAYS);break;case c0:n.depthFunc(n.LESS);break;case fa:n.depthFunc(n.LEQUAL);break;case u0:n.depthFunc(n.EQUAL);break;case d0:n.depthFunc(n.GEQUAL);break;case h0:n.depthFunc(n.GREATER);break;case f0:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Q=be}},setLocked:function(be){z=be},setClear:function(be){xe!==be&&(n.clearDepth(be),xe=be)},reset:function(){z=!1,oe=null,Q=null,xe=null}}}function i(){let z=!1,oe=null,Q=null,xe=null,be=null,Se=null,Ke=null,lt=null,ft=null;return{setTest:function(et){z||(et?pe(n.STENCIL_TEST):ne(n.STENCIL_TEST))},setMask:function(et){oe!==et&&!z&&(n.stencilMask(et),oe=et)},setFunc:function(et,Xt,Mt){(Q!==et||xe!==Xt||be!==Mt)&&(n.stencilFunc(et,Xt,Mt),Q=et,xe=Xt,be=Mt)},setOp:function(et,Xt,Mt){(Se!==et||Ke!==Xt||lt!==Mt)&&(n.stencilOp(et,Xt,Mt),Se=et,Ke=Xt,lt=Mt)},setLocked:function(et){z=et},setClear:function(et){ft!==et&&(n.clearStencil(et),ft=et)},reset:function(){z=!1,oe=null,Q=null,xe=null,be=null,Se=null,Ke=null,lt=null,ft=null}}}let r=new e,s=new t,a=new i,o=new WeakMap,l=new WeakMap,c={},u={},d=new WeakMap,h=[],f=null,m=!1,y=null,g=null,p=null,x=null,v=null,b=null,L=null,A=new we(0,0,0),E=0,D=!1,M=null,w=null,T=null,U=null,I=null,B=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,F=0,X=n.getParameter(n.VERSION);X.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(X)[1]),W=F>=1):X.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),W=F>=2);let k=null,re={},se=n.getParameter(n.SCISSOR_BOX),ve=n.getParameter(n.VIEWPORT),Le=new ot().fromArray(se),Je=new ot().fromArray(ve);function Z(z,oe,Q,xe){let be=new Uint8Array(4),Se=n.createTexture();n.bindTexture(z,Se),n.texParameteri(z,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(z,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ke=0;Ke<Q;Ke++)z===n.TEXTURE_3D||z===n.TEXTURE_2D_ARRAY?n.texImage3D(oe,0,n.RGBA,1,1,xe,0,n.RGBA,n.UNSIGNED_BYTE,be):n.texImage2D(oe+Ke,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,be);return Se}let q={};q[n.TEXTURE_2D]=Z(n.TEXTURE_2D,n.TEXTURE_2D,1),q[n.TEXTURE_CUBE_MAP]=Z(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),q[n.TEXTURE_2D_ARRAY]=Z(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),q[n.TEXTURE_3D]=Z(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),pe(n.DEPTH_TEST),s.setFunc(fa),de(!1),le(Cd),pe(n.CULL_FACE),ce(ti);function pe(z){c[z]!==!0&&(n.enable(z),c[z]=!0)}function ne(z){c[z]!==!1&&(n.disable(z),c[z]=!1)}function Fe(z,oe){return u[z]!==oe?(n.bindFramebuffer(z,oe),u[z]=oe,z===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=oe),z===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=oe),!0):!1}function _e(z,oe){let Q=h,xe=!1;if(z){Q=d.get(oe),Q===void 0&&(Q=[],d.set(oe,Q));let be=z.textures;if(Q.length!==be.length||Q[0]!==n.COLOR_ATTACHMENT0){for(let Se=0,Ke=be.length;Se<Ke;Se++)Q[Se]=n.COLOR_ATTACHMENT0+Se;Q.length=be.length,xe=!0}}else Q[0]!==n.BACK&&(Q[0]=n.BACK,xe=!0);xe&&n.drawBuffers(Q)}function H(z){return f!==z?(n.useProgram(z),f=z,!0):!1}let Ue={[Ai]:n.FUNC_ADD,[$g]:n.FUNC_SUBTRACT,[Wg]:n.FUNC_REVERSE_SUBTRACT};Ue[jg]=n.MIN,Ue[Xg]=n.MAX;let J={[Yg]:n.ZERO,[qg]:n.ONE,[Zg]:n.SRC_COLOR,[Yl]:n.SRC_ALPHA,[n0]:n.SRC_ALPHA_SATURATE,[e0]:n.DST_COLOR,[Kg]:n.DST_ALPHA,[Jg]:n.ONE_MINUS_SRC_COLOR,[ql]:n.ONE_MINUS_SRC_ALPHA,[t0]:n.ONE_MINUS_DST_COLOR,[Qg]:n.ONE_MINUS_DST_ALPHA,[i0]:n.CONSTANT_COLOR,[r0]:n.ONE_MINUS_CONSTANT_COLOR,[s0]:n.CONSTANT_ALPHA,[a0]:n.ONE_MINUS_CONSTANT_ALPHA};function ce(z,oe,Q,xe,be,Se,Ke,lt,ft,et){if(z===ti){m===!0&&(ne(n.BLEND),m=!1);return}if(m===!1&&(pe(n.BLEND),m=!0),z!==Gg){if(z!==y||et!==D){if((g!==Ai||v!==Ai)&&(n.blendEquation(n.FUNC_ADD),g=Ai,v=Ai),et)switch(z){case sr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Rd:n.blendFunc(n.ONE,n.ONE);break;case Pd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ld:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case sr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Rd:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Pd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ld:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}p=null,x=null,b=null,L=null,A.set(0,0,0),E=0,y=z,D=et}return}be=be||oe,Se=Se||Q,Ke=Ke||xe,(oe!==g||be!==v)&&(n.blendEquationSeparate(Ue[oe],Ue[be]),g=oe,v=be),(Q!==p||xe!==x||Se!==b||Ke!==L)&&(n.blendFuncSeparate(J[Q],J[xe],J[Se],J[Ke]),p=Q,x=xe,b=Se,L=Ke),(lt.equals(A)===!1||ft!==E)&&(n.blendColor(lt.r,lt.g,lt.b,ft),A.copy(lt),E=ft),y=z,D=!1}function K(z,oe){z.side===Pn?ne(n.CULL_FACE):pe(n.CULL_FACE);let Q=z.side===jt;oe&&(Q=!Q),de(Q),z.blending===sr&&z.transparent===!1?ce(ti):ce(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),s.setFunc(z.depthFunc),s.setTest(z.depthTest),s.setMask(z.depthWrite),r.setMask(z.colorWrite);let xe=z.stencilWrite;a.setTest(xe),xe&&(a.setMask(z.stencilWriteMask),a.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),a.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),Ae(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?pe(n.SAMPLE_ALPHA_TO_COVERAGE):ne(n.SAMPLE_ALPHA_TO_COVERAGE)}function de(z){M!==z&&(z?n.frontFace(n.CW):n.frontFace(n.CCW),M=z)}function le(z){z!==zg?(pe(n.CULL_FACE),z!==w&&(z===Cd?n.cullFace(n.BACK):z===Vg?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ne(n.CULL_FACE),w=z}function he(z){z!==T&&(W&&n.lineWidth(z),T=z)}function Ae(z,oe,Q){z?(pe(n.POLYGON_OFFSET_FILL),(U!==oe||I!==Q)&&(n.polygonOffset(oe,Q),U=oe,I=Q)):ne(n.POLYGON_OFFSET_FILL)}function P(z){z?pe(n.SCISSOR_TEST):ne(n.SCISSOR_TEST)}function S(z){z===void 0&&(z=n.TEXTURE0+B-1),k!==z&&(n.activeTexture(z),k=z)}function j(z,oe,Q){Q===void 0&&(k===null?Q=n.TEXTURE0+B-1:Q=k);let xe=re[Q];xe===void 0&&(xe={type:void 0,texture:void 0},re[Q]=xe),(xe.type!==z||xe.texture!==oe)&&(k!==Q&&(n.activeTexture(Q),k=Q),n.bindTexture(z,oe||q[z]),xe.type=z,xe.texture=oe)}function ee(){let z=re[k];z!==void 0&&z.type!==void 0&&(n.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ie(){try{n.compressedTexImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ce(){try{n.texSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function me(){try{n.texSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ge(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ke(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function fe(){try{n.texStorage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(){try{n.texStorage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function We(){try{n.texImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Pe(){try{n.texImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Me(z){Le.equals(z)===!1&&(n.scissor(z.x,z.y,z.z,z.w),Le.copy(z))}function De(z){Je.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),Je.copy(z))}function qe(z,oe){let Q=l.get(oe);Q===void 0&&(Q=new WeakMap,l.set(oe,Q));let xe=Q.get(z);xe===void 0&&(xe=n.getUniformBlockIndex(oe,z.name),Q.set(z,xe))}function ht(z,oe){let xe=l.get(oe).get(z);o.get(oe)!==xe&&(n.uniformBlockBinding(oe,xe,z.__bindingPointIndex),o.set(oe,xe))}function Ge(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},k=null,re={},u={},d=new WeakMap,h=[],f=null,m=!1,y=null,g=null,p=null,x=null,v=null,b=null,L=null,A=new we(0,0,0),E=0,D=!1,M=null,w=null,T=null,U=null,I=null,Le.set(0,0,n.canvas.width,n.canvas.height),Je.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:pe,disable:ne,bindFramebuffer:Fe,drawBuffers:_e,useProgram:H,setBlending:ce,setMaterial:K,setFlipSided:de,setCullFace:le,setLineWidth:he,setPolygonOffset:Ae,setScissorTest:P,activeTexture:S,bindTexture:j,unbindTexture:ee,compressedTexImage2D:ae,compressedTexImage3D:ie,texImage2D:We,texImage3D:Pe,updateUBOMapping:qe,uniformBlockBinding:ht,texStorage2D:fe,texStorage3D:Re,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:ge,compressedTexSubImage3D:ke,scissor:Me,viewport:De,reset:Ge}}function yE(n,e,t,i,r,s,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new te,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(P,S){return f?new OffscreenCanvas(P,S):Ea("canvas")}function y(P,S,j){let ee=1,ae=Ae(P);if((ae.width>j||ae.height>j)&&(ee=j/Math.max(ae.width,ae.height)),ee<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let ie=Math.floor(ee*ae.width),Ce=Math.floor(ee*ae.height);d===void 0&&(d=m(ie,Ce));let me=S?m(ie,Ce):d;return me.width=ie,me.height=Ce,me.getContext("2d").drawImage(P,0,0,ie,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ae.width+"x"+ae.height+") to ("+ie+"x"+Ce+")."),me}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ae.width+"x"+ae.height+")."),P;return P}function g(P){return P.generateMipmaps&&P.minFilter!==Rt&&P.minFilter!==bt}function p(P){n.generateMipmap(P)}function x(P,S,j,ee,ae=!1){if(P!==null){if(n[P]!==void 0)return n[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let ie=S;if(S===n.RED&&(j===n.FLOAT&&(ie=n.R32F),j===n.HALF_FLOAT&&(ie=n.R16F),j===n.UNSIGNED_BYTE&&(ie=n.R8)),S===n.RED_INTEGER&&(j===n.UNSIGNED_BYTE&&(ie=n.R8UI),j===n.UNSIGNED_SHORT&&(ie=n.R16UI),j===n.UNSIGNED_INT&&(ie=n.R32UI),j===n.BYTE&&(ie=n.R8I),j===n.SHORT&&(ie=n.R16I),j===n.INT&&(ie=n.R32I)),S===n.RG&&(j===n.FLOAT&&(ie=n.RG32F),j===n.HALF_FLOAT&&(ie=n.RG16F),j===n.UNSIGNED_BYTE&&(ie=n.RG8)),S===n.RG_INTEGER&&(j===n.UNSIGNED_BYTE&&(ie=n.RG8UI),j===n.UNSIGNED_SHORT&&(ie=n.RG16UI),j===n.UNSIGNED_INT&&(ie=n.RG32UI),j===n.BYTE&&(ie=n.RG8I),j===n.SHORT&&(ie=n.RG16I),j===n.INT&&(ie=n.RG32I)),S===n.RGB&&j===n.UNSIGNED_INT_5_9_9_9_REV&&(ie=n.RGB9_E5),S===n.RGBA){let Ce=ae?ba:at.getTransfer(ee);j===n.FLOAT&&(ie=n.RGBA32F),j===n.HALF_FLOAT&&(ie=n.RGBA16F),j===n.UNSIGNED_BYTE&&(ie=Ce===ut?n.SRGB8_ALPHA8:n.RGBA8),j===n.UNSIGNED_SHORT_4_4_4_4&&(ie=n.RGBA4),j===n.UNSIGNED_SHORT_5_5_5_1&&(ie=n.RGB5_A1)}return(ie===n.R16F||ie===n.R32F||ie===n.RG16F||ie===n.RG32F||ie===n.RGBA16F||ie===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function v(P,S){return g(P)===!0||P.isFramebufferTexture&&P.minFilter!==Rt&&P.minFilter!==bt?Math.log2(Math.max(S.width,S.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?S.mipmaps.length:1}function b(P){let S=P.target;S.removeEventListener("dispose",b),A(S),S.isVideoTexture&&u.delete(S)}function L(P){let S=P.target;S.removeEventListener("dispose",L),D(S)}function A(P){let S=i.get(P);if(S.__webglInit===void 0)return;let j=P.source,ee=h.get(j);if(ee){let ae=ee[S.__cacheKey];ae.usedTimes--,ae.usedTimes===0&&E(P),Object.keys(ee).length===0&&h.delete(j)}i.remove(P)}function E(P){let S=i.get(P);n.deleteTexture(S.__webglTexture);let j=P.source,ee=h.get(j);delete ee[S.__cacheKey],a.memory.textures--}function D(P){let S=i.get(P);if(P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(S.__webglFramebuffer[ee]))for(let ae=0;ae<S.__webglFramebuffer[ee].length;ae++)n.deleteFramebuffer(S.__webglFramebuffer[ee][ae]);else n.deleteFramebuffer(S.__webglFramebuffer[ee]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ee])}else{if(Array.isArray(S.__webglFramebuffer))for(let ee=0;ee<S.__webglFramebuffer.length;ee++)n.deleteFramebuffer(S.__webglFramebuffer[ee]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ee=0;ee<S.__webglColorRenderbuffer.length;ee++)S.__webglColorRenderbuffer[ee]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ee]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}let j=P.textures;for(let ee=0,ae=j.length;ee<ae;ee++){let ie=i.get(j[ee]);ie.__webglTexture&&(n.deleteTexture(ie.__webglTexture),a.memory.textures--),i.remove(j[ee])}i.remove(P)}let M=0;function w(){M=0}function T(){let P=M;return P>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+r.maxTextures),M+=1,P}function U(P){let S=[];return S.push(P.wrapS),S.push(P.wrapT),S.push(P.wrapR||0),S.push(P.magFilter),S.push(P.minFilter),S.push(P.anisotropy),S.push(P.internalFormat),S.push(P.format),S.push(P.type),S.push(P.generateMipmaps),S.push(P.premultiplyAlpha),S.push(P.flipY),S.push(P.unpackAlignment),S.push(P.colorSpace),S.join()}function I(P,S){let j=i.get(P);if(P.isVideoTexture&&le(P),P.isRenderTargetTexture===!1&&P.version>0&&j.__version!==P.version){let ee=P.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Le(j,P,S);return}}t.bindTexture(n.TEXTURE_2D,j.__webglTexture,n.TEXTURE0+S)}function B(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Le(j,P,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,j.__webglTexture,n.TEXTURE0+S)}function W(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Le(j,P,S);return}t.bindTexture(n.TEXTURE_3D,j.__webglTexture,n.TEXTURE0+S)}function F(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Je(j,P,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+S)}let X={[ga]:n.REPEAT,[gn]:n.CLAMP_TO_EDGE,[ya]:n.MIRRORED_REPEAT},k={[Rt]:n.NEAREST,[Tf]:n.NEAREST_MIPMAP_NEAREST,[ts]:n.NEAREST_MIPMAP_LINEAR,[bt]:n.LINEAR,[la]:n.LINEAR_MIPMAP_NEAREST,[Ln]:n.LINEAR_MIPMAP_LINEAR},re={[B0]:n.NEVER,[W0]:n.ALWAYS,[z0]:n.LESS,[Ff]:n.LEQUAL,[V0]:n.EQUAL,[$0]:n.GEQUAL,[H0]:n.GREATER,[G0]:n.NOTEQUAL};function se(P,S){if(S.type===yn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===bt||S.magFilter===la||S.magFilter===ts||S.magFilter===Ln||S.minFilter===bt||S.minFilter===la||S.minFilter===ts||S.minFilter===Ln)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(P,n.TEXTURE_WRAP_S,X[S.wrapS]),n.texParameteri(P,n.TEXTURE_WRAP_T,X[S.wrapT]),(P===n.TEXTURE_3D||P===n.TEXTURE_2D_ARRAY)&&n.texParameteri(P,n.TEXTURE_WRAP_R,X[S.wrapR]),n.texParameteri(P,n.TEXTURE_MAG_FILTER,k[S.magFilter]),n.texParameteri(P,n.TEXTURE_MIN_FILTER,k[S.minFilter]),S.compareFunction&&(n.texParameteri(P,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(P,n.TEXTURE_COMPARE_FUNC,re[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Rt||S.minFilter!==ts&&S.minFilter!==Ln||S.type===yn&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){let j=e.get("EXT_texture_filter_anisotropic");n.texParameterf(P,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function ve(P,S){let j=!1;P.__webglInit===void 0&&(P.__webglInit=!0,S.addEventListener("dispose",b));let ee=S.source,ae=h.get(ee);ae===void 0&&(ae={},h.set(ee,ae));let ie=U(S);if(ie!==P.__cacheKey){ae[ie]===void 0&&(ae[ie]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,j=!0),ae[ie].usedTimes++;let Ce=ae[P.__cacheKey];Ce!==void 0&&(ae[P.__cacheKey].usedTimes--,Ce.usedTimes===0&&E(S)),P.__cacheKey=ie,P.__webglTexture=ae[ie].texture}return j}function Le(P,S,j){let ee=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ee=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ee=n.TEXTURE_3D);let ae=ve(P,S),ie=S.source;t.bindTexture(ee,P.__webglTexture,n.TEXTURE0+j);let Ce=i.get(ie);if(ie.version!==Ce.__version||ae===!0){t.activeTexture(n.TEXTURE0+j);let me=at.getPrimaries(at.workingColorSpace),ge=S.colorSpace===Zn?null:at.getPrimaries(S.colorSpace),ke=S.colorSpace===Zn||me===ge?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke);let fe=y(S.image,!1,r.maxTextureSize);fe=he(S,fe);let Re=s.convert(S.format,S.colorSpace),We=s.convert(S.type),Pe=x(S.internalFormat,Re,We,S.colorSpace,S.isVideoTexture);se(ee,S);let Me,De=S.mipmaps,qe=S.isVideoTexture!==!0,ht=Ce.__version===void 0||ae===!0,Ge=ie.dataReady,z=v(S,fe);if(S.isDepthTexture)Pe=n.DEPTH_COMPONENT16,S.type===yn?Pe=n.DEPTH_COMPONENT32F:S.type===lr?Pe=n.DEPTH_COMPONENT24:S.type===_s&&(Pe=n.DEPTH24_STENCIL8),ht&&(qe?t.texStorage2D(n.TEXTURE_2D,1,Pe,fe.width,fe.height):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,We,null));else if(S.isDataTexture)if(De.length>0){qe&&ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,De[0].width,De[0].height);for(let oe=0,Q=De.length;oe<Q;oe++)Me=De[oe],qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Me.width,Me.height,Re,We,Me.data):t.texImage2D(n.TEXTURE_2D,oe,Pe,Me.width,Me.height,0,Re,We,Me.data);S.generateMipmaps=!1}else qe?(ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height),Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,fe.width,fe.height,Re,We,fe.data)):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,We,fe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){qe&&ht&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,De[0].width,De[0].height,fe.depth);for(let oe=0,Q=De.length;oe<Q;oe++)Me=De[oe],S.format!==en?Re!==null?qe?Ge&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,oe,0,0,0,Me.width,Me.height,fe.depth,Re,Me.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,oe,Pe,Me.width,Me.height,fe.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,oe,0,0,0,Me.width,Me.height,fe.depth,Re,We,Me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,oe,Pe,Me.width,Me.height,fe.depth,0,Re,We,Me.data)}else{qe&&ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,De[0].width,De[0].height);for(let oe=0,Q=De.length;oe<Q;oe++)Me=De[oe],S.format!==en?Re!==null?qe?Ge&&t.compressedTexSubImage2D(n.TEXTURE_2D,oe,0,0,Me.width,Me.height,Re,Me.data):t.compressedTexImage2D(n.TEXTURE_2D,oe,Pe,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Me.width,Me.height,Re,We,Me.data):t.texImage2D(n.TEXTURE_2D,oe,Pe,Me.width,Me.height,0,Re,We,Me.data)}else if(S.isDataArrayTexture)qe?(ht&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,fe.width,fe.height,fe.depth),Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,fe.width,fe.height,fe.depth,Re,We,fe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Pe,fe.width,fe.height,fe.depth,0,Re,We,fe.data);else if(S.isData3DTexture)qe?(ht&&t.texStorage3D(n.TEXTURE_3D,z,Pe,fe.width,fe.height,fe.depth),Ge&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,fe.width,fe.height,fe.depth,Re,We,fe.data)):t.texImage3D(n.TEXTURE_3D,0,Pe,fe.width,fe.height,fe.depth,0,Re,We,fe.data);else if(S.isFramebufferTexture){if(ht)if(qe)t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height);else{let oe=fe.width,Q=fe.height;for(let xe=0;xe<z;xe++)t.texImage2D(n.TEXTURE_2D,xe,Pe,oe,Q,0,Re,We,null),oe>>=1,Q>>=1}}else if(De.length>0){if(qe&&ht){let oe=Ae(De[0]);t.texStorage2D(n.TEXTURE_2D,z,Pe,oe.width,oe.height)}for(let oe=0,Q=De.length;oe<Q;oe++)Me=De[oe],qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Re,We,Me):t.texImage2D(n.TEXTURE_2D,oe,Pe,Re,We,Me);S.generateMipmaps=!1}else if(qe){if(ht){let oe=Ae(fe);t.texStorage2D(n.TEXTURE_2D,z,Pe,oe.width,oe.height)}Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Re,We,fe)}else t.texImage2D(n.TEXTURE_2D,0,Pe,Re,We,fe);g(S)&&p(ee),Ce.__version=ie.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Je(P,S,j){if(S.image.length!==6)return;let ee=ve(P,S),ae=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,P.__webglTexture,n.TEXTURE0+j);let ie=i.get(ae);if(ae.version!==ie.__version||ee===!0){t.activeTexture(n.TEXTURE0+j);let Ce=at.getPrimaries(at.workingColorSpace),me=S.colorSpace===Zn?null:at.getPrimaries(S.colorSpace),ge=S.colorSpace===Zn||Ce===me?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge);let ke=S.isCompressedTexture||S.image[0].isCompressedTexture,fe=S.image[0]&&S.image[0].isDataTexture,Re=[];for(let Q=0;Q<6;Q++)!ke&&!fe?Re[Q]=y(S.image[Q],!0,r.maxCubemapSize):Re[Q]=fe?S.image[Q].image:S.image[Q],Re[Q]=he(S,Re[Q]);let We=Re[0],Pe=s.convert(S.format,S.colorSpace),Me=s.convert(S.type),De=x(S.internalFormat,Pe,Me,S.colorSpace),qe=S.isVideoTexture!==!0,ht=ie.__version===void 0||ee===!0,Ge=ae.dataReady,z=v(S,We);se(n.TEXTURE_CUBE_MAP,S);let oe;if(ke){qe&&ht&&t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,We.width,We.height);for(let Q=0;Q<6;Q++){oe=Re[Q].mipmaps;for(let xe=0;xe<oe.length;xe++){let be=oe[xe];S.format!==en?Pe!==null?qe?Ge&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,0,0,be.width,be.height,Pe,be.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,De,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,0,0,be.width,be.height,Pe,Me,be.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,De,be.width,be.height,0,Pe,Me,be.data)}}}else{if(oe=S.mipmaps,qe&&ht){oe.length>0&&z++;let Q=Ae(Re[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(fe){qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Re[Q].width,Re[Q].height,Pe,Me,Re[Q].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,De,Re[Q].width,Re[Q].height,0,Pe,Me,Re[Q].data);for(let xe=0;xe<oe.length;xe++){let Se=oe[xe].image[Q].image;qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,0,0,Se.width,Se.height,Pe,Me,Se.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,De,Se.width,Se.height,0,Pe,Me,Se.data)}}else{qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Pe,Me,Re[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,De,Pe,Me,Re[Q]);for(let xe=0;xe<oe.length;xe++){let be=oe[xe];qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,0,0,Pe,Me,be.image[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,De,Pe,Me,be.image[Q])}}}g(S)&&p(n.TEXTURE_CUBE_MAP),ie.__version=ae.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Z(P,S,j,ee,ae,ie){let Ce=s.convert(j.format,j.colorSpace),me=s.convert(j.type),ge=x(j.internalFormat,Ce,me,j.colorSpace);if(!i.get(S).__hasExternalTextures){let fe=Math.max(1,S.width>>ie),Re=Math.max(1,S.height>>ie);ae===n.TEXTURE_3D||ae===n.TEXTURE_2D_ARRAY?t.texImage3D(ae,ie,ge,fe,Re,S.depth,0,Ce,me,null):t.texImage2D(ae,ie,ge,fe,Re,0,Ce,me,null)}t.bindFramebuffer(n.FRAMEBUFFER,P),de(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ee,ae,i.get(j).__webglTexture,0,K(S)):(ae===n.TEXTURE_2D||ae>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&ae<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ee,ae,i.get(j).__webglTexture,ie),t.bindFramebuffer(n.FRAMEBUFFER,null)}function q(P,S,j){if(n.bindRenderbuffer(n.RENDERBUFFER,P),S.depthBuffer&&!S.stencilBuffer){let ee=n.DEPTH_COMPONENT24;if(j||de(S)){let ae=S.depthTexture;ae&&ae.isDepthTexture&&(ae.type===yn?ee=n.DEPTH_COMPONENT32F:ae.type===lr&&(ee=n.DEPTH_COMPONENT24));let ie=K(S);de(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ie,ee,S.width,S.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,ie,ee,S.width,S.height)}else n.renderbufferStorage(n.RENDERBUFFER,ee,S.width,S.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,P)}else if(S.depthBuffer&&S.stencilBuffer){let ee=K(S);j&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,S.width,S.height):de(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,P)}else{let ee=S.textures;for(let ae=0;ae<ee.length;ae++){let ie=ee[ae],Ce=s.convert(ie.format,ie.colorSpace),me=s.convert(ie.type),ge=x(ie.internalFormat,Ce,me,ie.colorSpace),ke=K(S);j&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ke,ge,S.width,S.height):de(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ke,ge,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,ge,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function pe(P,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,P),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),I(S.depthTexture,0);let ee=i.get(S.depthTexture).__webglTexture,ae=K(S);if(S.depthTexture.format===ar)de(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0,ae):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0);else if(S.depthTexture.format===os)de(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0,ae):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0);else throw new Error("Unknown depthTexture format")}function ne(P){let S=i.get(P),j=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!S.__autoAllocateDepthBuffer){if(j)throw new Error("target.depthTexture not supported in Cube render targets");pe(S.__webglFramebuffer,P)}else if(j){S.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ee]),S.__webglDepthbuffer[ee]=n.createRenderbuffer(),q(S.__webglDepthbuffer[ee],P,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=n.createRenderbuffer(),q(S.__webglDepthbuffer,P,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Fe(P,S,j){let ee=i.get(P);S!==void 0&&Z(ee.__webglFramebuffer,P,P.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),j!==void 0&&ne(P)}function _e(P){let S=P.texture,j=i.get(P),ee=i.get(S);P.addEventListener("dispose",L);let ae=P.textures,ie=P.isWebGLCubeRenderTarget===!0,Ce=ae.length>1;if(Ce||(ee.__webglTexture===void 0&&(ee.__webglTexture=n.createTexture()),ee.__version=S.version,a.memory.textures++),ie){j.__webglFramebuffer=[];for(let me=0;me<6;me++)if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer[me]=[];for(let ge=0;ge<S.mipmaps.length;ge++)j.__webglFramebuffer[me][ge]=n.createFramebuffer()}else j.__webglFramebuffer[me]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer=[];for(let me=0;me<S.mipmaps.length;me++)j.__webglFramebuffer[me]=n.createFramebuffer()}else j.__webglFramebuffer=n.createFramebuffer();if(Ce)for(let me=0,ge=ae.length;me<ge;me++){let ke=i.get(ae[me]);ke.__webglTexture===void 0&&(ke.__webglTexture=n.createTexture(),a.memory.textures++)}if(P.samples>0&&de(P)===!1){j.__webglMultisampledFramebuffer=n.createFramebuffer(),j.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,j.__webglMultisampledFramebuffer);for(let me=0;me<ae.length;me++){let ge=ae[me];j.__webglColorRenderbuffer[me]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,j.__webglColorRenderbuffer[me]);let ke=s.convert(ge.format,ge.colorSpace),fe=s.convert(ge.type),Re=x(ge.internalFormat,ke,fe,ge.colorSpace,P.isXRRenderTarget===!0),We=K(P);n.renderbufferStorageMultisample(n.RENDERBUFFER,We,Re,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+me,n.RENDERBUFFER,j.__webglColorRenderbuffer[me])}n.bindRenderbuffer(n.RENDERBUFFER,null),P.depthBuffer&&(j.__webglDepthRenderbuffer=n.createRenderbuffer(),q(j.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ie){t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture),se(n.TEXTURE_CUBE_MAP,S);for(let me=0;me<6;me++)if(S.mipmaps&&S.mipmaps.length>0)for(let ge=0;ge<S.mipmaps.length;ge++)Z(j.__webglFramebuffer[me][ge],P,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+me,ge);else Z(j.__webglFramebuffer[me],P,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0);g(S)&&p(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ce){for(let me=0,ge=ae.length;me<ge;me++){let ke=ae[me],fe=i.get(ke);t.bindTexture(n.TEXTURE_2D,fe.__webglTexture),se(n.TEXTURE_2D,ke),Z(j.__webglFramebuffer,P,ke,n.COLOR_ATTACHMENT0+me,n.TEXTURE_2D,0),g(ke)&&p(n.TEXTURE_2D)}t.unbindTexture()}else{let me=n.TEXTURE_2D;if((P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(me=P.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(me,ee.__webglTexture),se(me,S),S.mipmaps&&S.mipmaps.length>0)for(let ge=0;ge<S.mipmaps.length;ge++)Z(j.__webglFramebuffer[ge],P,S,n.COLOR_ATTACHMENT0,me,ge);else Z(j.__webglFramebuffer,P,S,n.COLOR_ATTACHMENT0,me,0);g(S)&&p(me),t.unbindTexture()}P.depthBuffer&&ne(P)}function H(P){let S=P.textures;for(let j=0,ee=S.length;j<ee;j++){let ae=S[j];if(g(ae)){let ie=P.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ce=i.get(ae).__webglTexture;t.bindTexture(ie,Ce),p(ie),t.unbindTexture()}}}let Ue=[],J=[];function ce(P){if(P.samples>0){if(de(P)===!1){let S=P.textures,j=P.width,ee=P.height,ae=n.COLOR_BUFFER_BIT,ie=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ce=i.get(P),me=S.length>1;if(me)for(let ge=0;ge<S.length;ge++)t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let ge=0;ge<S.length;ge++){if(P.resolveDepthBuffer&&(P.depthBuffer&&(ae|=n.DEPTH_BUFFER_BIT),P.stencilBuffer&&P.resolveStencilBuffer&&(ae|=n.STENCIL_BUFFER_BIT)),me){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ce.__webglColorRenderbuffer[ge]);let ke=i.get(S[ge]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ke,0)}n.blitFramebuffer(0,0,j,ee,0,0,j,ee,ae,n.NEAREST),l===!0&&(Ue.length=0,J.length=0,Ue.push(n.COLOR_ATTACHMENT0+ge),P.depthBuffer&&P.resolveDepthBuffer===!1&&(Ue.push(ie),J.push(ie),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,J)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),me)for(let ge=0;ge<S.length;ge++){t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.RENDERBUFFER,Ce.__webglColorRenderbuffer[ge]);let ke=i.get(S[ge]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.TEXTURE_2D,ke,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}else if(P.depthBuffer&&P.resolveDepthBuffer===!1&&l){let S=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function K(P){return Math.min(r.maxSamples,P.samples)}function de(P){let S=i.get(P);return P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function le(P){let S=a.render.frame;u.get(P)!==S&&(u.set(P,S),P.update())}function he(P,S){let j=P.colorSpace,ee=P.format,ae=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||j!==ci&&j!==Zn&&(at.getTransfer(j)===ut?(ee!==en||ae!==ai)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",j)),S}function Ae(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=T,this.resetTextureUnits=w,this.setTexture2D=I,this.setTexture2DArray=B,this.setTexture3D=W,this.setTextureCube=F,this.rebindTextures=Fe,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=ce,this.setupDepthRenderbuffer=ne,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=de}function ry(n,e){function t(i,r=Zn){let s,a=at.getTransfer(r);if(i===ai)return n.UNSIGNED_BYTE;if(i===Rf)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pf)return n.UNSIGNED_SHORT_5_5_5_1;if(i===E0)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===S0)return n.BYTE;if(i===A0)return n.SHORT;if(i===If)return n.UNSIGNED_SHORT;if(i===Cf)return n.INT;if(i===lr)return n.UNSIGNED_INT;if(i===yn)return n.FLOAT;if(i===no)return n.HALF_FLOAT;if(i===T0)return n.ALPHA;if(i===I0)return n.RGB;if(i===en)return n.RGBA;if(i===C0)return n.LUMINANCE;if(i===R0)return n.LUMINANCE_ALPHA;if(i===ar)return n.DEPTH_COMPONENT;if(i===os)return n.DEPTH_STENCIL;if(i===Lf)return n.RED;if(i===Df)return n.RED_INTEGER;if(i===P0)return n.RG;if(i===Of)return n.RG_INTEGER;if(i===Uf)return n.RGBA_INTEGER;if(i===Hl||i===Gl||i===$l||i===Wl)if(a===ut)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Hl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Gl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Wl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Hl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Gl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Wl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Od||i===Ud||i===Nd||i===Fd)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Od)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ud)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Nd)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Fd)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===kd||i===Bd||i===zd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===kd||i===Bd)return a===ut?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===zd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Vd||i===Hd||i===Gd||i===$d||i===Wd||i===jd||i===Xd||i===Yd||i===qd||i===Zd||i===Jd||i===Kd||i===Qd||i===eh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Vd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$d)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Yd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===qd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eh)return a===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===jl||i===th||i===nh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===jl)return a===ut?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===th)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===L0||i===ih||i===rh||i===sh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===jl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ih)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===rh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===sh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===_s?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function wE(n,e){function t(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function i(g,p){p.color.getRGB(g.fogColor.value,Z0(n)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function r(g,p,x,v,b){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(g,p):p.isMeshToonMaterial?(s(g,p),d(g,p)):p.isMeshPhongMaterial?(s(g,p),u(g,p)):p.isMeshStandardMaterial?(s(g,p),h(g,p),p.isMeshPhysicalMaterial&&f(g,p,b)):p.isMeshMatcapMaterial?(s(g,p),m(g,p)):p.isMeshDepthMaterial?s(g,p):p.isMeshDistanceMaterial?(s(g,p),y(g,p)):p.isMeshNormalMaterial?s(g,p):p.isLineBasicMaterial?(a(g,p),p.isLineDashedMaterial&&o(g,p)):p.isPointsMaterial?l(g,p,x,v):p.isSpriteMaterial?c(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,t(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===jt&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===jt&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,t(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,t(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);let x=e.get(p),v=x.envMap,b=x.envMapRotation;if(v&&(g.envMap.value=v,ji.copy(b),ji.x*=-1,ji.y*=-1,ji.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(ji.y*=-1,ji.z*=-1),g.envMapRotation.value.setFromMatrix4(bE.makeRotationFromEuler(ji)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap){g.lightMap.value=p.lightMap;let L=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=p.lightMapIntensity*L,t(p.lightMap,g.lightMapTransform)}p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,x,v){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*x,g.scale.value=v*.5,p.map&&(g.map.value=p.map,t(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function d(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function h(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,x){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===jt&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function y(g,p){let x=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ME(n,e,t,i){let r={},s={},a=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,v){let b=v.program;i.uniformBlockBinding(x,b)}function c(x,v){let b=r[x.id];b===void 0&&(m(x),b=u(x),r[x.id]=b,x.addEventListener("dispose",g));let L=v.program;i.updateUBOMapping(x,L);let A=e.render.frame;s[x.id]!==A&&(h(x),s[x.id]=A)}function u(x){let v=d();x.__bindingPointIndex=v;let b=n.createBuffer(),L=x.__size,A=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,L,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,b),b}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(x){let v=r[x.id],b=x.uniforms,L=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let A=0,E=b.length;A<E;A++){let D=Array.isArray(b[A])?b[A]:[b[A]];for(let M=0,w=D.length;M<w;M++){let T=D[M];if(f(T,A,M,L)===!0){let U=T.__offset,I=Array.isArray(T.value)?T.value:[T.value],B=0;for(let W=0;W<I.length;W++){let F=I[W],X=y(F);typeof F=="number"||typeof F=="boolean"?(T.__data[0]=F,n.bufferSubData(n.UNIFORM_BUFFER,U+B,T.__data)):F.isMatrix3?(T.__data[0]=F.elements[0],T.__data[1]=F.elements[1],T.__data[2]=F.elements[2],T.__data[3]=0,T.__data[4]=F.elements[3],T.__data[5]=F.elements[4],T.__data[6]=F.elements[5],T.__data[7]=0,T.__data[8]=F.elements[6],T.__data[9]=F.elements[7],T.__data[10]=F.elements[8],T.__data[11]=0):(F.toArray(T.__data,B),B+=X.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,U,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,v,b,L){let A=x.value,E=v+"_"+b;if(L[E]===void 0)return typeof A=="number"||typeof A=="boolean"?L[E]=A:L[E]=A.clone(),!0;{let D=L[E];if(typeof A=="number"||typeof A=="boolean"){if(D!==A)return L[E]=A,!0}else if(D.equals(A)===!1)return D.copy(A),!0}return!1}function m(x){let v=x.uniforms,b=0,L=16;for(let E=0,D=v.length;E<D;E++){let M=Array.isArray(v[E])?v[E]:[v[E]];for(let w=0,T=M.length;w<T;w++){let U=M[w],I=Array.isArray(U.value)?U.value:[U.value];for(let B=0,W=I.length;B<W;B++){let F=I[B],X=y(F),k=b%L;k!==0&&L-k<X.boundary&&(b+=L-k),U.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=b,b+=X.storage}}}let A=b%L;return A>0&&(b+=L-A),x.__size=b,x.__cache={},this}function y(x){let v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let b=a.indexOf(v.__bindingPointIndex);a.splice(b,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function p(){for(let x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:p}}function xl(n,e,t,i,r,s){Kr.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Qs.x=s*Kr.x-r*Kr.y,Qs.y=r*Kr.x+s*Kr.y):Qs.copy(Kr),n.copy(e),n.x+=Qs.x,n.y+=Qs.y,n.applyMatrix4(sy)}function TE(n,e){return n.z-e.z}function IE(n,e){return e.z-n.z}function RE(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function El(n,e,t,i,r,s){let a=n.geometry.attributes.position;if(uc.fromBufferAttribute(a,r),dc.fromBufferAttribute(a,s),t.distanceSqToSegment(uc,dc,_d,cg)>i)return;_d.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(_d);if(!(l<e.near||l>e.far))return{distance:l,point:cg.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function fg(n,e,t,i,r,s,a){let o=Eh.distanceSqToPoint(n);if(o<t){let l=new R;Eh.closestPointToPoint(n,l),l.applyMatrix4(i);let c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}function zf(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,d){let h=(a-s)/c-(o-s)/(c+u)+(o-a)/u,f=(o-a)/u-(l-a)/(u+d)+(l-o)/d;h*=u,f*=u,r(a,o,h,f)},calc:function(s){let a=s*s,o=a*s;return n+e*s+t*a+i*o}}}function pg(n,e,t,i,r){let s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function PE(n,e){let t=1-n;return t*t*e}function LE(n,e){return 2*(1-n)*n*e}function DE(n,e){return n*n*e}function da(n,e,t,i){return PE(n,e)+LE(n,t)+DE(n,i)}function OE(n,e){let t=1-n;return t*t*t*e}function UE(n,e){let t=1-n;return 3*t*t*n*e}function NE(n,e){return 3*(1-n)*n*n*e}function FE(n,e){return n*n*n*e}function ha(n,e,t,i,r){return OE(n,e)+UE(n,t)+NE(n,i)+FE(n,r)}function ay(n,e,t,i,r){let s,a;if(r===eT(n,e,t,i)>0)for(s=e;s<t;s+=i)a=mg(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=mg(s,n[s],n[s+1],a);return a&&du(a,a.next)&&(Wa(a),a=a.next),a}function pr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(du(t,t.next)||pt(t.prev,t,t.next)===0)){if(Wa(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ga(n,e,t,i,r,s,a){if(!n)return;!a&&s&&YE(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?zE(n,i,r,s):BE(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),Wa(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=VE(pr(n),e,t),Ga(n,e,t,i,r,s,2)):a===2&&HE(n,e,t,i,r,s):Ga(pr(n),e,t,i,r,s,1);break}}}function BE(n){let e=n.prev,t=n,i=n.next;if(pt(e,t,i)>=0)return!1;let r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,d=o<l?o<c?o:c:l<c?l:c,h=r>s?r>a?r:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c,m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=h&&m.y>=d&&m.y<=f&&rs(r,o,s,l,a,c,m.x,m.y)&&pt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function zE(n,e,t,i){let r=n.prev,s=n,a=n.next;if(pt(r,s,a)>=0)return!1;let o=r.x,l=s.x,c=a.x,u=r.y,d=s.y,h=a.y,f=o<l?o<c?o:c:l<c?l:c,m=u<d?u<h?u:h:d<h?d:h,y=o>l?o>c?o:c:l>c?l:c,g=u>d?u>h?u:h:d>h?d:h,p=Lh(f,m,e,t,i),x=Lh(y,g,e,t,i),v=n.prevZ,b=n.nextZ;for(;v&&v.z>=p&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&rs(o,u,l,d,c,h,v.x,v.y)&&pt(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&rs(o,u,l,d,c,h,b.x,b.y)&&pt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=p;){if(v.x>=f&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&rs(o,u,l,d,c,h,v.x,v.y)&&pt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&rs(o,u,l,d,c,h,b.x,b.y)&&pt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function VE(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!du(r,s)&&oy(r,i,i.next,s)&&$a(r,s)&&$a(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Wa(i),Wa(i.next),i=n=s),i=i.next}while(i!==n);return pr(i)}function HE(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&JE(a,o)){let l=ly(a,o);a=pr(a,a.next),l=pr(l,l.next),Ga(a,e,t,i,r,s,0),Ga(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function GE(n,e,t,i){let r=[],s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=ay(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(ZE(c));for(r.sort($E),s=0;s<r.length;s++)t=WE(r[s],t);return t}function $E(n,e){return n.x-e.x}function WE(n,e){let t=jE(n,e);if(!t)return e;let i=ly(t,n);return pr(i,i.next),pr(t,t.next)}function jE(n,e){let t=e,i=-1/0,r,s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){let h=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let o=r,l=r.x,c=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&rs(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(d=Math.abs(a-t.y)/(s-t.x),$a(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&XE(r,t)))&&(r=t,u=d)),t=t.next;while(t!==o);return r}function XE(n,e){return pt(n.prev,n,e.prev)<0&&pt(e.next,n,n.next)<0}function YE(n,e,t,i){let r=n;do r.z===0&&(r.z=Lh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,qE(r)}function qE(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function Lh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function ZE(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function rs(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function JE(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!KE(n,e)&&($a(n,e)&&$a(e,n)&&QE(n,e)&&(pt(n.prev,n,e.prev)||pt(n,e.prev,e))||du(n,e)&&pt(n.prev,n,n.next)>0&&pt(e.prev,e,e.next)>0)}function pt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function du(n,e){return n.x===e.x&&n.y===e.y}function oy(n,e,t,i){let r=Ol(pt(n,e,t)),s=Ol(pt(n,e,i)),a=Ol(pt(t,i,n)),o=Ol(pt(t,i,e));return!!(r!==s&&a!==o||r===0&&Dl(n,t,e)||s===0&&Dl(n,i,e)||a===0&&Dl(t,n,i)||o===0&&Dl(t,e,i))}function Dl(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ol(n){return n>0?1:n<0?-1:0}function KE(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&oy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function $a(n,e){return pt(n.prev,n,n.next)<0?pt(n,e,n.next)>=0&&pt(n,n.prev,e)>=0:pt(n,e,n.prev)<0||pt(n,n.next,e)<0}function QE(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function ly(n,e){let t=new Dh(n.i,n.x,n.y),i=new Dh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function mg(n,e,t,i){let r=new Dh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Wa(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Dh(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function eT(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}function gg(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function yg(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function nT(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function iT(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function vg(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function rr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function cy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function uy(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Oh(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){let o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Vf(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function rT(n,e,t,i,r=30){let s=n.clone();s.name=e;let a=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],u=c.getValueSize(),d=[],h=[];for(let f=0;f<c.times.length;++f){let m=c.times[f]*r;if(!(m<t||m>=i)){d.push(c.times[f]);for(let y=0;y<u;++y)h.push(c.values[f*u+y])}}d.length!==0&&(c.times=rr(d,c.times.constructor),c.values=rr(h,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function sT(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){let o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;let c=n.tracks.find(function(p){return p.name===o.name&&p.ValueTypeName===l});if(c===void 0)continue;let u=0,d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let m=o.times.length-1,y;if(s<=o.times[0]){let p=u,x=d-u;y=o.values.slice(p,x)}else if(s>=o.times[m]){let p=m*d+u,x=p+d-u;y=o.values.slice(p,x)}else{let p=o.createInterpolant(),x=u,v=d-u;p.evaluate(s),y=p.resultBuffer.slice(x,v)}l==="quaternion"&&new Vt().fromArray(y).normalize().conjugate().toArray(y);let g=c.times.length;for(let p=0;p<g;++p){let x=p*f+h;if(l==="quaternion")Vt.multiplyQuaternionsFlat(c.values,x,y,0,c.values,x);else{let v=f-h*2;for(let b=0;b<v;++b)c.values[x+b]-=y[b]}}}return n.blendMode=Nf,n}function oT(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gr;case"vector":case"vector2":case"vector3":case"vector4":return yr;case"color":return Za;case"quaternion":return Pi;case"bool":case"boolean":return oi;case"string":return li}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function lT(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=oT(n.type);if(n.times===void 0){let t=[],i=[];Vf(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function Tg(){return(typeof performance>"u"?Date:performance).now()}function Pg(n,e){return n.distance-e.distance}function af(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,a=r.length;s<a;s++)af(r[s],e,t,!0)}}function hy(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,hy(n.children[t]));return e}function vt(n,e,t,i,r,s,a){Bl.set(r,s,a).unproject(i);let o=e[n];if(o!==void 0){let l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Bl.x,Bl.y,Bl.z)}}var Ob,Ub,Nb,zg,Cd,Vg,Fb,kb,Ef,Hg,Cn,ri,jt,Pn,ti,sr,Rd,Pd,Ld,Gg,Ai,$g,Wg,jg,Xg,Yg,qg,Zg,Jg,Yl,ql,Kg,Qg,e0,t0,n0,i0,r0,s0,a0,o0,l0,c0,fa,u0,d0,h0,f0,to,p0,m0,ni,g0,y0,v0,x0,_0,b0,w0,Dd,M0,ou,si,Ti,pa,ma,xs,ga,gn,ya,Rt,Tf,Bb,ts,zb,bt,la,Vb,Ln,Hb,ai,S0,A0,If,Cf,lr,yn,no,Rf,Pf,_s,E0,T0,I0,en,C0,R0,ar,os,Lf,Df,P0,Of,Uf,Hl,Gl,$l,Wl,Od,Ud,Nd,Fd,kd,Bd,zd,Vd,Hd,Gd,$d,Wd,jd,Xd,Yd,qd,Zd,Jd,Kd,Qd,eh,jl,th,nh,L0,ih,rh,sh,D0,O0,U0,va,xa,Xl,nr,ir,_a,lu,Nf,Gb,$b,Wb,N0,F0,Li,k0,Zn,mn,ci,cu,io,ba,ut,wa,Ma,jb,Qi,Xb,Yb,qb,Zb,Jb,Kb,Qb,ew,tw,nw,iw,rw,sw,ah,B0,z0,V0,Ff,H0,G0,$0,W0,Sa,aw,ow,lw,cw,uw,dw,hw,fw,pw,oh,Dn,Aa,En,kt,lm,or,ls,Pw,te,Ve,Wu,Lw,cm,um,dm,Zo,Dw,at,Dr,Zl,Ow,Kn,Uw,wt,ot,Jl,nn,cs,lh,Ta,ch,Vt,R,Yu,hm,Dt,$n,wn,Jo,Or,Ur,Nr,yi,vi,Vi,Ys,Ko,Qo,Hi,Nw,qs,Zu,Pt,Wn,Ju,el,xi,Ku,tl,Qu,Ii,Ne,Fr,Mn,Fw,kw,_i,nl,Kt,fm,pm,rn,us,Bw,mm,kr,jn,il,Zs,zw,Vw,gm,ym,vm,xm,Hw,Br,ed,it,Sn,Xn,td,Yn,zr,Vr,_m,nd,id,rd,Qn,q0,bi,rl,we,Bt,Gw,Lt,Nn,Jn,Ww,_t,sl,tt,uh,dh,hh,fh,Ia,ph,Ca,mh,Te,jw,pn,ad,Hr,Qt,Js,Ct,Xe,bm,Gi,al,wm,Gr,$r,Wr,od,ol,ll,cl,ul,Mm,Sm,Am,dl,hl,yt,cr,J0,qw,Zw,sn,hs,wi,Em,Tm,At,jr,Xr,Kl,ur,Ql,ld,Jw,Kw,Rn,$i,pl,dr,fs,eM,tM,nM,iM,rM,sM,aM,oM,lM,cM,uM,dM,hM,fM,pM,mM,gM,yM,vM,xM,_M,bM,wM,MM,SM,AM,EM,TM,IM,CM,RM,PM,LM,DM,OM,UM,NM,FM,kM,BM,zM,VM,HM,GM,$M,WM,jM,XM,YM,qM,ZM,JM,KM,QM,eS,tS,nS,iS,rS,sS,aS,oS,lS,cS,uS,dS,hS,fS,pS,mS,gS,yS,vS,xS,_S,bS,wS,MS,SS,AS,ES,TS,IS,CS,RS,PS,LS,DS,OS,US,NS,FS,kS,BS,zS,VS,HS,GS,$S,WS,jS,XS,YS,qS,ZS,JS,KS,QS,e1,t1,n1,i1,r1,s1,a1,o1,l1,c1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,_1,b1,w1,M1,S1,A1,E1,T1,I1,C1,R1,P1,L1,$e,ye,An,ml,Wi,D1,ps,is,Im,tr,cd,Cm,ud,dd,hd,fd,er,Yr,Rm,Ra,Pa,Q0,ey,ty,ny,iy,Om,Um,Nm,Fm,km,gh,yh,vh,pd,as,NA,FA,WA,jA,YA,nE,_h,bh,cE,La,Da,fE,pE,ec,Ei,vE,ua,xE,_E,wh,Mh,ji,bE,Sh,tc,nc,ic,ms,Gt,hr,Oa,qr,Ks,Zr,Jr,Kr,Qs,sy,yl,ea,vl,qm,md,Zm,rc,_l,Jm,sc,Km,Qm,eg,SE,tg,bl,gd,ng,yd,ac,Ua,On,ig,AE,oc,Ci,Qr,rg,wl,sg,EE,ta,na,lc,Ah,es,Mi,ag,CE,og,vd,Ml,Xi,ia,xd,zt,Sl,cc,Ot,uc,dc,lg,ra,Al,_d,cg,Fn,ug,dg,vn,hc,Na,hg,Eh,Tl,Il,fc,Th,Ih,gs,Ch,Rh,Ph,an,ys,pc,Cl,bd,wd,Md,mc,Fa,gc,ka,yc,Ba,za,Va,vc,xc,fr,Ha,_c,bc,vs,wc,Ri,Mc,Rl,Pl,Sd,Ll,Sc,ii,kE,Un,Ac,tT,Ec,ja,Tc,Ic,Xa,Cc,Rc,Pc,Lc,Dc,xg,Oc,Uc,Ya,Nc,Fc,kc,Bc,zc,Vc,Hc,aT,mr,Gc,qa,$c,on,oi,Za,gr,Wc,Pi,li,yr,vr,ei,Ja,dy,Ht,qn,Uh,Tn,Nh,Fh,xr,kh,Bh,zh,kn,jc,Ad,_g,bg,Ka,Vh,Xc,wg,sa,Ed,Hh,Yc,Gh,qc,Zc,Jc,Kc,Qc,eu,Qa,tu,nu,$h,cT,Mg,Sg,Wh,Ul,eo,jh,Ag,Eg,Yi,Xh,iu,qi,Ig,uT,Zi,Yh,ru,Ji,Cg,dT,Ki,qh,Zh,su,Hf,hT,Gf,fT,pT,mT,gT,yT,vT,xT,Jh,st,Kh,au,_T,Qh,ef,bT,tf,nf,rf,Rg,sf,of,lf,Lg,cf,Dg,Nl,uf,Og,df,Si,Fl,Td,hf,ff,wT,Ug,Ng,pf,mf,gf,Fg,kl,kg,yf,Bl,mt,vf,zl,xf,_f,bf,Bg,Vl,Id,wf,Mf,Sf,Af,py=Vy(()=>{"use strict";Ob="164",Ub={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Nb={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zg=0,Cd=1,Vg=2,Fb=3,kb=0,Ef=1,Hg=2,Cn=3,ri=0,jt=1,Pn=2,ti=0,sr=1,Rd=2,Pd=3,Ld=4,Gg=5,Ai=100,$g=101,Wg=102,jg=103,Xg=104,Yg=200,qg=201,Zg=202,Jg=203,Yl=204,ql=205,Kg=206,Qg=207,e0=208,t0=209,n0=210,i0=211,r0=212,s0=213,a0=214,o0=0,l0=1,c0=2,fa=3,u0=4,d0=5,h0=6,f0=7,to=0,p0=1,m0=2,ni=0,g0=1,y0=2,v0=3,x0=4,_0=5,b0=6,w0=7,Dd="attached",M0="detached",ou=300,si=301,Ti=302,pa=303,ma=304,xs=306,ga=1e3,gn=1001,ya=1002,Rt=1003,Tf=1004,Bb=1004,ts=1005,zb=1005,bt=1006,la=1007,Vb=1007,Ln=1008,Hb=1008,ai=1009,S0=1010,A0=1011,If=1012,Cf=1013,lr=1014,yn=1015,no=1016,Rf=1017,Pf=1018,_s=1020,E0=35902,T0=1021,I0=1022,en=1023,C0=1024,R0=1025,ar=1026,os=1027,Lf=1028,Df=1029,P0=1030,Of=1031,Uf=1033,Hl=33776,Gl=33777,$l=33778,Wl=33779,Od=35840,Ud=35841,Nd=35842,Fd=35843,kd=36196,Bd=37492,zd=37496,Vd=37808,Hd=37809,Gd=37810,$d=37811,Wd=37812,jd=37813,Xd=37814,Yd=37815,qd=37816,Zd=37817,Jd=37818,Kd=37819,Qd=37820,eh=37821,jl=36492,th=36494,nh=36495,L0=36283,ih=36284,rh=36285,sh=36286,D0=2200,O0=2201,U0=2202,va=2300,xa=2301,Xl=2302,nr=2400,ir=2401,_a=2402,lu=2500,Nf=2501,Gb=0,$b=1,Wb=2,N0=3200,F0=3201,Li=0,k0=1,Zn="",mn="srgb",ci="srgb-linear",cu="display-p3",io="display-p3-linear",ba="linear",ut="srgb",wa="rec709",Ma="p3",jb=0,Qi=7680,Xb=7681,Yb=7682,qb=7683,Zb=34055,Jb=34056,Kb=5386,Qb=512,ew=513,tw=514,nw=515,iw=516,rw=517,sw=518,ah=519,B0=512,z0=513,V0=514,Ff=515,H0=516,G0=517,$0=518,W0=519,Sa=35044,aw=35048,ow=35040,lw=35045,cw=35049,uw=35041,dw=35046,hw=35050,fw=35042,pw="100",oh="300 es",Dn=2e3,Aa=2001,En=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}},kt=["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"],lm=1234567,or=Math.PI/180,ls=180/Math.PI;Pw={DEG2RAD:or,RAD2DEG:ls,generateUUID:tn,clamp:gt,euclideanModulo:kf,mapLinear:mw,inverseLerp:gw,lerp:ca,damp:yw,pingpong:vw,smoothstep:xw,smootherstep:_w,randInt:bw,randFloat:ww,randFloatSpread:Mw,seededRandom:Sw,degToRad:Aw,radToDeg:Ew,isPowerOfTwo:Tw,ceilPowerOfTwo:Iw,floorPowerOfTwo:Cw,setQuaternionFromProperEuler:Rw,normalize:He,denormalize:Wt},te=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(gt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ve=class n{constructor(e,t,i,r,s,a,o,l,c){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){let u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],m=i[8],y=r[0],g=r[3],p=r[6],x=r[1],v=r[4],b=r[7],L=r[2],A=r[5],E=r[8];return s[0]=a*y+o*x+l*L,s[3]=a*g+o*v+l*A,s[6]=a*p+o*b+l*E,s[1]=c*y+u*x+d*L,s[4]=c*g+u*v+d*A,s[7]=c*p+u*b+d*E,s[2]=h*y+f*x+m*L,s[5]=h*g+f*v+m*A,s[8]=h*p+f*b+m*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*s,f=c*s-a*l,m=t*d+i*h+r*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/m;return e[0]=d*y,e[1]=(r*c-u*i)*y,e[2]=(o*i-r*a)*y,e[3]=h*y,e[4]=(u*t-r*l)*y,e[5]=(r*s-o*t)*y,e[6]=f*y,e[7]=(i*l-c*t)*y,e[8]=(a*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){let l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Wu.makeScale(e,t)),this}rotate(e){return this.premultiply(Wu.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wu.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Wu=new Ve;Lw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};cm={};um=new Ve().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),dm=new Ve().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Zo={[ci]:{transfer:ba,primaries:wa,toReference:n=>n,fromReference:n=>n},[mn]:{transfer:ut,primaries:wa,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[io]:{transfer:ba,primaries:Ma,toReference:n=>n.applyMatrix3(dm),fromReference:n=>n.applyMatrix3(um)},[cu]:{transfer:ut,primaries:Ma,toReference:n=>n.convertSRGBToLinear().applyMatrix3(dm),fromReference:n=>n.applyMatrix3(um).convertLinearToSRGB()}},Dw=new Set([ci,io]),at={enabled:!0,_workingColorSpace:ci,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Dw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Zo[e].toReference,r=Zo[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Zo[n].primaries},getTransfer:function(n){return n===Zn?ba:Zo[n].transfer}};Zl=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Dr===void 0&&(Dr=Ea("canvas")),Dr.width=e.width,Dr.height=e.height;let i=Dr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Dr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Ea("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=ss(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(ss(t[i]/255)*255):t[i]=ss(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Ow=0,Kn=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ow++}),this.uuid=tn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Xu(r[a].image)):s.push(Xu(r[a]))}else s=Xu(r);i.url=s}return t||(e.images[this.uuid]=i),i}};Uw=0,wt=class n extends En{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=gn,r=gn,s=bt,a=Ln,o=en,l=ai,c=n.DEFAULT_ANISOTROPY,u=Zn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Uw++}),this.uuid=tn(),this.name="",this.source=new Kn(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ou)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ga:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case ya:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ga:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case ya:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};wt.DEFAULT_IMAGE=null;wt.DEFAULT_MAPPING=ou;wt.DEFAULT_ANISOTROPY=1;ot=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],m=l[9],y=l[2],g=l[6],p=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(m-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(c+1)/2,b=(f+1)/2,L=(p+1)/2,A=(u+h)/4,E=(d+y)/4,D=(m+g)/4;return v>b&&v>L?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=A/i,s=E/i):b>L?b<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),i=A/r,s=D/r):L<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),i=E/s,r=D/s),this.set(i,r,s,t),this}let x=Math.sqrt((g-m)*(g-m)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(g-m)/x,this.y=(d-y)/x,this.z=(h-u)/x,this.w=Math.acos((c+f+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Jl=class extends En{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ot(0,0,e,t),this.scissorTest=!1,this.viewport=new ot(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Kn(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},nn=class extends Jl{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},cs=class extends wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Rt,this.minFilter=Rt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},lh=class extends nn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new cs(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Ta=class extends wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Rt,this.minFilter=Rt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ch=class extends nn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ta(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Vt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],d=i[r+3],h=s[a+0],f=s[a+1],m=s[a+2],y=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d;return}if(o===1){e[t+0]=h,e[t+1]=f,e[t+2]=m,e[t+3]=y;return}if(d!==y||l!==h||c!==f||u!==m){let g=1-o,p=l*h+c*f+u*m+d*y,x=p>=0?1:-1,v=1-p*p;if(v>Number.EPSILON){let L=Math.sqrt(v),A=Math.atan2(L,p*x);g=Math.sin(g*A)/L,o=Math.sin(o*A)/L}let b=o*x;if(l=l*g+h*b,c=c*g+f*b,u=u*g+m*b,d=d*g+y*b,g===1-o){let L=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=L,c*=L,u*=L,d*=L}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,a){let o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],d=s[a],h=s[a+1],f=s[a+2],m=s[a+3];return e[t]=o*m+u*d+l*f-c*h,e[t+1]=l*m+u*h+c*d-o*f,e[t+2]=c*m+u*f+o*h-l*d,e[t+3]=u*m-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),d=o(s/2),h=l(i/2),f=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=h*u*d+c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d-h*f*m;break;case"YXZ":this._x=h*u*d+c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d+h*f*m;break;case"ZXY":this._x=h*u*d-c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d-h*f*m;break;case"ZYX":this._x=h*u*d-c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d+h*f*m;break;case"YZX":this._x=h*u*d+c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d-h*f*m;break;case"XZY":this._x=h*u*d-c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d+h*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(a-r)*f}else if(i>o&&i>d){let f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(r+a)/f,this._z=(s+c)/f}else if(o>d){let f=2*Math.sqrt(1+o-i-d);this._w=(s-c)/f,this._x=(r+a)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+d-i-o);this._w=(a-r)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,a=this._w,o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;let l=1-o*o;if(l<=Number.EPSILON){let f=1-t;return this._w=f*a+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let c=Math.sqrt(l),u=Math.atan2(c,o),d=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=a*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(hm.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(hm.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),d=2*(s*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-s*d,this.z=r+l*d+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Yu.copy(this).projectOnVector(e),this.sub(Yu)}reflect(e){return this.sub(Yu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(gt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Yu=new R,hm=new Vt,Dt=class{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(wn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(wn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=wn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,wn):wn.fromBufferAttribute(s,a),wn.applyMatrix4(e.matrixWorld),this.expandByPoint(wn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Jo.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Jo.copy(i.boundingBox)),Jo.applyMatrix4(e.matrixWorld),this.union(Jo)}let r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,wn),wn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ys),Ko.subVectors(this.max,Ys),Or.subVectors(e.a,Ys),Ur.subVectors(e.b,Ys),Nr.subVectors(e.c,Ys),yi.subVectors(Ur,Or),vi.subVectors(Nr,Ur),Vi.subVectors(Or,Nr);let t=[0,-yi.z,yi.y,0,-vi.z,vi.y,0,-Vi.z,Vi.y,yi.z,0,-yi.x,vi.z,0,-vi.x,Vi.z,0,-Vi.x,-yi.y,yi.x,0,-vi.y,vi.x,0,-Vi.y,Vi.x,0];return!qu(t,Or,Ur,Nr,Ko)||(t=[1,0,0,0,1,0,0,0,1],!qu(t,Or,Ur,Nr,Ko))?!1:(Qo.crossVectors(yi,vi),t=[Qo.x,Qo.y,Qo.z],qu(t,Or,Ur,Nr,Ko))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(wn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:($n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($n),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},$n=[new R,new R,new R,new R,new R,new R,new R,new R],wn=new R,Jo=new Dt,Or=new R,Ur=new R,Nr=new R,yi=new R,vi=new R,Vi=new R,Ys=new R,Ko=new R,Qo=new R,Hi=new R;Nw=new Dt,qs=new R,Zu=new R,Pt=class{constructor(e=new R,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):Nw.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;qs.subVectors(e,this.center);let t=qs.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(qs,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Zu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(qs.copy(e.center).add(Zu)),this.expandByPoint(qs.copy(e.center).sub(Zu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Wn=new R,Ju=new R,el=new R,xi=new R,Ku=new R,tl=new R,Qu=new R,Ii=class{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ju.copy(e).add(t).multiplyScalar(.5),el.copy(t).sub(e).normalize(),xi.copy(this.origin).sub(Ju);let s=e.distanceTo(t)*.5,a=-this.direction.dot(el),o=xi.dot(this.direction),l=-xi.dot(el),c=xi.lengthSq(),u=Math.abs(1-a*a),d,h,f,m;if(u>0)if(d=a*l-o,h=a*o-l,m=s*u,d>=0)if(h>=-m)if(h<=m){let y=1/u;d*=y,h*=y,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-m?(d=Math.max(0,-(-a*s+o)),h=d>0?-s:Math.min(Math.max(-s,-l),s),f=-d*d+h*(h+2*l)+c):h<=m?(d=0,h=Math.min(Math.max(-s,-l),s),f=h*(h+2*l)+c):(d=Math.max(0,-(a*s+o)),h=d>0?s:Math.min(Math.max(-s,-l),s),f=-d*d+h*(h+2*l)+c);else h=a>0?-s:s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Ju).addScaledVector(el,h),f}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);let i=Wn.dot(this.direction),r=Wn.dot(Wn)-i*i,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l,c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,i,r,s){Ku.subVectors(t,e),tl.subVectors(i,e),Qu.crossVectors(Ku,tl);let a=this.direction.dot(Qu),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;xi.subVectors(this.origin,e);let l=o*this.direction.dot(tl.crossVectors(xi,tl));if(l<0)return null;let c=o*this.direction.dot(Ku.cross(xi));if(c<0||l+c>a)return null;let u=-o*xi.dot(Qu);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ne=class n{constructor(e,t,i,r,s,a,o,l,c,u,d,h,f,m,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c,u,d,h,f,m,y,g)}set(e,t,i,r,s,a,o,l,c,u,d,h,f,m,y,g){let p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=r,p[1]=s,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=u,p[10]=d,p[14]=h,p[3]=f,p[7]=m,p[11]=y,p[15]=g,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 n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/Fr.setFromMatrixColumn(e,0).length(),s=1/Fr.setFromMatrixColumn(e,1).length(),a=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=a*u,f=a*d,m=o*u,y=o*d;t[0]=l*u,t[4]=-l*d,t[8]=c,t[1]=f+m*c,t[5]=h-y*c,t[9]=-o*l,t[2]=y-h*c,t[6]=m+f*c,t[10]=a*l}else if(e.order==="YXZ"){let h=l*u,f=l*d,m=c*u,y=c*d;t[0]=h+y*o,t[4]=m*o-f,t[8]=a*c,t[1]=a*d,t[5]=a*u,t[9]=-o,t[2]=f*o-m,t[6]=y+h*o,t[10]=a*l}else if(e.order==="ZXY"){let h=l*u,f=l*d,m=c*u,y=c*d;t[0]=h-y*o,t[4]=-a*d,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*u,t[9]=y-h*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){let h=a*u,f=a*d,m=o*u,y=o*d;t[0]=l*u,t[4]=m*c-f,t[8]=h*c+y,t[1]=l*d,t[5]=y*c+h,t[9]=f*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){let h=a*l,f=a*c,m=o*l,y=o*c;t[0]=l*u,t[4]=y-h*d,t[8]=m*d+f,t[1]=d,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*d+m,t[10]=h-y*d}else if(e.order==="XZY"){let h=a*l,f=a*c,m=o*l,y=o*c;t[0]=l*u,t[4]=-d,t[8]=c*u,t[1]=h*d+y,t[5]=a*u,t[9]=f*d-m,t[2]=m*d-f,t[6]=o*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Fw,e,kw)}lookAt(e,t,i){let r=this.elements;return Kt.subVectors(e,t),Kt.lengthSq()===0&&(Kt.z=1),Kt.normalize(),_i.crossVectors(i,Kt),_i.lengthSq()===0&&(Math.abs(i.z)===1?Kt.x+=1e-4:Kt.z+=1e-4,Kt.normalize(),_i.crossVectors(i,Kt)),_i.normalize(),nl.crossVectors(Kt,_i),r[0]=_i.x,r[4]=nl.x,r[8]=Kt.x,r[1]=_i.y,r[5]=nl.y,r[9]=Kt.y,r[2]=_i.z,r[6]=nl.z,r[10]=Kt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],d=i[5],h=i[9],f=i[13],m=i[2],y=i[6],g=i[10],p=i[14],x=i[3],v=i[7],b=i[11],L=i[15],A=r[0],E=r[4],D=r[8],M=r[12],w=r[1],T=r[5],U=r[9],I=r[13],B=r[2],W=r[6],F=r[10],X=r[14],k=r[3],re=r[7],se=r[11],ve=r[15];return s[0]=a*A+o*w+l*B+c*k,s[4]=a*E+o*T+l*W+c*re,s[8]=a*D+o*U+l*F+c*se,s[12]=a*M+o*I+l*X+c*ve,s[1]=u*A+d*w+h*B+f*k,s[5]=u*E+d*T+h*W+f*re,s[9]=u*D+d*U+h*F+f*se,s[13]=u*M+d*I+h*X+f*ve,s[2]=m*A+y*w+g*B+p*k,s[6]=m*E+y*T+g*W+p*re,s[10]=m*D+y*U+g*F+p*se,s[14]=m*M+y*I+g*X+p*ve,s[3]=x*A+v*w+b*B+L*k,s[7]=x*E+v*T+b*W+L*re,s[11]=x*D+v*U+b*F+L*se,s[15]=x*M+v*I+b*X+L*ve,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],d=e[6],h=e[10],f=e[14],m=e[3],y=e[7],g=e[11],p=e[15];return m*(+s*l*d-r*c*d-s*o*h+i*c*h+r*o*f-i*l*f)+y*(+t*l*f-t*c*h+s*a*h-r*a*f+r*c*u-s*l*u)+g*(+t*c*d-t*o*f-s*a*d+i*a*f+s*o*u-i*c*u)+p*(-r*o*u-t*l*d+t*o*h+r*a*d-i*a*h+i*l*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=e[9],h=e[10],f=e[11],m=e[12],y=e[13],g=e[14],p=e[15],x=d*g*c-y*h*c+y*l*f-o*g*f-d*l*p+o*h*p,v=m*h*c-u*g*c-m*l*f+a*g*f+u*l*p-a*h*p,b=u*y*c-m*d*c+m*o*f-a*y*f-u*o*p+a*d*p,L=m*d*l-u*y*l-m*o*h+a*y*h+u*o*g-a*d*g,A=t*x+i*v+r*b+s*L;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/A;return e[0]=x*E,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*p-i*h*p)*E,e[2]=(o*g*s-y*l*s+y*r*c-i*g*c-o*r*p+i*l*p)*E,e[3]=(d*l*s-o*h*s-d*r*c+i*h*c+o*r*f-i*l*f)*E,e[4]=v*E,e[5]=(u*g*s-m*h*s+m*r*f-t*g*f-u*r*p+t*h*p)*E,e[6]=(m*l*s-a*g*s-m*r*c+t*g*c+a*r*p-t*l*p)*E,e[7]=(a*h*s-u*l*s+u*r*c-t*h*c-a*r*f+t*l*f)*E,e[8]=b*E,e[9]=(m*d*s-u*y*s-m*i*f+t*y*f+u*i*p-t*d*p)*E,e[10]=(a*y*s-m*o*s+m*i*c-t*y*c-a*i*p+t*o*p)*E,e[11]=(u*o*s-a*d*s-u*i*c+t*d*c+a*i*f-t*o*f)*E,e[12]=L*E,e[13]=(u*y*r-m*d*r+m*i*h-t*y*h-u*i*g+t*d*g)*E,e[14]=(m*o*r-a*y*r-m*i*l+t*y*l+a*i*g-t*o*g)*E,e[15]=(a*d*r-u*o*r+u*i*l-t*d*l-a*i*h+t*o*h)*E,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,d=o+o,h=s*c,f=s*u,m=s*d,y=a*u,g=a*d,p=o*d,x=l*c,v=l*u,b=l*d,L=i.x,A=i.y,E=i.z;return r[0]=(1-(y+p))*L,r[1]=(f+b)*L,r[2]=(m-v)*L,r[3]=0,r[4]=(f-b)*A,r[5]=(1-(h+p))*A,r[6]=(g+x)*A,r[7]=0,r[8]=(m+v)*E,r[9]=(g-x)*E,r[10]=(1-(h+y))*E,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=Fr.set(r[0],r[1],r[2]).length(),a=Fr.set(r[4],r[5],r[6]).length(),o=Fr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Mn.copy(this);let c=1/s,u=1/a,d=1/o;return Mn.elements[0]*=c,Mn.elements[1]*=c,Mn.elements[2]*=c,Mn.elements[4]*=u,Mn.elements[5]*=u,Mn.elements[6]*=u,Mn.elements[8]*=d,Mn.elements[9]*=d,Mn.elements[10]*=d,t.setFromRotationMatrix(Mn),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Dn){let l=this.elements,c=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,m;if(o===Dn)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Aa)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=Dn){let l=this.elements,c=1/(t-e),u=1/(i-r),d=1/(a-s),h=(t+e)*c,f=(i+r)*u,m,y;if(o===Dn)m=(a+s)*d,y=-2*d;else if(o===Aa)m=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-h,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=y,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Fr=new R,Mn=new Ne,Fw=new R(0,0,0),kw=new R(1,1,1),_i=new R,nl=new R,Kt=new R,fm=new Ne,pm=new Vt,rn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-gt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(gt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return fm.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fm,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pm.setFromEuler(this),this.setFromQuaternion(pm,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};rn.DEFAULT_ORDER="XYZ";us=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Bw=0,mm=new R,kr=new Vt,jn=new Ne,il=new R,Zs=new R,zw=new R,Vw=new Vt,gm=new R(1,0,0),ym=new R(0,1,0),vm=new R(0,0,1),xm={type:"added"},Hw={type:"removed"},Br={type:"childadded",child:null},ed={type:"childremoved",child:null},it=class n extends En{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Bw++}),this.uuid=tn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new R,t=new rn,i=new Vt,r=new R(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ne},normalMatrix:{value:new Ve}}),this.matrix=new Ne,this.matrixWorld=new Ne,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.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.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return kr.setFromAxisAngle(e,t),this.quaternion.multiply(kr),this}rotateOnWorldAxis(e,t){return kr.setFromAxisAngle(e,t),this.quaternion.premultiply(kr),this}rotateX(e){return this.rotateOnAxis(gm,e)}rotateY(e){return this.rotateOnAxis(ym,e)}rotateZ(e){return this.rotateOnAxis(vm,e)}translateOnAxis(e,t){return mm.copy(e).applyQuaternion(this.quaternion),this.position.add(mm.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(gm,e)}translateY(e){return this.translateOnAxis(ym,e)}translateZ(e){return this.translateOnAxis(vm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(jn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?il.copy(e):il.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Zs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jn.lookAt(Zs,il,this.up):jn.lookAt(il,Zs,this.up),this.quaternion.setFromRotationMatrix(jn),r&&(jn.extractRotation(r.matrixWorld),kr.setFromRotationMatrix(jn),this.quaternion.premultiply(kr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(xm),Br.child=e,this.dispatchEvent(Br),Br.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Hw),ed.child=e,this.dispatchEvent(ed),ed.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),jn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jn.multiply(e.parent.matrixWorld)),e.applyMatrix4(jn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(xm),Br.child=e,this.dispatchEvent(Br),Br.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,e,zw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,Vw,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++){let o=r[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){let o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),d=a(e.shapes),h=a(e.skeletons),f=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){let l=[];for(let c in o){let u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};it.DEFAULT_UP=new R(0,1,0);it.DEFAULT_MATRIX_AUTO_UPDATE=!0;it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Sn=new R,Xn=new R,td=new R,Yn=new R,zr=new R,Vr=new R,_m=new R,nd=new R,id=new R,rd=new R,Qn=class n{constructor(e=new R,t=new R,i=new R){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Sn.subVectors(e,t),r.cross(Sn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Sn.subVectors(r,t),Xn.subVectors(i,t),td.subVectors(e,t);let a=Sn.dot(Sn),o=Sn.dot(Xn),l=Sn.dot(td),c=Xn.dot(Xn),u=Xn.dot(td),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(c*l-o*u)*h,m=(a*u-o*l)*h;return s.set(1-f-m,m,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Yn)===null?!1:Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,Yn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Yn.x),l.addScaledVector(a,Yn.y),l.addScaledVector(o,Yn.z),l)}static isFrontFacing(e,t,i,r){return Sn.subVectors(i,t),Xn.subVectors(e,t),Sn.cross(Xn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Sn.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),Sn.cross(Xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,a,o;zr.subVectors(r,i),Vr.subVectors(s,i),nd.subVectors(e,i);let l=zr.dot(nd),c=Vr.dot(nd);if(l<=0&&c<=0)return t.copy(i);id.subVectors(e,r);let u=zr.dot(id),d=Vr.dot(id);if(u>=0&&d<=u)return t.copy(r);let h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(zr,a);rd.subVectors(e,s);let f=zr.dot(rd),m=Vr.dot(rd);if(m>=0&&f<=m)return t.copy(s);let y=f*c-l*m;if(y<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Vr,o);let g=u*m-f*d;if(g<=0&&d-u>=0&&f-m>=0)return _m.subVectors(s,r),o=(d-u)/(d-u+(f-m)),t.copy(r).addScaledVector(_m,o);let p=1/(g+y+h);return a=y*p,o=h*p,t.copy(i).addScaledVector(zr,a).addScaledVector(Vr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},q0={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},bi={h:0,s:0,l:0},rl={h:0,s:0,l:0};we=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=mn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,at.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=at.workingColorSpace){return this.r=e,this.g=t,this.b=i,at.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=at.workingColorSpace){if(e=kf(e,1),t=gt(t,0,1),i=gt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=sd(a,s,e+1/3),this.g=sd(a,s,e),this.b=sd(a,s,e-1/3)}return at.toWorkingColorSpace(this,r),this}setStyle(e,t=mn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=mn){let i=q0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ss(e.r),this.g=ss(e.g),this.b=ss(e.b),this}copyLinearToSRGB(e){return this.r=ju(e.r),this.g=ju(e.g),this.b=ju(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mn){return at.fromWorkingColorSpace(Bt.copy(this),e),Math.round(gt(Bt.r*255,0,255))*65536+Math.round(gt(Bt.g*255,0,255))*256+Math.round(gt(Bt.b*255,0,255))}getHexString(e=mn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=at.workingColorSpace){at.fromWorkingColorSpace(Bt.copy(this),t);let i=Bt.r,r=Bt.g,s=Bt.b,a=Math.max(i,r,s),o=Math.min(i,r,s),l,c,u=(o+a)/2;if(o===a)l=0,c=0;else{let d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-i)/d+2;break;case s:l=(i-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=at.workingColorSpace){return at.fromWorkingColorSpace(Bt.copy(this),t),e.r=Bt.r,e.g=Bt.g,e.b=Bt.b,e}getStyle(e=mn){at.fromWorkingColorSpace(Bt.copy(this),e);let t=Bt.r,i=Bt.g,r=Bt.b;return e!==mn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(bi),this.setHSL(bi.h+e,bi.s+t,bi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(bi),e.getHSL(rl);let i=ca(bi.h,rl.h,t),r=ca(bi.s,rl.s,t),s=ca(bi.l,rl.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Bt=new we;we.NAMES=q0;Gw=0,Lt=class extends En{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gw++}),this.uuid=tn(),this.name="",this.type="Material",this.blending=sr,this.side=ri,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Yl,this.blendDst=ql,this.blendEquation=Ai,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=fa,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ah,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qi,this.stencilZFail=Qi,this.stencilZPass=Qi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==sr&&(i.blending=this.blending),this.side!==ri&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Yl&&(i.blendSrc=this.blendSrc),this.blendDst!==ql&&(i.blendDst=this.blendDst),this.blendEquation!==Ai&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==fa&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ah&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qi&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Qi&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Qi&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let a=[];for(let o in s){let l=s[o];delete l.metadata,a.push(l)}return a}if(t){let s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Nn=class extends Lt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new we(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=to,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Jn=$w();Ww={toHalfFloat:Yt,fromHalfFloat:aa},_t=new R,sl=new te,tt=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Sa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=yn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Y0("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)sl.fromBufferAttribute(this,t),sl.applyMatrix3(e),this.setXY(t,sl.x,sl.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyMatrix3(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyMatrix4(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyNormalMatrix(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.transformDirection(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Wt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=He(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wt(t,this.array)),t}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wt(t,this.array)),t}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Wt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Wt(t,this.array)),t}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Sa&&(e.usage=this.usage),e}},uh=class extends tt{constructor(e,t,i){super(new Int8Array(e),t,i)}},dh=class extends tt{constructor(e,t,i){super(new Uint8Array(e),t,i)}},hh=class extends tt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},fh=class extends tt{constructor(e,t,i){super(new Int16Array(e),t,i)}},Ia=class extends tt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},ph=class extends tt{constructor(e,t,i){super(new Int32Array(e),t,i)}},Ca=class extends tt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},mh=class extends tt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=aa(this.array[e*this.itemSize]);return this.normalized&&(t=Wt(t,this.array)),t}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize]=Yt(t),this}getY(e){let t=aa(this.array[e*this.itemSize+1]);return this.normalized&&(t=Wt(t,this.array)),t}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+1]=Yt(t),this}getZ(e){let t=aa(this.array[e*this.itemSize+2]);return this.normalized&&(t=Wt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+2]=Yt(t),this}getW(e){let t=aa(this.array[e*this.itemSize+3]);return this.normalized&&(t=Wt(t,this.array)),t}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+3]=Yt(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this.array[e+2]=Yt(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this.array[e+2]=Yt(r),this.array[e+3]=Yt(s),this}},Te=class extends tt{constructor(e,t,i){super(new Float32Array(e),t,i)}},jw=0,pn=new Ne,ad=new it,Hr=new R,Qt=new Dt,Js=new Dt,Ct=new R,Xe=class n extends En{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jw++}),this.uuid=tn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(j0(e)?Ca:Ia)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Ve().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pn.makeRotationFromQuaternion(e),this.applyMatrix4(pn),this}rotateX(e){return pn.makeRotationX(e),this.applyMatrix4(pn),this}rotateY(e){return pn.makeRotationY(e),this.applyMatrix4(pn),this}rotateZ(e){return pn.makeRotationZ(e),this.applyMatrix4(pn),this}translate(e,t,i){return pn.makeTranslation(e,t,i),this.applyMatrix4(pn),this}scale(e,t,i){return pn.makeScale(e,t,i),this.applyMatrix4(pn),this}lookAt(e){return ad.lookAt(e),ad.updateMatrix(),this.applyMatrix4(ad.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hr).negate(),this.translate(Hr.x,Hr.y,Hr.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Te(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];Qt.setFromBufferAttribute(s),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,Qt.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,Qt.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(Qt.min),this.boundingBox.expandByPoint(Qt.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 Pt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){let i=this.boundingSphere.center;if(Qt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){let o=t[s];Js.setFromBufferAttribute(o),this.morphTargetsRelative?(Ct.addVectors(Qt.min,Js.min),Qt.expandByPoint(Ct),Ct.addVectors(Qt.max,Js.max),Qt.expandByPoint(Ct)):(Qt.expandByPoint(Js.min),Qt.expandByPoint(Js.max))}Qt.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)Ct.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ct));if(t)for(let s=0,a=t.length;s<a;s++){let o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)Ct.fromBufferAttribute(o,c),l&&(Hr.fromBufferAttribute(e,c),Ct.add(Hr)),r=Math.max(r,i.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(r),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 e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new tt(new Float32Array(4*i.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let D=0;D<i.count;D++)o[D]=new R,l[D]=new R;let c=new R,u=new R,d=new R,h=new te,f=new te,m=new te,y=new R,g=new R;function p(D,M,w){c.fromBufferAttribute(i,D),u.fromBufferAttribute(i,M),d.fromBufferAttribute(i,w),h.fromBufferAttribute(s,D),f.fromBufferAttribute(s,M),m.fromBufferAttribute(s,w),u.sub(c),d.sub(c),f.sub(h),m.sub(h);let T=1/(f.x*m.y-m.x*f.y);isFinite(T)&&(y.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(T),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(T),o[D].add(y),o[M].add(y),o[w].add(y),l[D].add(g),l[M].add(g),l[w].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let D=0,M=x.length;D<M;++D){let w=x[D],T=w.start,U=w.count;for(let I=T,B=T+U;I<B;I+=3)p(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let v=new R,b=new R,L=new R,A=new R;function E(D){L.fromBufferAttribute(r,D),A.copy(L);let M=o[D];v.copy(M),v.sub(L.multiplyScalar(L.dot(M))).normalize(),b.crossVectors(A,M);let T=b.dot(l[D])<0?-1:1;a.setXYZW(D,v.x,v.y,v.z,T)}for(let D=0,M=x.length;D<M;++D){let w=x[D],T=w.start,U=w.count;for(let I=T,B=T+U;I<B;I+=3)E(e.getX(I+0)),E(e.getX(I+1)),E(e.getX(I+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new tt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new R,s=new R,a=new R,o=new R,l=new R,c=new R,u=new R,d=new R;if(e)for(let h=0,f=e.count;h<f;h+=3){let m=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),u.subVectors(a,s),d.subVectors(r,s),u.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,g),o.add(u),l.add(u),c.add(u),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(o,l){let c=o.array,u=o.itemSize,d=o.normalized,h=new c.constructor(l.length*u),f=0,m=0;for(let y=0,g=l.length;y<g;y++){o.isInterleavedBufferAttribute?f=l[y]*o.data.stride+o.offset:f=l[y]*u;for(let p=0;p<u;p++)h[m++]=c[f++]}return new tt(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let l=r[o],c=e(l,i);t.setAttribute(o,c)}let s=this.morphAttributes;for(let o in s){let l=[],c=s[o];for(let u=0,d=c.length;u<d;u++){let h=c[u],f=e(h,i);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let l in i){let c=i[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d];u.push(f.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let c in r){let u=r[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],d=s[c];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let c=0,u=a.length;c<u;c++){let d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},bm=new Ne,Gi=new Ii,al=new Pt,wm=new R,Gr=new R,$r=new R,Wr=new R,od=new R,ol=new R,ll=new te,cl=new te,ul=new te,Mm=new R,Sm=new R,Am=new R,dl=new R,hl=new R,yt=class extends it{constructor(e=new Xe,t=new Nn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(s&&o){ol.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=o[l],d=s[l];u!==0&&(od.fromBufferAttribute(d,e),a?ol.addScaledVector(od,u):ol.addScaledVector(od.sub(t),u))}t.add(ol)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),al.copy(i.boundingSphere),al.applyMatrix4(s),Gi.copy(e.ray).recast(e.near),!(al.containsPoint(Gi.origin)===!1&&(Gi.intersectSphere(al,wm)===null||Gi.origin.distanceToSquared(wm)>(e.far-e.near)**2))&&(bm.copy(s).invert(),Gi.copy(e.ray).applyMatrix4(bm),!(i.boundingBox!==null&&Gi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Gi)))}_computeIntersections(e,t,i){let r,s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,y=h.length;m<y;m++){let g=h[m],p=a[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let b=x,L=v;b<L;b+=3){let A=o.getX(b),E=o.getX(b+1),D=o.getX(b+2);r=fl(this,p,e,i,c,u,d,A,E,D),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let m=Math.max(0,f.start),y=Math.min(o.count,f.start+f.count);for(let g=m,p=y;g<p;g+=3){let x=o.getX(g),v=o.getX(g+1),b=o.getX(g+2);r=fl(this,a,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,y=h.length;m<y;m++){let g=h[m],p=a[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let b=x,L=v;b<L;b+=3){let A=b,E=b+1,D=b+2;r=fl(this,p,e,i,c,u,d,A,E,D),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let m=Math.max(0,f.start),y=Math.min(l.count,f.start+f.count);for(let g=m,p=y;g<p;g+=3){let x=g,v=g+1,b=g+2;r=fl(this,a,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};cr=class n extends Xe{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};let o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let l=[],c=[],u=[],d=[],h=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(d,2));function m(y,g,p,x,v,b,L,A,E,D,M){let w=b/E,T=L/D,U=b/2,I=L/2,B=A/2,W=E+1,F=D+1,X=0,k=0,re=new R;for(let se=0;se<F;se++){let ve=se*T-I;for(let Le=0;Le<W;Le++){let Je=Le*w-U;re[y]=Je*x,re[g]=ve*v,re[p]=B,c.push(re.x,re.y,re.z),re[y]=0,re[g]=0,re[p]=A>0?1:-1,u.push(re.x,re.y,re.z),d.push(Le/E),d.push(1-se/D),X+=1}}for(let se=0;se<D;se++)for(let ve=0;ve<E;ve++){let Le=h+ve+W*se,Je=h+ve+W*(se+1),Z=h+(ve+1)+W*(se+1),q=h+(ve+1)+W*se;l.push(Le,Je,q),l.push(Je,Z,q),k+=6}o.addGroup(f,k,M),f+=k,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};J0={clone:ds,merge:$t},qw=`void main() {
200
+ `+k)}else U!==""?console.warn("THREE.WebGLProgram: Program Info Log:",U):(I===""||B==="")&&(F=!1);F&&(T.diagnostics={runnable:W,programLog:U,vertexShader:{log:I,prefix:g},fragmentShader:{log:B,prefix:m}})}r.deleteShader(L),r.deleteShader(A),D=new os(r,y),M=XA(r,y)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let M;this.getAttributes=function(){return M===void 0&&E(this),M};let w=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return w===!1&&(w=r.getProgramParameter(y,BA)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=zA++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=L,this.fragmentShader=A,this}function oE(n,e,t,i,r,s,o){let a=new us,l=new _h,c=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,p={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 y(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,w,T,U,I){let B=U.fog,W=I.geometry,F=M.isMeshStandardMaterial?U.environment:null,X=(M.isMeshStandardMaterial?t:e).get(M.envMap||F),k=X&&X.mapping===xs?X.image.height:null,re=p[M.type];M.precision!==null&&(f=r.getMaxPrecision(M.precision),f!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",f,"instead."));let se=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,ve=se!==void 0?se.length:0,Le=0;W.morphAttributes.position!==void 0&&(Le=1),W.morphAttributes.normal!==void 0&&(Le=2),W.morphAttributes.color!==void 0&&(Le=3);let Je,Z,q,pe;if(re){let et=An[re];Je=et.vertexShader,Z=et.fragmentShader}else Je=M.vertexShader,Z=M.fragmentShader,l.update(M),q=l.getVertexShaderID(M),pe=l.getFragmentShaderID(M);let ne=n.getRenderTarget(),Fe=I.isInstancedMesh===!0,_e=I.isBatchedMesh===!0,H=!!M.map,Ue=!!M.matcap,J=!!X,ce=!!M.aoMap,K=!!M.lightMap,de=!!M.bumpMap,le=!!M.normalMap,he=!!M.displacementMap,Ae=!!M.emissiveMap,P=!!M.metalnessMap,S=!!M.roughnessMap,j=M.anisotropy>0,ee=M.clearcoat>0,oe=M.dispersion>0,ie=M.iridescence>0,Ce=M.sheen>0,me=M.transmission>0,ge=j&&!!M.anisotropyMap,ke=ee&&!!M.clearcoatMap,fe=ee&&!!M.clearcoatNormalMap,Re=ee&&!!M.clearcoatRoughnessMap,We=ie&&!!M.iridescenceMap,Pe=ie&&!!M.iridescenceThicknessMap,Me=Ce&&!!M.sheenColorMap,De=Ce&&!!M.sheenRoughnessMap,qe=!!M.specularMap,ht=!!M.specularColorMap,Ge=!!M.specularIntensityMap,z=me&&!!M.transmissionMap,ae=me&&!!M.thicknessMap,Q=!!M.gradientMap,xe=!!M.alphaMap,be=M.alphaTest>0,Se=!!M.alphaHash,Ke=!!M.extensions,lt=ni;M.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(lt=n.toneMapping);let ft={shaderID:re,shaderType:M.type,shaderName:M.name,vertexShader:Je,fragmentShader:Z,defines:M.defines,customVertexShaderID:q,customFragmentShaderID:pe,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:f,batching:_e,instancing:Fe,instancingColor:Fe&&I.instanceColor!==null,instancingMorph:Fe&&I.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ne===null?n.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:ci,alphaToCoverage:!!M.alphaToCoverage,map:H,matcap:Ue,envMap:J,envMapMode:J&&X.mapping,envMapCubeUVHeight:k,aoMap:ce,lightMap:K,bumpMap:de,normalMap:le,displacementMap:h&&he,emissiveMap:Ae,normalMapObjectSpace:le&&M.normalMapType===B0,normalMapTangentSpace:le&&M.normalMapType===Li,metalnessMap:P,roughnessMap:S,anisotropy:j,anisotropyMap:ge,clearcoat:ee,clearcoatMap:ke,clearcoatNormalMap:fe,clearcoatRoughnessMap:Re,dispersion:oe,iridescence:ie,iridescenceMap:We,iridescenceThicknessMap:Pe,sheen:Ce,sheenColorMap:Me,sheenRoughnessMap:De,specularMap:qe,specularColorMap:ht,specularIntensityMap:Ge,transmission:me,transmissionMap:z,thicknessMap:ae,gradientMap:Q,opaque:M.transparent===!1&&M.blending===sr&&M.alphaToCoverage===!1,alphaMap:xe,alphaTest:be,alphaHash:Se,combine:M.combine,mapUv:H&&y(M.map.channel),aoMapUv:ce&&y(M.aoMap.channel),lightMapUv:K&&y(M.lightMap.channel),bumpMapUv:de&&y(M.bumpMap.channel),normalMapUv:le&&y(M.normalMap.channel),displacementMapUv:he&&y(M.displacementMap.channel),emissiveMapUv:Ae&&y(M.emissiveMap.channel),metalnessMapUv:P&&y(M.metalnessMap.channel),roughnessMapUv:S&&y(M.roughnessMap.channel),anisotropyMapUv:ge&&y(M.anisotropyMap.channel),clearcoatMapUv:ke&&y(M.clearcoatMap.channel),clearcoatNormalMapUv:fe&&y(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&y(M.clearcoatRoughnessMap.channel),iridescenceMapUv:We&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:Pe&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&y(M.sheenRoughnessMap.channel),specularMapUv:qe&&y(M.specularMap.channel),specularColorMapUv:ht&&y(M.specularColorMap.channel),specularIntensityMapUv:Ge&&y(M.specularIntensityMap.channel),transmissionMapUv:z&&y(M.transmissionMap.channel),thicknessMapUv:ae&&y(M.thicknessMap.channel),alphaMapUv:xe&&y(M.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(le||j),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!W.attributes.uv&&(H||xe),fog:!!B,useFog:M.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:I.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:Le,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&T.length>0,shadowMapType:n.shadowMap.type,toneMapping:lt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:H&&M.map.isVideoTexture===!0&&ot.getTransfer(M.map.colorSpace)===ut,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Pn,flipSided:M.side===jt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Ke&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Ke&&M.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return ft.vertexUv1s=c.has(1),ft.vertexUv2s=c.has(2),ft.vertexUv3s=c.has(3),c.clear(),ft}function m(M){let w=[];if(M.shaderID?w.push(M.shaderID):(w.push(M.customVertexShaderID),w.push(M.customFragmentShaderID)),M.defines!==void 0)for(let T in M.defines)w.push(T),w.push(M.defines[T]);return M.isRawShaderMaterial===!1&&(x(w,M),v(w,M),w.push(n.outputColorSpace)),w.push(M.customProgramCacheKey),w.join()}function x(M,w){M.push(w.precision),M.push(w.outputColorSpace),M.push(w.envMapMode),M.push(w.envMapCubeUVHeight),M.push(w.mapUv),M.push(w.alphaMapUv),M.push(w.lightMapUv),M.push(w.aoMapUv),M.push(w.bumpMapUv),M.push(w.normalMapUv),M.push(w.displacementMapUv),M.push(w.emissiveMapUv),M.push(w.metalnessMapUv),M.push(w.roughnessMapUv),M.push(w.anisotropyMapUv),M.push(w.clearcoatMapUv),M.push(w.clearcoatNormalMapUv),M.push(w.clearcoatRoughnessMapUv),M.push(w.iridescenceMapUv),M.push(w.iridescenceThicknessMapUv),M.push(w.sheenColorMapUv),M.push(w.sheenRoughnessMapUv),M.push(w.specularMapUv),M.push(w.specularColorMapUv),M.push(w.specularIntensityMapUv),M.push(w.transmissionMapUv),M.push(w.thicknessMapUv),M.push(w.combine),M.push(w.fogExp2),M.push(w.sizeAttenuation),M.push(w.morphTargetsCount),M.push(w.morphAttributeCount),M.push(w.numDirLights),M.push(w.numPointLights),M.push(w.numSpotLights),M.push(w.numSpotLightMaps),M.push(w.numHemiLights),M.push(w.numRectAreaLights),M.push(w.numDirLightShadows),M.push(w.numPointLightShadows),M.push(w.numSpotLightShadows),M.push(w.numSpotLightShadowsWithMaps),M.push(w.numLightProbes),M.push(w.shadowMapType),M.push(w.toneMapping),M.push(w.numClippingPlanes),M.push(w.numClipIntersection),M.push(w.depthPacking)}function v(M,w){a.disableAll(),w.supportsVertexTextures&&a.enable(0),w.instancing&&a.enable(1),w.instancingColor&&a.enable(2),w.instancingMorph&&a.enable(3),w.matcap&&a.enable(4),w.envMap&&a.enable(5),w.normalMapObjectSpace&&a.enable(6),w.normalMapTangentSpace&&a.enable(7),w.clearcoat&&a.enable(8),w.iridescence&&a.enable(9),w.alphaTest&&a.enable(10),w.vertexColors&&a.enable(11),w.vertexAlphas&&a.enable(12),w.vertexUv1s&&a.enable(13),w.vertexUv2s&&a.enable(14),w.vertexUv3s&&a.enable(15),w.vertexTangents&&a.enable(16),w.anisotropy&&a.enable(17),w.alphaHash&&a.enable(18),w.batching&&a.enable(19),w.dispersion&&a.enable(20),M.push(a.mask),a.disableAll(),w.fog&&a.enable(0),w.useFog&&a.enable(1),w.flatShading&&a.enable(2),w.logarithmicDepthBuffer&&a.enable(3),w.skinning&&a.enable(4),w.morphTargets&&a.enable(5),w.morphNormals&&a.enable(6),w.morphColors&&a.enable(7),w.premultipliedAlpha&&a.enable(8),w.shadowMapEnabled&&a.enable(9),w.useLegacyLights&&a.enable(10),w.doubleSided&&a.enable(11),w.flipSided&&a.enable(12),w.useDepthPacking&&a.enable(13),w.dithering&&a.enable(14),w.transmission&&a.enable(15),w.sheen&&a.enable(16),w.opaque&&a.enable(17),w.pointsUvs&&a.enable(18),w.decodeVideoTexture&&a.enable(19),w.alphaToCoverage&&a.enable(20),M.push(a.mask)}function b(M){let w=p[M.type],T;if(w){let U=An[w];T=K0.clone(U.uniforms)}else T=M.uniforms;return T}function L(M,w){let T;for(let U=0,I=u.length;U<I;U++){let B=u[U];if(B.cacheKey===w){T=B,++T.usedTimes;break}}return T===void 0&&(T=new rE(n,w,M,s),u.push(T)),T}function A(M){if(--M.usedTimes===0){let w=u.indexOf(M);u[w]=u[u.length-1],u.pop(),M.destroy()}}function E(M){l.remove(M)}function D(){l.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:b,acquireProgram:L,releaseProgram:A,releaseShaderCache:E,programs:u,dispose:D}}function aE(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function lE(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function Xm(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ym(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(d,h,f,p,y,g){let m=n[e];return m===void 0?(m={id:d.id,object:d,geometry:h,material:f,groupOrder:p,renderOrder:d.renderOrder,z:y,group:g},n[e]=m):(m.id=d.id,m.object=d,m.geometry=h,m.material=f,m.groupOrder=p,m.renderOrder=d.renderOrder,m.z=y,m.group=g),e++,m}function a(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.push(m):f.transparent===!0?r.push(m):t.push(m)}function l(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.unshift(m):f.transparent===!0?r.unshift(m):t.unshift(m)}function c(d,h){t.length>1&&t.sort(d||lE),i.length>1&&i.sort(h||Xm),r.length>1&&r.sort(h||Xm)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:l,finish:u,sort:c}}function cE(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new Ym,n.set(i,[o])):r>=s.length?(o=new Ym,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function uE(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new we};break;case"SpotLight":t={position:new R,direction:new R,color:new we,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new we,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new we,groundColor:new we};break;case"RectAreaLight":t={color:new we,position:new R,halfWidth:new R,halfHeight:new R};break}return n[e.id]=t,t}}}function dE(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function fE(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function pE(n){let e=new uE,t=dE(),i={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 c=0;c<9;c++)i.probe.push(new R);let r=new R,s=new Ne,o=new Ne;function a(c,u){let d=0,h=0,f=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let p=0,y=0,g=0,m=0,x=0,v=0,b=0,L=0,A=0,E=0,D=0;c.sort(fE);let M=u===!0?Math.PI:1;for(let T=0,U=c.length;T<U;T++){let I=c[T],B=I.color,W=I.intensity,F=I.distance,X=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=B.r*W*M,h+=B.g*W*M,f+=B.b*W*M;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],W);D++}else if(I.isDirectionalLight){let k=e.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*M),I.castShadow){let re=I.shadow,se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,i.directionalShadow[p]=se,i.directionalShadowMap[p]=X,i.directionalShadowMatrix[p]=I.shadow.matrix,v++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=e.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(B).multiplyScalar(W*M),k.distance=F,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[g]=k;let re=I.shadow;if(I.map&&(i.spotLightMap[A]=I.map,A++,re.updateMatrices(I),I.castShadow&&E++),i.spotLightMatrix[g]=re.matrix,I.castShadow){let se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,i.spotShadow[g]=se,i.spotShadowMap[g]=X,L++}g++}else if(I.isRectAreaLight){let k=e.get(I);k.color.copy(B).multiplyScalar(W),k.halfWidth.set(I.width*.5,0,0),k.halfHeight.set(0,I.height*.5,0),i.rectArea[m]=k,m++}else if(I.isPointLight){let k=e.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*M),k.distance=I.distance,k.decay=I.decay,I.castShadow){let re=I.shadow,se=t.get(I);se.shadowBias=re.bias,se.shadowNormalBias=re.normalBias,se.shadowRadius=re.radius,se.shadowMapSize=re.mapSize,se.shadowCameraNear=re.camera.near,se.shadowCameraFar=re.camera.far,i.pointShadow[y]=se,i.pointShadowMap[y]=X,i.pointShadowMatrix[y]=I.shadow.matrix,b++}i.point[y]=k,y++}else if(I.isHemisphereLight){let k=e.get(I);k.skyColor.copy(I.color).multiplyScalar(W*M),k.groundColor.copy(I.groundColor).multiplyScalar(W*M),i.hemi[x]=k,x++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ye.LTC_FLOAT_1,i.rectAreaLTC2=ye.LTC_FLOAT_2):(i.rectAreaLTC1=ye.LTC_HALF_1,i.rectAreaLTC2=ye.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let w=i.hash;(w.directionalLength!==p||w.pointLength!==y||w.spotLength!==g||w.rectAreaLength!==m||w.hemiLength!==x||w.numDirectionalShadows!==v||w.numPointShadows!==b||w.numSpotShadows!==L||w.numSpotMaps!==A||w.numLightProbes!==D)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=m,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=L,i.spotShadowMap.length=L,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=L+A-E,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=E,i.numLightProbes=D,w.directionalLength=p,w.pointLength=y,w.spotLength=g,w.rectAreaLength=m,w.hemiLength=x,w.numDirectionalShadows=v,w.numPointShadows=b,w.numSpotShadows=L,w.numSpotMaps=A,w.numLightProbes=D,i.version=hE++)}function l(c,u){let d=0,h=0,f=0,p=0,y=0,g=u.matrixWorldInverse;for(let m=0,x=c.length;m<x;m++){let v=c[m];if(v.isDirectionalLight){let b=i.directional[d];b.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),d++}else if(v.isSpotLight){let b=i.spot[f];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),b.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let b=i.rectArea[p];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),b.halfWidth.set(v.width*.5,0,0),b.halfHeight.set(0,v.height*.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){let b=i.point[h];b.position.setFromMatrixPosition(v.matrixWorld),b.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let b=i.hemi[y];b.direction.setFromMatrixPosition(v.matrixWorld),b.direction.transformDirection(g),y++}}}return{setup:a,setupView:l,state:i}}function qm(n){let e=new pE(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(u){e.setup(t,u)}function l(u){e.setupView(t,u)}let c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function mE(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new qm(n),e.set(r,[a])):s>=o.length?(a=new qm(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function vE(n,e,t){let i=new dr,r=new te,s=new te,o=new at,a=new Do({depthPacking:k0}),l=new Oo,c={},u=t.maxTextureSize,d={[ri]:jt,[jt]:ri,[Pn]:Pn},h=new sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:gE,fragmentShader:yE}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new Xe;p.setAttribute("position",new tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new yt(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ef;let m=this.type;this.render=function(A,E,D){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||A.length===0)return;let M=n.getRenderTarget(),w=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),U=n.state;U.setBlending(ti),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let I=m!==Cn&&this.type===Cn,B=m===Cn&&this.type!==Cn;for(let W=0,F=A.length;W<F;W++){let X=A[W],k=X.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",X,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);let re=k.getFrameExtents();if(r.multiply(re),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/re.x),r.x=s.x*re.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/re.y),r.y=s.y*re.y,k.mapSize.y=s.y)),k.map===null||I===!0||B===!0){let ve=this.type!==Cn?{minFilter:Rt,magFilter:Rt}:{};k.map!==null&&k.map.dispose(),k.map=new nn(r.x,r.y,ve),k.map.texture.name=X.name+".shadowMap",k.camera.updateProjectionMatrix()}n.setRenderTarget(k.map),n.clear();let se=k.getViewportCount();for(let ve=0;ve<se;ve++){let Le=k.getViewport(ve);o.set(s.x*Le.x,s.y*Le.y,s.x*Le.z,s.y*Le.w),U.viewport(o),k.updateMatrices(X,ve),i=k.getFrustum(),b(E,D,k.camera,X,this.type)}k.isPointLightShadow!==!0&&this.type===Cn&&x(k,D),k.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(M,w,T)};function x(A,E){let D=e.update(y);h.defines.VSM_SAMPLES!==A.blurSamples&&(h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new nn(r.x,r.y)),h.uniforms.shadow_pass.value=A.map.texture,h.uniforms.resolution.value=A.mapSize,h.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(E,null,D,h,y,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value=A.mapSize,f.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(E,null,D,f,y,null)}function v(A,E,D,M){let w=null,T=D.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(T!==void 0)w=T;else if(w=D.isPointLight===!0?l:a,n.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){let U=w.uuid,I=E.uuid,B=c[U];B===void 0&&(B={},c[U]=B);let W=B[I];W===void 0&&(W=w.clone(),B[I]=W,E.addEventListener("dispose",L)),w=W}if(w.visible=E.visible,w.wireframe=E.wireframe,M===Cn?w.side=E.shadowSide!==null?E.shadowSide:E.side:w.side=E.shadowSide!==null?E.shadowSide:d[E.side],w.alphaMap=E.alphaMap,w.alphaTest=E.alphaTest,w.map=E.map,w.clipShadows=E.clipShadows,w.clippingPlanes=E.clippingPlanes,w.clipIntersection=E.clipIntersection,w.displacementMap=E.displacementMap,w.displacementScale=E.displacementScale,w.displacementBias=E.displacementBias,w.wireframeLinewidth=E.wireframeLinewidth,w.linewidth=E.linewidth,D.isPointLight===!0&&w.isMeshDistanceMaterial===!0){let U=n.properties.get(w);U.light=D}return w}function b(A,E,D,M,w){if(A.visible===!1)return;if(A.layers.test(E.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&w===Cn)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,A.matrixWorld);let I=e.update(A),B=A.material;if(Array.isArray(B)){let W=I.groups;for(let F=0,X=W.length;F<X;F++){let k=W[F],re=B[k.materialIndex];if(re&&re.visible){let se=v(A,re,M,w);A.onBeforeShadow(n,A,E,D,I,se,k),n.renderBufferDirect(D,null,I,se,A,k),A.onAfterShadow(n,A,E,D,I,se,k)}}}else if(B.visible){let W=v(A,B,M,w);A.onBeforeShadow(n,A,E,D,I,W,null),n.renderBufferDirect(D,null,I,W,A,null),A.onAfterShadow(n,A,E,D,I,W,null)}}let U=A.children;for(let I=0,B=U.length;I<B;I++)b(U[I],E,D,M,w)}function L(A){A.target.removeEventListener("dispose",L);for(let D in c){let M=c[D],w=A.target.uuid;w in M&&(M[w].dispose(),delete M[w])}}}function xE(n){function e(){let z=!1,ae=new at,Q=null,xe=new at(0,0,0,0);return{setMask:function(be){Q!==be&&!z&&(n.colorMask(be,be,be,be),Q=be)},setLocked:function(be){z=be},setClear:function(be,Se,Ke,lt,ft){ft===!0&&(be*=lt,Se*=lt,Ke*=lt),ae.set(be,Se,Ke,lt),xe.equals(ae)===!1&&(n.clearColor(be,Se,Ke,lt),xe.copy(ae))},reset:function(){z=!1,Q=null,xe.set(-1,0,0,0)}}}function t(){let z=!1,ae=null,Q=null,xe=null;return{setTest:function(be){be?pe(n.DEPTH_TEST):ne(n.DEPTH_TEST)},setMask:function(be){ae!==be&&!z&&(n.depthMask(be),ae=be)},setFunc:function(be){if(Q!==be){switch(be){case l0:n.depthFunc(n.NEVER);break;case c0:n.depthFunc(n.ALWAYS);break;case u0:n.depthFunc(n.LESS);break;case po:n.depthFunc(n.LEQUAL);break;case d0:n.depthFunc(n.EQUAL);break;case h0:n.depthFunc(n.GEQUAL);break;case f0:n.depthFunc(n.GREATER);break;case p0:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Q=be}},setLocked:function(be){z=be},setClear:function(be){xe!==be&&(n.clearDepth(be),xe=be)},reset:function(){z=!1,ae=null,Q=null,xe=null}}}function i(){let z=!1,ae=null,Q=null,xe=null,be=null,Se=null,Ke=null,lt=null,ft=null;return{setTest:function(et){z||(et?pe(n.STENCIL_TEST):ne(n.STENCIL_TEST))},setMask:function(et){ae!==et&&!z&&(n.stencilMask(et),ae=et)},setFunc:function(et,Xt,Mt){(Q!==et||xe!==Xt||be!==Mt)&&(n.stencilFunc(et,Xt,Mt),Q=et,xe=Xt,be=Mt)},setOp:function(et,Xt,Mt){(Se!==et||Ke!==Xt||lt!==Mt)&&(n.stencilOp(et,Xt,Mt),Se=et,Ke=Xt,lt=Mt)},setLocked:function(et){z=et},setClear:function(et){ft!==et&&(n.clearStencil(et),ft=et)},reset:function(){z=!1,ae=null,Q=null,xe=null,be=null,Se=null,Ke=null,lt=null,ft=null}}}let r=new e,s=new t,o=new i,a=new WeakMap,l=new WeakMap,c={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,b=null,L=null,A=new we(0,0,0),E=0,D=!1,M=null,w=null,T=null,U=null,I=null,B=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,F=0,X=n.getParameter(n.VERSION);X.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(X)[1]),W=F>=1):X.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),W=F>=2);let k=null,re={},se=n.getParameter(n.SCISSOR_BOX),ve=n.getParameter(n.VIEWPORT),Le=new at().fromArray(se),Je=new at().fromArray(ve);function Z(z,ae,Q,xe){let be=new Uint8Array(4),Se=n.createTexture();n.bindTexture(z,Se),n.texParameteri(z,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(z,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ke=0;Ke<Q;Ke++)z===n.TEXTURE_3D||z===n.TEXTURE_2D_ARRAY?n.texImage3D(ae,0,n.RGBA,1,1,xe,0,n.RGBA,n.UNSIGNED_BYTE,be):n.texImage2D(ae+Ke,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,be);return Se}let q={};q[n.TEXTURE_2D]=Z(n.TEXTURE_2D,n.TEXTURE_2D,1),q[n.TEXTURE_CUBE_MAP]=Z(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),q[n.TEXTURE_2D_ARRAY]=Z(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),q[n.TEXTURE_3D]=Z(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),pe(n.DEPTH_TEST),s.setFunc(po),de(!1),le(Cd),pe(n.CULL_FACE),ce(ti);function pe(z){c[z]!==!0&&(n.enable(z),c[z]=!0)}function ne(z){c[z]!==!1&&(n.disable(z),c[z]=!1)}function Fe(z,ae){return u[z]!==ae?(n.bindFramebuffer(z,ae),u[z]=ae,z===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=ae),z===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=ae),!0):!1}function _e(z,ae){let Q=h,xe=!1;if(z){Q=d.get(ae),Q===void 0&&(Q=[],d.set(ae,Q));let be=z.textures;if(Q.length!==be.length||Q[0]!==n.COLOR_ATTACHMENT0){for(let Se=0,Ke=be.length;Se<Ke;Se++)Q[Se]=n.COLOR_ATTACHMENT0+Se;Q.length=be.length,xe=!0}}else Q[0]!==n.BACK&&(Q[0]=n.BACK,xe=!0);xe&&n.drawBuffers(Q)}function H(z){return f!==z?(n.useProgram(z),f=z,!0):!1}let Ue={[Ai]:n.FUNC_ADD,[Wg]:n.FUNC_SUBTRACT,[jg]:n.FUNC_REVERSE_SUBTRACT};Ue[Xg]=n.MIN,Ue[Yg]=n.MAX;let J={[qg]:n.ZERO,[Zg]:n.ONE,[Jg]:n.SRC_COLOR,[Yl]:n.SRC_ALPHA,[i0]:n.SRC_ALPHA_SATURATE,[t0]:n.DST_COLOR,[Qg]:n.DST_ALPHA,[Kg]:n.ONE_MINUS_SRC_COLOR,[ql]:n.ONE_MINUS_SRC_ALPHA,[n0]:n.ONE_MINUS_DST_COLOR,[e0]:n.ONE_MINUS_DST_ALPHA,[r0]:n.CONSTANT_COLOR,[s0]:n.ONE_MINUS_CONSTANT_COLOR,[o0]:n.CONSTANT_ALPHA,[a0]:n.ONE_MINUS_CONSTANT_ALPHA};function ce(z,ae,Q,xe,be,Se,Ke,lt,ft,et){if(z===ti){p===!0&&(ne(n.BLEND),p=!1);return}if(p===!1&&(pe(n.BLEND),p=!0),z!==$g){if(z!==y||et!==D){if((g!==Ai||v!==Ai)&&(n.blendEquation(n.FUNC_ADD),g=Ai,v=Ai),et)switch(z){case sr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Rd:n.blendFunc(n.ONE,n.ONE);break;case Pd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ld:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case sr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Rd:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Pd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ld:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}m=null,x=null,b=null,L=null,A.set(0,0,0),E=0,y=z,D=et}return}be=be||ae,Se=Se||Q,Ke=Ke||xe,(ae!==g||be!==v)&&(n.blendEquationSeparate(Ue[ae],Ue[be]),g=ae,v=be),(Q!==m||xe!==x||Se!==b||Ke!==L)&&(n.blendFuncSeparate(J[Q],J[xe],J[Se],J[Ke]),m=Q,x=xe,b=Se,L=Ke),(lt.equals(A)===!1||ft!==E)&&(n.blendColor(lt.r,lt.g,lt.b,ft),A.copy(lt),E=ft),y=z,D=!1}function K(z,ae){z.side===Pn?ne(n.CULL_FACE):pe(n.CULL_FACE);let Q=z.side===jt;ae&&(Q=!Q),de(Q),z.blending===sr&&z.transparent===!1?ce(ti):ce(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),s.setFunc(z.depthFunc),s.setTest(z.depthTest),s.setMask(z.depthWrite),r.setMask(z.colorWrite);let xe=z.stencilWrite;o.setTest(xe),xe&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),Ae(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?pe(n.SAMPLE_ALPHA_TO_COVERAGE):ne(n.SAMPLE_ALPHA_TO_COVERAGE)}function de(z){M!==z&&(z?n.frontFace(n.CW):n.frontFace(n.CCW),M=z)}function le(z){z!==Vg?(pe(n.CULL_FACE),z!==w&&(z===Cd?n.cullFace(n.BACK):z===Hg?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ne(n.CULL_FACE),w=z}function he(z){z!==T&&(W&&n.lineWidth(z),T=z)}function Ae(z,ae,Q){z?(pe(n.POLYGON_OFFSET_FILL),(U!==ae||I!==Q)&&(n.polygonOffset(ae,Q),U=ae,I=Q)):ne(n.POLYGON_OFFSET_FILL)}function P(z){z?pe(n.SCISSOR_TEST):ne(n.SCISSOR_TEST)}function S(z){z===void 0&&(z=n.TEXTURE0+B-1),k!==z&&(n.activeTexture(z),k=z)}function j(z,ae,Q){Q===void 0&&(k===null?Q=n.TEXTURE0+B-1:Q=k);let xe=re[Q];xe===void 0&&(xe={type:void 0,texture:void 0},re[Q]=xe),(xe.type!==z||xe.texture!==ae)&&(k!==Q&&(n.activeTexture(Q),k=Q),n.bindTexture(z,ae||q[z]),xe.type=z,xe.texture=ae)}function ee(){let z=re[k];z!==void 0&&z.type!==void 0&&(n.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function oe(){try{n.compressedTexImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ie(){try{n.compressedTexImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ce(){try{n.texSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function me(){try{n.texSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ge(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ke(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function fe(){try{n.texStorage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(){try{n.texStorage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function We(){try{n.texImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Pe(){try{n.texImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Me(z){Le.equals(z)===!1&&(n.scissor(z.x,z.y,z.z,z.w),Le.copy(z))}function De(z){Je.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),Je.copy(z))}function qe(z,ae){let Q=l.get(ae);Q===void 0&&(Q=new WeakMap,l.set(ae,Q));let xe=Q.get(z);xe===void 0&&(xe=n.getUniformBlockIndex(ae,z.name),Q.set(z,xe))}function ht(z,ae){let xe=l.get(ae).get(z);a.get(ae)!==xe&&(n.uniformBlockBinding(ae,xe,z.__bindingPointIndex),a.set(ae,xe))}function Ge(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},k=null,re={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,b=null,L=null,A=new we(0,0,0),E=0,D=!1,M=null,w=null,T=null,U=null,I=null,Le.set(0,0,n.canvas.width,n.canvas.height),Je.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:pe,disable:ne,bindFramebuffer:Fe,drawBuffers:_e,useProgram:H,setBlending:ce,setMaterial:K,setFlipSided:de,setCullFace:le,setLineWidth:he,setPolygonOffset:Ae,setScissorTest:P,activeTexture:S,bindTexture:j,unbindTexture:ee,compressedTexImage2D:oe,compressedTexImage3D:ie,texImage2D:We,texImage3D:Pe,updateUBOMapping:qe,uniformBlockBinding:ht,texStorage2D:fe,texStorage3D:Re,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:ge,compressedTexSubImage3D:ke,scissor:Me,viewport:De,reset:Ge}}function _E(n,e,t,i,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new te,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(P,S){return f?new OffscreenCanvas(P,S):To("canvas")}function y(P,S,j){let ee=1,oe=Ae(P);if((oe.width>j||oe.height>j)&&(ee=j/Math.max(oe.width,oe.height)),ee<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let ie=Math.floor(ee*oe.width),Ce=Math.floor(ee*oe.height);d===void 0&&(d=p(ie,Ce));let me=S?p(ie,Ce):d;return me.width=ie,me.height=Ce,me.getContext("2d").drawImage(P,0,0,ie,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+ie+"x"+Ce+")."),me}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),P;return P}function g(P){return P.generateMipmaps&&P.minFilter!==Rt&&P.minFilter!==bt}function m(P){n.generateMipmap(P)}function x(P,S,j,ee,oe=!1){if(P!==null){if(n[P]!==void 0)return n[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let ie=S;if(S===n.RED&&(j===n.FLOAT&&(ie=n.R32F),j===n.HALF_FLOAT&&(ie=n.R16F),j===n.UNSIGNED_BYTE&&(ie=n.R8)),S===n.RED_INTEGER&&(j===n.UNSIGNED_BYTE&&(ie=n.R8UI),j===n.UNSIGNED_SHORT&&(ie=n.R16UI),j===n.UNSIGNED_INT&&(ie=n.R32UI),j===n.BYTE&&(ie=n.R8I),j===n.SHORT&&(ie=n.R16I),j===n.INT&&(ie=n.R32I)),S===n.RG&&(j===n.FLOAT&&(ie=n.RG32F),j===n.HALF_FLOAT&&(ie=n.RG16F),j===n.UNSIGNED_BYTE&&(ie=n.RG8)),S===n.RG_INTEGER&&(j===n.UNSIGNED_BYTE&&(ie=n.RG8UI),j===n.UNSIGNED_SHORT&&(ie=n.RG16UI),j===n.UNSIGNED_INT&&(ie=n.RG32UI),j===n.BYTE&&(ie=n.RG8I),j===n.SHORT&&(ie=n.RG16I),j===n.INT&&(ie=n.RG32I)),S===n.RGB&&j===n.UNSIGNED_INT_5_9_9_9_REV&&(ie=n.RGB9_E5),S===n.RGBA){let Ce=oe?wo:ot.getTransfer(ee);j===n.FLOAT&&(ie=n.RGBA32F),j===n.HALF_FLOAT&&(ie=n.RGBA16F),j===n.UNSIGNED_BYTE&&(ie=Ce===ut?n.SRGB8_ALPHA8:n.RGBA8),j===n.UNSIGNED_SHORT_4_4_4_4&&(ie=n.RGBA4),j===n.UNSIGNED_SHORT_5_5_5_1&&(ie=n.RGB5_A1)}return(ie===n.R16F||ie===n.R32F||ie===n.RG16F||ie===n.RG32F||ie===n.RGBA16F||ie===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function v(P,S){return g(P)===!0||P.isFramebufferTexture&&P.minFilter!==Rt&&P.minFilter!==bt?Math.log2(Math.max(S.width,S.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?S.mipmaps.length:1}function b(P){let S=P.target;S.removeEventListener("dispose",b),A(S),S.isVideoTexture&&u.delete(S)}function L(P){let S=P.target;S.removeEventListener("dispose",L),D(S)}function A(P){let S=i.get(P);if(S.__webglInit===void 0)return;let j=P.source,ee=h.get(j);if(ee){let oe=ee[S.__cacheKey];oe.usedTimes--,oe.usedTimes===0&&E(P),Object.keys(ee).length===0&&h.delete(j)}i.remove(P)}function E(P){let S=i.get(P);n.deleteTexture(S.__webglTexture);let j=P.source,ee=h.get(j);delete ee[S.__cacheKey],o.memory.textures--}function D(P){let S=i.get(P);if(P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(S.__webglFramebuffer[ee]))for(let oe=0;oe<S.__webglFramebuffer[ee].length;oe++)n.deleteFramebuffer(S.__webglFramebuffer[ee][oe]);else n.deleteFramebuffer(S.__webglFramebuffer[ee]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ee])}else{if(Array.isArray(S.__webglFramebuffer))for(let ee=0;ee<S.__webglFramebuffer.length;ee++)n.deleteFramebuffer(S.__webglFramebuffer[ee]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ee=0;ee<S.__webglColorRenderbuffer.length;ee++)S.__webglColorRenderbuffer[ee]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ee]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}let j=P.textures;for(let ee=0,oe=j.length;ee<oe;ee++){let ie=i.get(j[ee]);ie.__webglTexture&&(n.deleteTexture(ie.__webglTexture),o.memory.textures--),i.remove(j[ee])}i.remove(P)}let M=0;function w(){M=0}function T(){let P=M;return P>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+r.maxTextures),M+=1,P}function U(P){let S=[];return S.push(P.wrapS),S.push(P.wrapT),S.push(P.wrapR||0),S.push(P.magFilter),S.push(P.minFilter),S.push(P.anisotropy),S.push(P.internalFormat),S.push(P.format),S.push(P.type),S.push(P.generateMipmaps),S.push(P.premultiplyAlpha),S.push(P.flipY),S.push(P.unpackAlignment),S.push(P.colorSpace),S.join()}function I(P,S){let j=i.get(P);if(P.isVideoTexture&&le(P),P.isRenderTargetTexture===!1&&P.version>0&&j.__version!==P.version){let ee=P.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Le(j,P,S);return}}t.bindTexture(n.TEXTURE_2D,j.__webglTexture,n.TEXTURE0+S)}function B(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Le(j,P,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,j.__webglTexture,n.TEXTURE0+S)}function W(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Le(j,P,S);return}t.bindTexture(n.TEXTURE_3D,j.__webglTexture,n.TEXTURE0+S)}function F(P,S){let j=i.get(P);if(P.version>0&&j.__version!==P.version){Je(j,P,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+S)}let X={[yo]:n.REPEAT,[gn]:n.CLAMP_TO_EDGE,[vo]:n.MIRRORED_REPEAT},k={[Rt]:n.NEAREST,[Tf]:n.NEAREST_MIPMAP_NEAREST,[ts]:n.NEAREST_MIPMAP_LINEAR,[bt]:n.LINEAR,[lo]:n.LINEAR_MIPMAP_NEAREST,[Ln]:n.LINEAR_MIPMAP_LINEAR},re={[z0]:n.NEVER,[j0]:n.ALWAYS,[V0]:n.LESS,[Ff]:n.LEQUAL,[H0]:n.EQUAL,[W0]:n.GEQUAL,[G0]:n.GREATER,[$0]:n.NOTEQUAL};function se(P,S){if(S.type===yn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===bt||S.magFilter===lo||S.magFilter===ts||S.magFilter===Ln||S.minFilter===bt||S.minFilter===lo||S.minFilter===ts||S.minFilter===Ln)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(P,n.TEXTURE_WRAP_S,X[S.wrapS]),n.texParameteri(P,n.TEXTURE_WRAP_T,X[S.wrapT]),(P===n.TEXTURE_3D||P===n.TEXTURE_2D_ARRAY)&&n.texParameteri(P,n.TEXTURE_WRAP_R,X[S.wrapR]),n.texParameteri(P,n.TEXTURE_MAG_FILTER,k[S.magFilter]),n.texParameteri(P,n.TEXTURE_MIN_FILTER,k[S.minFilter]),S.compareFunction&&(n.texParameteri(P,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(P,n.TEXTURE_COMPARE_FUNC,re[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Rt||S.minFilter!==ts&&S.minFilter!==Ln||S.type===yn&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){let j=e.get("EXT_texture_filter_anisotropic");n.texParameterf(P,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function ve(P,S){let j=!1;P.__webglInit===void 0&&(P.__webglInit=!0,S.addEventListener("dispose",b));let ee=S.source,oe=h.get(ee);oe===void 0&&(oe={},h.set(ee,oe));let ie=U(S);if(ie!==P.__cacheKey){oe[ie]===void 0&&(oe[ie]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,j=!0),oe[ie].usedTimes++;let Ce=oe[P.__cacheKey];Ce!==void 0&&(oe[P.__cacheKey].usedTimes--,Ce.usedTimes===0&&E(S)),P.__cacheKey=ie,P.__webglTexture=oe[ie].texture}return j}function Le(P,S,j){let ee=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ee=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ee=n.TEXTURE_3D);let oe=ve(P,S),ie=S.source;t.bindTexture(ee,P.__webglTexture,n.TEXTURE0+j);let Ce=i.get(ie);if(ie.version!==Ce.__version||oe===!0){t.activeTexture(n.TEXTURE0+j);let me=ot.getPrimaries(ot.workingColorSpace),ge=S.colorSpace===Zn?null:ot.getPrimaries(S.colorSpace),ke=S.colorSpace===Zn||me===ge?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke);let fe=y(S.image,!1,r.maxTextureSize);fe=he(S,fe);let Re=s.convert(S.format,S.colorSpace),We=s.convert(S.type),Pe=x(S.internalFormat,Re,We,S.colorSpace,S.isVideoTexture);se(ee,S);let Me,De=S.mipmaps,qe=S.isVideoTexture!==!0,ht=Ce.__version===void 0||oe===!0,Ge=ie.dataReady,z=v(S,fe);if(S.isDepthTexture)Pe=n.DEPTH_COMPONENT16,S.type===yn?Pe=n.DEPTH_COMPONENT32F:S.type===lr?Pe=n.DEPTH_COMPONENT24:S.type===_s&&(Pe=n.DEPTH24_STENCIL8),ht&&(qe?t.texStorage2D(n.TEXTURE_2D,1,Pe,fe.width,fe.height):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,We,null));else if(S.isDataTexture)if(De.length>0){qe&&ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,De[0].width,De[0].height);for(let ae=0,Q=De.length;ae<Q;ae++)Me=De[ae],qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,We,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,We,Me.data);S.generateMipmaps=!1}else qe?(ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height),Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,fe.width,fe.height,Re,We,fe.data)):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,We,fe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){qe&&ht&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,De[0].width,De[0].height,fe.depth);for(let ae=0,Q=De.length;ae<Q;ae++)Me=De[ae],S.format!==en?Re!==null?qe?Ge&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,Me.width,Me.height,fe.depth,Re,Me.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ae,Pe,Me.width,Me.height,fe.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,Me.width,Me.height,fe.depth,Re,We,Me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Pe,Me.width,Me.height,fe.depth,0,Re,We,Me.data)}else{qe&&ht&&t.texStorage2D(n.TEXTURE_2D,z,Pe,De[0].width,De[0].height);for(let ae=0,Q=De.length;ae<Q;ae++)Me=De[ae],S.format!==en?Re!==null?qe?Ge&&t.compressedTexSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,Me.data):t.compressedTexImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,We,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,We,Me.data)}else if(S.isDataArrayTexture)qe?(ht&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,fe.width,fe.height,fe.depth),Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,fe.width,fe.height,fe.depth,Re,We,fe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Pe,fe.width,fe.height,fe.depth,0,Re,We,fe.data);else if(S.isData3DTexture)qe?(ht&&t.texStorage3D(n.TEXTURE_3D,z,Pe,fe.width,fe.height,fe.depth),Ge&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,fe.width,fe.height,fe.depth,Re,We,fe.data)):t.texImage3D(n.TEXTURE_3D,0,Pe,fe.width,fe.height,fe.depth,0,Re,We,fe.data);else if(S.isFramebufferTexture){if(ht)if(qe)t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height);else{let ae=fe.width,Q=fe.height;for(let xe=0;xe<z;xe++)t.texImage2D(n.TEXTURE_2D,xe,Pe,ae,Q,0,Re,We,null),ae>>=1,Q>>=1}}else if(De.length>0){if(qe&&ht){let ae=Ae(De[0]);t.texStorage2D(n.TEXTURE_2D,z,Pe,ae.width,ae.height)}for(let ae=0,Q=De.length;ae<Q;ae++)Me=De[ae],qe?Ge&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Re,We,Me):t.texImage2D(n.TEXTURE_2D,ae,Pe,Re,We,Me);S.generateMipmaps=!1}else if(qe){if(ht){let ae=Ae(fe);t.texStorage2D(n.TEXTURE_2D,z,Pe,ae.width,ae.height)}Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Re,We,fe)}else t.texImage2D(n.TEXTURE_2D,0,Pe,Re,We,fe);g(S)&&m(ee),Ce.__version=ie.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Je(P,S,j){if(S.image.length!==6)return;let ee=ve(P,S),oe=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,P.__webglTexture,n.TEXTURE0+j);let ie=i.get(oe);if(oe.version!==ie.__version||ee===!0){t.activeTexture(n.TEXTURE0+j);let Ce=ot.getPrimaries(ot.workingColorSpace),me=S.colorSpace===Zn?null:ot.getPrimaries(S.colorSpace),ge=S.colorSpace===Zn||Ce===me?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge);let ke=S.isCompressedTexture||S.image[0].isCompressedTexture,fe=S.image[0]&&S.image[0].isDataTexture,Re=[];for(let Q=0;Q<6;Q++)!ke&&!fe?Re[Q]=y(S.image[Q],!0,r.maxCubemapSize):Re[Q]=fe?S.image[Q].image:S.image[Q],Re[Q]=he(S,Re[Q]);let We=Re[0],Pe=s.convert(S.format,S.colorSpace),Me=s.convert(S.type),De=x(S.internalFormat,Pe,Me,S.colorSpace),qe=S.isVideoTexture!==!0,ht=ie.__version===void 0||ee===!0,Ge=oe.dataReady,z=v(S,We);se(n.TEXTURE_CUBE_MAP,S);let ae;if(ke){qe&&ht&&t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,We.width,We.height);for(let Q=0;Q<6;Q++){ae=Re[Q].mipmaps;for(let xe=0;xe<ae.length;xe++){let be=ae[xe];S.format!==en?Pe!==null?qe?Ge&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,0,0,be.width,be.height,Pe,be.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,De,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,0,0,be.width,be.height,Pe,Me,be.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe,De,be.width,be.height,0,Pe,Me,be.data)}}}else{if(ae=S.mipmaps,qe&&ht){ae.length>0&&z++;let Q=Ae(Re[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(fe){qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Re[Q].width,Re[Q].height,Pe,Me,Re[Q].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,De,Re[Q].width,Re[Q].height,0,Pe,Me,Re[Q].data);for(let xe=0;xe<ae.length;xe++){let Se=ae[xe].image[Q].image;qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,0,0,Se.width,Se.height,Pe,Me,Se.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,De,Se.width,Se.height,0,Pe,Me,Se.data)}}else{qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Pe,Me,Re[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,De,Pe,Me,Re[Q]);for(let xe=0;xe<ae.length;xe++){let be=ae[xe];qe?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,0,0,Pe,Me,be.image[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,xe+1,De,Pe,Me,be.image[Q])}}}g(S)&&m(n.TEXTURE_CUBE_MAP),ie.__version=oe.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Z(P,S,j,ee,oe,ie){let Ce=s.convert(j.format,j.colorSpace),me=s.convert(j.type),ge=x(j.internalFormat,Ce,me,j.colorSpace);if(!i.get(S).__hasExternalTextures){let fe=Math.max(1,S.width>>ie),Re=Math.max(1,S.height>>ie);oe===n.TEXTURE_3D||oe===n.TEXTURE_2D_ARRAY?t.texImage3D(oe,ie,ge,fe,Re,S.depth,0,Ce,me,null):t.texImage2D(oe,ie,ge,fe,Re,0,Ce,me,null)}t.bindFramebuffer(n.FRAMEBUFFER,P),de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ee,oe,i.get(j).__webglTexture,0,K(S)):(oe===n.TEXTURE_2D||oe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&oe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ee,oe,i.get(j).__webglTexture,ie),t.bindFramebuffer(n.FRAMEBUFFER,null)}function q(P,S,j){if(n.bindRenderbuffer(n.RENDERBUFFER,P),S.depthBuffer&&!S.stencilBuffer){let ee=n.DEPTH_COMPONENT24;if(j||de(S)){let oe=S.depthTexture;oe&&oe.isDepthTexture&&(oe.type===yn?ee=n.DEPTH_COMPONENT32F:oe.type===lr&&(ee=n.DEPTH_COMPONENT24));let ie=K(S);de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ie,ee,S.width,S.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,ie,ee,S.width,S.height)}else n.renderbufferStorage(n.RENDERBUFFER,ee,S.width,S.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,P)}else if(S.depthBuffer&&S.stencilBuffer){let ee=K(S);j&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,P)}else{let ee=S.textures;for(let oe=0;oe<ee.length;oe++){let ie=ee[oe],Ce=s.convert(ie.format,ie.colorSpace),me=s.convert(ie.type),ge=x(ie.internalFormat,Ce,me,ie.colorSpace),ke=K(S);j&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ke,ge,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ke,ge,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,ge,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function pe(P,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,P),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),I(S.depthTexture,0);let ee=i.get(S.depthTexture).__webglTexture,oe=K(S);if(S.depthTexture.format===or)de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0);else if(S.depthTexture.format===as)de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0);else throw new Error("Unknown depthTexture format")}function ne(P){let S=i.get(P),j=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!S.__autoAllocateDepthBuffer){if(j)throw new Error("target.depthTexture not supported in Cube render targets");pe(S.__webglFramebuffer,P)}else if(j){S.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ee]),S.__webglDepthbuffer[ee]=n.createRenderbuffer(),q(S.__webglDepthbuffer[ee],P,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=n.createRenderbuffer(),q(S.__webglDepthbuffer,P,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Fe(P,S,j){let ee=i.get(P);S!==void 0&&Z(ee.__webglFramebuffer,P,P.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),j!==void 0&&ne(P)}function _e(P){let S=P.texture,j=i.get(P),ee=i.get(S);P.addEventListener("dispose",L);let oe=P.textures,ie=P.isWebGLCubeRenderTarget===!0,Ce=oe.length>1;if(Ce||(ee.__webglTexture===void 0&&(ee.__webglTexture=n.createTexture()),ee.__version=S.version,o.memory.textures++),ie){j.__webglFramebuffer=[];for(let me=0;me<6;me++)if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer[me]=[];for(let ge=0;ge<S.mipmaps.length;ge++)j.__webglFramebuffer[me][ge]=n.createFramebuffer()}else j.__webglFramebuffer[me]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer=[];for(let me=0;me<S.mipmaps.length;me++)j.__webglFramebuffer[me]=n.createFramebuffer()}else j.__webglFramebuffer=n.createFramebuffer();if(Ce)for(let me=0,ge=oe.length;me<ge;me++){let ke=i.get(oe[me]);ke.__webglTexture===void 0&&(ke.__webglTexture=n.createTexture(),o.memory.textures++)}if(P.samples>0&&de(P)===!1){j.__webglMultisampledFramebuffer=n.createFramebuffer(),j.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,j.__webglMultisampledFramebuffer);for(let me=0;me<oe.length;me++){let ge=oe[me];j.__webglColorRenderbuffer[me]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,j.__webglColorRenderbuffer[me]);let ke=s.convert(ge.format,ge.colorSpace),fe=s.convert(ge.type),Re=x(ge.internalFormat,ke,fe,ge.colorSpace,P.isXRRenderTarget===!0),We=K(P);n.renderbufferStorageMultisample(n.RENDERBUFFER,We,Re,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+me,n.RENDERBUFFER,j.__webglColorRenderbuffer[me])}n.bindRenderbuffer(n.RENDERBUFFER,null),P.depthBuffer&&(j.__webglDepthRenderbuffer=n.createRenderbuffer(),q(j.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ie){t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture),se(n.TEXTURE_CUBE_MAP,S);for(let me=0;me<6;me++)if(S.mipmaps&&S.mipmaps.length>0)for(let ge=0;ge<S.mipmaps.length;ge++)Z(j.__webglFramebuffer[me][ge],P,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+me,ge);else Z(j.__webglFramebuffer[me],P,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0);g(S)&&m(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ce){for(let me=0,ge=oe.length;me<ge;me++){let ke=oe[me],fe=i.get(ke);t.bindTexture(n.TEXTURE_2D,fe.__webglTexture),se(n.TEXTURE_2D,ke),Z(j.__webglFramebuffer,P,ke,n.COLOR_ATTACHMENT0+me,n.TEXTURE_2D,0),g(ke)&&m(n.TEXTURE_2D)}t.unbindTexture()}else{let me=n.TEXTURE_2D;if((P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(me=P.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(me,ee.__webglTexture),se(me,S),S.mipmaps&&S.mipmaps.length>0)for(let ge=0;ge<S.mipmaps.length;ge++)Z(j.__webglFramebuffer[ge],P,S,n.COLOR_ATTACHMENT0,me,ge);else Z(j.__webglFramebuffer,P,S,n.COLOR_ATTACHMENT0,me,0);g(S)&&m(me),t.unbindTexture()}P.depthBuffer&&ne(P)}function H(P){let S=P.textures;for(let j=0,ee=S.length;j<ee;j++){let oe=S[j];if(g(oe)){let ie=P.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ce=i.get(oe).__webglTexture;t.bindTexture(ie,Ce),m(ie),t.unbindTexture()}}}let Ue=[],J=[];function ce(P){if(P.samples>0){if(de(P)===!1){let S=P.textures,j=P.width,ee=P.height,oe=n.COLOR_BUFFER_BIT,ie=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ce=i.get(P),me=S.length>1;if(me)for(let ge=0;ge<S.length;ge++)t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let ge=0;ge<S.length;ge++){if(P.resolveDepthBuffer&&(P.depthBuffer&&(oe|=n.DEPTH_BUFFER_BIT),P.stencilBuffer&&P.resolveStencilBuffer&&(oe|=n.STENCIL_BUFFER_BIT)),me){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ce.__webglColorRenderbuffer[ge]);let ke=i.get(S[ge]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ke,0)}n.blitFramebuffer(0,0,j,ee,0,0,j,ee,oe,n.NEAREST),l===!0&&(Ue.length=0,J.length=0,Ue.push(n.COLOR_ATTACHMENT0+ge),P.depthBuffer&&P.resolveDepthBuffer===!1&&(Ue.push(ie),J.push(ie),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,J)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),me)for(let ge=0;ge<S.length;ge++){t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.RENDERBUFFER,Ce.__webglColorRenderbuffer[ge]);let ke=i.get(S[ge]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ce.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.TEXTURE_2D,ke,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}else if(P.depthBuffer&&P.resolveDepthBuffer===!1&&l){let S=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function K(P){return Math.min(r.maxSamples,P.samples)}function de(P){let S=i.get(P);return P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function le(P){let S=o.render.frame;u.get(P)!==S&&(u.set(P,S),P.update())}function he(P,S){let j=P.colorSpace,ee=P.format,oe=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||j!==ci&&j!==Zn&&(ot.getTransfer(j)===ut?(ee!==en||oe!==oi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",j)),S}function Ae(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=T,this.resetTextureUnits=w,this.setTexture2D=I,this.setTexture2DArray=B,this.setTexture3D=W,this.setTextureCube=F,this.rebindTextures=Fe,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=ce,this.setupDepthRenderbuffer=ne,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=de}function sy(n,e){function t(i,r=Zn){let s,o=ot.getTransfer(r);if(i===oi)return n.UNSIGNED_BYTE;if(i===Rf)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pf)return n.UNSIGNED_SHORT_5_5_5_1;if(i===T0)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===A0)return n.BYTE;if(i===E0)return n.SHORT;if(i===If)return n.UNSIGNED_SHORT;if(i===Cf)return n.INT;if(i===lr)return n.UNSIGNED_INT;if(i===yn)return n.FLOAT;if(i===ia)return n.HALF_FLOAT;if(i===I0)return n.ALPHA;if(i===C0)return n.RGB;if(i===en)return n.RGBA;if(i===R0)return n.LUMINANCE;if(i===P0)return n.LUMINANCE_ALPHA;if(i===or)return n.DEPTH_COMPONENT;if(i===as)return n.DEPTH_STENCIL;if(i===Lf)return n.RED;if(i===Df)return n.RED_INTEGER;if(i===L0)return n.RG;if(i===Of)return n.RG_INTEGER;if(i===Uf)return n.RGBA_INTEGER;if(i===Hl||i===Gl||i===$l||i===Wl)if(o===ut)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Hl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Gl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Wl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Hl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Gl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Wl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Od||i===Ud||i===Nd||i===Fd)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Od)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ud)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Nd)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Fd)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===kd||i===Bd||i===zd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===kd||i===Bd)return o===ut?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===zd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Vd||i===Hd||i===Gd||i===$d||i===Wd||i===jd||i===Xd||i===Yd||i===qd||i===Zd||i===Jd||i===Kd||i===Qd||i===eh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Vd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$d)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Yd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===qd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eh)return o===ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===jl||i===th||i===nh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===jl)return o===ut?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===th)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===D0||i===ih||i===rh||i===sh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===jl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ih)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===rh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===sh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===_s?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function AE(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,J0(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,x,v,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),u(g,m)):m.isMeshStandardMaterial?(s(g,m),h(g,m),m.isMeshPhysicalMaterial&&f(g,m,b)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),y(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?l(g,m,x,v):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===jt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===jt&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x=e.get(m),v=x.envMap,b=x.envMapRotation;if(v&&(g.envMap.value=v,ji.copy(b),ji.x*=-1,ji.y*=-1,ji.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(ji.y*=-1,ji.z*=-1),g.envMapRotation.value.setFromMatrix4(SE.makeRotationFromEuler(ji)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let L=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*L,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,x,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*x,g.scale.value=v*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function u(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,x){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===jt&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function y(g,m){let x=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function EE(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,v){let b=v.program;i.uniformBlockBinding(x,b)}function c(x,v){let b=r[x.id];b===void 0&&(p(x),b=u(x),r[x.id]=b,x.addEventListener("dispose",g));let L=v.program;i.updateUBOMapping(x,L);let A=e.render.frame;s[x.id]!==A&&(h(x),s[x.id]=A)}function u(x){let v=d();x.__bindingPointIndex=v;let b=n.createBuffer(),L=x.__size,A=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,L,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,b),b}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(x){let v=r[x.id],b=x.uniforms,L=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let A=0,E=b.length;A<E;A++){let D=Array.isArray(b[A])?b[A]:[b[A]];for(let M=0,w=D.length;M<w;M++){let T=D[M];if(f(T,A,M,L)===!0){let U=T.__offset,I=Array.isArray(T.value)?T.value:[T.value],B=0;for(let W=0;W<I.length;W++){let F=I[W],X=y(F);typeof F=="number"||typeof F=="boolean"?(T.__data[0]=F,n.bufferSubData(n.UNIFORM_BUFFER,U+B,T.__data)):F.isMatrix3?(T.__data[0]=F.elements[0],T.__data[1]=F.elements[1],T.__data[2]=F.elements[2],T.__data[3]=0,T.__data[4]=F.elements[3],T.__data[5]=F.elements[4],T.__data[6]=F.elements[5],T.__data[7]=0,T.__data[8]=F.elements[6],T.__data[9]=F.elements[7],T.__data[10]=F.elements[8],T.__data[11]=0):(F.toArray(T.__data,B),B+=X.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,U,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,v,b,L){let A=x.value,E=v+"_"+b;if(L[E]===void 0)return typeof A=="number"||typeof A=="boolean"?L[E]=A:L[E]=A.clone(),!0;{let D=L[E];if(typeof A=="number"||typeof A=="boolean"){if(D!==A)return L[E]=A,!0}else if(D.equals(A)===!1)return D.copy(A),!0}return!1}function p(x){let v=x.uniforms,b=0,L=16;for(let E=0,D=v.length;E<D;E++){let M=Array.isArray(v[E])?v[E]:[v[E]];for(let w=0,T=M.length;w<T;w++){let U=M[w],I=Array.isArray(U.value)?U.value:[U.value];for(let B=0,W=I.length;B<W;B++){let F=I[B],X=y(F),k=b%L;k!==0&&L-k<X.boundary&&(b+=L-k),U.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=b,b+=X.storage}}}let A=b%L;return A>0&&(b+=L-A),x.__size=b,x.__cache={},this}function y(x){let v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let b=o.indexOf(v.__bindingPointIndex);o.splice(b,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function m(){for(let x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:l,update:c,dispose:m}}function xl(n,e,t,i,r,s){Kr.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Qs.x=s*Kr.x-r*Kr.y,Qs.y=r*Kr.x+s*Kr.y):Qs.copy(Kr),n.copy(e),n.x+=Qs.x,n.y+=Qs.y,n.applyMatrix4(oy)}function RE(n,e){return n.z-e.z}function PE(n,e){return e.z-n.z}function DE(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function El(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(uc.fromBufferAttribute(o,r),dc.fromBufferAttribute(o,s),t.distanceSqToSegment(uc,dc,_d,ug)>i)return;_d.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(_d);if(!(l<e.near||l>e.far))return{distance:l,point:ug.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function pg(n,e,t,i,r,s,o){let a=Eh.distanceSqToPoint(n);if(a<t){let l=new R;Eh.closestPointToPoint(n,l),l.applyMatrix4(i);let c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}function zf(){let n=0,e=0,t=0,i=0;function r(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,i=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){r(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,d){let h=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+d)+(l-a)/d;h*=u,f*=u,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function mg(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,l=n*a;return(2*t-2*i+s+o)*l+(-3*t+3*i-2*s-o)*a+s*n+t}function OE(n,e){let t=1-n;return t*t*e}function UE(n,e){return 2*(1-n)*n*e}function NE(n,e){return n*n*e}function ho(n,e,t,i){return OE(n,e)+UE(n,t)+NE(n,i)}function FE(n,e){let t=1-n;return t*t*t*e}function kE(n,e){let t=1-n;return 3*t*t*n*e}function BE(n,e){return 3*(1-n)*n*n*e}function zE(n,e){return n*n*n*e}function fo(n,e,t,i,r){return FE(n,e)+kE(n,t)+BE(n,i)+zE(n,r)}function ay(n,e,t,i,r){let s,o;if(r===iT(n,e,t,i)>0)for(s=e;s<t;s+=i)o=gg(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=gg(s,n[s],n[s+1],o);return o&&du(o,o.next)&&(jo(o),o=o.next),o}function pr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(du(t,t.next)||pt(t.prev,t,t.next)===0)){if(jo(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function $o(n,e,t,i,r,s,o){if(!n)return;!o&&s&&JE(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?GE(n,i,r,s):HE(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),jo(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=$E(pr(n),e,t),$o(n,e,t,i,r,s,2)):o===2&&WE(n,e,t,i,r,s):$o(pr(n),e,t,i,r,s,1);break}}}function HE(n){let e=n.prev,t=n,i=n.next;if(pt(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<l?a<c?a:c:l<c?l:c,h=r>s?r>o?r:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&rs(r,a,s,l,o,c,p.x,p.y)&&pt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function GE(n,e,t,i){let r=n.prev,s=n,o=n.next;if(pt(r,s,o)>=0)return!1;let a=r.x,l=s.x,c=o.x,u=r.y,d=s.y,h=o.y,f=a<l?a<c?a:c:l<c?l:c,p=u<d?u<h?u:h:d<h?d:h,y=a>l?a>c?a:c:l>c?l:c,g=u>d?u>h?u:h:d>h?d:h,m=Lh(f,p,e,t,i),x=Lh(y,g,e,t,i),v=n.prevZ,b=n.nextZ;for(;v&&v.z>=m&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&rs(a,u,l,d,c,h,v.x,v.y)&&pt(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&rs(a,u,l,d,c,h,b.x,b.y)&&pt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&rs(a,u,l,d,c,h,v.x,v.y)&&pt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&rs(a,u,l,d,c,h,b.x,b.y)&&pt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function $E(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!du(r,s)&&ly(r,i,i.next,s)&&Wo(r,s)&&Wo(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),jo(i),jo(i.next),i=n=s),i=i.next}while(i!==n);return pr(i)}function WE(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&eT(o,a)){let l=cy(o,a);o=pr(o,o.next),l=pr(l,l.next),$o(o,e,t,i,r,s,0),$o(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function jE(n,e,t,i){let r=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:n.length,c=ay(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(QE(c));for(r.sort(XE),s=0;s<r.length;s++)t=YE(r[s],t);return t}function XE(n,e){return n.x-e.x}function YE(n,e){let t=qE(n,e);if(!t)return e;let i=cy(t,n);return pr(i,i.next),pr(t,t.next)}function qE(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,l=r.x,c=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&rs(o<c?s:i,o,l,c,o<c?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),Wo(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&ZE(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function ZE(n,e){return pt(n.prev,n,e.prev)<0&&pt(e.next,n,n.next)<0}function JE(n,e,t,i){let r=n;do r.z===0&&(r.z=Lh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,KE(r)}function KE(n){let e,t,i,r,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function Lh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function QE(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function rs(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function eT(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!tT(n,e)&&(Wo(n,e)&&Wo(e,n)&&nT(n,e)&&(pt(n.prev,n,e.prev)||pt(n,e.prev,e))||du(n,e)&&pt(n.prev,n,n.next)>0&&pt(e.prev,e,e.next)>0)}function pt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function du(n,e){return n.x===e.x&&n.y===e.y}function ly(n,e,t,i){let r=Ol(pt(n,e,t)),s=Ol(pt(n,e,i)),o=Ol(pt(t,i,n)),a=Ol(pt(t,i,e));return!!(r!==s&&o!==a||r===0&&Dl(n,t,e)||s===0&&Dl(n,i,e)||o===0&&Dl(t,n,i)||a===0&&Dl(t,e,i))}function Dl(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ol(n){return n>0?1:n<0?-1:0}function tT(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&ly(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Wo(n,e){return pt(n.prev,n,n.next)<0?pt(n,e,n.next)>=0&&pt(n,n.prev,e)>=0:pt(n,e,n.prev)<0||pt(n,n.next,e)<0}function nT(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function cy(n,e){let t=new Dh(n.i,n.x,n.y),i=new Dh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function gg(n,e,t,i){let r=new Dh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function jo(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Dh(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function iT(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function yg(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function vg(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function sT(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function oT(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function xg(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function rr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function uy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function dy(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Oh(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function Vf(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function aT(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],u=c.getValueSize(),d=[],h=[];for(let f=0;f<c.times.length;++f){let p=c.times[f]*r;if(!(p<t||p>=i)){d.push(c.times[f]);for(let y=0;y<u;++y)h.push(c.values[f*u+y])}}d.length!==0&&(c.times=rr(d,c.times.constructor),c.values=rr(h,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function lT(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=n.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===l});if(c===void 0)continue;let u=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let m=u,x=d-u;y=a.values.slice(m,x)}else if(s>=a.times[p]){let m=p*d+u,x=m+d-u;y=a.values.slice(m,x)}else{let m=a.createInterpolant(),x=u,v=d-u;m.evaluate(s),y=m.resultBuffer.slice(x,v)}l==="quaternion"&&new Vt().fromArray(y).normalize().conjugate().toArray(y);let g=c.times.length;for(let m=0;m<g;++m){let x=m*f+h;if(l==="quaternion")Vt.multiplyQuaternionsFlat(c.values,x,y,0,c.values,x);else{let v=f-h*2;for(let b=0;b<v;++b)c.values[x+b]-=y[b]}}}return n.blendMode=Nf,n}function uT(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gr;case"vector":case"vector2":case"vector3":case"vector4":return yr;case"color":return Jo;case"quaternion":return Pi;case"bool":case"boolean":return ai;case"string":return li}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function dT(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=uT(n.type);if(n.times===void 0){let t=[],i=[];Vf(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function Ig(){return(typeof performance>"u"?Date:performance).now()}function Lg(n,e){return n.distance-e.distance}function of(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)of(r[s],e,t,!0)}}function fy(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,fy(n.children[t]));return e}function vt(n,e,t,i,r,s,o){Bl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Bl.x,Bl.y,Bl.z)}}var Fb,kb,Bb,Vg,Cd,Hg,zb,Vb,Ef,Gg,Cn,ri,jt,Pn,ti,sr,Rd,Pd,Ld,$g,Ai,Wg,jg,Xg,Yg,qg,Zg,Jg,Kg,Yl,ql,Qg,e0,t0,n0,i0,r0,s0,o0,a0,l0,c0,u0,po,d0,h0,f0,p0,na,m0,g0,ni,y0,v0,x0,_0,b0,w0,M0,Dd,S0,au,si,Ti,mo,go,xs,yo,gn,vo,Rt,Tf,Hb,ts,Gb,bt,lo,$b,Ln,Wb,oi,A0,E0,If,Cf,lr,yn,ia,Rf,Pf,_s,T0,I0,C0,en,R0,P0,or,as,Lf,Df,L0,Of,Uf,Hl,Gl,$l,Wl,Od,Ud,Nd,Fd,kd,Bd,zd,Vd,Hd,Gd,$d,Wd,jd,Xd,Yd,qd,Zd,Jd,Kd,Qd,eh,jl,th,nh,D0,ih,rh,sh,O0,U0,N0,xo,_o,Xl,nr,ir,bo,lu,Nf,jb,Xb,Yb,F0,k0,Li,B0,Zn,mn,ci,cu,ra,wo,ut,Mo,So,qb,Qi,Zb,Jb,Kb,Qb,ew,tw,nw,iw,rw,sw,ow,aw,lw,oh,z0,V0,H0,Ff,G0,$0,W0,j0,Ao,cw,uw,dw,hw,fw,pw,mw,gw,yw,ah,Dn,Eo,En,kt,cm,ar,ls,Ow,te,Ve,Wu,Uw,um,dm,hm,Za,Nw,ot,Dr,Zl,Fw,Kn,kw,wt,at,Jl,nn,cs,lh,Io,ch,Vt,R,Yu,fm,Dt,$n,wn,Ja,Or,Ur,Nr,yi,vi,Vi,Ys,Ka,Qa,Hi,Bw,qs,Zu,Pt,Wn,Ju,el,xi,Ku,tl,Qu,Ii,Ne,Fr,Mn,zw,Vw,_i,nl,Kt,pm,mm,rn,us,Hw,gm,kr,jn,il,Zs,Gw,$w,ym,vm,xm,_m,Ww,Br,ed,it,Sn,Xn,td,Yn,zr,Vr,bm,nd,id,rd,Qn,Z0,bi,rl,we,Bt,jw,Lt,Nn,Jn,Yw,_t,sl,tt,uh,dh,hh,fh,Co,ph,Ro,mh,Te,qw,pn,od,Hr,Qt,Js,Ct,Xe,wm,Gi,ol,Mm,Gr,$r,Wr,ad,al,ll,cl,ul,Sm,Am,Em,dl,hl,yt,cr,K0,Kw,Qw,sn,hs,wi,Tm,Im,At,jr,Xr,Kl,ur,Ql,ld,eM,tM,Rn,$i,pl,dr,fs,iM,rM,sM,oM,aM,lM,cM,uM,dM,hM,fM,pM,mM,gM,yM,vM,xM,_M,bM,wM,MM,SM,AM,EM,TM,IM,CM,RM,PM,LM,DM,OM,UM,NM,FM,kM,BM,zM,VM,HM,GM,$M,WM,jM,XM,YM,qM,ZM,JM,KM,QM,eS,tS,nS,iS,rS,sS,oS,aS,lS,cS,uS,dS,hS,fS,pS,mS,gS,yS,vS,xS,_S,bS,wS,MS,SS,AS,ES,TS,IS,CS,RS,PS,LS,DS,OS,US,NS,FS,kS,BS,zS,VS,HS,GS,$S,WS,jS,XS,YS,qS,ZS,JS,KS,QS,e1,t1,n1,i1,r1,s1,o1,a1,l1,c1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,_1,b1,w1,M1,S1,A1,E1,T1,I1,C1,R1,P1,L1,D1,O1,U1,$e,ye,An,ml,Wi,N1,ps,is,Cm,tr,cd,Rm,ud,dd,hd,fd,er,Yr,Pm,Po,Lo,ey,ty,ny,iy,ry,Um,Nm,Fm,km,Bm,gh,yh,vh,pd,os,BA,zA,YA,qA,JA,sE,_h,bh,hE,Do,Oo,gE,yE,ec,Ei,bE,uo,wE,ME,wh,Mh,ji,SE,Sh,tc,nc,ic,ms,Gt,hr,Uo,qr,Ks,Zr,Jr,Kr,Qs,oy,yl,eo,vl,Zm,md,Jm,rc,_l,Km,sc,Qm,eg,tg,TE,ng,bl,gd,ig,yd,oc,No,On,rg,IE,ac,Ci,Qr,sg,wl,og,CE,to,no,lc,Ah,es,Mi,ag,LE,lg,vd,Ml,Xi,io,xd,zt,Sl,cc,Ot,uc,dc,cg,ro,Al,_d,ug,Fn,dg,hg,vn,hc,Fo,fg,Eh,Tl,Il,fc,Th,Ih,gs,Ch,Rh,Ph,on,ys,pc,Cl,bd,wd,Md,mc,ko,gc,Bo,yc,zo,Vo,Ho,vc,xc,fr,Go,_c,bc,vs,wc,Ri,Mc,Rl,Pl,Sd,Ll,Sc,ii,VE,Un,Ac,rT,Ec,Xo,Tc,Ic,Yo,Cc,Rc,Pc,Lc,Dc,_g,Oc,Uc,qo,Nc,Fc,kc,Bc,zc,Vc,Hc,cT,mr,Gc,Zo,$c,an,ai,Jo,gr,Wc,Pi,li,yr,vr,ei,Ko,hy,Ht,qn,Uh,Tn,Nh,Fh,xr,kh,Bh,zh,kn,jc,Ad,bg,wg,Qo,Vh,Xc,Mg,so,Ed,Hh,Yc,Gh,qc,Zc,Jc,Kc,Qc,eu,ea,tu,nu,$h,hT,Sg,Ag,Wh,Ul,ta,jh,Eg,Tg,Yi,Xh,iu,qi,Cg,fT,Zi,Yh,ru,Ji,Rg,pT,Ki,qh,Zh,su,Hf,mT,Gf,gT,yT,vT,xT,_T,bT,wT,Jh,st,Kh,ou,MT,Qh,ef,ST,tf,nf,rf,Pg,sf,af,lf,Dg,cf,Og,Nl,uf,Ug,df,Si,Fl,Td,hf,ff,AT,Ng,Fg,pf,mf,gf,kg,kl,Bg,yf,Bl,mt,vf,zl,xf,_f,bf,zg,Vl,Id,wf,Mf,Sf,Af,my=Hy(()=>{"use strict";Fb="164",kb={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Bb={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Vg=0,Cd=1,Hg=2,zb=3,Vb=0,Ef=1,Gg=2,Cn=3,ri=0,jt=1,Pn=2,ti=0,sr=1,Rd=2,Pd=3,Ld=4,$g=5,Ai=100,Wg=101,jg=102,Xg=103,Yg=104,qg=200,Zg=201,Jg=202,Kg=203,Yl=204,ql=205,Qg=206,e0=207,t0=208,n0=209,i0=210,r0=211,s0=212,o0=213,a0=214,l0=0,c0=1,u0=2,po=3,d0=4,h0=5,f0=6,p0=7,na=0,m0=1,g0=2,ni=0,y0=1,v0=2,x0=3,_0=4,b0=5,w0=6,M0=7,Dd="attached",S0="detached",au=300,si=301,Ti=302,mo=303,go=304,xs=306,yo=1e3,gn=1001,vo=1002,Rt=1003,Tf=1004,Hb=1004,ts=1005,Gb=1005,bt=1006,lo=1007,$b=1007,Ln=1008,Wb=1008,oi=1009,A0=1010,E0=1011,If=1012,Cf=1013,lr=1014,yn=1015,ia=1016,Rf=1017,Pf=1018,_s=1020,T0=35902,I0=1021,C0=1022,en=1023,R0=1024,P0=1025,or=1026,as=1027,Lf=1028,Df=1029,L0=1030,Of=1031,Uf=1033,Hl=33776,Gl=33777,$l=33778,Wl=33779,Od=35840,Ud=35841,Nd=35842,Fd=35843,kd=36196,Bd=37492,zd=37496,Vd=37808,Hd=37809,Gd=37810,$d=37811,Wd=37812,jd=37813,Xd=37814,Yd=37815,qd=37816,Zd=37817,Jd=37818,Kd=37819,Qd=37820,eh=37821,jl=36492,th=36494,nh=36495,D0=36283,ih=36284,rh=36285,sh=36286,O0=2200,U0=2201,N0=2202,xo=2300,_o=2301,Xl=2302,nr=2400,ir=2401,bo=2402,lu=2500,Nf=2501,jb=0,Xb=1,Yb=2,F0=3200,k0=3201,Li=0,B0=1,Zn="",mn="srgb",ci="srgb-linear",cu="display-p3",ra="display-p3-linear",wo="linear",ut="srgb",Mo="rec709",So="p3",qb=0,Qi=7680,Zb=7681,Jb=7682,Kb=7683,Qb=34055,ew=34056,tw=5386,nw=512,iw=513,rw=514,sw=515,ow=516,aw=517,lw=518,oh=519,z0=512,V0=513,H0=514,Ff=515,G0=516,$0=517,W0=518,j0=519,Ao=35044,cw=35048,uw=35040,dw=35045,hw=35049,fw=35041,pw=35046,mw=35050,gw=35042,yw="100",ah="300 es",Dn=2e3,Eo=2001,En=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},kt=["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"],cm=1234567,ar=Math.PI/180,ls=180/Math.PI;Ow={DEG2RAD:ar,RAD2DEG:ls,generateUUID:tn,clamp:gt,euclideanModulo:kf,mapLinear:vw,inverseLerp:xw,lerp:co,damp:_w,pingpong:bw,smoothstep:ww,smootherstep:Mw,randInt:Sw,randFloat:Aw,randFloatSpread:Ew,seededRandom:Tw,degToRad:Iw,radToDeg:Cw,isPowerOfTwo:Rw,ceilPowerOfTwo:Pw,floorPowerOfTwo:Lw,setQuaternionFromProperEuler:Dw,normalize:He,denormalize:Wt},te=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(gt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ve=class n{constructor(e,t,i,r,s,o,a,l,c){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c)}set(e,t,i,r,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],y=r[0],g=r[3],m=r[6],x=r[1],v=r[4],b=r[7],L=r[2],A=r[5],E=r[8];return s[0]=o*y+a*x+l*L,s[3]=o*g+a*v+l*A,s[6]=o*m+a*b+l*E,s[1]=c*y+u*x+d*L,s[4]=c*g+u*v+d*A,s[7]=c*m+u*b+d*E,s[2]=h*y+f*x+p*L,s[5]=h*g+f*v+p*A,s[8]=h*m+f*b+p*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+r*s*c-r*o*l}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],d=u*o-a*c,h=a*l-u*s,f=c*s-o*l,p=t*d+i*h+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/p;return e[0]=d*y,e[1]=(r*c-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=h*y,e[4]=(u*t-r*l)*y,e[5]=(r*s-a*t)*y,e[6]=f*y,e[7]=(i*l-c*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Wu.makeScale(e,t)),this}rotate(e){return this.premultiply(Wu.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wu.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Wu=new Ve;Uw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};um={};dm=new Ve().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),hm=new Ve().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Za={[ci]:{transfer:wo,primaries:Mo,toReference:n=>n,fromReference:n=>n},[mn]:{transfer:ut,primaries:Mo,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[ra]:{transfer:wo,primaries:So,toReference:n=>n.applyMatrix3(hm),fromReference:n=>n.applyMatrix3(dm)},[cu]:{transfer:ut,primaries:So,toReference:n=>n.convertSRGBToLinear().applyMatrix3(hm),fromReference:n=>n.applyMatrix3(dm).convertLinearToSRGB()}},Nw=new Set([ci,ra]),ot={enabled:!0,_workingColorSpace:ci,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Nw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Za[e].toReference,r=Za[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Za[n].primaries},getTransfer:function(n){return n===Zn?wo:Za[n].transfer}};Zl=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Dr===void 0&&(Dr=To("canvas")),Dr.width=e.width,Dr.height=e.height;let i=Dr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Dr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=To("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=ss(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(ss(t[i]/255)*255):t[i]=ss(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Fw=0,Kn=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fw++}),this.uuid=tn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Xu(r[o].image)):s.push(Xu(r[o]))}else s=Xu(r);i.url=s}return t||(e.images[this.uuid]=i),i}};kw=0,wt=class n extends En{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=gn,r=gn,s=bt,o=Ln,a=en,l=oi,c=n.DEFAULT_ANISOTROPY,u=Zn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kw++}),this.uuid=tn(),this.name="",this.source=new Kn(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==au)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case yo:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case vo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case yo:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case vo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};wt.DEFAULT_IMAGE=null;wt.DEFAULT_MAPPING=au;wt.DEFAULT_ANISOTROPY=1;at=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],y=l[2],g=l[6],m=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(c+1)/2,b=(f+1)/2,L=(m+1)/2,A=(u+h)/4,E=(d+y)/4,D=(p+g)/4;return v>b&&v>L?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=A/i,s=E/i):b>L?b<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),i=A/r,s=D/r):L<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),i=E/s,r=D/s),this.set(i,r,s,t),this}let x=Math.sqrt((g-p)*(g-p)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(g-p)/x,this.y=(d-y)/x,this.z=(h-u)/x,this.w=Math.acos((c+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Jl=class extends En{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Kn(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},nn=class extends Jl{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},cs=class extends wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Rt,this.minFilter=Rt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},lh=class extends nn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new cs(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Io=class extends wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Rt,this.minFilter=Rt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ch=class extends nn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Io(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Vt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let l=i[r+0],c=i[r+1],u=i[r+2],d=i[r+3],h=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=p,e[t+3]=y;return}if(d!==y||l!==h||c!==f||u!==p){let g=1-a,m=l*h+c*f+u*p+d*y,x=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){let L=Math.sqrt(v),A=Math.atan2(L,m*x);g=Math.sin(g*A)/L,a=Math.sin(a*A)/L}let b=a*x;if(l=l*g+h*b,c=c*g+f*b,u=u*g+p*b,d=d*g+y*b,g===1-a){let L=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=L,c*=L,u*=L,d*=L}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],d=s[o],h=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-a*f,e[t+2]=c*p+u*f+a*h-l*d,e[t+3]=u*p-a*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),d=a(s/2),h=l(i/2),f=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-r)*f}else if(i>a&&i>d){let f=2*Math.sqrt(1+i-a-d);this._w=(u-l)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-i-d);this._w=(s-c)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+d-i-a);this._w=(o-r)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),d=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=o*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fm.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fm.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+l*c+o*d-a*u,this.y=i+l*u+a*c-s*d,this.z=r+l*d+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Yu.copy(this).projectOnVector(e),this.sub(Yu)}reflect(e){return this.sub(Yu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(gt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Yu=new R,fm=new Vt,Dt=class{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(wn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(wn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=wn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,wn):wn.fromBufferAttribute(s,o),wn.applyMatrix4(e.matrixWorld),this.expandByPoint(wn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ja.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ja.copy(i.boundingBox)),Ja.applyMatrix4(e.matrixWorld),this.union(Ja)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,wn),wn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ys),Ka.subVectors(this.max,Ys),Or.subVectors(e.a,Ys),Ur.subVectors(e.b,Ys),Nr.subVectors(e.c,Ys),yi.subVectors(Ur,Or),vi.subVectors(Nr,Ur),Vi.subVectors(Or,Nr);let t=[0,-yi.z,yi.y,0,-vi.z,vi.y,0,-Vi.z,Vi.y,yi.z,0,-yi.x,vi.z,0,-vi.x,Vi.z,0,-Vi.x,-yi.y,yi.x,0,-vi.y,vi.x,0,-Vi.y,Vi.x,0];return!qu(t,Or,Ur,Nr,Ka)||(t=[1,0,0,0,1,0,0,0,1],!qu(t,Or,Ur,Nr,Ka))?!1:(Qa.crossVectors(yi,vi),t=[Qa.x,Qa.y,Qa.z],qu(t,Or,Ur,Nr,Ka))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(wn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:($n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($n),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},$n=[new R,new R,new R,new R,new R,new R,new R,new R],wn=new R,Ja=new Dt,Or=new R,Ur=new R,Nr=new R,yi=new R,vi=new R,Vi=new R,Ys=new R,Ka=new R,Qa=new R,Hi=new R;Bw=new Dt,qs=new R,Zu=new R,Pt=class{constructor(e=new R,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):Bw.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;qs.subVectors(e,this.center);let t=qs.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(qs,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Zu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(qs.copy(e.center).add(Zu)),this.expandByPoint(qs.copy(e.center).sub(Zu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Wn=new R,Ju=new R,el=new R,xi=new R,Ku=new R,tl=new R,Qu=new R,Ii=class{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ju.copy(e).add(t).multiplyScalar(.5),el.copy(t).sub(e).normalize(),xi.copy(this.origin).sub(Ju);let s=e.distanceTo(t)*.5,o=-this.direction.dot(el),a=xi.dot(this.direction),l=-xi.dot(el),c=xi.lengthSq(),u=Math.abs(1-o*o),d,h,f,p;if(u>0)if(d=o*l-a,h=o*a-l,p=s*u,d>=0)if(h>=-p)if(h<=p){let y=1/u;d*=y,h*=y,f=d*(d+o*h+2*a)+h*(o*d+h+2*l)+c}else h=s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h=-s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-o*s+a)),h=d>0?-s:Math.min(Math.max(-s,-l),s),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-s,-l),s),f=h*(h+2*l)+c):(d=Math.max(0,-(o*s+a)),h=d>0?s:Math.min(Math.max(-s,-l),s),f=-d*d+h*(h+2*l)+c);else h=o>0?-s:s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Ju).addScaledVector(el,h),f}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);let i=Wn.dot(this.direction),r=Wn.dot(Wn)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||a>r)||((a>i||i!==i)&&(i=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,i,r,s){Ku.subVectors(t,e),tl.subVectors(i,e),Qu.crossVectors(Ku,tl);let o=this.direction.dot(Qu),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;xi.subVectors(this.origin,e);let l=a*this.direction.dot(tl.crossVectors(xi,tl));if(l<0)return null;let c=a*this.direction.dot(Ku.cross(xi));if(c<0||l+c>o)return null;let u=-a*xi.dot(Qu);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ne=class n{constructor(e,t,i,r,s,o,a,l,c,u,d,h,f,p,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c,u,d,h,f,p,y,g)}set(e,t,i,r,s,o,a,l,c,u,d,h,f,p,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=d,m[14]=h,m[3]=f,m[7]=p,m[11]=y,m[15]=g,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 n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/Fr.setFromMatrixColumn(e,0).length(),s=1/Fr.setFromMatrixColumn(e,1).length(),o=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=l*u,t[4]=-l*d,t[8]=c,t[1]=f+p*c,t[5]=h-y*c,t[9]=-a*l,t[2]=y-h*c,t[6]=p+f*c,t[10]=o*l}else if(e.order==="YXZ"){let h=l*u,f=l*d,p=c*u,y=c*d;t[0]=h+y*a,t[4]=p*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=y+h*a,t[10]=o*l}else if(e.order==="ZXY"){let h=l*u,f=l*d,p=c*u,y=c*d;t[0]=h-y*a,t[4]=-o*d,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=y-h*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=l*u,t[4]=p*c-f,t[8]=h*c+y,t[1]=l*d,t[5]=y*c+h,t[9]=f*c-p,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let h=o*l,f=o*c,p=a*l,y=a*c;t[0]=l*u,t[4]=y-h*d,t[8]=p*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*d+p,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*l,f=o*c,p=a*l,y=a*c;t[0]=l*u,t[4]=-d,t[8]=c*u,t[1]=h*d+y,t[5]=o*u,t[9]=f*d-p,t[2]=p*d-f,t[6]=a*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(zw,e,Vw)}lookAt(e,t,i){let r=this.elements;return Kt.subVectors(e,t),Kt.lengthSq()===0&&(Kt.z=1),Kt.normalize(),_i.crossVectors(i,Kt),_i.lengthSq()===0&&(Math.abs(i.z)===1?Kt.x+=1e-4:Kt.z+=1e-4,Kt.normalize(),_i.crossVectors(i,Kt)),_i.normalize(),nl.crossVectors(Kt,_i),r[0]=_i.x,r[4]=nl.x,r[8]=Kt.x,r[1]=_i.y,r[5]=nl.y,r[9]=Kt.y,r[2]=_i.z,r[6]=nl.z,r[10]=Kt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],d=i[5],h=i[9],f=i[13],p=i[2],y=i[6],g=i[10],m=i[14],x=i[3],v=i[7],b=i[11],L=i[15],A=r[0],E=r[4],D=r[8],M=r[12],w=r[1],T=r[5],U=r[9],I=r[13],B=r[2],W=r[6],F=r[10],X=r[14],k=r[3],re=r[7],se=r[11],ve=r[15];return s[0]=o*A+a*w+l*B+c*k,s[4]=o*E+a*T+l*W+c*re,s[8]=o*D+a*U+l*F+c*se,s[12]=o*M+a*I+l*X+c*ve,s[1]=u*A+d*w+h*B+f*k,s[5]=u*E+d*T+h*W+f*re,s[9]=u*D+d*U+h*F+f*se,s[13]=u*M+d*I+h*X+f*ve,s[2]=p*A+y*w+g*B+m*k,s[6]=p*E+y*T+g*W+m*re,s[10]=p*D+y*U+g*F+m*se,s[14]=p*M+y*I+g*X+m*ve,s[3]=x*A+v*w+b*B+L*k,s[7]=x*E+v*T+b*W+L*re,s[11]=x*D+v*U+b*F+L*se,s[15]=x*M+v*I+b*X+L*ve,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],d=e[6],h=e[10],f=e[14],p=e[3],y=e[7],g=e[11],m=e[15];return p*(+s*l*d-r*c*d-s*a*h+i*c*h+r*a*f-i*l*f)+y*(+t*l*f-t*c*h+s*o*h-r*o*f+r*c*u-s*l*u)+g*(+t*c*d-t*a*f-s*o*d+i*o*f+s*a*u-i*c*u)+m*(-r*a*u-t*l*d+t*a*h+r*o*d-i*o*h+i*l*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],d=e[9],h=e[10],f=e[11],p=e[12],y=e[13],g=e[14],m=e[15],x=d*g*c-y*h*c+y*l*f-a*g*f-d*l*m+a*h*m,v=p*h*c-u*g*c-p*l*f+o*g*f+u*l*m-o*h*m,b=u*y*c-p*d*c+p*a*f-o*y*f-u*a*m+o*d*m,L=p*d*l-u*y*l-p*a*h+o*y*h+u*a*g-o*d*g,A=t*x+i*v+r*b+s*L;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/A;return e[0]=x*E,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*m-i*h*m)*E,e[2]=(a*g*s-y*l*s+y*r*c-i*g*c-a*r*m+i*l*m)*E,e[3]=(d*l*s-a*h*s-d*r*c+i*h*c+a*r*f-i*l*f)*E,e[4]=v*E,e[5]=(u*g*s-p*h*s+p*r*f-t*g*f-u*r*m+t*h*m)*E,e[6]=(p*l*s-o*g*s-p*r*c+t*g*c+o*r*m-t*l*m)*E,e[7]=(o*h*s-u*l*s+u*r*c-t*h*c-o*r*f+t*l*f)*E,e[8]=b*E,e[9]=(p*d*s-u*y*s-p*i*f+t*y*f+u*i*m-t*d*m)*E,e[10]=(o*y*s-p*a*s+p*i*c-t*y*c-o*i*m+t*a*m)*E,e[11]=(u*a*s-o*d*s-u*i*c+t*d*c+o*i*f-t*a*f)*E,e[12]=L*E,e[13]=(u*y*r-p*d*r+p*i*h-t*y*h-u*i*g+t*d*g)*E,e[14]=(p*a*r-o*y*r-p*i*l+t*y*l+o*i*g-t*a*g)*E,e[15]=(o*d*r-u*a*r+u*i*l-t*d*l-o*i*h+t*a*h)*E,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,d=a+a,h=s*c,f=s*u,p=s*d,y=o*u,g=o*d,m=a*d,x=l*c,v=l*u,b=l*d,L=i.x,A=i.y,E=i.z;return r[0]=(1-(y+m))*L,r[1]=(f+b)*L,r[2]=(p-v)*L,r[3]=0,r[4]=(f-b)*A,r[5]=(1-(h+m))*A,r[6]=(g+x)*A,r[7]=0,r[8]=(p+v)*E,r[9]=(g-x)*E,r[10]=(1-(h+y))*E,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=Fr.set(r[0],r[1],r[2]).length(),o=Fr.set(r[4],r[5],r[6]).length(),a=Fr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Mn.copy(this);let c=1/s,u=1/o,d=1/a;return Mn.elements[0]*=c,Mn.elements[1]*=c,Mn.elements[2]*=c,Mn.elements[4]*=u,Mn.elements[5]*=u,Mn.elements[6]*=u,Mn.elements[8]*=d,Mn.elements[9]*=d,Mn.elements[10]*=d,t.setFromRotationMatrix(Mn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Dn){let l=this.elements,c=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,p;if(a===Dn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===Eo)f=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Dn){let l=this.elements,c=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*c,f=(i+r)*u,p,y;if(a===Dn)p=(o+s)*d,y=-2*d;else if(a===Eo)p=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-h,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=y,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Fr=new R,Mn=new Ne,zw=new R(0,0,0),Vw=new R(1,1,1),_i=new R,nl=new R,Kt=new R,pm=new Ne,mm=new Vt,rn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-gt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(gt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return pm.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pm,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return mm.setFromEuler(this),this.setFromQuaternion(mm,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};rn.DEFAULT_ORDER="XYZ";us=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Hw=0,gm=new R,kr=new Vt,jn=new Ne,il=new R,Zs=new R,Gw=new R,$w=new Vt,ym=new R(1,0,0),vm=new R(0,1,0),xm=new R(0,0,1),_m={type:"added"},Ww={type:"removed"},Br={type:"childadded",child:null},ed={type:"childremoved",child:null},it=class n extends En{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Hw++}),this.uuid=tn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new R,t=new rn,i=new Vt,r=new R(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ne},normalMatrix:{value:new Ve}}),this.matrix=new Ne,this.matrixWorld=new Ne,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.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.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return kr.setFromAxisAngle(e,t),this.quaternion.multiply(kr),this}rotateOnWorldAxis(e,t){return kr.setFromAxisAngle(e,t),this.quaternion.premultiply(kr),this}rotateX(e){return this.rotateOnAxis(ym,e)}rotateY(e){return this.rotateOnAxis(vm,e)}rotateZ(e){return this.rotateOnAxis(xm,e)}translateOnAxis(e,t){return gm.copy(e).applyQuaternion(this.quaternion),this.position.add(gm.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ym,e)}translateY(e){return this.translateOnAxis(vm,e)}translateZ(e){return this.translateOnAxis(xm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(jn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?il.copy(e):il.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Zs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jn.lookAt(Zs,il,this.up):jn.lookAt(il,Zs,this.up),this.quaternion.setFromRotationMatrix(jn),r&&(jn.extractRotation(r.matrixWorld),kr.setFromRotationMatrix(jn),this.quaternion.premultiply(kr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(_m),Br.child=e,this.dispatchEvent(Br),Br.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ww),ed.child=e,this.dispatchEvent(ed),ed.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),jn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jn.multiply(e.parent.matrixWorld)),e.applyMatrix4(jn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(_m),Br.child=e,this.dispatchEvent(Br),Br.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,e,Gw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,$w,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];r.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),p=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};it.DEFAULT_UP=new R(0,1,0);it.DEFAULT_MATRIX_AUTO_UPDATE=!0;it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Sn=new R,Xn=new R,td=new R,Yn=new R,zr=new R,Vr=new R,bm=new R,nd=new R,id=new R,rd=new R,Qn=class n{constructor(e=new R,t=new R,i=new R){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Sn.subVectors(e,t),r.cross(Sn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Sn.subVectors(r,t),Xn.subVectors(i,t),td.subVectors(e,t);let o=Sn.dot(Sn),a=Sn.dot(Xn),l=Sn.dot(td),c=Xn.dot(Xn),u=Xn.dot(td),d=o*c-a*a;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(c*l-a*u)*h,p=(o*u-a*l)*h;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Yn)===null?!1:Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Yn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Yn.x),l.addScaledVector(o,Yn.y),l.addScaledVector(a,Yn.z),l)}static isFrontFacing(e,t,i,r){return Sn.subVectors(i,t),Xn.subVectors(e,t),Sn.cross(Xn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Sn.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),Sn.cross(Xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;zr.subVectors(r,i),Vr.subVectors(s,i),nd.subVectors(e,i);let l=zr.dot(nd),c=Vr.dot(nd);if(l<=0&&c<=0)return t.copy(i);id.subVectors(e,r);let u=zr.dot(id),d=Vr.dot(id);if(u>=0&&d<=u)return t.copy(r);let h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(zr,o);rd.subVectors(e,s);let f=zr.dot(rd),p=Vr.dot(rd);if(p>=0&&f<=p)return t.copy(s);let y=f*c-l*p;if(y<=0&&c>=0&&p<=0)return a=c/(c-p),t.copy(i).addScaledVector(Vr,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return bm.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(bm,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(zr,o).addScaledVector(Vr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Z0={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},bi={h:0,s:0,l:0},rl={h:0,s:0,l:0};we=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=mn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ot.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=ot.workingColorSpace){return this.r=e,this.g=t,this.b=i,ot.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=ot.workingColorSpace){if(e=kf(e,1),t=gt(t,0,1),i=gt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=sd(o,s,e+1/3),this.g=sd(o,s,e),this.b=sd(o,s,e-1/3)}return ot.toWorkingColorSpace(this,r),this}setStyle(e,t=mn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=mn){let i=Z0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ss(e.r),this.g=ss(e.g),this.b=ss(e.b),this}copyLinearToSRGB(e){return this.r=ju(e.r),this.g=ju(e.g),this.b=ju(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mn){return ot.fromWorkingColorSpace(Bt.copy(this),e),Math.round(gt(Bt.r*255,0,255))*65536+Math.round(gt(Bt.g*255,0,255))*256+Math.round(gt(Bt.b*255,0,255))}getHexString(e=mn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ot.workingColorSpace){ot.fromWorkingColorSpace(Bt.copy(this),t);let i=Bt.r,r=Bt.g,s=Bt.b,o=Math.max(i,r,s),a=Math.min(i,r,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=u<=.5?d/(o+a):d/(2-o-a),o){case i:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-i)/d+2;break;case s:l=(i-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=ot.workingColorSpace){return ot.fromWorkingColorSpace(Bt.copy(this),t),e.r=Bt.r,e.g=Bt.g,e.b=Bt.b,e}getStyle(e=mn){ot.fromWorkingColorSpace(Bt.copy(this),e);let t=Bt.r,i=Bt.g,r=Bt.b;return e!==mn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(bi),this.setHSL(bi.h+e,bi.s+t,bi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(bi),e.getHSL(rl);let i=co(bi.h,rl.h,t),r=co(bi.s,rl.s,t),s=co(bi.l,rl.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Bt=new we;we.NAMES=Z0;jw=0,Lt=class extends En{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jw++}),this.uuid=tn(),this.name="",this.type="Material",this.blending=sr,this.side=ri,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Yl,this.blendDst=ql,this.blendEquation=Ai,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=po,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=oh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qi,this.stencilZFail=Qi,this.stencilZPass=Qi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==sr&&(i.blending=this.blending),this.side!==ri&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Yl&&(i.blendSrc=this.blendSrc),this.blendDst!==ql&&(i.blendDst=this.blendDst),this.blendEquation!==Ai&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==po&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==oh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qi&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Qi&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Qi&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Nn=class extends Lt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new we(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=na,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Jn=Xw();Yw={toHalfFloat:Yt,fromHalfFloat:oo},_t=new R,sl=new te,tt=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Ao,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=yn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return q0("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)sl.fromBufferAttribute(this,t),sl.applyMatrix3(e),this.setXY(t,sl.x,sl.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyMatrix3(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyMatrix4(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.applyNormalMatrix(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)_t.fromBufferAttribute(this,t),_t.transformDirection(e),this.setXYZ(t,_t.x,_t.y,_t.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Wt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=He(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wt(t,this.array)),t}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wt(t,this.array)),t}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Wt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Wt(t,this.array)),t}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ao&&(e.usage=this.usage),e}},uh=class extends tt{constructor(e,t,i){super(new Int8Array(e),t,i)}},dh=class extends tt{constructor(e,t,i){super(new Uint8Array(e),t,i)}},hh=class extends tt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},fh=class extends tt{constructor(e,t,i){super(new Int16Array(e),t,i)}},Co=class extends tt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},ph=class extends tt{constructor(e,t,i){super(new Int32Array(e),t,i)}},Ro=class extends tt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},mh=class extends tt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=oo(this.array[e*this.itemSize]);return this.normalized&&(t=Wt(t,this.array)),t}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize]=Yt(t),this}getY(e){let t=oo(this.array[e*this.itemSize+1]);return this.normalized&&(t=Wt(t,this.array)),t}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+1]=Yt(t),this}getZ(e){let t=oo(this.array[e*this.itemSize+2]);return this.normalized&&(t=Wt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+2]=Yt(t),this}getW(e){let t=oo(this.array[e*this.itemSize+3]);return this.normalized&&(t=Wt(t,this.array)),t}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.array[e*this.itemSize+3]=Yt(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this.array[e+2]=Yt(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.array[e+0]=Yt(t),this.array[e+1]=Yt(i),this.array[e+2]=Yt(r),this.array[e+3]=Yt(s),this}},Te=class extends tt{constructor(e,t,i){super(new Float32Array(e),t,i)}},qw=0,pn=new Ne,od=new it,Hr=new R,Qt=new Dt,Js=new Dt,Ct=new R,Xe=class n extends En{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qw++}),this.uuid=tn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(X0(e)?Ro:Co)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Ve().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pn.makeRotationFromQuaternion(e),this.applyMatrix4(pn),this}rotateX(e){return pn.makeRotationX(e),this.applyMatrix4(pn),this}rotateY(e){return pn.makeRotationY(e),this.applyMatrix4(pn),this}rotateZ(e){return pn.makeRotationZ(e),this.applyMatrix4(pn),this}translate(e,t,i){return pn.makeTranslation(e,t,i),this.applyMatrix4(pn),this}scale(e,t,i){return pn.makeScale(e,t,i),this.applyMatrix4(pn),this}lookAt(e){return od.lookAt(e),od.updateMatrix(),this.applyMatrix4(od.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hr).negate(),this.translate(Hr.x,Hr.y,Hr.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Te(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];Qt.setFromBufferAttribute(s),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,Qt.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,Qt.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(Qt.min),this.boundingBox.expandByPoint(Qt.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 Pt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){let i=this.boundingSphere.center;if(Qt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Js.setFromBufferAttribute(a),this.morphTargetsRelative?(Ct.addVectors(Qt.min,Js.min),Qt.expandByPoint(Ct),Ct.addVectors(Qt.max,Js.max),Qt.expandByPoint(Ct)):(Qt.expandByPoint(Js.min),Qt.expandByPoint(Js.max))}Qt.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Ct.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ct));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Ct.fromBufferAttribute(a,c),l&&(Hr.fromBufferAttribute(e,c),Ct.add(Hr)),r=Math.max(r,i.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(r),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 e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new tt(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let D=0;D<i.count;D++)a[D]=new R,l[D]=new R;let c=new R,u=new R,d=new R,h=new te,f=new te,p=new te,y=new R,g=new R;function m(D,M,w){c.fromBufferAttribute(i,D),u.fromBufferAttribute(i,M),d.fromBufferAttribute(i,w),h.fromBufferAttribute(s,D),f.fromBufferAttribute(s,M),p.fromBufferAttribute(s,w),u.sub(c),d.sub(c),f.sub(h),p.sub(h);let T=1/(f.x*p.y-p.x*f.y);isFinite(T)&&(y.copy(u).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(T),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(T),a[D].add(y),a[M].add(y),a[w].add(y),l[D].add(g),l[M].add(g),l[w].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let D=0,M=x.length;D<M;++D){let w=x[D],T=w.start,U=w.count;for(let I=T,B=T+U;I<B;I+=3)m(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let v=new R,b=new R,L=new R,A=new R;function E(D){L.fromBufferAttribute(r,D),A.copy(L);let M=a[D];v.copy(M),v.sub(L.multiplyScalar(L.dot(M))).normalize(),b.crossVectors(A,M);let T=b.dot(l[D])<0?-1:1;o.setXYZW(D,v.x,v.y,v.z,T)}for(let D=0,M=x.length;D<M;++D){let w=x[D],T=w.start,U=w.count;for(let I=T,B=T+U;I<B;I+=3)E(e.getX(I+0)),E(e.getX(I+1)),E(e.getX(I+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new tt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new R,s=new R,o=new R,a=new R,l=new R,c=new R,u=new R,d=new R;if(e)for(let h=0,f=e.count;h<f;h+=3){let p=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,p),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,g),a.add(u),l.add(u),c.add(u),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,d=a.normalized,h=new c.constructor(l.length*u),f=0,p=0;for(let y=0,g=l.length;y<g;y++){a.isInterleavedBufferAttribute?f=l[y]*a.data.stride+a.offset:f=l[y]*u;for(let m=0;m<u;m++)h[p++]=c[f++]}return new tt(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let l=r[a],c=e(l,i);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let u=0,d=c.length;u<d;u++){let h=c[u],f=e(h,i);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let l in i){let c=i[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d];u.push(f.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let c in r){let u=r[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],d=s[c];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},wm=new Ne,Gi=new Ii,ol=new Pt,Mm=new R,Gr=new R,$r=new R,Wr=new R,ad=new R,al=new R,ll=new te,cl=new te,ul=new te,Sm=new R,Am=new R,Em=new R,dl=new R,hl=new R,yt=class extends it{constructor(e=new Xe,t=new Nn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){al.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],d=s[l];u!==0&&(ad.fromBufferAttribute(d,e),o?al.addScaledVector(ad,u):al.addScaledVector(ad.sub(t),u))}t.add(al)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ol.copy(i.boundingSphere),ol.applyMatrix4(s),Gi.copy(e.ray).recast(e.near),!(ol.containsPoint(Gi.origin)===!1&&(Gi.intersectSphere(ol,Mm)===null||Gi.origin.distanceToSquared(Mm)>(e.far-e.near)**2))&&(wm.copy(s).invert(),Gi.copy(e.ray).applyMatrix4(wm),!(i.boundingBox!==null&&Gi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Gi)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let b=x,L=v;b<L;b+=3){let A=a.getX(b),E=a.getX(b+1),D=a.getX(b+2);r=fl(this,m,e,i,c,u,d,A,E,D),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=a.getX(g),v=a.getX(g+1),b=a.getX(g+2);r=fl(this,o,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let b=x,L=v;b<L;b+=3){let A=b,E=b+1,D=b+2;r=fl(this,m,e,i,c,u,d,A,E,D),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(l.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=g,v=g+1,b=g+2;r=fl(this,o,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};cr=class n extends Xe{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],d=[],h=0,f=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(d,2));function p(y,g,m,x,v,b,L,A,E,D,M){let w=b/E,T=L/D,U=b/2,I=L/2,B=A/2,W=E+1,F=D+1,X=0,k=0,re=new R;for(let se=0;se<F;se++){let ve=se*T-I;for(let Le=0;Le<W;Le++){let Je=Le*w-U;re[y]=Je*x,re[g]=ve*v,re[m]=B,c.push(re.x,re.y,re.z),re[y]=0,re[g]=0,re[m]=A>0?1:-1,u.push(re.x,re.y,re.z),d.push(Le/E),d.push(1-se/D),X+=1}}for(let se=0;se<D;se++)for(let ve=0;ve<E;ve++){let Le=h+ve+W*se,Je=h+ve+W*(se+1),Z=h+(ve+1)+W*(se+1),q=h+(ve+1)+W*se;l.push(Le,Je,q),l.push(Je,Z,q),k+=6}a.addGroup(f,k,M),f+=k,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};K0={clone:ds,merge:$t},Kw=`void main() {
201
201
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
202
- }`,Zw=`void main() {
202
+ }`,Qw=`void main() {
203
203
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
204
- }`,sn=class extends Lt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=qw,this.fragmentShader=Zw,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ds(e.uniforms),this.uniformsGroups=Yw(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},hs=class extends it{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ne,this.projectionMatrix=new Ne,this.projectionMatrixInverse=new Ne,this.coordinateSystem=Dn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},wi=new R,Em=new te,Tm=new te,At=class extends hs{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=ls*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(or*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ls*2*Math.atan(Math.tan(or*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Em,Tm),t.subVectors(Tm,Em)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(or*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}let o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},jr=-90,Xr=1,Kl=class extends it{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new At(jr,Xr,e,t);r.layers=this.layers,this.add(r);let s=new At(jr,Xr,e,t);s.layers=this.layers,this.add(s);let a=new At(jr,Xr,e,t);a.layers=this.layers,this.add(a);let o=new At(jr,Xr,e,t);o.layers=this.layers,this.add(o);let l=new At(jr,Xr,e,t);l.layers=this.layers,this.add(l);let c=new At(jr,Xr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(let c of t)this.remove(c);if(e===Dn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Aa)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}},ur=class extends wt{constructor(e,t,i,r,s,a,o,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:si,super(e,t,i,r,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ql=class extends nn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new ur(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:bt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
204
+ }`,sn=class extends Lt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Kw,this.fragmentShader=Qw,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ds(e.uniforms),this.uniformsGroups=Jw(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},hs=class extends it{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ne,this.projectionMatrix=new Ne,this.projectionMatrixInverse=new Ne,this.coordinateSystem=Dn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},wi=new R,Tm=new te,Im=new te,At=class extends hs{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=ls*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ar*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ls*2*Math.atan(Math.tan(ar*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Tm,Im),t.subVectors(Im,Tm)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ar*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/c,r*=o.width/l,i*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},jr=-90,Xr=1,Kl=class extends it{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new At(jr,Xr,e,t);r.layers=this.layers,this.add(r);let s=new At(jr,Xr,e,t);s.layers=this.layers,this.add(s);let o=new At(jr,Xr,e,t);o.layers=this.layers,this.add(o);let a=new At(jr,Xr,e,t);a.layers=this.layers,this.add(a);let l=new At(jr,Xr,e,t);l.layers=this.layers,this.add(l);let c=new At(jr,Xr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===Dn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Eo)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},ur=class extends wt{constructor(e,t,i,r,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:si,super(e,t,i,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ql=class extends nn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new ur(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:bt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
205
205
 
206
206
  varying vec3 vWorldDirection;
207
207
 
@@ -236,9 +236,9 @@ Program Info Log: `+U+`
236
236
  gl_FragColor = texture2D( tEquirect, sampleUV );
237
237
 
238
238
  }
239
- `},r=new cr(5,5,5),s=new sn({name:"CubemapFromEquirect",uniforms:ds(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:jt,blending:ti});s.uniforms.tEquirect.value=t;let a=new yt(r,s),o=t.minFilter;return t.minFilter===Ln&&(t.minFilter=bt),new Kl(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}},ld=new R,Jw=new R,Kw=new Ve,Rn=class{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=ld.subVectors(i,t).cross(Jw.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(ld),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||Kw.getNormalMatrix(e),r=this.coplanarPoint(ld).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},$i=new Pt,pl=new R,dr=class{constructor(e=new Rn,t=new Rn,i=new Rn,r=new Rn,s=new Rn,a=new Rn){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Dn){let i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],u=r[5],d=r[6],h=r[7],f=r[8],m=r[9],y=r[10],g=r[11],p=r[12],x=r[13],v=r[14],b=r[15];if(i[0].setComponents(l-s,h-c,g-f,b-p).normalize(),i[1].setComponents(l+s,h+c,g+f,b+p).normalize(),i[2].setComponents(l+a,h+u,g+m,b+x).normalize(),i[3].setComponents(l-a,h-u,g-m,b-x).normalize(),i[4].setComponents(l-o,h-d,g-y,b-v).normalize(),t===Dn)i[5].setComponents(l+o,h+d,g+y,b+v).normalize();else if(t===Aa)i[5].setComponents(o,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$i.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),$i.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($i)}intersectsSprite(e){return $i.center.set(0,0,0),$i.radius=.7071067811865476,$i.applyMatrix4(e.matrixWorld),this.intersectsSphere($i)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(pl.x=r.normal.x>0?e.max.x:e.min.x,pl.y=r.normal.y>0?e.max.y:e.min.y,pl.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pl)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};fs=class n extends Xe{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,u=l+1,d=e/o,h=t/l,f=[],m=[],y=[],g=[];for(let p=0;p<u;p++){let x=p*h-a;for(let v=0;v<c;v++){let b=v*d-s;m.push(b,-x,0),y.push(0,0,1),g.push(v/o),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let x=0;x<o;x++){let v=x+c*p,b=x+c*(p+1),L=x+1+c*(p+1),A=x+1+c*p;f.push(v,b,A),f.push(b,L,A)}this.setIndex(f),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(y,3)),this.setAttribute("uv",new Te(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},eM=`#ifdef USE_ALPHAHASH
239
+ `},r=new cr(5,5,5),s=new sn({name:"CubemapFromEquirect",uniforms:ds(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:jt,blending:ti});s.uniforms.tEquirect.value=t;let o=new yt(r,s),a=t.minFilter;return t.minFilter===Ln&&(t.minFilter=bt),new Kl(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},ld=new R,eM=new R,tM=new Ve,Rn=class{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=ld.subVectors(i,t).cross(eM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(ld),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||tM.getNormalMatrix(e),r=this.coplanarPoint(ld).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},$i=new Pt,pl=new R,dr=class{constructor(e=new Rn,t=new Rn,i=new Rn,r=new Rn,s=new Rn,o=new Rn){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Dn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],u=r[5],d=r[6],h=r[7],f=r[8],p=r[9],y=r[10],g=r[11],m=r[12],x=r[13],v=r[14],b=r[15];if(i[0].setComponents(l-s,h-c,g-f,b-m).normalize(),i[1].setComponents(l+s,h+c,g+f,b+m).normalize(),i[2].setComponents(l+o,h+u,g+p,b+x).normalize(),i[3].setComponents(l-o,h-u,g-p,b-x).normalize(),i[4].setComponents(l-a,h-d,g-y,b-v).normalize(),t===Dn)i[5].setComponents(l+a,h+d,g+y,b+v).normalize();else if(t===Eo)i[5].setComponents(a,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$i.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),$i.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($i)}intersectsSprite(e){return $i.center.set(0,0,0),$i.radius=.7071067811865476,$i.applyMatrix4(e.matrixWorld),this.intersectsSphere($i)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(pl.x=r.normal.x>0?e.max.x:e.min.x,pl.y=r.normal.y>0?e.max.y:e.min.y,pl.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pl)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};fs=class n extends Xe{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),l=Math.floor(r),c=a+1,u=l+1,d=e/a,h=t/l,f=[],p=[],y=[],g=[];for(let m=0;m<u;m++){let x=m*h-o;for(let v=0;v<c;v++){let b=v*d-s;p.push(b,-x,0),y.push(0,0,1),g.push(v/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let x=0;x<a;x++){let v=x+c*m,b=x+c*(m+1),L=x+1+c*(m+1),A=x+1+c*m;f.push(v,b,A),f.push(b,L,A)}this.setIndex(f),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(y,3)),this.setAttribute("uv",new Te(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},iM=`#ifdef USE_ALPHAHASH
240
240
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
241
- #endif`,tM=`#ifdef USE_ALPHAHASH
241
+ #endif`,rM=`#ifdef USE_ALPHAHASH
242
242
  const float ALPHA_HASH_SCALE = 0.05;
243
243
  float hash2D( vec2 value ) {
244
244
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -273,20 +273,20 @@ Program Info Log: `+U+`
273
273
  : cases.z;
274
274
  return clamp( threshold , 1.0e-6, 1.0 );
275
275
  }
276
- #endif`,nM=`#ifdef USE_ALPHAMAP
276
+ #endif`,sM=`#ifdef USE_ALPHAMAP
277
277
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
278
- #endif`,iM=`#ifdef USE_ALPHAMAP
278
+ #endif`,oM=`#ifdef USE_ALPHAMAP
279
279
  uniform sampler2D alphaMap;
280
- #endif`,rM=`#ifdef USE_ALPHATEST
280
+ #endif`,aM=`#ifdef USE_ALPHATEST
281
281
  #ifdef ALPHA_TO_COVERAGE
282
282
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
283
283
  if ( diffuseColor.a == 0.0 ) discard;
284
284
  #else
285
285
  if ( diffuseColor.a < alphaTest ) discard;
286
286
  #endif
287
- #endif`,sM=`#ifdef USE_ALPHATEST
287
+ #endif`,lM=`#ifdef USE_ALPHATEST
288
288
  uniform float alphaTest;
289
- #endif`,aM=`#ifdef USE_AOMAP
289
+ #endif`,cM=`#ifdef USE_AOMAP
290
290
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
291
291
  reflectedLight.indirectDiffuse *= ambientOcclusion;
292
292
  #if defined( USE_CLEARCOAT )
@@ -299,10 +299,10 @@ Program Info Log: `+U+`
299
299
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
300
300
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
301
301
  #endif
302
- #endif`,oM=`#ifdef USE_AOMAP
302
+ #endif`,uM=`#ifdef USE_AOMAP
303
303
  uniform sampler2D aoMap;
304
304
  uniform float aoMapIntensity;
305
- #endif`,lM=`#ifdef USE_BATCHING
305
+ #endif`,dM=`#ifdef USE_BATCHING
306
306
  attribute float batchId;
307
307
  uniform highp sampler2D batchingTexture;
308
308
  mat4 getBatchingMatrix( const in float i ) {
@@ -316,15 +316,15 @@ Program Info Log: `+U+`
316
316
  vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
317
317
  return mat4( v1, v2, v3, v4 );
318
318
  }
319
- #endif`,cM=`#ifdef USE_BATCHING
319
+ #endif`,hM=`#ifdef USE_BATCHING
320
320
  mat4 batchingMatrix = getBatchingMatrix( batchId );
321
- #endif`,uM=`vec3 transformed = vec3( position );
321
+ #endif`,fM=`vec3 transformed = vec3( position );
322
322
  #ifdef USE_ALPHAHASH
323
323
  vPosition = vec3( position );
324
- #endif`,dM=`vec3 objectNormal = vec3( normal );
324
+ #endif`,pM=`vec3 objectNormal = vec3( normal );
325
325
  #ifdef USE_TANGENT
326
326
  vec3 objectTangent = vec3( tangent.xyz );
327
- #endif`,hM=`float G_BlinnPhong_Implicit( ) {
327
+ #endif`,mM=`float G_BlinnPhong_Implicit( ) {
328
328
  return 0.25;
329
329
  }
330
330
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -338,7 +338,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
338
338
  float G = G_BlinnPhong_Implicit( );
339
339
  float D = D_BlinnPhong( shininess, dotNH );
340
340
  return F * ( G * D );
341
- } // validated`,fM=`#ifdef USE_IRIDESCENCE
341
+ } // validated`,gM=`#ifdef USE_IRIDESCENCE
342
342
  const mat3 XYZ_TO_REC709 = mat3(
343
343
  3.2404542, -0.9692660, 0.0556434,
344
344
  -1.5371385, 1.8760108, -0.2040259,
@@ -401,7 +401,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
401
401
  }
402
402
  return max( I, vec3( 0.0 ) );
403
403
  }
404
- #endif`,pM=`#ifdef USE_BUMPMAP
404
+ #endif`,yM=`#ifdef USE_BUMPMAP
405
405
  uniform sampler2D bumpMap;
406
406
  uniform float bumpScale;
407
407
  vec2 dHdxy_fwd() {
@@ -422,7 +422,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
422
422
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
423
423
  return normalize( abs( fDet ) * surf_norm - vGrad );
424
424
  }
425
- #endif`,mM=`#if NUM_CLIPPING_PLANES > 0
425
+ #endif`,vM=`#if NUM_CLIPPING_PLANES > 0
426
426
  vec4 plane;
427
427
  #ifdef ALPHA_TO_COVERAGE
428
428
  float distanceToPlane, distanceGradient;
@@ -468,26 +468,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
468
468
  if ( clipped ) discard;
469
469
  #endif
470
470
  #endif
471
- #endif`,gM=`#if NUM_CLIPPING_PLANES > 0
471
+ #endif`,xM=`#if NUM_CLIPPING_PLANES > 0
472
472
  varying vec3 vClipPosition;
473
473
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
474
- #endif`,yM=`#if NUM_CLIPPING_PLANES > 0
474
+ #endif`,_M=`#if NUM_CLIPPING_PLANES > 0
475
475
  varying vec3 vClipPosition;
476
- #endif`,vM=`#if NUM_CLIPPING_PLANES > 0
476
+ #endif`,bM=`#if NUM_CLIPPING_PLANES > 0
477
477
  vClipPosition = - mvPosition.xyz;
478
- #endif`,xM=`#if defined( USE_COLOR_ALPHA )
478
+ #endif`,wM=`#if defined( USE_COLOR_ALPHA )
479
479
  diffuseColor *= vColor;
480
480
  #elif defined( USE_COLOR )
481
481
  diffuseColor.rgb *= vColor;
482
- #endif`,_M=`#if defined( USE_COLOR_ALPHA )
482
+ #endif`,MM=`#if defined( USE_COLOR_ALPHA )
483
483
  varying vec4 vColor;
484
484
  #elif defined( USE_COLOR )
485
485
  varying vec3 vColor;
486
- #endif`,bM=`#if defined( USE_COLOR_ALPHA )
486
+ #endif`,SM=`#if defined( USE_COLOR_ALPHA )
487
487
  varying vec4 vColor;
488
488
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
489
489
  varying vec3 vColor;
490
- #endif`,wM=`#if defined( USE_COLOR_ALPHA )
490
+ #endif`,AM=`#if defined( USE_COLOR_ALPHA )
491
491
  vColor = vec4( 1.0 );
492
492
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
493
493
  vColor = vec3( 1.0 );
@@ -497,7 +497,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
497
497
  #endif
498
498
  #ifdef USE_INSTANCING_COLOR
499
499
  vColor.xyz *= instanceColor.xyz;
500
- #endif`,MM=`#define PI 3.141592653589793
500
+ #endif`,EM=`#define PI 3.141592653589793
501
501
  #define PI2 6.283185307179586
502
502
  #define PI_HALF 1.5707963267948966
503
503
  #define RECIPROCAL_PI 0.3183098861837907
@@ -575,7 +575,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
575
575
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
576
576
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
577
577
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
578
- } // validated`,SM=`#ifdef ENVMAP_TYPE_CUBE_UV
578
+ } // validated`,TM=`#ifdef ENVMAP_TYPE_CUBE_UV
579
579
  #define cubeUV_minMipLevel 4.0
580
580
  #define cubeUV_minTileSize 16.0
581
581
  float getFace( vec3 direction ) {
@@ -668,7 +668,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
668
668
  return vec4( mix( color0, color1, mipF ), 1.0 );
669
669
  }
670
670
  }
671
- #endif`,AM=`vec3 transformedNormal = objectNormal;
671
+ #endif`,IM=`vec3 transformedNormal = objectNormal;
672
672
  #ifdef USE_TANGENT
673
673
  vec3 transformedTangent = objectTangent;
674
674
  #endif
@@ -697,18 +697,18 @@ transformedNormal = normalMatrix * transformedNormal;
697
697
  #ifdef FLIP_SIDED
698
698
  transformedTangent = - transformedTangent;
699
699
  #endif
700
- #endif`,EM=`#ifdef USE_DISPLACEMENTMAP
700
+ #endif`,CM=`#ifdef USE_DISPLACEMENTMAP
701
701
  uniform sampler2D displacementMap;
702
702
  uniform float displacementScale;
703
703
  uniform float displacementBias;
704
- #endif`,TM=`#ifdef USE_DISPLACEMENTMAP
704
+ #endif`,RM=`#ifdef USE_DISPLACEMENTMAP
705
705
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
706
- #endif`,IM=`#ifdef USE_EMISSIVEMAP
706
+ #endif`,PM=`#ifdef USE_EMISSIVEMAP
707
707
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
708
708
  totalEmissiveRadiance *= emissiveColor.rgb;
709
- #endif`,CM=`#ifdef USE_EMISSIVEMAP
709
+ #endif`,LM=`#ifdef USE_EMISSIVEMAP
710
710
  uniform sampler2D emissiveMap;
711
- #endif`,RM="gl_FragColor = linearToOutputTexel( gl_FragColor );",PM=`
711
+ #endif`,DM="gl_FragColor = linearToOutputTexel( gl_FragColor );",OM=`
712
712
  const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
713
713
  vec3( 0.8224621, 0.177538, 0.0 ),
714
714
  vec3( 0.0331941, 0.9668058, 0.0 ),
@@ -736,7 +736,7 @@ vec4 LinearToLinear( in vec4 value ) {
736
736
  }
737
737
  vec4 LinearTosRGB( in vec4 value ) {
738
738
  return sRGBTransferOETF( value );
739
- }`,LM=`#ifdef USE_ENVMAP
739
+ }`,UM=`#ifdef USE_ENVMAP
740
740
  #ifdef ENV_WORLDPOS
741
741
  vec3 cameraToFrag;
742
742
  if ( isOrthographic ) {
@@ -765,7 +765,7 @@ vec4 LinearTosRGB( in vec4 value ) {
765
765
  #elif defined( ENVMAP_BLENDING_ADD )
766
766
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
767
767
  #endif
768
- #endif`,DM=`#ifdef USE_ENVMAP
768
+ #endif`,NM=`#ifdef USE_ENVMAP
769
769
  uniform float envMapIntensity;
770
770
  uniform float flipEnvMap;
771
771
  uniform mat3 envMapRotation;
@@ -775,7 +775,7 @@ vec4 LinearTosRGB( in vec4 value ) {
775
775
  uniform sampler2D envMap;
776
776
  #endif
777
777
 
778
- #endif`,OM=`#ifdef USE_ENVMAP
778
+ #endif`,FM=`#ifdef USE_ENVMAP
779
779
  uniform float reflectivity;
780
780
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
781
781
  #define ENV_WORLDPOS
@@ -786,7 +786,7 @@ vec4 LinearTosRGB( in vec4 value ) {
786
786
  #else
787
787
  varying vec3 vReflect;
788
788
  #endif
789
- #endif`,UM=`#ifdef USE_ENVMAP
789
+ #endif`,kM=`#ifdef USE_ENVMAP
790
790
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
791
791
  #define ENV_WORLDPOS
792
792
  #endif
@@ -797,7 +797,7 @@ vec4 LinearTosRGB( in vec4 value ) {
797
797
  varying vec3 vReflect;
798
798
  uniform float refractionRatio;
799
799
  #endif
800
- #endif`,NM=`#ifdef USE_ENVMAP
800
+ #endif`,BM=`#ifdef USE_ENVMAP
801
801
  #ifdef ENV_WORLDPOS
802
802
  vWorldPosition = worldPosition.xyz;
803
803
  #else
@@ -814,18 +814,18 @@ vec4 LinearTosRGB( in vec4 value ) {
814
814
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
815
815
  #endif
816
816
  #endif
817
- #endif`,FM=`#ifdef USE_FOG
817
+ #endif`,zM=`#ifdef USE_FOG
818
818
  vFogDepth = - mvPosition.z;
819
- #endif`,kM=`#ifdef USE_FOG
819
+ #endif`,VM=`#ifdef USE_FOG
820
820
  varying float vFogDepth;
821
- #endif`,BM=`#ifdef USE_FOG
821
+ #endif`,HM=`#ifdef USE_FOG
822
822
  #ifdef FOG_EXP2
823
823
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
824
824
  #else
825
825
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
826
826
  #endif
827
827
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
828
- #endif`,zM=`#ifdef USE_FOG
828
+ #endif`,GM=`#ifdef USE_FOG
829
829
  uniform vec3 fogColor;
830
830
  varying float vFogDepth;
831
831
  #ifdef FOG_EXP2
@@ -834,7 +834,7 @@ vec4 LinearTosRGB( in vec4 value ) {
834
834
  uniform float fogNear;
835
835
  uniform float fogFar;
836
836
  #endif
837
- #endif`,VM=`#ifdef USE_GRADIENTMAP
837
+ #endif`,$M=`#ifdef USE_GRADIENTMAP
838
838
  uniform sampler2D gradientMap;
839
839
  #endif
840
840
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -846,12 +846,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
846
846
  vec2 fw = fwidth( coord ) * 0.5;
847
847
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
848
848
  #endif
849
- }`,HM=`#ifdef USE_LIGHTMAP
849
+ }`,WM=`#ifdef USE_LIGHTMAP
850
850
  uniform sampler2D lightMap;
851
851
  uniform float lightMapIntensity;
852
- #endif`,GM=`LambertMaterial material;
852
+ #endif`,jM=`LambertMaterial material;
853
853
  material.diffuseColor = diffuseColor.rgb;
854
- material.specularStrength = specularStrength;`,$M=`varying vec3 vViewPosition;
854
+ material.specularStrength = specularStrength;`,XM=`varying vec3 vViewPosition;
855
855
  struct LambertMaterial {
856
856
  vec3 diffuseColor;
857
857
  float specularStrength;
@@ -865,7 +865,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
865
865
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
866
866
  }
867
867
  #define RE_Direct RE_Direct_Lambert
868
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,WM=`uniform bool receiveShadow;
868
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,YM=`uniform bool receiveShadow;
869
869
  uniform vec3 ambientLightColor;
870
870
  #if defined( USE_LIGHT_PROBES )
871
871
  uniform vec3 lightProbe[ 9 ];
@@ -988,7 +988,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
988
988
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
989
989
  return irradiance;
990
990
  }
991
- #endif`,jM=`#ifdef USE_ENVMAP
991
+ #endif`,qM=`#ifdef USE_ENVMAP
992
992
  vec3 getIBLIrradiance( const in vec3 normal ) {
993
993
  #ifdef ENVMAP_TYPE_CUBE_UV
994
994
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -1021,8 +1021,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1021
1021
  #endif
1022
1022
  }
1023
1023
  #endif
1024
- #endif`,XM=`ToonMaterial material;
1025
- material.diffuseColor = diffuseColor.rgb;`,YM=`varying vec3 vViewPosition;
1024
+ #endif`,ZM=`ToonMaterial material;
1025
+ material.diffuseColor = diffuseColor.rgb;`,JM=`varying vec3 vViewPosition;
1026
1026
  struct ToonMaterial {
1027
1027
  vec3 diffuseColor;
1028
1028
  };
@@ -1034,11 +1034,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
1034
1034
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1035
1035
  }
1036
1036
  #define RE_Direct RE_Direct_Toon
1037
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qM=`BlinnPhongMaterial material;
1037
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,KM=`BlinnPhongMaterial material;
1038
1038
  material.diffuseColor = diffuseColor.rgb;
1039
1039
  material.specularColor = specular;
1040
1040
  material.specularShininess = shininess;
1041
- material.specularStrength = specularStrength;`,ZM=`varying vec3 vViewPosition;
1041
+ material.specularStrength = specularStrength;`,QM=`varying vec3 vViewPosition;
1042
1042
  struct BlinnPhongMaterial {
1043
1043
  vec3 diffuseColor;
1044
1044
  vec3 specularColor;
@@ -1055,7 +1055,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
1055
1055
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1056
1056
  }
1057
1057
  #define RE_Direct RE_Direct_BlinnPhong
1058
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,JM=`PhysicalMaterial material;
1058
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,eS=`PhysicalMaterial material;
1059
1059
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
1060
1060
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
1061
1061
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -1141,7 +1141,7 @@ material.roughness = min( material.roughness, 1.0 );
1141
1141
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1142
1142
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1143
1143
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1144
- #endif`,KM=`struct PhysicalMaterial {
1144
+ #endif`,tS=`struct PhysicalMaterial {
1145
1145
  vec3 diffuseColor;
1146
1146
  float roughness;
1147
1147
  vec3 specularColor;
@@ -1442,7 +1442,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1442
1442
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1443
1443
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1444
1444
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1445
- }`,QM=`
1445
+ }`,nS=`
1446
1446
  vec3 geometryPosition = - vViewPosition;
1447
1447
  vec3 geometryNormal = normal;
1448
1448
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1557,7 +1557,7 @@ IncidentLight directLight;
1557
1557
  #if defined( RE_IndirectSpecular )
1558
1558
  vec3 radiance = vec3( 0.0 );
1559
1559
  vec3 clearcoatRadiance = vec3( 0.0 );
1560
- #endif`,eS=`#if defined( RE_IndirectDiffuse )
1560
+ #endif`,iS=`#if defined( RE_IndirectDiffuse )
1561
1561
  #ifdef USE_LIGHTMAP
1562
1562
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1563
1563
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1576,33 +1576,33 @@ IncidentLight directLight;
1576
1576
  #ifdef USE_CLEARCOAT
1577
1577
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1578
1578
  #endif
1579
- #endif`,tS=`#if defined( RE_IndirectDiffuse )
1579
+ #endif`,rS=`#if defined( RE_IndirectDiffuse )
1580
1580
  RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1581
1581
  #endif
1582
1582
  #if defined( RE_IndirectSpecular )
1583
1583
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1584
- #endif`,nS=`#if defined( USE_LOGDEPTHBUF )
1584
+ #endif`,sS=`#if defined( USE_LOGDEPTHBUF )
1585
1585
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1586
- #endif`,iS=`#if defined( USE_LOGDEPTHBUF )
1586
+ #endif`,oS=`#if defined( USE_LOGDEPTHBUF )
1587
1587
  uniform float logDepthBufFC;
1588
1588
  varying float vFragDepth;
1589
1589
  varying float vIsPerspective;
1590
- #endif`,rS=`#ifdef USE_LOGDEPTHBUF
1590
+ #endif`,aS=`#ifdef USE_LOGDEPTHBUF
1591
1591
  varying float vFragDepth;
1592
1592
  varying float vIsPerspective;
1593
- #endif`,sS=`#ifdef USE_LOGDEPTHBUF
1593
+ #endif`,lS=`#ifdef USE_LOGDEPTHBUF
1594
1594
  vFragDepth = 1.0 + gl_Position.w;
1595
1595
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1596
- #endif`,aS=`#ifdef USE_MAP
1596
+ #endif`,cS=`#ifdef USE_MAP
1597
1597
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1598
1598
  #ifdef DECODE_VIDEO_TEXTURE
1599
1599
  sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
1600
1600
 
1601
1601
  #endif
1602
1602
  diffuseColor *= sampledDiffuseColor;
1603
- #endif`,oS=`#ifdef USE_MAP
1603
+ #endif`,uS=`#ifdef USE_MAP
1604
1604
  uniform sampler2D map;
1605
- #endif`,lS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1605
+ #endif`,dS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1606
1606
  #if defined( USE_POINTS_UV )
1607
1607
  vec2 uv = vUv;
1608
1608
  #else
@@ -1614,7 +1614,7 @@ IncidentLight directLight;
1614
1614
  #endif
1615
1615
  #ifdef USE_ALPHAMAP
1616
1616
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1617
- #endif`,cS=`#if defined( USE_POINTS_UV )
1617
+ #endif`,hS=`#if defined( USE_POINTS_UV )
1618
1618
  varying vec2 vUv;
1619
1619
  #else
1620
1620
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1626,19 +1626,19 @@ IncidentLight directLight;
1626
1626
  #endif
1627
1627
  #ifdef USE_ALPHAMAP
1628
1628
  uniform sampler2D alphaMap;
1629
- #endif`,uS=`float metalnessFactor = metalness;
1629
+ #endif`,fS=`float metalnessFactor = metalness;
1630
1630
  #ifdef USE_METALNESSMAP
1631
1631
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1632
1632
  metalnessFactor *= texelMetalness.b;
1633
- #endif`,dS=`#ifdef USE_METALNESSMAP
1633
+ #endif`,pS=`#ifdef USE_METALNESSMAP
1634
1634
  uniform sampler2D metalnessMap;
1635
- #endif`,hS=`#ifdef USE_INSTANCING_MORPH
1635
+ #endif`,mS=`#ifdef USE_INSTANCING_MORPH
1636
1636
  float morphTargetInfluences[MORPHTARGETS_COUNT];
1637
1637
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1638
1638
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1639
1639
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1640
1640
  }
1641
- #endif`,fS=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1641
+ #endif`,gS=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1642
1642
  vColor *= morphTargetBaseInfluence;
1643
1643
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1644
1644
  #if defined( USE_COLOR_ALPHA )
@@ -1647,7 +1647,7 @@ IncidentLight directLight;
1647
1647
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1648
1648
  #endif
1649
1649
  }
1650
- #endif`,pS=`#ifdef USE_MORPHNORMALS
1650
+ #endif`,yS=`#ifdef USE_MORPHNORMALS
1651
1651
  objectNormal *= morphTargetBaseInfluence;
1652
1652
  #ifdef MORPHTARGETS_TEXTURE
1653
1653
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1659,7 +1659,7 @@ IncidentLight directLight;
1659
1659
  objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
1660
1660
  objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
1661
1661
  #endif
1662
- #endif`,mS=`#ifdef USE_MORPHTARGETS
1662
+ #endif`,vS=`#ifdef USE_MORPHTARGETS
1663
1663
  #ifndef USE_INSTANCING_MORPH
1664
1664
  uniform float morphTargetBaseInfluence;
1665
1665
  #endif
@@ -1683,7 +1683,7 @@ IncidentLight directLight;
1683
1683
  uniform float morphTargetInfluences[ 4 ];
1684
1684
  #endif
1685
1685
  #endif
1686
- #endif`,gS=`#ifdef USE_MORPHTARGETS
1686
+ #endif`,xS=`#ifdef USE_MORPHTARGETS
1687
1687
  transformed *= morphTargetBaseInfluence;
1688
1688
  #ifdef MORPHTARGETS_TEXTURE
1689
1689
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1701,7 +1701,7 @@ IncidentLight directLight;
1701
1701
  transformed += morphTarget7 * morphTargetInfluences[ 7 ];
1702
1702
  #endif
1703
1703
  #endif
1704
- #endif`,yS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1704
+ #endif`,_S=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1705
1705
  #ifdef FLAT_SHADED
1706
1706
  vec3 fdx = dFdx( vViewPosition );
1707
1707
  vec3 fdy = dFdy( vViewPosition );
@@ -1742,7 +1742,7 @@ IncidentLight directLight;
1742
1742
  tbn2[1] *= faceDirection;
1743
1743
  #endif
1744
1744
  #endif
1745
- vec3 nonPerturbedNormal = normal;`,vS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1745
+ vec3 nonPerturbedNormal = normal;`,bS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1746
1746
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1747
1747
  #ifdef FLIP_SIDED
1748
1748
  normal = - normal;
@@ -1757,25 +1757,25 @@ vec3 nonPerturbedNormal = normal;`,vS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1757
1757
  normal = normalize( tbn * mapN );
1758
1758
  #elif defined( USE_BUMPMAP )
1759
1759
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1760
- #endif`,xS=`#ifndef FLAT_SHADED
1760
+ #endif`,wS=`#ifndef FLAT_SHADED
1761
1761
  varying vec3 vNormal;
1762
1762
  #ifdef USE_TANGENT
1763
1763
  varying vec3 vTangent;
1764
1764
  varying vec3 vBitangent;
1765
1765
  #endif
1766
- #endif`,_S=`#ifndef FLAT_SHADED
1766
+ #endif`,MS=`#ifndef FLAT_SHADED
1767
1767
  varying vec3 vNormal;
1768
1768
  #ifdef USE_TANGENT
1769
1769
  varying vec3 vTangent;
1770
1770
  varying vec3 vBitangent;
1771
1771
  #endif
1772
- #endif`,bS=`#ifndef FLAT_SHADED
1772
+ #endif`,SS=`#ifndef FLAT_SHADED
1773
1773
  vNormal = normalize( transformedNormal );
1774
1774
  #ifdef USE_TANGENT
1775
1775
  vTangent = normalize( transformedTangent );
1776
1776
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1777
1777
  #endif
1778
- #endif`,wS=`#ifdef USE_NORMALMAP
1778
+ #endif`,AS=`#ifdef USE_NORMALMAP
1779
1779
  uniform sampler2D normalMap;
1780
1780
  uniform vec2 normalScale;
1781
1781
  #endif
@@ -1797,13 +1797,13 @@ vec3 nonPerturbedNormal = normal;`,vS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1797
1797
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1798
1798
  return mat3( T * scale, B * scale, N );
1799
1799
  }
1800
- #endif`,MS=`#ifdef USE_CLEARCOAT
1800
+ #endif`,ES=`#ifdef USE_CLEARCOAT
1801
1801
  vec3 clearcoatNormal = nonPerturbedNormal;
1802
- #endif`,SS=`#ifdef USE_CLEARCOAT_NORMALMAP
1802
+ #endif`,TS=`#ifdef USE_CLEARCOAT_NORMALMAP
1803
1803
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1804
1804
  clearcoatMapN.xy *= clearcoatNormalScale;
1805
1805
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1806
- #endif`,AS=`#ifdef USE_CLEARCOATMAP
1806
+ #endif`,IS=`#ifdef USE_CLEARCOATMAP
1807
1807
  uniform sampler2D clearcoatMap;
1808
1808
  #endif
1809
1809
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1812,18 +1812,18 @@ vec3 nonPerturbedNormal = normal;`,vS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1812
1812
  #endif
1813
1813
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1814
1814
  uniform sampler2D clearcoatRoughnessMap;
1815
- #endif`,ES=`#ifdef USE_IRIDESCENCEMAP
1815
+ #endif`,CS=`#ifdef USE_IRIDESCENCEMAP
1816
1816
  uniform sampler2D iridescenceMap;
1817
1817
  #endif
1818
1818
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1819
1819
  uniform sampler2D iridescenceThicknessMap;
1820
- #endif`,TS=`#ifdef OPAQUE
1820
+ #endif`,RS=`#ifdef OPAQUE
1821
1821
  diffuseColor.a = 1.0;
1822
1822
  #endif
1823
1823
  #ifdef USE_TRANSMISSION
1824
1824
  diffuseColor.a *= material.transmissionAlpha;
1825
1825
  #endif
1826
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,IS=`vec3 packNormalToRGB( const in vec3 normal ) {
1826
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,PS=`vec3 packNormalToRGB( const in vec3 normal ) {
1827
1827
  return normalize( normal ) * 0.5 + 0.5;
1828
1828
  }
1829
1829
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1864,9 +1864,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1864
1864
  }
1865
1865
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1866
1866
  return ( near * far ) / ( ( far - near ) * depth - far );
1867
- }`,CS=`#ifdef PREMULTIPLIED_ALPHA
1867
+ }`,LS=`#ifdef PREMULTIPLIED_ALPHA
1868
1868
  gl_FragColor.rgb *= gl_FragColor.a;
1869
- #endif`,RS=`vec4 mvPosition = vec4( transformed, 1.0 );
1869
+ #endif`,DS=`vec4 mvPosition = vec4( transformed, 1.0 );
1870
1870
  #ifdef USE_BATCHING
1871
1871
  mvPosition = batchingMatrix * mvPosition;
1872
1872
  #endif
@@ -1874,22 +1874,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1874
1874
  mvPosition = instanceMatrix * mvPosition;
1875
1875
  #endif
1876
1876
  mvPosition = modelViewMatrix * mvPosition;
1877
- gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
1877
+ gl_Position = projectionMatrix * mvPosition;`,OS=`#ifdef DITHERING
1878
1878
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1879
- #endif`,LS=`#ifdef DITHERING
1879
+ #endif`,US=`#ifdef DITHERING
1880
1880
  vec3 dithering( vec3 color ) {
1881
1881
  float grid_position = rand( gl_FragCoord.xy );
1882
1882
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1883
1883
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1884
1884
  return color + dither_shift_RGB;
1885
1885
  }
1886
- #endif`,DS=`float roughnessFactor = roughness;
1886
+ #endif`,NS=`float roughnessFactor = roughness;
1887
1887
  #ifdef USE_ROUGHNESSMAP
1888
1888
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1889
1889
  roughnessFactor *= texelRoughness.g;
1890
- #endif`,OS=`#ifdef USE_ROUGHNESSMAP
1890
+ #endif`,FS=`#ifdef USE_ROUGHNESSMAP
1891
1891
  uniform sampler2D roughnessMap;
1892
- #endif`,US=`#if NUM_SPOT_LIGHT_COORDS > 0
1892
+ #endif`,kS=`#if NUM_SPOT_LIGHT_COORDS > 0
1893
1893
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1894
1894
  #endif
1895
1895
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2072,7 +2072,7 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2072
2072
  }
2073
2073
  return shadow;
2074
2074
  }
2075
- #endif`,NS=`#if NUM_SPOT_LIGHT_COORDS > 0
2075
+ #endif`,BS=`#if NUM_SPOT_LIGHT_COORDS > 0
2076
2076
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2077
2077
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2078
2078
  #endif
@@ -2110,7 +2110,7 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2110
2110
  };
2111
2111
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2112
2112
  #endif
2113
- #endif`,FS=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2113
+ #endif`,zS=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2114
2114
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
2115
2115
  vec4 shadowWorldPosition;
2116
2116
  #endif
@@ -2142,7 +2142,7 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2142
2142
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2143
2143
  }
2144
2144
  #pragma unroll_loop_end
2145
- #endif`,kS=`float getShadowMask() {
2145
+ #endif`,VS=`float getShadowMask() {
2146
2146
  float shadow = 1.0;
2147
2147
  #ifdef USE_SHADOWMAP
2148
2148
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2174,12 +2174,12 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2174
2174
  #endif
2175
2175
  #endif
2176
2176
  return shadow;
2177
- }`,BS=`#ifdef USE_SKINNING
2177
+ }`,HS=`#ifdef USE_SKINNING
2178
2178
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2179
2179
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2180
2180
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2181
2181
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2182
- #endif`,zS=`#ifdef USE_SKINNING
2182
+ #endif`,GS=`#ifdef USE_SKINNING
2183
2183
  uniform mat4 bindMatrix;
2184
2184
  uniform mat4 bindMatrixInverse;
2185
2185
  uniform highp sampler2D boneTexture;
@@ -2194,7 +2194,7 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2194
2194
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2195
2195
  return mat4( v1, v2, v3, v4 );
2196
2196
  }
2197
- #endif`,VS=`#ifdef USE_SKINNING
2197
+ #endif`,$S=`#ifdef USE_SKINNING
2198
2198
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2199
2199
  vec4 skinned = vec4( 0.0 );
2200
2200
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2202,7 +2202,7 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2202
2202
  skinned += boneMatZ * skinVertex * skinWeight.z;
2203
2203
  skinned += boneMatW * skinVertex * skinWeight.w;
2204
2204
  transformed = ( bindMatrixInverse * skinned ).xyz;
2205
- #endif`,HS=`#ifdef USE_SKINNING
2205
+ #endif`,WS=`#ifdef USE_SKINNING
2206
2206
  mat4 skinMatrix = mat4( 0.0 );
2207
2207
  skinMatrix += skinWeight.x * boneMatX;
2208
2208
  skinMatrix += skinWeight.y * boneMatY;
@@ -2213,17 +2213,17 @@ gl_Position = projectionMatrix * mvPosition;`,PS=`#ifdef DITHERING
2213
2213
  #ifdef USE_TANGENT
2214
2214
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2215
2215
  #endif
2216
- #endif`,GS=`float specularStrength;
2216
+ #endif`,jS=`float specularStrength;
2217
2217
  #ifdef USE_SPECULARMAP
2218
2218
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2219
2219
  specularStrength = texelSpecular.r;
2220
2220
  #else
2221
2221
  specularStrength = 1.0;
2222
- #endif`,$S=`#ifdef USE_SPECULARMAP
2222
+ #endif`,XS=`#ifdef USE_SPECULARMAP
2223
2223
  uniform sampler2D specularMap;
2224
- #endif`,WS=`#if defined( TONE_MAPPING )
2224
+ #endif`,YS=`#if defined( TONE_MAPPING )
2225
2225
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2226
- #endif`,jS=`#ifndef saturate
2226
+ #endif`,qS=`#ifndef saturate
2227
2227
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2228
2228
  #endif
2229
2229
  uniform float toneMappingExposure;
@@ -2320,7 +2320,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2320
2320
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2321
2321
  return mix( color, vec3( newPeak ), g );
2322
2322
  }
2323
- vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISSION
2323
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,ZS=`#ifdef USE_TRANSMISSION
2324
2324
  material.transmission = transmission;
2325
2325
  material.transmissionAlpha = 1.0;
2326
2326
  material.thickness = thickness;
@@ -2341,7 +2341,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2341
2341
  material.attenuationColor, material.attenuationDistance );
2342
2342
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2343
2343
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2344
- #endif`,YS=`#ifdef USE_TRANSMISSION
2344
+ #endif`,JS=`#ifdef USE_TRANSMISSION
2345
2345
  uniform float transmission;
2346
2346
  uniform float thickness;
2347
2347
  uniform float attenuationDistance;
@@ -2472,7 +2472,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2472
2472
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2473
2473
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2474
2474
  }
2475
- #endif`,qS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2475
+ #endif`,KS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2476
2476
  varying vec2 vUv;
2477
2477
  #endif
2478
2478
  #ifdef USE_MAP
@@ -2542,7 +2542,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2542
2542
  #ifdef USE_THICKNESSMAP
2543
2543
  uniform mat3 thicknessMapTransform;
2544
2544
  varying vec2 vThicknessMapUv;
2545
- #endif`,ZS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2545
+ #endif`,QS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2546
2546
  varying vec2 vUv;
2547
2547
  #endif
2548
2548
  #ifdef USE_MAP
@@ -2636,7 +2636,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2636
2636
  #ifdef USE_THICKNESSMAP
2637
2637
  uniform mat3 thicknessMapTransform;
2638
2638
  varying vec2 vThicknessMapUv;
2639
- #endif`,JS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2639
+ #endif`,e1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2640
2640
  vUv = vec3( uv, 1 ).xy;
2641
2641
  #endif
2642
2642
  #ifdef USE_MAP
@@ -2707,7 +2707,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2707
2707
  #endif
2708
2708
  #ifdef USE_THICKNESSMAP
2709
2709
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2710
- #endif`,KS=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2710
+ #endif`,t1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2711
2711
  vec4 worldPosition = vec4( transformed, 1.0 );
2712
2712
  #ifdef USE_BATCHING
2713
2713
  worldPosition = batchingMatrix * worldPosition;
@@ -2716,12 +2716,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,XS=`#ifdef USE_TRANSMISS
2716
2716
  worldPosition = instanceMatrix * worldPosition;
2717
2717
  #endif
2718
2718
  worldPosition = modelMatrix * worldPosition;
2719
- #endif`,QS=`varying vec2 vUv;
2719
+ #endif`,n1=`varying vec2 vUv;
2720
2720
  uniform mat3 uvTransform;
2721
2721
  void main() {
2722
2722
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2723
2723
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2724
- }`,e1=`uniform sampler2D t2D;
2724
+ }`,i1=`uniform sampler2D t2D;
2725
2725
  uniform float backgroundIntensity;
2726
2726
  varying vec2 vUv;
2727
2727
  void main() {
@@ -2733,14 +2733,14 @@ void main() {
2733
2733
  gl_FragColor = texColor;
2734
2734
  #include <tonemapping_fragment>
2735
2735
  #include <colorspace_fragment>
2736
- }`,t1=`varying vec3 vWorldDirection;
2736
+ }`,r1=`varying vec3 vWorldDirection;
2737
2737
  #include <common>
2738
2738
  void main() {
2739
2739
  vWorldDirection = transformDirection( position, modelMatrix );
2740
2740
  #include <begin_vertex>
2741
2741
  #include <project_vertex>
2742
2742
  gl_Position.z = gl_Position.w;
2743
- }`,n1=`#ifdef ENVMAP_TYPE_CUBE
2743
+ }`,s1=`#ifdef ENVMAP_TYPE_CUBE
2744
2744
  uniform samplerCube envMap;
2745
2745
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2746
2746
  uniform sampler2D envMap;
@@ -2763,14 +2763,14 @@ void main() {
2763
2763
  gl_FragColor = texColor;
2764
2764
  #include <tonemapping_fragment>
2765
2765
  #include <colorspace_fragment>
2766
- }`,i1=`varying vec3 vWorldDirection;
2766
+ }`,o1=`varying vec3 vWorldDirection;
2767
2767
  #include <common>
2768
2768
  void main() {
2769
2769
  vWorldDirection = transformDirection( position, modelMatrix );
2770
2770
  #include <begin_vertex>
2771
2771
  #include <project_vertex>
2772
2772
  gl_Position.z = gl_Position.w;
2773
- }`,r1=`uniform samplerCube tCube;
2773
+ }`,a1=`uniform samplerCube tCube;
2774
2774
  uniform float tFlip;
2775
2775
  uniform float opacity;
2776
2776
  varying vec3 vWorldDirection;
@@ -2780,7 +2780,7 @@ void main() {
2780
2780
  gl_FragColor.a *= opacity;
2781
2781
  #include <tonemapping_fragment>
2782
2782
  #include <colorspace_fragment>
2783
- }`,s1=`#include <common>
2783
+ }`,l1=`#include <common>
2784
2784
  #include <batching_pars_vertex>
2785
2785
  #include <uv_pars_vertex>
2786
2786
  #include <displacementmap_pars_vertex>
@@ -2807,7 +2807,7 @@ void main() {
2807
2807
  #include <logdepthbuf_vertex>
2808
2808
  #include <clipping_planes_vertex>
2809
2809
  vHighPrecisionZW = gl_Position.zw;
2810
- }`,a1=`#if DEPTH_PACKING == 3200
2810
+ }`,c1=`#if DEPTH_PACKING == 3200
2811
2811
  uniform float opacity;
2812
2812
  #endif
2813
2813
  #include <common>
@@ -2837,7 +2837,7 @@ void main() {
2837
2837
  #elif DEPTH_PACKING == 3201
2838
2838
  gl_FragColor = packDepthToRGBA( fragCoordZ );
2839
2839
  #endif
2840
- }`,o1=`#define DISTANCE
2840
+ }`,u1=`#define DISTANCE
2841
2841
  varying vec3 vWorldPosition;
2842
2842
  #include <common>
2843
2843
  #include <batching_pars_vertex>
@@ -2864,7 +2864,7 @@ void main() {
2864
2864
  #include <worldpos_vertex>
2865
2865
  #include <clipping_planes_vertex>
2866
2866
  vWorldPosition = worldPosition.xyz;
2867
- }`,l1=`#define DISTANCE
2867
+ }`,d1=`#define DISTANCE
2868
2868
  uniform vec3 referencePosition;
2869
2869
  uniform float nearDistance;
2870
2870
  uniform float farDistance;
@@ -2888,13 +2888,13 @@ void main () {
2888
2888
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2889
2889
  dist = saturate( dist );
2890
2890
  gl_FragColor = packDepthToRGBA( dist );
2891
- }`,c1=`varying vec3 vWorldDirection;
2891
+ }`,h1=`varying vec3 vWorldDirection;
2892
2892
  #include <common>
2893
2893
  void main() {
2894
2894
  vWorldDirection = transformDirection( position, modelMatrix );
2895
2895
  #include <begin_vertex>
2896
2896
  #include <project_vertex>
2897
- }`,u1=`uniform sampler2D tEquirect;
2897
+ }`,f1=`uniform sampler2D tEquirect;
2898
2898
  varying vec3 vWorldDirection;
2899
2899
  #include <common>
2900
2900
  void main() {
@@ -2903,7 +2903,7 @@ void main() {
2903
2903
  gl_FragColor = texture2D( tEquirect, sampleUV );
2904
2904
  #include <tonemapping_fragment>
2905
2905
  #include <colorspace_fragment>
2906
- }`,d1=`uniform float scale;
2906
+ }`,p1=`uniform float scale;
2907
2907
  attribute float lineDistance;
2908
2908
  varying float vLineDistance;
2909
2909
  #include <common>
@@ -2925,7 +2925,7 @@ void main() {
2925
2925
  #include <logdepthbuf_vertex>
2926
2926
  #include <clipping_planes_vertex>
2927
2927
  #include <fog_vertex>
2928
- }`,h1=`uniform vec3 diffuse;
2928
+ }`,m1=`uniform vec3 diffuse;
2929
2929
  uniform float opacity;
2930
2930
  uniform float dashSize;
2931
2931
  uniform float totalSize;
@@ -2953,7 +2953,7 @@ void main() {
2953
2953
  #include <colorspace_fragment>
2954
2954
  #include <fog_fragment>
2955
2955
  #include <premultiplied_alpha_fragment>
2956
- }`,f1=`#include <common>
2956
+ }`,g1=`#include <common>
2957
2957
  #include <batching_pars_vertex>
2958
2958
  #include <uv_pars_vertex>
2959
2959
  #include <envmap_pars_vertex>
@@ -2985,7 +2985,7 @@ void main() {
2985
2985
  #include <worldpos_vertex>
2986
2986
  #include <envmap_vertex>
2987
2987
  #include <fog_vertex>
2988
- }`,p1=`uniform vec3 diffuse;
2988
+ }`,y1=`uniform vec3 diffuse;
2989
2989
  uniform float opacity;
2990
2990
  #ifndef FLAT_SHADED
2991
2991
  varying vec3 vNormal;
@@ -3033,7 +3033,7 @@ void main() {
3033
3033
  #include <fog_fragment>
3034
3034
  #include <premultiplied_alpha_fragment>
3035
3035
  #include <dithering_fragment>
3036
- }`,m1=`#define LAMBERT
3036
+ }`,v1=`#define LAMBERT
3037
3037
  varying vec3 vViewPosition;
3038
3038
  #include <common>
3039
3039
  #include <batching_pars_vertex>
@@ -3072,7 +3072,7 @@ void main() {
3072
3072
  #include <envmap_vertex>
3073
3073
  #include <shadowmap_vertex>
3074
3074
  #include <fog_vertex>
3075
- }`,g1=`#define LAMBERT
3075
+ }`,x1=`#define LAMBERT
3076
3076
  uniform vec3 diffuse;
3077
3077
  uniform vec3 emissive;
3078
3078
  uniform float opacity;
@@ -3129,7 +3129,7 @@ void main() {
3129
3129
  #include <fog_fragment>
3130
3130
  #include <premultiplied_alpha_fragment>
3131
3131
  #include <dithering_fragment>
3132
- }`,y1=`#define MATCAP
3132
+ }`,_1=`#define MATCAP
3133
3133
  varying vec3 vViewPosition;
3134
3134
  #include <common>
3135
3135
  #include <batching_pars_vertex>
@@ -3163,7 +3163,7 @@ void main() {
3163
3163
  #include <clipping_planes_vertex>
3164
3164
  #include <fog_vertex>
3165
3165
  vViewPosition = - mvPosition.xyz;
3166
- }`,v1=`#define MATCAP
3166
+ }`,b1=`#define MATCAP
3167
3167
  uniform vec3 diffuse;
3168
3168
  uniform float opacity;
3169
3169
  uniform sampler2D matcap;
@@ -3209,7 +3209,7 @@ void main() {
3209
3209
  #include <fog_fragment>
3210
3210
  #include <premultiplied_alpha_fragment>
3211
3211
  #include <dithering_fragment>
3212
- }`,x1=`#define NORMAL
3212
+ }`,w1=`#define NORMAL
3213
3213
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3214
3214
  varying vec3 vViewPosition;
3215
3215
  #endif
@@ -3242,7 +3242,7 @@ void main() {
3242
3242
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3243
3243
  vViewPosition = - mvPosition.xyz;
3244
3244
  #endif
3245
- }`,_1=`#define NORMAL
3245
+ }`,M1=`#define NORMAL
3246
3246
  uniform float opacity;
3247
3247
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3248
3248
  varying vec3 vViewPosition;
@@ -3264,7 +3264,7 @@ void main() {
3264
3264
  #ifdef OPAQUE
3265
3265
  gl_FragColor.a = 1.0;
3266
3266
  #endif
3267
- }`,b1=`#define PHONG
3267
+ }`,S1=`#define PHONG
3268
3268
  varying vec3 vViewPosition;
3269
3269
  #include <common>
3270
3270
  #include <batching_pars_vertex>
@@ -3303,7 +3303,7 @@ void main() {
3303
3303
  #include <envmap_vertex>
3304
3304
  #include <shadowmap_vertex>
3305
3305
  #include <fog_vertex>
3306
- }`,w1=`#define PHONG
3306
+ }`,A1=`#define PHONG
3307
3307
  uniform vec3 diffuse;
3308
3308
  uniform vec3 emissive;
3309
3309
  uniform vec3 specular;
@@ -3362,7 +3362,7 @@ void main() {
3362
3362
  #include <fog_fragment>
3363
3363
  #include <premultiplied_alpha_fragment>
3364
3364
  #include <dithering_fragment>
3365
- }`,M1=`#define STANDARD
3365
+ }`,E1=`#define STANDARD
3366
3366
  varying vec3 vViewPosition;
3367
3367
  #ifdef USE_TRANSMISSION
3368
3368
  varying vec3 vWorldPosition;
@@ -3405,7 +3405,7 @@ void main() {
3405
3405
  #ifdef USE_TRANSMISSION
3406
3406
  vWorldPosition = worldPosition.xyz;
3407
3407
  #endif
3408
- }`,S1=`#define STANDARD
3408
+ }`,T1=`#define STANDARD
3409
3409
  #ifdef PHYSICAL
3410
3410
  #define IOR
3411
3411
  #define USE_SPECULAR
@@ -3530,7 +3530,7 @@ void main() {
3530
3530
  #include <fog_fragment>
3531
3531
  #include <premultiplied_alpha_fragment>
3532
3532
  #include <dithering_fragment>
3533
- }`,A1=`#define TOON
3533
+ }`,I1=`#define TOON
3534
3534
  varying vec3 vViewPosition;
3535
3535
  #include <common>
3536
3536
  #include <batching_pars_vertex>
@@ -3567,7 +3567,7 @@ void main() {
3567
3567
  #include <worldpos_vertex>
3568
3568
  #include <shadowmap_vertex>
3569
3569
  #include <fog_vertex>
3570
- }`,E1=`#define TOON
3570
+ }`,C1=`#define TOON
3571
3571
  uniform vec3 diffuse;
3572
3572
  uniform vec3 emissive;
3573
3573
  uniform float opacity;
@@ -3620,7 +3620,7 @@ void main() {
3620
3620
  #include <fog_fragment>
3621
3621
  #include <premultiplied_alpha_fragment>
3622
3622
  #include <dithering_fragment>
3623
- }`,T1=`uniform float size;
3623
+ }`,R1=`uniform float size;
3624
3624
  uniform float scale;
3625
3625
  #include <common>
3626
3626
  #include <color_pars_vertex>
@@ -3651,7 +3651,7 @@ void main() {
3651
3651
  #include <clipping_planes_vertex>
3652
3652
  #include <worldpos_vertex>
3653
3653
  #include <fog_vertex>
3654
- }`,I1=`uniform vec3 diffuse;
3654
+ }`,P1=`uniform vec3 diffuse;
3655
3655
  uniform float opacity;
3656
3656
  #include <common>
3657
3657
  #include <color_pars_fragment>
@@ -3676,7 +3676,7 @@ void main() {
3676
3676
  #include <colorspace_fragment>
3677
3677
  #include <fog_fragment>
3678
3678
  #include <premultiplied_alpha_fragment>
3679
- }`,C1=`#include <common>
3679
+ }`,L1=`#include <common>
3680
3680
  #include <batching_pars_vertex>
3681
3681
  #include <fog_pars_vertex>
3682
3682
  #include <morphtarget_pars_vertex>
@@ -3699,7 +3699,7 @@ void main() {
3699
3699
  #include <worldpos_vertex>
3700
3700
  #include <shadowmap_vertex>
3701
3701
  #include <fog_vertex>
3702
- }`,R1=`uniform vec3 color;
3702
+ }`,D1=`uniform vec3 color;
3703
3703
  uniform float opacity;
3704
3704
  #include <common>
3705
3705
  #include <packing>
@@ -3715,7 +3715,7 @@ void main() {
3715
3715
  #include <tonemapping_fragment>
3716
3716
  #include <colorspace_fragment>
3717
3717
  #include <fog_fragment>
3718
- }`,P1=`uniform float rotation;
3718
+ }`,O1=`uniform float rotation;
3719
3719
  uniform vec2 center;
3720
3720
  #include <common>
3721
3721
  #include <uv_pars_vertex>
@@ -3741,7 +3741,7 @@ void main() {
3741
3741
  #include <logdepthbuf_vertex>
3742
3742
  #include <clipping_planes_vertex>
3743
3743
  #include <fog_vertex>
3744
- }`,L1=`uniform vec3 diffuse;
3744
+ }`,U1=`uniform vec3 diffuse;
3745
3745
  uniform float opacity;
3746
3746
  #include <common>
3747
3747
  #include <uv_pars_fragment>
@@ -3766,9 +3766,9 @@ void main() {
3766
3766
  #include <tonemapping_fragment>
3767
3767
  #include <colorspace_fragment>
3768
3768
  #include <fog_fragment>
3769
- }`,$e={alphahash_fragment:eM,alphahash_pars_fragment:tM,alphamap_fragment:nM,alphamap_pars_fragment:iM,alphatest_fragment:rM,alphatest_pars_fragment:sM,aomap_fragment:aM,aomap_pars_fragment:oM,batching_pars_vertex:lM,batching_vertex:cM,begin_vertex:uM,beginnormal_vertex:dM,bsdfs:hM,iridescence_fragment:fM,bumpmap_pars_fragment:pM,clipping_planes_fragment:mM,clipping_planes_pars_fragment:gM,clipping_planes_pars_vertex:yM,clipping_planes_vertex:vM,color_fragment:xM,color_pars_fragment:_M,color_pars_vertex:bM,color_vertex:wM,common:MM,cube_uv_reflection_fragment:SM,defaultnormal_vertex:AM,displacementmap_pars_vertex:EM,displacementmap_vertex:TM,emissivemap_fragment:IM,emissivemap_pars_fragment:CM,colorspace_fragment:RM,colorspace_pars_fragment:PM,envmap_fragment:LM,envmap_common_pars_fragment:DM,envmap_pars_fragment:OM,envmap_pars_vertex:UM,envmap_physical_pars_fragment:jM,envmap_vertex:NM,fog_vertex:FM,fog_pars_vertex:kM,fog_fragment:BM,fog_pars_fragment:zM,gradientmap_pars_fragment:VM,lightmap_pars_fragment:HM,lights_lambert_fragment:GM,lights_lambert_pars_fragment:$M,lights_pars_begin:WM,lights_toon_fragment:XM,lights_toon_pars_fragment:YM,lights_phong_fragment:qM,lights_phong_pars_fragment:ZM,lights_physical_fragment:JM,lights_physical_pars_fragment:KM,lights_fragment_begin:QM,lights_fragment_maps:eS,lights_fragment_end:tS,logdepthbuf_fragment:nS,logdepthbuf_pars_fragment:iS,logdepthbuf_pars_vertex:rS,logdepthbuf_vertex:sS,map_fragment:aS,map_pars_fragment:oS,map_particle_fragment:lS,map_particle_pars_fragment:cS,metalnessmap_fragment:uS,metalnessmap_pars_fragment:dS,morphinstance_vertex:hS,morphcolor_vertex:fS,morphnormal_vertex:pS,morphtarget_pars_vertex:mS,morphtarget_vertex:gS,normal_fragment_begin:yS,normal_fragment_maps:vS,normal_pars_fragment:xS,normal_pars_vertex:_S,normal_vertex:bS,normalmap_pars_fragment:wS,clearcoat_normal_fragment_begin:MS,clearcoat_normal_fragment_maps:SS,clearcoat_pars_fragment:AS,iridescence_pars_fragment:ES,opaque_fragment:TS,packing:IS,premultiplied_alpha_fragment:CS,project_vertex:RS,dithering_fragment:PS,dithering_pars_fragment:LS,roughnessmap_fragment:DS,roughnessmap_pars_fragment:OS,shadowmap_pars_fragment:US,shadowmap_pars_vertex:NS,shadowmap_vertex:FS,shadowmask_pars_fragment:kS,skinbase_vertex:BS,skinning_pars_vertex:zS,skinning_vertex:VS,skinnormal_vertex:HS,specularmap_fragment:GS,specularmap_pars_fragment:$S,tonemapping_fragment:WS,tonemapping_pars_fragment:jS,transmission_fragment:XS,transmission_pars_fragment:YS,uv_pars_fragment:qS,uv_pars_vertex:ZS,uv_vertex:JS,worldpos_vertex:KS,background_vert:QS,background_frag:e1,backgroundCube_vert:t1,backgroundCube_frag:n1,cube_vert:i1,cube_frag:r1,depth_vert:s1,depth_frag:a1,distanceRGBA_vert:o1,distanceRGBA_frag:l1,equirect_vert:c1,equirect_frag:u1,linedashed_vert:d1,linedashed_frag:h1,meshbasic_vert:f1,meshbasic_frag:p1,meshlambert_vert:m1,meshlambert_frag:g1,meshmatcap_vert:y1,meshmatcap_frag:v1,meshnormal_vert:x1,meshnormal_frag:_1,meshphong_vert:b1,meshphong_frag:w1,meshphysical_vert:M1,meshphysical_frag:S1,meshtoon_vert:A1,meshtoon_frag:E1,points_vert:T1,points_frag:I1,shadow_vert:C1,shadow_frag:R1,sprite_vert:P1,sprite_frag:L1},ye={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new we(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new we(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new we(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},An={basic:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},specular:{value:new we(1118481)},shininess:{value:30}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:$t([ye.common,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.roughnessmap,ye.metalnessmap,ye.fog,ye.lights,{emissive:{value:new we(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:$t([ye.common,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.gradientmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:$t([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:$t([ye.points,ye.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:$t([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:$t([ye.common,ye.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:$t([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:$t([ye.sprite,ye.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distanceRGBA:{uniforms:$t([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distanceRGBA_vert,fragmentShader:$e.distanceRGBA_frag},shadow:{uniforms:$t([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};An.physical={uniforms:$t([An.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new we(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new we(0)},specularColor:{value:new we(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};ml={r:0,b:0,g:0},Wi=new rn,D1=new Ne;ps=class extends hs{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},is=4,Im=[.125,.215,.35,.446,.526,.582],tr=20,cd=new ps,Cm=new we,ud=null,dd=0,hd=0,fd=!1,er=(1+Math.sqrt(5))/2,Yr=1/er,Rm=[new R(-er,Yr,0),new R(er,Yr,0),new R(-Yr,0,er),new R(Yr,0,er),new R(0,er,-Yr),new R(0,er,Yr),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)],Ra=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){ud=this._renderer.getRenderTarget(),dd=this._renderer.getActiveCubeFace(),hd=this._renderer.getActiveMipmapLevel(),fd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Dm(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Lm(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ud,dd,hd),this._renderer.xr.enabled=fd,e.scissorTest=!1,gl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===si||e.mapping===Ti?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ud=this._renderer.getRenderTarget(),dd=this._renderer.getActiveCubeFace(),hd=this._renderer.getActiveMipmapLevel(),fd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:bt,minFilter:bt,generateMipmaps:!1,type:no,format:en,colorSpace:ci,depthBuffer:!1},r=Pm(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Pm(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=z1(s)),this._blurMaterial=V1(s,e,t)}return r}_compileMaterial(e){let t=new yt(this._lodPlanes[0],e);this._renderer.compile(t,cd)}_sceneToCubeUV(e,t,i,r){let o=new At(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(Cm),u.toneMapping=ni,u.autoClear=!1;let f=new Nn({name:"PMREM.Background",side:jt,depthWrite:!1,depthTest:!1}),m=new yt(new cr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Cm),y=!0);for(let p=0;p<6;p++){let x=p%3;x===0?(o.up.set(0,l[p],0),o.lookAt(c[p],0,0)):x===1?(o.up.set(0,0,l[p]),o.lookAt(0,c[p],0)):(o.up.set(0,l[p],0),o.lookAt(0,0,c[p]));let v=this._cubeSize;gl(r,x*v,p>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(m,o),u.render(e,o)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===si||e.mapping===Ti;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Dm()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Lm());let s=r?this._cubemapMaterial:this._equirectMaterial,a=new yt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;let l=this._cubeSize;gl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,cd)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Rm[(r-s-1)%Rm.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new yt(this._lodPlanes[r],c),h=c.uniforms,f=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*tr-1),y=s/m,g=isFinite(s)?1+Math.floor(u*y):tr;g>tr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${tr}`);let p=[],x=0;for(let E=0;E<tr;++E){let D=E/y,M=Math.exp(-D*D/2);p.push(M),E===0?x+=M:E<g&&(x+=2*M)}for(let E=0;E<p.length;E++)p[E]=p[E]/x;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=p,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);let{_lodMax:v}=this;h.dTheta.value=m,h.mipInt.value=v-i;let b=this._sizeLods[r],L=3*b*(r>v-is?r-v+is:0),A=4*(this._cubeSize-b);gl(t,L,A,3*b,2*b),l.setRenderTarget(t),l.render(d,cd)}};Pa=class extends wt{constructor(e,t,i,r,s,a,o,l,c,u){if(u=u!==void 0?u:ar,u!==ar&&u!==os)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===ar&&(i=lr),i===void 0&&u===os&&(i=_s),super(null,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Rt,this.minFilter=l!==void 0?l:Rt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Q0=new wt,ey=new Pa(1,1);ey.compareFunction=Ff;ty=new cs,ny=new Ta,iy=new ur,Om=[],Um=[],Nm=new Float32Array(16),Fm=new Float32Array(9),km=new Float32Array(4);gh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=pA(t.type)}},yh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=OA(t.type)}},vh=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,a=r.length;s!==a;++s){let o=r[s];o.setValue(e,t[o.id],i)}}},pd=/(\w+)(\])?(\[|\.)?/g;as=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);UA(s,a,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){let o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let a=e[r];a.id in t&&i.push(a)}return i}};NA=37297,FA=0;WA=/^[ \t]*#include +<([\w\d./]+)>/gm;jA=new Map;YA=/#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;nE=0,_h=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new bh(e),t.set(e,i)),i}},bh=class{constructor(e){this.id=nE++,this.code=e,this.usedTimes=0}};cE=0;La=class extends Lt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=N0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Da=class extends Lt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},fE=`void main() {
3769
+ }`,$e={alphahash_fragment:iM,alphahash_pars_fragment:rM,alphamap_fragment:sM,alphamap_pars_fragment:oM,alphatest_fragment:aM,alphatest_pars_fragment:lM,aomap_fragment:cM,aomap_pars_fragment:uM,batching_pars_vertex:dM,batching_vertex:hM,begin_vertex:fM,beginnormal_vertex:pM,bsdfs:mM,iridescence_fragment:gM,bumpmap_pars_fragment:yM,clipping_planes_fragment:vM,clipping_planes_pars_fragment:xM,clipping_planes_pars_vertex:_M,clipping_planes_vertex:bM,color_fragment:wM,color_pars_fragment:MM,color_pars_vertex:SM,color_vertex:AM,common:EM,cube_uv_reflection_fragment:TM,defaultnormal_vertex:IM,displacementmap_pars_vertex:CM,displacementmap_vertex:RM,emissivemap_fragment:PM,emissivemap_pars_fragment:LM,colorspace_fragment:DM,colorspace_pars_fragment:OM,envmap_fragment:UM,envmap_common_pars_fragment:NM,envmap_pars_fragment:FM,envmap_pars_vertex:kM,envmap_physical_pars_fragment:qM,envmap_vertex:BM,fog_vertex:zM,fog_pars_vertex:VM,fog_fragment:HM,fog_pars_fragment:GM,gradientmap_pars_fragment:$M,lightmap_pars_fragment:WM,lights_lambert_fragment:jM,lights_lambert_pars_fragment:XM,lights_pars_begin:YM,lights_toon_fragment:ZM,lights_toon_pars_fragment:JM,lights_phong_fragment:KM,lights_phong_pars_fragment:QM,lights_physical_fragment:eS,lights_physical_pars_fragment:tS,lights_fragment_begin:nS,lights_fragment_maps:iS,lights_fragment_end:rS,logdepthbuf_fragment:sS,logdepthbuf_pars_fragment:oS,logdepthbuf_pars_vertex:aS,logdepthbuf_vertex:lS,map_fragment:cS,map_pars_fragment:uS,map_particle_fragment:dS,map_particle_pars_fragment:hS,metalnessmap_fragment:fS,metalnessmap_pars_fragment:pS,morphinstance_vertex:mS,morphcolor_vertex:gS,morphnormal_vertex:yS,morphtarget_pars_vertex:vS,morphtarget_vertex:xS,normal_fragment_begin:_S,normal_fragment_maps:bS,normal_pars_fragment:wS,normal_pars_vertex:MS,normal_vertex:SS,normalmap_pars_fragment:AS,clearcoat_normal_fragment_begin:ES,clearcoat_normal_fragment_maps:TS,clearcoat_pars_fragment:IS,iridescence_pars_fragment:CS,opaque_fragment:RS,packing:PS,premultiplied_alpha_fragment:LS,project_vertex:DS,dithering_fragment:OS,dithering_pars_fragment:US,roughnessmap_fragment:NS,roughnessmap_pars_fragment:FS,shadowmap_pars_fragment:kS,shadowmap_pars_vertex:BS,shadowmap_vertex:zS,shadowmask_pars_fragment:VS,skinbase_vertex:HS,skinning_pars_vertex:GS,skinning_vertex:$S,skinnormal_vertex:WS,specularmap_fragment:jS,specularmap_pars_fragment:XS,tonemapping_fragment:YS,tonemapping_pars_fragment:qS,transmission_fragment:ZS,transmission_pars_fragment:JS,uv_pars_fragment:KS,uv_pars_vertex:QS,uv_vertex:e1,worldpos_vertex:t1,background_vert:n1,background_frag:i1,backgroundCube_vert:r1,backgroundCube_frag:s1,cube_vert:o1,cube_frag:a1,depth_vert:l1,depth_frag:c1,distanceRGBA_vert:u1,distanceRGBA_frag:d1,equirect_vert:h1,equirect_frag:f1,linedashed_vert:p1,linedashed_frag:m1,meshbasic_vert:g1,meshbasic_frag:y1,meshlambert_vert:v1,meshlambert_frag:x1,meshmatcap_vert:_1,meshmatcap_frag:b1,meshnormal_vert:w1,meshnormal_frag:M1,meshphong_vert:S1,meshphong_frag:A1,meshphysical_vert:E1,meshphysical_frag:T1,meshtoon_vert:I1,meshtoon_frag:C1,points_vert:R1,points_frag:P1,shadow_vert:L1,shadow_frag:D1,sprite_vert:O1,sprite_frag:U1},ye={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new we(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new we(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new we(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},An={basic:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:$t([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},specular:{value:new we(1118481)},shininess:{value:30}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:$t([ye.common,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.roughnessmap,ye.metalnessmap,ye.fog,ye.lights,{emissive:{value:new we(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:$t([ye.common,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.gradientmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:$t([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:$t([ye.points,ye.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:$t([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:$t([ye.common,ye.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:$t([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:$t([ye.sprite,ye.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distanceRGBA:{uniforms:$t([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distanceRGBA_vert,fragmentShader:$e.distanceRGBA_frag},shadow:{uniforms:$t([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};An.physical={uniforms:$t([An.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new we(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new we(0)},specularColor:{value:new we(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};ml={r:0,b:0,g:0},Wi=new rn,N1=new Ne;ps=class extends hs{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},is=4,Cm=[.125,.215,.35,.446,.526,.582],tr=20,cd=new ps,Rm=new we,ud=null,dd=0,hd=0,fd=!1,er=(1+Math.sqrt(5))/2,Yr=1/er,Pm=[new R(-er,Yr,0),new R(er,Yr,0),new R(-Yr,0,er),new R(Yr,0,er),new R(0,er,-Yr),new R(0,er,Yr),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)],Po=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){ud=this._renderer.getRenderTarget(),dd=this._renderer.getActiveCubeFace(),hd=this._renderer.getActiveMipmapLevel(),fd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Om(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Dm(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ud,dd,hd),this._renderer.xr.enabled=fd,e.scissorTest=!1,gl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===si||e.mapping===Ti?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ud=this._renderer.getRenderTarget(),dd=this._renderer.getActiveCubeFace(),hd=this._renderer.getActiveMipmapLevel(),fd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:bt,minFilter:bt,generateMipmaps:!1,type:ia,format:en,colorSpace:ci,depthBuffer:!1},r=Lm(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Lm(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=G1(s)),this._blurMaterial=$1(s,e,t)}return r}_compileMaterial(e){let t=new yt(this._lodPlanes[0],e);this._renderer.compile(t,cd)}_sceneToCubeUV(e,t,i,r){let a=new At(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(Rm),u.toneMapping=ni,u.autoClear=!1;let f=new Nn({name:"PMREM.Background",side:jt,depthWrite:!1,depthTest:!1}),p=new yt(new cr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Rm),y=!0);for(let m=0;m<6;m++){let x=m%3;x===0?(a.up.set(0,l[m],0),a.lookAt(c[m],0,0)):x===1?(a.up.set(0,0,l[m]),a.lookAt(0,c[m],0)):(a.up.set(0,l[m],0),a.lookAt(0,0,c[m]));let v=this._cubeSize;gl(r,x*v,m>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===si||e.mapping===Ti;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Om()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Dm());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new yt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;gl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,cd)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Pm[(r-s-1)%Pm.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new yt(this._lodPlanes[r],c),h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*tr-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):tr;g>tr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${tr}`);let m=[],x=0;for(let E=0;E<tr;++E){let D=E/y,M=Math.exp(-D*D/2);m.push(M),E===0?x+=M:E<g&&(x+=2*M)}for(let E=0;E<m.length;E++)m[E]=m[E]/x;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=m,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:v}=this;h.dTheta.value=p,h.mipInt.value=v-i;let b=this._sizeLods[r],L=3*b*(r>v-is?r-v+is:0),A=4*(this._cubeSize-b);gl(t,L,A,3*b,2*b),l.setRenderTarget(t),l.render(d,cd)}};Lo=class extends wt{constructor(e,t,i,r,s,o,a,l,c,u){if(u=u!==void 0?u:or,u!==or&&u!==as)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===or&&(i=lr),i===void 0&&u===as&&(i=_s),super(null,r,s,o,a,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Rt,this.minFilter=l!==void 0?l:Rt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ey=new wt,ty=new Lo(1,1);ty.compareFunction=Ff;ny=new cs,iy=new Io,ry=new ur,Um=[],Nm=[],Fm=new Float32Array(16),km=new Float32Array(9),Bm=new Float32Array(4);gh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=yA(t.type)}},yh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=FA(t.type)}},vh=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},pd=/(\w+)(\])?(\[|\.)?/g;os=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);kA(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};BA=37297,zA=0;YA=/^[ \t]*#include +<([\w\d./]+)>/gm;qA=new Map;JA=/#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;sE=0,_h=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new bh(e),t.set(e,i)),i}},bh=class{constructor(e){this.id=sE++,this.code=e,this.usedTimes=0}};hE=0;Do=class extends Lt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=F0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Oo=class extends Lt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},gE=`void main() {
3770
3770
  gl_Position = vec4( position, 1.0 );
3771
- }`,pE=`uniform sampler2D shadow_pass;
3771
+ }`,yE=`uniform sampler2D shadow_pass;
3772
3772
  uniform vec2 resolution;
3773
3773
  uniform float radius;
3774
3774
  #include <packing>
@@ -3794,12 +3794,12 @@ void main() {
3794
3794
  squared_mean = squared_mean / samples;
3795
3795
  float std_dev = sqrt( squared_mean - mean * mean );
3796
3796
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3797
- }`;ec=class extends At{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ei=class extends it{constructor(){super(),this.isGroup=!0,this.type="Group"}},vE={type:"move"},ua=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ei,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 Ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null,o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),p=this._getHandJoint(c,y);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let u=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,m=.005;c.inputState.pinching&&h>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vE)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Ei;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},xE=`
3797
+ }`;ec=class extends At{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ei=class extends it{constructor(){super(),this.isGroup=!0,this.type="Group"}},bE={type:"move"},uo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ei,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 Ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),m=this._getHandJoint(c,y);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let u=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,p=.005;c.inputState.pinching&&h>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(bE)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Ei;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},wE=`
3798
3798
  void main() {
3799
3799
 
3800
3800
  gl_Position = vec4( position, 1.0 );
3801
3801
 
3802
- }`,_E=`
3802
+ }`,ME=`
3803
3803
  uniform sampler2DArray depthColor;
3804
3804
  uniform float depthWidth;
3805
3805
  uniform float depthHeight;
@@ -3818,20 +3818,20 @@ void main() {
3818
3818
 
3819
3819
  }
3820
3820
 
3821
- }`,wh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new sn({vertexShader:xE,fragmentShader:_E,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new yt(new fs(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},Mh=class extends En{constructor(e,t){super();let i=this,r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,m=null,y=new wh,g=t.getContextAttributes(),p=null,x=null,v=[],b=[],L=new te,A=null,E=new At;E.layers.enable(1),E.viewport=new ot;let D=new At;D.layers.enable(2),D.viewport=new ot;let M=[E,D],w=new ec;w.layers.enable(1),w.layers.enable(2);let T=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let q=v[Z];return q===void 0&&(q=new ua,v[Z]=q),q.getTargetRaySpace()},this.getControllerGrip=function(Z){let q=v[Z];return q===void 0&&(q=new ua,v[Z]=q),q.getGripSpace()},this.getHand=function(Z){let q=v[Z];return q===void 0&&(q=new ua,v[Z]=q),q.getHandSpace()};function I(Z){let q=b.indexOf(Z.inputSource);if(q===-1)return;let pe=v[q];pe!==void 0&&(pe.update(Z.inputSource,Z.frame,c||a),pe.dispatchEvent({type:Z.type,data:Z.inputSource}))}function B(){r.removeEventListener("select",I),r.removeEventListener("selectstart",I),r.removeEventListener("selectend",I),r.removeEventListener("squeeze",I),r.removeEventListener("squeezestart",I),r.removeEventListener("squeezeend",I),r.removeEventListener("end",B),r.removeEventListener("inputsourceschange",W);for(let Z=0;Z<v.length;Z++){let q=b[Z];q!==null&&(b[Z]=null,v[Z].disconnect(q))}T=null,U=null,y.reset(),e.setRenderTarget(p),f=null,h=null,d=null,r=null,x=null,Je.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(L.width,L.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){o=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",I),r.addEventListener("selectstart",I),r.addEventListener("selectend",I),r.addEventListener("squeeze",I),r.addEventListener("squeezestart",I),r.addEventListener("squeezeend",I),r.addEventListener("end",B),r.addEventListener("inputsourceschange",W),g.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(L),r.renderState.layers===void 0){let q={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,q),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new nn(f.framebufferWidth,f.framebufferHeight,{format:en,type:ai,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let q=null,pe=null,ne=null;g.depth&&(ne=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,q=g.stencil?os:ar,pe=g.stencil?_s:lr);let Fe={colorFormat:t.RGBA8,depthFormat:ne,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(Fe),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),x=new nn(h.textureWidth,h.textureHeight,{format:en,type:ai,depthTexture:new Pa(h.textureWidth,h.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Je.setContext(r),Je.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function W(Z){for(let q=0;q<Z.removed.length;q++){let pe=Z.removed[q],ne=b.indexOf(pe);ne>=0&&(b[ne]=null,v[ne].disconnect(pe))}for(let q=0;q<Z.added.length;q++){let pe=Z.added[q],ne=b.indexOf(pe);if(ne===-1){for(let _e=0;_e<v.length;_e++)if(_e>=b.length){b.push(pe),ne=_e;break}else if(b[_e]===null){b[_e]=pe,ne=_e;break}if(ne===-1)break}let Fe=v[ne];Fe&&Fe.connect(pe)}}let F=new R,X=new R;function k(Z,q,pe){F.setFromMatrixPosition(q.matrixWorld),X.setFromMatrixPosition(pe.matrixWorld);let ne=F.distanceTo(X),Fe=q.projectionMatrix.elements,_e=pe.projectionMatrix.elements,H=Fe[14]/(Fe[10]-1),Ue=Fe[14]/(Fe[10]+1),J=(Fe[9]+1)/Fe[5],ce=(Fe[9]-1)/Fe[5],K=(Fe[8]-1)/Fe[0],de=(_e[8]+1)/_e[0],le=H*K,he=H*de,Ae=ne/(-K+de),P=Ae*-K;q.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(P),Z.translateZ(Ae),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();let S=H+Ae,j=Ue+Ae,ee=le-P,ae=he+(ne-P),ie=J*Ue/j*S,Ce=ce*Ue/j*S;Z.projectionMatrix.makePerspective(ee,ae,ie,Ce,S,j),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function re(Z,q){q===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(q.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;y.texture!==null&&(Z.near=y.depthNear,Z.far=y.depthFar),w.near=D.near=E.near=Z.near,w.far=D.far=E.far=Z.far,(T!==w.near||U!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,U=w.far,E.near=T,E.far=U,D.near=T,D.far=U,E.updateProjectionMatrix(),D.updateProjectionMatrix(),Z.updateProjectionMatrix());let q=Z.parent,pe=w.cameras;re(w,q);for(let ne=0;ne<pe.length;ne++)re(pe[ne],q);pe.length===2?k(w,E,D):w.projectionMatrix.copy(E.projectionMatrix),se(Z,w,q)};function se(Z,q,pe){pe===null?Z.matrix.copy(q.matrixWorld):(Z.matrix.copy(pe.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(q.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(q.projectionMatrix),Z.projectionMatrixInverse.copy(q.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=ls*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return w},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(Z){l=Z,h!==null&&(h.fixedFoveation=Z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Z)},this.hasDepthSensing=function(){return y.texture!==null};let ve=null;function Le(Z,q){if(u=q.getViewerPose(c||a),m=q,u!==null){let pe=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let ne=!1;pe.length!==w.cameras.length&&(w.cameras.length=0,ne=!0);for(let _e=0;_e<pe.length;_e++){let H=pe[_e],Ue=null;if(f!==null)Ue=f.getViewport(H);else{let ce=d.getViewSubImage(h,H);Ue=ce.viewport,_e===0&&(e.setRenderTargetTextures(x,ce.colorTexture,h.ignoreDepthValues?void 0:ce.depthStencilTexture),e.setRenderTarget(x))}let J=M[_e];J===void 0&&(J=new At,J.layers.enable(_e),J.viewport=new ot,M[_e]=J),J.matrix.fromArray(H.transform.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale),J.projectionMatrix.fromArray(H.projectionMatrix),J.projectionMatrixInverse.copy(J.projectionMatrix).invert(),J.viewport.set(Ue.x,Ue.y,Ue.width,Ue.height),_e===0&&(w.matrix.copy(J.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),ne===!0&&w.cameras.push(J)}let Fe=r.enabledFeatures;if(Fe&&Fe.includes("depth-sensing")){let _e=d.getDepthInformation(pe[0]);_e&&_e.isValid&&_e.texture&&y.init(e,_e,r.renderState)}}for(let pe=0;pe<v.length;pe++){let ne=b[pe],Fe=v[pe];ne!==null&&Fe!==void 0&&Fe.update(ne,q,c||a)}y.render(e,w),ve&&ve(Z,q),q.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:q}),m=null}let Je=new K0;Je.setAnimationLoop(Le),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}},ji=new rn,bE=new Ne;Sh=class{constructor(e={}){let{canvas:t=X0(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=a;let f=new Uint32Array(4),m=new Int32Array(4),y=null,g=null,p=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=mn,this._useLegacyLights=!1,this.toneMapping=ni,this.toneMappingExposure=1;let v=this,b=!1,L=0,A=0,E=null,D=-1,M=null,w=new ot,T=new ot,U=null,I=new we(0),B=0,W=t.width,F=t.height,X=1,k=null,re=null,se=new ot(0,0,W,F),ve=new ot(0,0,W,F),Le=!1,Je=new dr,Z=!1,q=!1,pe=new Ne,ne=new R,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return E===null?X:1}let H=i;function Ue(_,O){return t.getContext(_,O)}try{let _={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",z,!1),t.addEventListener("webglcontextrestored",oe,!1),t.addEventListener("webglcontextcreationerror",Q,!1),H===null){let O="webgl2";if(H=Ue(O,_),H===null)throw Ue(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(_){throw console.error("THREE.WebGLRenderer: "+_.message),_}let J,ce,K,de,le,he,Ae,P,S,j,ee,ae,ie,Ce,me,ge,ke,fe,Re,We,Pe,Me,De,qe;function ht(){J=new G1(H),J.init(),Me=new ry(H,J),ce=new F1(H,J,e,Me),K=new gE(H),de=new j1(H),le=new rE,he=new yE(H,J,K,le,ce,Me,de),Ae=new B1(v),P=new H1(v),S=new Qw(H),De=new U1(H,S),j=new $1(H,S,de,De),ee=new Y1(H,j,S,de),Re=new X1(H,ce,he),ge=new k1(le),ae=new iE(v,Ae,P,J,ce,De,ge),ie=new wE(v,le),Ce=new aE,me=new hE(J),fe=new O1(v,Ae,P,K,ee,h,l),ke=new mE(v,ee,ce),qe=new ME(H,de,ce,K),We=new N1(H,J,de),Pe=new W1(H,J,de),de.programs=ae.programs,v.capabilities=ce,v.extensions=J,v.properties=le,v.renderLists=Ce,v.shadowMap=ke,v.state=K,v.info=de}ht();let Ge=new Mh(v,H);this.xr=Ge,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let _=J.get("WEBGL_lose_context");_&&_.loseContext()},this.forceContextRestore=function(){let _=J.get("WEBGL_lose_context");_&&_.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(_){_!==void 0&&(X=_,this.setSize(W,F,!1))},this.getSize=function(_){return _.set(W,F)},this.setSize=function(_,O,V=!0){if(Ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=_,F=O,t.width=Math.floor(_*X),t.height=Math.floor(O*X),V===!0&&(t.style.width=_+"px",t.style.height=O+"px"),this.setViewport(0,0,_,O)},this.getDrawingBufferSize=function(_){return _.set(W*X,F*X).floor()},this.setDrawingBufferSize=function(_,O,V){W=_,F=O,X=V,t.width=Math.floor(_*V),t.height=Math.floor(O*V),this.setViewport(0,0,_,O)},this.getCurrentViewport=function(_){return _.copy(w)},this.getViewport=function(_){return _.copy(se)},this.setViewport=function(_,O,V,N){_.isVector4?se.set(_.x,_.y,_.z,_.w):se.set(_,O,V,N),K.viewport(w.copy(se).multiplyScalar(X).round())},this.getScissor=function(_){return _.copy(ve)},this.setScissor=function(_,O,V,N){_.isVector4?ve.set(_.x,_.y,_.z,_.w):ve.set(_,O,V,N),K.scissor(T.copy(ve).multiplyScalar(X).round())},this.getScissorTest=function(){return Le},this.setScissorTest=function(_){K.setScissorTest(Le=_)},this.setOpaqueSort=function(_){k=_},this.setTransparentSort=function(_){re=_},this.getClearColor=function(_){return _.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(_=!0,O=!0,V=!0){let N=0;if(_){let $=!1;if(E!==null){let ue=E.texture.format;$=ue===Uf||ue===Of||ue===Df}if($){let ue=E.texture.type,Ee=ue===ai||ue===lr||ue===If||ue===_s||ue===Rf||ue===Pf,Ie=fe.getClearColor(),Oe=fe.getClearAlpha(),Be=Ie.r,je=Ie.g,Ye=Ie.b;Ee?(f[0]=Be,f[1]=je,f[2]=Ye,f[3]=Oe,H.clearBufferuiv(H.COLOR,0,f)):(m[0]=Be,m[1]=je,m[2]=Ye,m[3]=Oe,H.clearBufferiv(H.COLOR,0,m))}else N|=H.COLOR_BUFFER_BIT}O&&(N|=H.DEPTH_BUFFER_BIT),V&&(N|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(N)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",z,!1),t.removeEventListener("webglcontextrestored",oe,!1),t.removeEventListener("webglcontextcreationerror",Q,!1),Ce.dispose(),me.dispose(),le.dispose(),Ae.dispose(),P.dispose(),ee.dispose(),De.dispose(),qe.dispose(),ae.dispose(),Ge.dispose(),Ge.removeEventListener("sessionstart",et),Ge.removeEventListener("sessionend",Xt),Mt.stop()};function z(_){_.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function oe(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let _=de.autoReset,O=ke.enabled,V=ke.autoUpdate,N=ke.needsUpdate,$=ke.type;ht(),de.autoReset=_,ke.enabled=O,ke.autoUpdate=V,ke.needsUpdate=N,ke.type=$}function Q(_){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_.statusMessage)}function xe(_){let O=_.target;O.removeEventListener("dispose",xe),be(O)}function be(_){Se(_),le.remove(_)}function Se(_){let O=le.get(_).programs;O!==void 0&&(O.forEach(function(V){ae.releaseProgram(V)}),_.isShaderMaterial&&ae.releaseShaderCache(_))}this.renderBufferDirect=function(_,O,V,N,$,ue){O===null&&(O=Fe);let Ee=$.isMesh&&$.matrixWorld.determinant()<0,Ie=gu(_,O,V,N,$);K.setMaterial(N,Ee);let Oe=V.index,Be=1;if(N.wireframe===!0){if(Oe=j.getWireframeAttribute(V),Oe===void 0)return;Be=2}let je=V.drawRange,Ye=V.attributes.position,xt=je.start*Be,Ut=(je.start+je.count)*Be;ue!==null&&(xt=Math.max(xt,ue.start*Be),Ut=Math.min(Ut,(ue.start+ue.count)*Be)),Oe!==null?(xt=Math.max(xt,0),Ut=Math.min(Ut,Oe.count)):Ye!=null&&(xt=Math.max(xt,0),Ut=Math.min(Ut,Ye.count));let qt=Ut-xt;if(qt<0||qt===1/0)return;De.setup($,N,Ie,V,Oe);let zn,nt=We;if(Oe!==null&&(zn=S.get(Oe),nt=Pe,nt.setIndex(zn)),$.isMesh)N.wireframe===!0?(K.setLineWidth(N.wireframeLinewidth*_e()),nt.setMode(H.LINES)):nt.setMode(H.TRIANGLES);else if($.isLine){let ze=N.linewidth;ze===void 0&&(ze=1),K.setLineWidth(ze*_e()),$.isLineSegments?nt.setMode(H.LINES):$.isLineLoop?nt.setMode(H.LINE_LOOP):nt.setMode(H.LINE_STRIP)}else $.isPoints?nt.setMode(H.POINTS):$.isSprite&&nt.setMode(H.TRIANGLES);if($.isBatchedMesh)$._multiDrawInstances!==null?nt.renderMultiDrawInstances($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount,$._multiDrawInstances):nt.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else if($.isInstancedMesh)nt.renderInstances(xt,qt,$.count);else if(V.isInstancedBufferGeometry){let ze=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Ts=Math.min(V.instanceCount,ze);nt.renderInstances(xt,qt,Ts)}else nt.render(xt,qt)};function Ke(_,O,V){_.transparent===!0&&_.side===Pn&&_.forceSinglePass===!1?(_.side=jt,_.needsUpdate=!0,Mr(_,O,V),_.side=ri,_.needsUpdate=!0,Mr(_,O,V),_.side=Pn):Mr(_,O,V)}this.compile=function(_,O,V=null){V===null&&(V=_),g=me.get(V),g.init(O),x.push(g),V.traverseVisible(function($){$.isLight&&$.layers.test(O.layers)&&(g.pushLight($),$.castShadow&&g.pushShadow($))}),_!==V&&_.traverseVisible(function($){$.isLight&&$.layers.test(O.layers)&&(g.pushLight($),$.castShadow&&g.pushShadow($))}),g.setupLights(v._useLegacyLights);let N=new Set;return _.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let Ee=0;Ee<ue.length;Ee++){let Ie=ue[Ee];Ke(Ie,V,$),N.add(Ie)}else Ke(ue,V,$),N.add(ue)}),x.pop(),g=null,N},this.compileAsync=function(_,O,V=null){let N=this.compile(_,O,V);return new Promise($=>{function ue(){if(N.forEach(function(Ee){le.get(Ee).currentProgram.isReady()&&N.delete(Ee)}),N.size===0){$(_);return}setTimeout(ue,10)}J.get("KHR_parallel_shader_compile")!==null?ue():setTimeout(ue,10)})};let lt=null;function ft(_){lt&&lt(_)}function et(){Mt.stop()}function Xt(){Mt.start()}let Mt=new K0;Mt.setAnimationLoop(ft),typeof self<"u"&&Mt.setContext(self),this.setAnimationLoop=function(_){lt=_,Ge.setAnimationLoop(_),_===null?Mt.stop():Mt.start()},Ge.addEventListener("sessionstart",et),Ge.addEventListener("sessionend",Xt),this.render=function(_,O){if(O!==void 0&&O.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Ge.enabled===!0&&Ge.isPresenting===!0&&(Ge.cameraAutoUpdate===!0&&Ge.updateCamera(O),O=Ge.getCamera()),_.isScene===!0&&_.onBeforeRender(v,_,O,E),g=me.get(_,x.length),g.init(O),x.push(g),pe.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Je.setFromProjectionMatrix(pe),q=this.localClippingEnabled,Z=ge.init(this.clippingPlanes,q),y=Ce.get(_,p.length),y.init(),p.push(y),lo(_,O,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,re);let V=Ge.enabled===!1||Ge.isPresenting===!1||Ge.hasDepthSensing()===!1;V&&fe.addToRenderList(y,_),this.info.render.frame++,Z===!0&&ge.beginShadows();let N=g.state.shadowsArray;ke.render(N,_,O),Z===!0&&ge.endShadows(),this.info.autoReset===!0&&this.info.reset();let $=y.opaque,ue=y.transmissive;if(g.setupLights(v._useLegacyLights),O.isArrayCamera){let Ee=O.cameras;if(ue.length>0)for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];co($,ue,_,Be)}V&&fe.render(_);for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];As(y,_,Be,Be.viewport)}}else ue.length>0&&co($,ue,_,O),V&&fe.render(_),As(y,_,O);E!==null&&(he.updateMultisampleRenderTarget(E),he.updateRenderTargetMipmap(E)),_.isScene===!0&&_.onAfterRender(v,_,O),De.resetDefaultState(),D=-1,M=null,x.pop(),x.length>0?(g=x[x.length-1],Z===!0&&ge.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,p.pop(),p.length>0?y=p[p.length-1]:y=null};function lo(_,O,V,N){if(_.visible===!1)return;if(_.layers.test(O.layers)){if(_.isGroup)V=_.renderOrder;else if(_.isLOD)_.autoUpdate===!0&&_.update(O);else if(_.isLight)g.pushLight(_),_.castShadow&&g.pushShadow(_);else if(_.isSprite){if(!_.frustumCulled||Je.intersectsSprite(_)){N&&ne.setFromMatrixPosition(_.matrixWorld).applyMatrix4(pe);let Ee=ee.update(_),Ie=_.material;Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}else if((_.isMesh||_.isLine||_.isPoints)&&(!_.frustumCulled||Je.intersectsObject(_))){let Ee=ee.update(_),Ie=_.material;if(N&&(_.boundingSphere!==void 0?(_.boundingSphere===null&&_.computeBoundingSphere(),ne.copy(_.boundingSphere.center)):(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),ne.copy(Ee.boundingSphere.center)),ne.applyMatrix4(_.matrixWorld).applyMatrix4(pe)),Array.isArray(Ie)){let Oe=Ee.groups;for(let Be=0,je=Oe.length;Be<je;Be++){let Ye=Oe[Be],xt=Ie[Ye.materialIndex];xt&&xt.visible&&y.push(_,Ee,xt,V,ne.z,Ye)}}else Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}let ue=_.children;for(let Ee=0,Ie=ue.length;Ee<Ie;Ee++)lo(ue[Ee],O,V,N)}function As(_,O,V,N){let $=_.opaque,ue=_.transmissive,Ee=_.transparent;g.setupLightsView(V),Z===!0&&ge.setGlobalState(v.clippingPlanes,V),N&&K.viewport(w.copy(N)),$.length>0&&wr($,O,V),ue.length>0&&wr(ue,O,V),Ee.length>0&&wr(Ee,O,V),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function co(_,O,V,N){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[N.id]===void 0&&(g.state.transmissionRenderTarget[N.id]=new nn(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?no:ai,minFilter:Ln,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let ue=g.state.transmissionRenderTarget[N.id],Ee=N.viewport||w;ue.setSize(Ee.z,Ee.w);let Ie=v.getRenderTarget();v.setRenderTarget(ue),v.getClearColor(I),B=v.getClearAlpha(),B<1&&v.setClearColor(16777215,.5),v.clear();let Oe=v.toneMapping;v.toneMapping=ni;let Be=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),g.setupLightsView(N),Z===!0&&ge.setGlobalState(v.clippingPlanes,N),wr(_,V,N),he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue),J.has("WEBGL_multisampled_render_to_texture")===!1){let je=!1;for(let Ye=0,xt=O.length;Ye<xt;Ye++){let Ut=O[Ye],qt=Ut.object,zn=Ut.geometry,nt=Ut.material,ze=Ut.group;if(nt.side===Pn&&qt.layers.test(N.layers)){let Ts=nt.side;nt.side=jt,nt.needsUpdate=!0,uo(qt,V,N,zn,nt,ze),nt.side=Ts,nt.needsUpdate=!0,je=!0}}je===!0&&(he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue))}v.setRenderTarget(Ie),v.setClearColor(I,B),Be!==void 0&&(N.viewport=Be),v.toneMapping=Oe}function wr(_,O,V){let N=O.isScene===!0?O.overrideMaterial:null;for(let $=0,ue=_.length;$<ue;$++){let Ee=_[$],Ie=Ee.object,Oe=Ee.geometry,Be=N===null?Ee.material:N,je=Ee.group;Ie.layers.test(V.layers)&&uo(Ie,O,V,Oe,Be,je)}}function uo(_,O,V,N,$,ue){_.onBeforeRender(v,O,V,N,$,ue),_.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,_.matrixWorld),_.normalMatrix.getNormalMatrix(_.modelViewMatrix),$.onBeforeRender(v,O,V,N,_,ue),$.transparent===!0&&$.side===Pn&&$.forceSinglePass===!1?($.side=jt,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=ri,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=Pn):v.renderBufferDirect(V,O,N,$,_,ue),_.onAfterRender(v,O,V,N,$,ue)}function Mr(_,O,V){O.isScene!==!0&&(O=Fe);let N=le.get(_),$=g.state.lights,ue=g.state.shadowsArray,Ee=$.state.version,Ie=ae.getParameters(_,$.state,ue,O,V),Oe=ae.getProgramCacheKey(Ie),Be=N.programs;N.environment=_.isMeshStandardMaterial?O.environment:null,N.fog=O.fog,N.envMap=(_.isMeshStandardMaterial?P:Ae).get(_.envMap||N.environment),N.envMapRotation=N.environment!==null&&_.envMap===null?O.environmentRotation:_.envMapRotation,Be===void 0&&(_.addEventListener("dispose",xe),Be=new Map,N.programs=Be);let je=Be.get(Oe);if(je!==void 0){if(N.currentProgram===je&&N.lightsStateVersion===Ee)return ho(_,Ie),je}else Ie.uniforms=ae.getUniforms(_),_.onBuild(V,Ie,v),_.onBeforeCompile(Ie,v),je=ae.acquireProgram(Ie,Oe),Be.set(Oe,je),N.uniforms=Ie.uniforms;let Ye=N.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(Ye.clippingPlanes=ge.uniform),ho(_,Ie),N.needsLights=G(_),N.lightsStateVersion=Ee,N.needsLights&&(Ye.ambientLightColor.value=$.state.ambient,Ye.lightProbe.value=$.state.probe,Ye.directionalLights.value=$.state.directional,Ye.directionalLightShadows.value=$.state.directionalShadow,Ye.spotLights.value=$.state.spot,Ye.spotLightShadows.value=$.state.spotShadow,Ye.rectAreaLights.value=$.state.rectArea,Ye.ltc_1.value=$.state.rectAreaLTC1,Ye.ltc_2.value=$.state.rectAreaLTC2,Ye.pointLights.value=$.state.point,Ye.pointLightShadows.value=$.state.pointShadow,Ye.hemisphereLights.value=$.state.hemi,Ye.directionalShadowMap.value=$.state.directionalShadowMap,Ye.directionalShadowMatrix.value=$.state.directionalShadowMatrix,Ye.spotShadowMap.value=$.state.spotShadowMap,Ye.spotLightMatrix.value=$.state.spotLightMatrix,Ye.spotLightMap.value=$.state.spotLightMap,Ye.pointShadowMap.value=$.state.pointShadowMap,Ye.pointShadowMatrix.value=$.state.pointShadowMatrix),N.currentProgram=je,N.uniformsList=null,je}function Es(_){if(_.uniformsList===null){let O=_.currentProgram.getUniforms();_.uniformsList=as.seqWithValue(O.seq,_.uniforms)}return _.uniformsList}function ho(_,O){let V=le.get(_);V.outputColorSpace=O.outputColorSpace,V.batching=O.batching,V.instancing=O.instancing,V.instancingColor=O.instancingColor,V.instancingMorph=O.instancingMorph,V.skinning=O.skinning,V.morphTargets=O.morphTargets,V.morphNormals=O.morphNormals,V.morphColors=O.morphColors,V.morphTargetsCount=O.morphTargetsCount,V.numClippingPlanes=O.numClippingPlanes,V.numIntersection=O.numClipIntersection,V.vertexAlphas=O.vertexAlphas,V.vertexTangents=O.vertexTangents,V.toneMapping=O.toneMapping}function gu(_,O,V,N,$){O.isScene!==!0&&(O=Fe),he.resetTextureUnits();let ue=O.fog,Ee=N.isMeshStandardMaterial?O.environment:null,Ie=E===null?v.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:ci,Oe=(N.isMeshStandardMaterial?P:Ae).get(N.envMap||Ee),Be=N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,je=!!V.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),Ye=!!V.morphAttributes.position,xt=!!V.morphAttributes.normal,Ut=!!V.morphAttributes.color,qt=ni;N.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(qt=v.toneMapping);let zn=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,nt=zn!==void 0?zn.length:0,ze=le.get(N),Ts=g.state.lights;if(Z===!0&&(q===!0||_!==M)){let ln=_===M&&N.id===D;ge.setState(N,_,ln)}let dt=!1;N.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Ts.state.version||ze.outputColorSpace!==Ie||$.isBatchedMesh&&ze.batching===!1||!$.isBatchedMesh&&ze.batching===!0||$.isInstancedMesh&&ze.instancing===!1||!$.isInstancedMesh&&ze.instancing===!0||$.isSkinnedMesh&&ze.skinning===!1||!$.isSkinnedMesh&&ze.skinning===!0||$.isInstancedMesh&&ze.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&ze.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&ze.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&ze.instancingMorph===!1&&$.morphTexture!==null||ze.envMap!==Oe||N.fog===!0&&ze.fog!==ue||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==ge.numPlanes||ze.numIntersection!==ge.numIntersection)||ze.vertexAlphas!==Be||ze.vertexTangents!==je||ze.morphTargets!==Ye||ze.morphNormals!==xt||ze.morphColors!==Ut||ze.toneMapping!==qt||ze.morphTargetsCount!==nt)&&(dt=!0):(dt=!0,ze.__version=N.version);let Oi=ze.currentProgram;dt===!0&&(Oi=Mr(N,O,$));let qf=!1,Is=!1,yu=!1,Nt=Oi.getUniforms(),di=ze.uniforms;if(K.useProgram(Oi.program)&&(qf=!0,Is=!0,yu=!0),N.id!==D&&(D=N.id,Is=!0),qf||M!==_){Nt.setValue(H,"projectionMatrix",_.projectionMatrix),Nt.setValue(H,"viewMatrix",_.matrixWorldInverse);let ln=Nt.map.cameraPosition;ln!==void 0&&ln.setValue(H,ne.setFromMatrixPosition(_.matrixWorld)),ce.logarithmicDepthBuffer&&Nt.setValue(H,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&Nt.setValue(H,"isOrthographic",_.isOrthographicCamera===!0),M!==_&&(M=_,Is=!0,yu=!0)}if($.isSkinnedMesh){Nt.setOptional(H,$,"bindMatrix"),Nt.setOptional(H,$,"bindMatrixInverse");let ln=$.skeleton;ln&&(ln.boneTexture===null&&ln.computeBoneTexture(),Nt.setValue(H,"boneTexture",ln.boneTexture,he))}$.isBatchedMesh&&(Nt.setOptional(H,$,"batchingTexture"),Nt.setValue(H,"batchingTexture",$._matricesTexture,he));let vu=V.morphAttributes;if((vu.position!==void 0||vu.normal!==void 0||vu.color!==void 0)&&Re.update($,V,Oi),(Is||ze.receiveShadow!==$.receiveShadow)&&(ze.receiveShadow=$.receiveShadow,Nt.setValue(H,"receiveShadow",$.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(di.envMap.value=Oe,di.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&O.environment!==null&&(di.envMapIntensity.value=O.environmentIntensity),Is&&(Nt.setValue(H,"toneMappingExposure",v.toneMappingExposure),ze.needsLights&&C(di,yu),ue&&N.fog===!0&&ie.refreshFogUniforms(di,ue),ie.refreshMaterialUniforms(di,N,X,F,g.state.transmissionRenderTarget[_.id]),as.upload(H,Es(ze),di,he)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(as.upload(H,Es(ze),di,he),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&Nt.setValue(H,"center",$.center),Nt.setValue(H,"modelViewMatrix",$.modelViewMatrix),Nt.setValue(H,"normalMatrix",$.normalMatrix),Nt.setValue(H,"modelMatrix",$.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){let ln=N.uniformsGroups;for(let xu=0,Fy=ln.length;xu<Fy;xu++){let Zf=ln[xu];qe.update(Zf,Oi),qe.bind(Zf,Oi)}}return Oi}function C(_,O){_.ambientLightColor.needsUpdate=O,_.lightProbe.needsUpdate=O,_.directionalLights.needsUpdate=O,_.directionalLightShadows.needsUpdate=O,_.pointLights.needsUpdate=O,_.pointLightShadows.needsUpdate=O,_.spotLights.needsUpdate=O,_.spotLightShadows.needsUpdate=O,_.rectAreaLights.needsUpdate=O,_.hemisphereLights.needsUpdate=O}function G(_){return _.isMeshLambertMaterial||_.isMeshToonMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isShadowMaterial||_.isShaderMaterial&&_.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(_,O,V){le.get(_.texture).__webglTexture=O,le.get(_.depthTexture).__webglTexture=V;let N=le.get(_);N.__hasExternalTextures=!0,N.__autoAllocateDepthBuffer=V===void 0,N.__autoAllocateDepthBuffer||J.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),N.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(_,O){let V=le.get(_);V.__webglFramebuffer=O,V.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(_,O=0,V=0){E=_,L=O,A=V;let N=!0,$=null,ue=!1,Ee=!1;if(_){let Oe=le.get(_);Oe.__useDefaultFramebuffer!==void 0?(K.bindFramebuffer(H.FRAMEBUFFER,null),N=!1):Oe.__webglFramebuffer===void 0?he.setupRenderTarget(_):Oe.__hasExternalTextures&&he.rebindTextures(_,le.get(_.texture).__webglTexture,le.get(_.depthTexture).__webglTexture);let Be=_.texture;(Be.isData3DTexture||Be.isDataArrayTexture||Be.isCompressedArrayTexture)&&(Ee=!0);let je=le.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(je[O])?$=je[O][V]:$=je[O],ue=!0):_.samples>0&&he.useMultisampledRTT(_)===!1?$=le.get(_).__webglMultisampledFramebuffer:Array.isArray(je)?$=je[V]:$=je,w.copy(_.viewport),T.copy(_.scissor),U=_.scissorTest}else w.copy(se).multiplyScalar(X).floor(),T.copy(ve).multiplyScalar(X).floor(),U=Le;if(K.bindFramebuffer(H.FRAMEBUFFER,$)&&N&&K.drawBuffers(_,$),K.viewport(w),K.scissor(T),K.setScissorTest(U),ue){let Oe=le.get(_.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+O,Oe.__webglTexture,V)}else if(Ee){let Oe=le.get(_.texture),Be=O||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,Oe.__webglTexture,V||0,Be)}D=-1},this.readRenderTargetPixels=function(_,O,V,N,$,ue,Ee){if(!(_&&_.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=le.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&Ee!==void 0&&(Ie=Ie[Ee]),Ie){K.bindFramebuffer(H.FRAMEBUFFER,Ie);try{let Oe=_.texture,Be=Oe.format,je=Oe.type;if(!ce.textureFormatReadable(Be)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ce.textureTypeReadable(je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=_.width-N&&V>=0&&V<=_.height-$&&H.readPixels(O,V,N,$,Me.convert(Be),Me.convert(je),ue)}finally{let Oe=E!==null?le.get(E).__webglFramebuffer:null;K.bindFramebuffer(H.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(_,O,V=0){let N=Math.pow(2,-V),$=Math.floor(O.image.width*N),ue=Math.floor(O.image.height*N);he.setTexture2D(O,0),H.copyTexSubImage2D(H.TEXTURE_2D,V,0,0,_.x,_.y,$,ue),K.unbindTexture()},this.copyTextureToTexture=function(_,O,V,N=0){let $=O.image.width,ue=O.image.height,Ee=Me.convert(V.format),Ie=Me.convert(V.type);he.setTexture2D(V,0),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,V.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,V.unpackAlignment),O.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,N,_.x,_.y,$,ue,Ee,Ie,O.image.data):O.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,N,_.x,_.y,O.mipmaps[0].width,O.mipmaps[0].height,Ee,O.mipmaps[0].data):H.texSubImage2D(H.TEXTURE_2D,N,_.x,_.y,Ee,Ie,O.image),N===0&&V.generateMipmaps&&H.generateMipmap(H.TEXTURE_2D),K.unbindTexture()},this.copyTextureToTexture3D=function(_,O,V,N,$=0){let ue=_.max.x-_.min.x,Ee=_.max.y-_.min.y,Ie=_.max.z-_.min.z,Oe=Me.convert(N.format),Be=Me.convert(N.type),je;if(N.isData3DTexture)he.setTexture3D(N,0),je=H.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)he.setTexture2DArray(N,0),je=H.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,N.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,N.unpackAlignment);let Ye=H.getParameter(H.UNPACK_ROW_LENGTH),xt=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Ut=H.getParameter(H.UNPACK_SKIP_PIXELS),qt=H.getParameter(H.UNPACK_SKIP_ROWS),zn=H.getParameter(H.UNPACK_SKIP_IMAGES),nt=V.isCompressedTexture?V.mipmaps[$]:V.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,nt.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,nt.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,_.min.x),H.pixelStorei(H.UNPACK_SKIP_ROWS,_.min.y),H.pixelStorei(H.UNPACK_SKIP_IMAGES,_.min.z),V.isDataTexture||V.isData3DTexture?H.texSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,nt.data):N.isCompressedArrayTexture?H.compressedTexSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,nt.data):H.texSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,nt),H.pixelStorei(H.UNPACK_ROW_LENGTH,Ye),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,xt),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ut),H.pixelStorei(H.UNPACK_SKIP_ROWS,qt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,zn),$===0&&N.generateMipmaps&&H.generateMipmap(je),K.unbindTexture()},this.initTexture=function(_){_.isCubeTexture?he.setTextureCube(_,0):_.isData3DTexture?he.setTexture3D(_,0):_.isDataArrayTexture||_.isCompressedArrayTexture?he.setTexture2DArray(_,0):he.setTexture2D(_,0),K.unbindTexture()},this.resetState=function(){L=0,A=0,E=null,K.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Dn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===cu?"display-p3":"srgb",t.unpackColorSpace=at.workingColorSpace===io?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},tc=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new we(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},nc=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new we(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ic=class extends it{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(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},ms=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=tn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Y0("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Gt=new R,hr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Wt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=He(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Wt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Wt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Wt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Wt(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Oa=class extends Lt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ks=new R,Zr=new R,Jr=new R,Kr=new te,Qs=new te,sy=new Ne,yl=new R,ea=new R,vl=new R,qm=new te,md=new te,Zm=new te,rc=class extends it{constructor(e=new Oa){if(super(),this.isSprite=!0,this.type="Sprite",qr===void 0){qr=new Xe;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new ms(t,5);qr.setIndex([0,1,2,0,2,3]),qr.setAttribute("position",new hr(i,3,0,!1)),qr.setAttribute("uv",new hr(i,2,3,!1))}this.geometry=qr,this.material=e,this.center=new te(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zr.setFromMatrixScale(this.matrixWorld),sy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Jr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zr.multiplyScalar(-Jr.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let a=this.center;xl(yl.set(-.5,-.5,0),Jr,a,Zr,r,s),xl(ea.set(.5,-.5,0),Jr,a,Zr,r,s),xl(vl.set(.5,.5,0),Jr,a,Zr,r,s),qm.set(0,0),md.set(1,0),Zm.set(1,1);let o=e.ray.intersectTriangle(yl,ea,vl,!1,Ks);if(o===null&&(xl(ea.set(-.5,.5,0),Jr,a,Zr,r,s),md.set(0,1),o=e.ray.intersectTriangle(yl,vl,ea,!1,Ks),o===null))return;let l=e.ray.origin.distanceTo(Ks);l<e.near||l>e.far||t.push({distance:l,point:Ks.clone(),uv:Qn.getInterpolation(Ks,yl,ea,vl,qm,md,Zm,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};_l=new R,Jm=new R,sc=class extends it{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){_l.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(_l);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){_l.setFromMatrixPosition(e.matrixWorld),Jm.setFromMatrixPosition(this.matrixWorld);let i=_l.distanceTo(Jm)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}},Km=new R,Qm=new ot,eg=new ot,SE=new R,tg=new Ne,bl=new R,gd=new Pt,ng=new Ne,yd=new Ii,ac=class extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Dd,this.bindMatrix=new Ne,this.bindMatrixInverse=new Ne,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Dt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,bl),this.boundingBox.expandByPoint(bl)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Pt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,bl),this.boundingSphere.expandByPoint(bl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gd.copy(this.boundingSphere),gd.applyMatrix4(r),e.ray.intersectsSphere(gd)!==!1&&(ng.copy(r).invert(),yd.copy(e.ray).applyMatrix4(ng),!(this.boundingBox!==null&&yd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,yd)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ot,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Dd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===M0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;Qm.fromBufferAttribute(r.attributes.skinIndex,e),eg.fromBufferAttribute(r.attributes.skinWeight,e),Km.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let a=eg.getComponent(s);if(a!==0){let o=Qm.getComponent(s);tg.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(SE.copy(Km).applyMatrix4(tg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}},Ua=class extends it{constructor(){super(),this.isBone=!0,this.type="Bone"}},On=class extends wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=Rt,u=Rt,d,h){super(null,a,o,l,c,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ig=new Ne,AE=new Ne,oc=class n{constructor(e=[],t=[]){this.uuid=tn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ne)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Ne;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let o=e[s]?e[s].matrixWorld:AE;ig.multiplyMatrices(o,t[s]),ig.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new On(t,e,e,en,yn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Ua),this.bones.push(a),this.boneInverses.push(new Ne().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let o=i[r];e.boneInverses.push(o.toArray())}return e}},Ci=class extends tt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Qr=new Ne,rg=new Ne,wl=[],sg=new Dt,EE=new Ne,ta=new yt,na=new Pt,lc=class extends yt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ci(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,EE)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Dt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qr),sg.copy(e.boundingBox).applyMatrix4(Qr),this.boundingBox.union(sg)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Pt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qr),na.copy(e.boundingSphere).applyMatrix4(Qr),this.boundingSphere.union(na)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(ta.geometry=this.geometry,ta.material=this.material,ta.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),na.copy(this.boundingSphere),na.applyMatrix4(i),e.ray.intersectsSphere(na)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Qr),rg.multiplyMatrices(i,Qr),ta.matrixWorld=rg,ta.raycast(e,wl);for(let a=0,o=wl.length;a<o;a++){let l=wl[a];l.instanceId=s,l.object=this,t.push(l)}wl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ci(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new On(new Float32Array(r*this.count),r,this.count,Lf,yn));let s=this.morphTexture.source.data.data,a=0;for(let c=0;c<i.length;c++)a+=i[c];let o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};Ah=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},es="batchId",Mi=new Ne,ag=new Ne,CE=new Ne,og=new Ne,vd=new dr,Ml=new Dt,Xi=new Pt,ia=new R,xd=new Ah,zt=new yt,Sl=[];cc=class extends yt{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new Xe,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new On(t,e,e,en,yn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let o in e.attributes){let l=e.getAttribute(o),{array:c,itemSize:u,normalized:d}=l,h=new c.constructor(i*u),f=new tt(h,u,d);t.setAttribute(o,f)}if(e.getIndex()!==null){let o=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new tt(o,1))}let a=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(es,new tt(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(es))throw new Error(`BatchedMesh: Geometry cannot use attribute "${es}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===es)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Mi),this.getBoundingBoxAt(r,Ml).applyMatrix4(Mi),t.union(Ml))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Pt);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Mi),this.getBoundingSphereAt(r,Xi).applyMatrix4(Mi),t.union(Xi))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,m=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,CE.toArray(m,y*16),f.needsUpdate=!0,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Dt,sphereInitialized:!1,sphere:new Pt});let g=this.geometry.getAttribute(es);for(let p=0;p<r.vertexCount;p++)g.setX(r.vertexStart+p,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let l=o.vertexStart,c=o.vertexCount;for(let f in i.attributes){if(f===es)continue;let m=t.getAttribute(f),y=i.getAttribute(f);RE(m,y,l);let g=m.itemSize;for(let p=m.count,x=c;p<x;p++){let v=l+p;for(let b=0;b<g;b++)y.setComponent(v,b,0)}y.needsUpdate=!0,y.addUpdateRange(l*g,c*g)}if(r){let f=o.indexStart;for(let m=0;m<a.count;m++)s.setX(f+m,l+a.getX(m));for(let m=a.count,y=o.indexCount;m<y;m++)s.setX(f+m,l);s.needsUpdate=!0,s.addUpdateRange(f,o.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?a.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,a=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let o=a.index,l=a.attributes.position,c=this._drawRanges[e];for(let u=c.start,d=c.start+c.count;u<d;u++){let h=u;o&&(h=o.getX(h)),s.expandByPoint(ia.fromBufferAttribute(l,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,a=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Ml),Ml.getCenter(s.center);let o=a.index,l=a.attributes.position,c=this._drawRanges[e],u=0;for(let d=c.start,h=c.start+c.count;d<h;d++){let f=d;o&&(f=o.getX(f)),ia.fromBufferAttribute(l,f),u=Math.max(u,s.center.distanceToSquared(ia))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;zt.material=this.material,zt.geometry.index=l.index,zt.geometry.attributes=l.attributes,zt.geometry.boundingBox===null&&(zt.geometry.boundingBox=new Dt),zt.geometry.boundingSphere===null&&(zt.geometry.boundingSphere=new Pt);for(let c=0;c<a;c++){if(!i[c]||!r[c])continue;let u=s[c];zt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,zt.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,zt.geometry.boundingBox),this.getBoundingSphereAt(c,zt.geometry.boundingSphere),zt.raycast(e,Sl);for(let d=0,h=Sl.length;d<h;d++){let f=Sl[d];f.object=this,f.batchId=c,t.push(f)}Sl.length=0}zt.material=null,zt.geometry.index=null,zt.geometry.attributes={},zt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(og.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vd.setFromProjectionMatrix(og,e.coordinateSystem));let m=0;if(this.sortObjects){ag.copy(this.matrixWorld).invert(),ia.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ag);for(let p=0,x=c.length;p<x;p++)if(c[p]&&l[p]){this.getMatrixAt(p,Mi),this.getBoundingSphereAt(p,Xi).applyMatrix4(Mi);let v=!1;if(f&&(v=!vd.intersectsSphere(Xi)),!v){let b=ia.distanceTo(Xi.center);xd.push(h[p],b)}}let y=xd.list,g=this.customSort;g===null?y.sort(s.transparent?IE:TE):g.call(this,y,i);for(let p=0,x=y.length;p<x;p++){let v=y[p];u[m]=v.start*o,d[m]=v.count,m++}xd.reset()}else for(let y=0,g=c.length;y<g;y++)if(c[y]&&l[y]){let p=!1;if(f&&(this.getMatrixAt(y,Mi),this.getBoundingSphereAt(y,Xi).applyMatrix4(Mi),p=!vd.intersectsSphere(Xi)),!p){let x=h[y];u[m]=x.start*o,d[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}},Ot=class extends Lt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new we(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},uc=new R,dc=new R,lg=new Ne,ra=new Ii,Al=new Pt,_d=new R,cg=new R,Fn=class extends it{constructor(e=new Xe,t=new Ot){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)uc.fromBufferAttribute(t,r-1),dc.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=uc.distanceTo(dc);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Al.copy(i.boundingSphere),Al.applyMatrix4(r),Al.radius+=s,e.ray.intersectsSphere(Al)===!1)return;lg.copy(r).invert(),ra.copy(e.ray).applyMatrix4(lg);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,a.start),m=Math.min(u.count,a.start+a.count);for(let y=f,g=m-1;y<g;y+=c){let p=u.getX(y),x=u.getX(y+1),v=El(this,e,ra,l,p,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(m-1),g=u.getX(f),p=El(this,e,ra,l,y,g);p&&t.push(p)}}else{let f=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let y=f,g=m-1;y<g;y+=c){let p=El(this,e,ra,l,y,y+1);p&&t.push(p)}if(this.isLineLoop){let y=El(this,e,ra,l,m-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};ug=new R,dg=new R,vn=class extends Fn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)ug.fromBufferAttribute(t,r),dg.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+ug.distanceTo(dg);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hc=class extends Fn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Na=class extends Lt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},hg=new Ne,Eh=new Ii,Tl=new Pt,Il=new R,fc=class extends it{constructor(e=new Xe,t=new Na){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Tl.copy(i.boundingSphere),Tl.applyMatrix4(r),Tl.radius+=s,e.ray.intersectsSphere(Tl)===!1)return;hg.copy(r).invert(),Eh.copy(e.ray).applyMatrix4(hg);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,d=i.attributes.position;if(c!==null){let h=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let m=h,y=f;m<y;m++){let g=c.getX(m);Il.fromBufferAttribute(d,g),fg(Il,g,l,r,e,t,this)}}else{let h=Math.max(0,a.start),f=Math.min(d.count,a.start+a.count);for(let m=h,y=f;m<y;m++)Il.fromBufferAttribute(d,m),fg(Il,m,l,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};Th=class extends wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:bt,this.magFilter=s!==void 0?s:bt,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Ih=class extends wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Rt,this.minFilter=Rt,this.generateMipmaps=!1,this.needsUpdate=!0}},gs=class extends wt{constructor(e,t,i,r,s,a,o,l,c,u,d,h){super(null,a,o,l,c,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Ch=class extends gs{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gn}},Rh=class extends gs{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,si),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Ph=class extends wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},an=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(a-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new te:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new R,r=[],s=[],a=[],o=new R,l=new Ne;for(let f=0;f<=e;f++){let m=f/e;r[f]=this.getTangentAt(m,new R)}s[0]=new R,a[0]=new R;let c=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(r[f-1],r[f]),o.length()>Number.EPSILON){o.normalize();let m=Math.acos(gt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(gt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],f*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ys=class extends an{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new te){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let o=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=c-this.aY;l=h*u-f*d+this.aX,c=h*d+f*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},pc=class extends ys{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};Cl=new R,bd=new zf,wd=new zf,Md=new zf,mc=class extends an{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new R){let i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e,o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(Cl.subVectors(r[0],r[1]).add(r[0]),c=Cl);let d=r[o%s],h=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(Cl.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Cl),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),bd.initNonuniformCatmullRom(c.x,d.x,h.x,u.x,m,y,g),wd.initNonuniformCatmullRom(c.y,d.y,h.y,u.y,m,y,g),Md.initNonuniformCatmullRom(c.z,d.z,h.z,u.z,m,y,g)}else this.curveType==="catmullrom"&&(bd.initCatmullRom(c.x,d.x,h.x,u.x,this.tension),wd.initCatmullRom(c.y,d.y,h.y,u.y,this.tension),Md.initCatmullRom(c.z,d.z,h.z,u.z,this.tension));return i.set(bd.calc(l),wd.calc(l),Md.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new R().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};Fa=class extends an{constructor(e=new te,t=new te,i=new te,r=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new te){let i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(ha(e,r.x,s.x,a.x,o.x),ha(e,r.y,s.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},gc=class extends an{constructor(e=new R,t=new R,i=new R,r=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new R){let i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(ha(e,r.x,s.x,a.x,o.x),ha(e,r.y,s.y,a.y,o.y),ha(e,r.z,s.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ka=class extends an{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},yc=class extends an{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ba=class extends an{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(da(e,r.x,s.x,a.x),da(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},za=class extends an{constructor(e=new R,t=new R,i=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new R){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(da(e,r.x,s.x,a.x),da(e,r.y,s.y,a.y),da(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Va=class extends an{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return i.set(pg(o,l.x,c.x,u.x,d.x),pg(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new te().fromArray(r))}return this}},vc=Object.freeze({__proto__:null,ArcCurve:pc,CatmullRomCurve3:mc,CubicBezierCurve:Fa,CubicBezierCurve3:gc,EllipseCurve:ys,LineCurve:ka,LineCurve3:yc,QuadraticBezierCurve:Ba,QuadraticBezierCurve3:za,SplineCurve:Va}),xc=class extends an{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new vc[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){let u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new vc[r.type]().fromJSON(r))}return this}},fr=class extends xc{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ka(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Ba(this.currentPoint.clone(),new te(e,t),new te(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let o=new Fa(this.currentPoint.clone(),new te(e,t),new te(i,r),new te(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Va(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){let c=new ys(e,t,i,r,s,a,o,l);if(this.curves.length>0){let d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Ha=class n extends Xe{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=gt(r,0,Math.PI*2);let s=[],a=[],o=[],l=[],c=[],u=1/t,d=new R,h=new te,f=new R,m=new R,y=new R,g=0,p=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,p=e[x+1].y-e[x].y,f.x=p*1,f.y=-g,f.z=p*0,y.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,p=e[x+1].y-e[x].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),l.push(f.x,f.y,f.z),y.copy(m)}for(let x=0;x<=t;x++){let v=i+x*u*r,b=Math.sin(v),L=Math.cos(v);for(let A=0;A<=e.length-1;A++){d.x=e[A].x*b,d.y=e[A].y,d.z=e[A].x*L,a.push(d.x,d.y,d.z),h.x=x/t,h.y=A/(e.length-1),o.push(h.x,h.y);let E=l[3*A+0]*b,D=l[3*A+1],M=l[3*A+0]*L;c.push(E,D,M)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){let b=v+x*e.length,L=b,A=b+e.length,E=b+e.length+1,D=b+1;s.push(L,A,D),s.push(E,D,A)}this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("uv",new Te(o,2)),this.setAttribute("normal",new Te(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},_c=class n extends Ha{constructor(e=1,t=1,i=4,r=8){let s=new fr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},bc=class n extends Xe{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],a=[],o=[],l=[],c=new R,u=new te;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[h]/e+1)/2,u.y=(a[h+1]/e+1)/2,l.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(o,3)),this.setAttribute("uv",new Te(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},vs=class n extends Xe{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};let c=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],m=0,y=[],g=i/2,p=0;x(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(f,2));function x(){let b=new R,L=new R,A=0,E=(t-e)/i;for(let D=0;D<=s;D++){let M=[],w=D/s,T=w*(t-e)+e;for(let U=0;U<=r;U++){let I=U/r,B=I*l+o,W=Math.sin(B),F=Math.cos(B);L.x=T*W,L.y=-w*i+g,L.z=T*F,d.push(L.x,L.y,L.z),b.set(W,E,F).normalize(),h.push(b.x,b.y,b.z),f.push(I,1-w),M.push(m++)}y.push(M)}for(let D=0;D<r;D++)for(let M=0;M<s;M++){let w=y[M][D],T=y[M+1][D],U=y[M+1][D+1],I=y[M][D+1];u.push(w,T,I),u.push(T,U,I),A+=6}c.addGroup(p,A,0),p+=A}function v(b){let L=m,A=new te,E=new R,D=0,M=b===!0?e:t,w=b===!0?1:-1;for(let U=1;U<=r;U++)d.push(0,g*w,0),h.push(0,w,0),f.push(.5,.5),m++;let T=m;for(let U=0;U<=r;U++){let B=U/r*l+o,W=Math.cos(B),F=Math.sin(B);E.x=M*F,E.y=g*w,E.z=M*W,d.push(E.x,E.y,E.z),h.push(0,w,0),A.x=W*.5+.5,A.y=F*.5*w+.5,f.push(A.x,A.y),m++}for(let U=0;U<r;U++){let I=L+U,B=T+U;b===!0?u.push(B,B+1,I):u.push(B+1,B,I),D+=3}c.addGroup(p,D,b===!0?1:2),p+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},wc=class n extends vs{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ri=class n extends Xe{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){let v=new R,b=new R,L=new R;for(let A=0;A<t.length;A+=3)f(t[A+0],v),f(t[A+1],b),f(t[A+2],L),l(v,b,L,x)}function l(x,v,b,L){let A=L+1,E=[];for(let D=0;D<=A;D++){E[D]=[];let M=x.clone().lerp(b,D/A),w=v.clone().lerp(b,D/A),T=A-D;for(let U=0;U<=T;U++)U===0&&D===A?E[D][U]=M:E[D][U]=M.clone().lerp(w,U/T)}for(let D=0;D<A;D++)for(let M=0;M<2*(A-D)-1;M++){let w=Math.floor(M/2);M%2===0?(h(E[D][w+1]),h(E[D+1][w]),h(E[D][w])):(h(E[D][w+1]),h(E[D+1][w+1]),h(E[D+1][w]))}}function c(x){let v=new R;for(let b=0;b<s.length;b+=3)v.x=s[b+0],v.y=s[b+1],v.z=s[b+2],v.normalize().multiplyScalar(x),s[b+0]=v.x,s[b+1]=v.y,s[b+2]=v.z}function u(){let x=new R;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let b=g(x)/2/Math.PI+.5,L=p(x)/Math.PI+.5;a.push(b,1-L)}m(),d()}function d(){for(let x=0;x<a.length;x+=6){let v=a[x+0],b=a[x+2],L=a[x+4],A=Math.max(v,b,L),E=Math.min(v,b,L);A>.9&&E<.1&&(v<.2&&(a[x+0]+=1),b<.2&&(a[x+2]+=1),L<.2&&(a[x+4]+=1))}}function h(x){s.push(x.x,x.y,x.z)}function f(x,v){let b=x*3;v.x=e[b+0],v.y=e[b+1],v.z=e[b+2]}function m(){let x=new R,v=new R,b=new R,L=new R,A=new te,E=new te,D=new te;for(let M=0,w=0;M<s.length;M+=9,w+=6){x.set(s[M+0],s[M+1],s[M+2]),v.set(s[M+3],s[M+4],s[M+5]),b.set(s[M+6],s[M+7],s[M+8]),A.set(a[w+0],a[w+1]),E.set(a[w+2],a[w+3]),D.set(a[w+4],a[w+5]),L.copy(x).add(v).add(b).divideScalar(3);let T=g(L);y(A,w+0,x,T),y(E,w+2,v,T),y(D,w+4,b,T)}}function y(x,v,b,L){L<0&&x.x===1&&(a[v]=x.x-1),b.x===0&&b.z===0&&(a[v]=L/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function p(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},Mc=class n extends Ri{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[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(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Rl=new R,Pl=new R,Sd=new R,Ll=new Qn,Sc=class extends Xe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(or*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);let{a:y,b:g,c:p}=Ll;if(y.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),p.fromBufferAttribute(o,c[2]),Ll.getNormal(Sd),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let x=0;x<3;x++){let v=(x+1)%3,b=d[x],L=d[v],A=Ll[u[x]],E=Ll[u[v]],D=`${b}_${L}`,M=`${L}_${b}`;M in h&&h[M]?(Sd.dot(h[M].normal)<=s&&(f.push(A.x,A.y,A.z),f.push(E.x,E.y,E.z)),h[M]=null):D in h||(h[D]={index0:c[x],index1:c[v],normal:Sd.clone()})}}for(let m in h)if(h[m]){let{index0:y,index1:g}=h[m];Rl.fromBufferAttribute(o,y),Pl.fromBufferAttribute(o,g),f.push(Rl.x,Rl.y,Rl.z),f.push(Pl.x,Pl.y,Pl.z)}this.setAttribute("position",new Te(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ii=class extends fr{constructor(e){super(e),this.uuid=tn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new fr().fromJSON(r))}return this}},kE={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=ay(n,0,r,t,!0),a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,d,h,f;if(i&&(s=GE(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)d=n[m],h=n[m+1],d<o&&(o=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);f=Math.max(c-o,u-l),f=f!==0?32767/f:0}return Ga(s,a,t,o,l,f,0),a}};Un=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];gg(e),yg(i,e);let a=e.length;t.forEach(gg);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,yg(i,t[l]);let o=kE.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}};Ac=class n extends Xe{constructor(e=new ii([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){let c=e[o];a(c)}this.setAttribute("position",new Te(r,3)),this.setAttribute("uv",new Te(s,2)),this.computeVertexNormals();function a(o){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:tT,v,b=!1,L,A,E,D;p&&(v=p.getSpacedPoints(u),b=!0,h=!1,L=p.computeFrenetFrames(u,!1),A=new R,E=new R,D=new R),h||(g=0,f=0,m=0,y=0);let M=o.extractPoints(c),w=M.shape,T=M.holes;if(!Un.isClockWise(w)){w=w.reverse();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];Un.isClockWise(K)&&(T[J]=K.reverse())}}let I=Un.triangulateShape(w,T),B=w;for(let J=0,ce=T.length;J<ce;J++){let K=T[J];w=w.concat(K)}function W(J,ce,K){return ce||console.error("THREE.ExtrudeGeometry: vec does not exist"),J.clone().addScaledVector(ce,K)}let F=w.length,X=I.length;function k(J,ce,K){let de,le,he,Ae=J.x-ce.x,P=J.y-ce.y,S=K.x-J.x,j=K.y-J.y,ee=Ae*Ae+P*P,ae=Ae*j-P*S;if(Math.abs(ae)>Number.EPSILON){let ie=Math.sqrt(ee),Ce=Math.sqrt(S*S+j*j),me=ce.x-P/ie,ge=ce.y+Ae/ie,ke=K.x-j/Ce,fe=K.y+S/Ce,Re=((ke-me)*j-(fe-ge)*S)/(Ae*j-P*S);de=me+Ae*Re-J.x,le=ge+P*Re-J.y;let We=de*de+le*le;if(We<=2)return new te(de,le);he=Math.sqrt(We/2)}else{let ie=!1;Ae>Number.EPSILON?S>Number.EPSILON&&(ie=!0):Ae<-Number.EPSILON?S<-Number.EPSILON&&(ie=!0):Math.sign(P)===Math.sign(j)&&(ie=!0),ie?(de=-P,le=Ae,he=Math.sqrt(ee)):(de=Ae,le=P,he=Math.sqrt(ee/2))}return new te(de/he,le/he)}let re=[];for(let J=0,ce=B.length,K=ce-1,de=J+1;J<ce;J++,K++,de++)K===ce&&(K=0),de===ce&&(de=0),re[J]=k(B[J],B[K],B[de]);let se=[],ve,Le=re.concat();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];ve=[];for(let de=0,le=K.length,he=le-1,Ae=de+1;de<le;de++,he++,Ae++)he===le&&(he=0),Ae===le&&(Ae=0),ve[de]=k(K[de],K[he],K[Ae]);se.push(ve),Le=Le.concat(ve)}for(let J=0;J<g;J++){let ce=J/g,K=f*Math.cos(ce*Math.PI/2),de=m*Math.sin(ce*Math.PI/2)+y;for(let le=0,he=B.length;le<he;le++){let Ae=W(B[le],re[le],de);ne(Ae.x,Ae.y,-K)}for(let le=0,he=T.length;le<he;le++){let Ae=T[le];ve=se[le];for(let P=0,S=Ae.length;P<S;P++){let j=W(Ae[P],ve[P],de);ne(j.x,j.y,-K)}}}let Je=m+y;for(let J=0;J<F;J++){let ce=h?W(w[J],Le[J],Je):w[J];b?(E.copy(L.normals[0]).multiplyScalar(ce.x),A.copy(L.binormals[0]).multiplyScalar(ce.y),D.copy(v[0]).add(E).add(A),ne(D.x,D.y,D.z)):ne(ce.x,ce.y,0)}for(let J=1;J<=u;J++)for(let ce=0;ce<F;ce++){let K=h?W(w[ce],Le[ce],Je):w[ce];b?(E.copy(L.normals[J]).multiplyScalar(K.x),A.copy(L.binormals[J]).multiplyScalar(K.y),D.copy(v[J]).add(E).add(A),ne(D.x,D.y,D.z)):ne(K.x,K.y,d/u*J)}for(let J=g-1;J>=0;J--){let ce=J/g,K=f*Math.cos(ce*Math.PI/2),de=m*Math.sin(ce*Math.PI/2)+y;for(let le=0,he=B.length;le<he;le++){let Ae=W(B[le],re[le],de);ne(Ae.x,Ae.y,d+K)}for(let le=0,he=T.length;le<he;le++){let Ae=T[le];ve=se[le];for(let P=0,S=Ae.length;P<S;P++){let j=W(Ae[P],ve[P],de);b?ne(j.x,j.y+v[u-1].y,v[u-1].x+K):ne(j.x,j.y,d+K)}}}Z(),q();function Z(){let J=r.length/3;if(h){let ce=0,K=F*ce;for(let de=0;de<X;de++){let le=I[de];Fe(le[2]+K,le[1]+K,le[0]+K)}ce=u+g*2,K=F*ce;for(let de=0;de<X;de++){let le=I[de];Fe(le[0]+K,le[1]+K,le[2]+K)}}else{for(let ce=0;ce<X;ce++){let K=I[ce];Fe(K[2],K[1],K[0])}for(let ce=0;ce<X;ce++){let K=I[ce];Fe(K[0]+F*u,K[1]+F*u,K[2]+F*u)}}i.addGroup(J,r.length/3-J,0)}function q(){let J=r.length/3,ce=0;pe(B,ce),ce+=B.length;for(let K=0,de=T.length;K<de;K++){let le=T[K];pe(le,ce),ce+=le.length}i.addGroup(J,r.length/3-J,1)}function pe(J,ce){let K=J.length;for(;--K>=0;){let de=K,le=K-1;le<0&&(le=J.length-1);for(let he=0,Ae=u+g*2;he<Ae;he++){let P=F*he,S=F*(he+1),j=ce+de+P,ee=ce+le+P,ae=ce+le+S,ie=ce+de+S;_e(j,ee,ae,ie)}}}function ne(J,ce,K){l.push(J),l.push(ce),l.push(K)}function Fe(J,ce,K){H(J),H(ce),H(K);let de=r.length/3,le=x.generateTopUV(i,r,de-3,de-2,de-1);Ue(le[0]),Ue(le[1]),Ue(le[2])}function _e(J,ce,K,de){H(J),H(ce),H(de),H(ce),H(K),H(de);let le=r.length/3,he=x.generateSideWallUV(i,r,le-6,le-3,le-2,le-1);Ue(he[0]),Ue(he[1]),Ue(he[3]),Ue(he[1]),Ue(he[2]),Ue(he[3])}function H(J){r.push(l[J*3+0]),r.push(l[J*3+1]),r.push(l[J*3+2])}function Ue(J){s.push(J.x),s.push(J.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return nT(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,a=e.shapes.length;s<a;s++){let o=t[e.shapes[s]];i.push(o)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new vc[r.type]().fromJSON(r)),new n(i,e.options)}},tT={generateTopUV:function(n,e,t,i,r){let s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new te(s,a),new te(o,l),new te(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){let a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],m=e[r*3+2],y=e[s*3],g=e[s*3+1],p=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new te(a,1-l),new te(c,1-d),new te(h,1-m),new te(y,1-p)]:[new te(o,1-l),new te(u,1-d),new te(f,1-m),new te(g,1-p)]}};Ec=class n extends Ri{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[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(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},ja=class n extends Ri{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[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(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Tc=class n extends Xe{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);let o=[],l=[],c=[],u=[],d=e,h=(t-e)/r,f=new R,m=new te;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let p=s+g/i*a;f.x=d*Math.cos(p),f.y=d*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),m.x=(f.x/t+1)/2,m.y=(f.y/t+1)/2,u.push(m.x,m.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let p=0;p<i;p++){let x=p+g,v=x,b=x+i+1,L=x+i+2,A=x+1;o.push(v,b,A),o.push(b,L,A)}}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Ic=class n extends Xe{constructor(e=new ii([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],a=[],o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new Te(r,3)),this.setAttribute("normal",new Te(s,3)),this.setAttribute("uv",new Te(a,2));function c(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,m=h.holes;Un.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,p=m.length;g<p;g++){let x=m[g];Un.isClockWise(x)===!0&&(m[g]=x.reverse())}let y=Un.triangulateShape(f,m);for(let g=0,p=m.length;g<p;g++){let x=m[g];f=f.concat(x)}for(let g=0,p=f.length;g<p;g++){let x=f[g];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let g=0,p=y.length;g<p;g++){let x=y[g],v=x[0]+d,b=x[1]+d,L=x[2]+d;i.push(v,b,L),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return iT(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let a=t[e.shapes[r]];i.push(a)}return new n(i,e.curveSegments)}};Xa=class n extends Xe{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let l=Math.min(a+o,Math.PI),c=0,u=[],d=new R,h=new R,f=[],m=[],y=[],g=[];for(let p=0;p<=i;p++){let x=[],v=p/i,b=0;p===0&&a===0?b=.5/t:p===i&&l===Math.PI&&(b=-.5/t);for(let L=0;L<=t;L++){let A=L/t;d.x=-e*Math.cos(r+A*s)*Math.sin(a+v*o),d.y=e*Math.cos(a+v*o),d.z=e*Math.sin(r+A*s)*Math.sin(a+v*o),m.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(A+b,1-v),x.push(c++)}u.push(x)}for(let p=0;p<i;p++)for(let x=0;x<t;x++){let v=u[p][x+1],b=u[p][x],L=u[p+1][x],A=u[p+1][x+1];(p!==0||a>0)&&f.push(v,b,A),(p!==i-1||l<Math.PI)&&f.push(b,L,A)}this.setIndex(f),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(y,3)),this.setAttribute("uv",new Te(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},Cc=class n extends Ri{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Rc=class n extends Xe{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],c=[],u=new R,d=new R,h=new R;for(let f=0;f<=i;f++)for(let m=0;m<=r;m++){let y=m/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),o.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),l.push(h.x,h.y,h.z),c.push(m/r),c.push(f/i)}for(let f=1;f<=i;f++)for(let m=1;m<=r;m++){let y=(r+1)*f+m-1,g=(r+1)*(f-1)+m-1,p=(r+1)*(f-1)+m,x=(r+1)*f+m;a.push(y,g,x),a.push(g,p,x)}this.setIndex(a),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},Pc=class n extends Xe{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let o=[],l=[],c=[],u=[],d=new R,h=new R,f=new R,m=new R,y=new R,g=new R,p=new R;for(let v=0;v<=i;++v){let b=v/i*s*Math.PI*2;x(b,s,a,e,f),x(b+.01,s,a,e,m),g.subVectors(m,f),p.addVectors(m,f),y.crossVectors(g,p),p.crossVectors(y,g),y.normalize(),p.normalize();for(let L=0;L<=r;++L){let A=L/r*Math.PI*2,E=-t*Math.cos(A),D=t*Math.sin(A);d.x=f.x+(E*p.x+D*y.x),d.y=f.y+(E*p.y+D*y.y),d.z=f.z+(E*p.z+D*y.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),c.push(h.x,h.y,h.z),u.push(v/i),u.push(L/r)}}for(let v=1;v<=i;v++)for(let b=1;b<=r;b++){let L=(r+1)*(v-1)+(b-1),A=(r+1)*v+(b-1),E=(r+1)*v+b,D=(r+1)*(v-1)+b;o.push(L,A,D),o.push(A,E,D)}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function x(v,b,L,A,E){let D=Math.cos(v),M=Math.sin(v),w=L/b*v,T=Math.cos(w);E.x=A*(2+T)*.5*D,E.y=A*(2+T)*M*.5,E.z=A*Math.sin(w)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},Lc=class n extends Xe{constructor(e=new za(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new R,l=new R,c=new te,u=new R,d=[],h=[],f=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(f,2));function y(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),x(),p()}function g(v){u=e.getPointAt(v/t,u);let b=a.normals[v],L=a.binormals[v];for(let A=0;A<=r;A++){let E=A/r*Math.PI*2,D=Math.sin(E),M=-Math.cos(E);l.x=M*b.x+D*L.x,l.y=M*b.y+D*L.y,l.z=M*b.z+D*L.z,l.normalize(),h.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,d.push(o.x,o.y,o.z)}}function p(){for(let v=1;v<=t;v++)for(let b=1;b<=r;b++){let L=(r+1)*(v-1)+(b-1),A=(r+1)*v+(b-1),E=(r+1)*v+b,D=(r+1)*(v-1)+b;m.push(L,A,D),m.push(A,E,D)}}function x(){for(let v=0;v<=t;v++)for(let b=0;b<=r;b++)c.x=v/t,c.y=b/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new vc[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},Dc=class extends Xe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new R,s=new R;if(e.index!==null){let a=e.attributes.position,o=e.index,l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){let d=l[c],h=d.start,f=d.count;for(let m=h,y=h+f;m<y;m+=3)for(let g=0;g<3;g++){let p=o.getX(m+g),x=o.getX(m+(g+1)%3);r.fromBufferAttribute(a,p),s.fromBufferAttribute(a,x),vg(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){let u=3*o+c,d=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,d),vg(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Te(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};xg=Object.freeze({__proto__:null,BoxGeometry:cr,CapsuleGeometry:_c,CircleGeometry:bc,ConeGeometry:wc,CylinderGeometry:vs,DodecahedronGeometry:Mc,EdgesGeometry:Sc,ExtrudeGeometry:Ac,IcosahedronGeometry:Ec,LatheGeometry:Ha,OctahedronGeometry:ja,PlaneGeometry:fs,PolyhedronGeometry:Ri,RingGeometry:Tc,ShapeGeometry:Ic,SphereGeometry:Xa,TetrahedronGeometry:Cc,TorusGeometry:Rc,TorusKnotGeometry:Pc,TubeGeometry:Lc,WireframeGeometry:Dc}),Oc=class extends Lt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new we(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Uc=class extends sn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ya=class extends Lt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new we(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 we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Nc=class extends Ya{constructor(e){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 te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new we(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 we(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new we(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Fc=class extends Lt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new we(16777215),this.specular=new we(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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=to,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},kc=class extends Lt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new we(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Bc=class extends Lt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},zc=class extends Lt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new we(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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=to,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Vc=class extends Lt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new we(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Hc=class extends Ot{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};aT={convertArray:rr,isTypedArray:cy,getKeyframeOrder:uy,sortedArray:Oh,flattenJSON:Vf,subclip:rT,makeClipAdditive:sT},mr=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break n}if(!(e>=s)){let o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break n}break e}for(;i<a;){let o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Gc=class extends mr{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:nr,endingEnd:nr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case ir:s=e,o=2*t-i;break;case _a:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case ir:a=e,l=2*i-t;break;case _a:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}let c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,p=-h*g+2*h*y-h*m,x=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*m+1,v=(-1-f)*g+(1.5+f)*y+.5*m,b=f*g-f*y;for(let L=0;L!==o;++L)s[L]=p*a[u+L]+x*a[c+L]+v*a[l+L]+b*a[d+L];return s}},qa=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==o;++h)s[h]=a[c+h]*d+a[l+h]*u;return s}},$c=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},on=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=rr(t,this.TimeBufferType),this.values=rr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:rr(e.times,Array),values:rr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $c(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new qa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Gc(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case va:t=this.InterpolantFactoryMethodDiscrete;break;case xa:t=this.InterpolantFactoryMethodLinear;break;case Xl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return va;case this.InterpolantFactoryMethodLinear:return xa;case this.InterpolantFactoryMethodSmooth:return Xl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){let l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&cy(r))for(let o=0,l=r.length;o!==l;++o){let c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Xl,s=e.length-1,a=1;for(let o=1;o<s;++o){let l=!1,c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{let d=o*i,h=d-i,f=d+i;for(let m=0;m!==i;++m){let y=t[d+m];if(y!==t[h+m]||y!==t[f+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];let d=o*i,h=a*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};on.prototype.TimeBufferType=Float32Array;on.prototype.ValueBufferType=Float32Array;on.prototype.DefaultInterpolation=xa;oi=class extends on{};oi.prototype.ValueTypeName="bool";oi.prototype.ValueBufferType=Array;oi.prototype.DefaultInterpolation=va;oi.prototype.InterpolantFactoryMethodLinear=void 0;oi.prototype.InterpolantFactoryMethodSmooth=void 0;Za=class extends on{};Za.prototype.ValueTypeName="color";gr=class extends on{};gr.prototype.ValueTypeName="number";Wc=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t),c=e*o;for(let u=c+o;c!==u;c+=4)Vt.slerpFlat(s,0,a,c-o,a,c,l);return s}},Pi=class extends on{InterpolantFactoryMethodLinear(e){return new Wc(this.times,this.values,this.getValueSize(),e)}};Pi.prototype.ValueTypeName="quaternion";Pi.prototype.DefaultInterpolation=xa;Pi.prototype.InterpolantFactoryMethodSmooth=void 0;li=class extends on{};li.prototype.ValueTypeName="string";li.prototype.ValueBufferType=Array;li.prototype.DefaultInterpolation=va;li.prototype.InterpolantFactoryMethodLinear=void 0;li.prototype.InterpolantFactoryMethodSmooth=void 0;yr=class extends on{};yr.prototype.ValueTypeName="vector";vr=class{constructor(e="",t=-1,i=[],r=lu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=tn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(lT(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(on.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);let u=uy(l);l=Oh(l,1,u),c=Oh(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new gr(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){let c=e[o],u=c.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(c)}}let a=[];for(let o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,m,y){if(f.length!==0){let g=[],p=[];Vf(f,g,p,m),g.length!==0&&y.push(new d(h,g,p))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let d=0;d<c.length;d++){let h=c[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},m;for(m=0;m<h.length;m++)if(h[m].morphTargets)for(let y=0;y<h[m].morphTargets.length;y++)f[h[m].morphTargets[y]]=-1;for(let y in f){let g=[],p=[];for(let x=0;x!==h[m].morphTargets.length;++x){let v=h[m];g.push(v.time),p.push(v.morphTarget===y?1:0)}r.push(new gr(".morphTargetInfluence["+y+"]",g,p))}l=f.length*a}else{let f=".bones["+t[d].name+"]";i(yr,f+".position",h,"pos",r),i(Pi,f+".quaternion",h,"rot",r),i(yr,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};ei={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Ja=class{constructor(e,t,i){let r=this,s=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){let d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;d<h;d+=2){let f=c[d],m=c[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return m}return null}}},dy=new Ja,Ht=class{constructor(e){this.manager=e!==void 0?e:dy,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Ht.DEFAULT_MATERIAL_NAME="__DEFAULT";qn={},Uh=class extends Error{constructor(e,t){super(e),this.response=t}},Tn=class extends Ht{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=ei.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(qn[e]!==void 0){qn[e].push({onLoad:t,onProgress:i,onError:r});return}qn[e]=[],qn[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=qn[e],d=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=h?parseInt(h):0,m=f!==0,y=0,g=new ReadableStream({start(p){x();function x(){d.read().then(({done:v,value:b})=>{if(v)p.close();else{y+=b.byteLength;let L=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:f});for(let A=0,E=u.length;A<E;A++){let D=u[A];D.onProgress&&D.onProgress(L)}p.enqueue(b),x()}})}}});return new Response(g)}else throw new Uh(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{let d=/charset="?([^;"\s]*)"?/i.exec(o),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{ei.add(e,c);let u=qn[e];delete qn[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=qn[e];if(u===void 0)throw this.manager.itemError(e),c;delete qn[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Nh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Tn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=vr.parse(e[i]);t.push(r)}return t}},Fh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=[],o=new gs,l=new Tn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(d){l.load(e[d],function(h){let f=s.parse(h,!0);a[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(o.minFilter=bt),o.image=a,o.format=f.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else l.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let m=0;m<f;m++){a[m]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)a[m].mipmaps.push(h.mipmaps[m*h.mipmapCount+y]),a[m].format=h.format,a[m].width=h.width,a[m].height=h.height}o.image=a}else o.image.width=h.width,o.image.height=h.height,o.mipmaps=h.mipmaps;h.mipmapCount===1&&(o.minFilter=bt),o.format=h.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}},xr=class extends Ht{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=ei.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let o=Ea("img");function l(){u(),ei.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}},kh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=new ur;s.colorSpace=mn;let a=new xr(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}},Bh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new On,o=new Tn(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:gn,a.wrapT=c.wrapT!==void 0?c.wrapT:gn,a.magFilter=c.magFilter!==void 0?c.magFilter:bt,a.minFilter=c.minFilter!==void 0?c.minFilter:bt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Ln),c.mipmapCount===1&&(a.minFilter=bt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}},zh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=new wt,a=new xr(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},kn=class extends it{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new we(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},jc=class extends kn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.groundColor=new we(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Ad=new Ne,_g=new R,bg=new R,Ka=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.map=null,this.mapPass=null,this.matrix=new Ne,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new dr,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new ot(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;_g.setFromMatrixPosition(e.matrixWorld),t.position.copy(_g),bg.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bg),t.updateMatrixWorld(),Ad.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ad),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ad)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Vh=class extends Ka{constructor(){super(new At(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ls*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Xc=class extends kn{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new Vh}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},wg=new Ne,sa=new R,Ed=new R,Hh=class extends Ka{constructor(){super(new At(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(4,2),this._viewportCount=6,this._viewports=[new ot(2,1,1,1),new ot(0,1,1,1),new ot(3,1,1,1),new ot(1,1,1,1),new ot(3,0,1,1),new ot(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),sa.setFromMatrixPosition(e.matrixWorld),i.position.copy(sa),Ed.copy(i.position),Ed.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Ed),i.updateMatrixWorld(),r.makeTranslation(-sa.x,-sa.y,-sa.z),wg.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wg)}},Yc=class extends kn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Hh}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Gh=class extends Ka{constructor(){super(new ps(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qc=class extends kn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.shadow=new Gh}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Zc=class extends kn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Jc=class extends kn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Kc=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new R)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Qc=class extends kn{constructor(e=new Kc,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},eu=class n extends Ht{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,a=new Tn(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new we().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new we().setHex(a.value);break;case"v2":r.uniforms[s].value=new te().fromArray(a.value);break;case"v3":r.uniforms[s].value=new R().fromArray(a.value);break;case"v4":r.uniforms[s].value=new ot().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ve().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Ne().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new te().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:Oc,SpriteMaterial:Oa,RawShaderMaterial:Uc,ShaderMaterial:sn,PointsMaterial:Na,MeshPhysicalMaterial:Nc,MeshStandardMaterial:Ya,MeshPhongMaterial:Fc,MeshToonMaterial:kc,MeshNormalMaterial:Bc,MeshLambertMaterial:zc,MeshDepthMaterial:La,MeshDistanceMaterial:Da,MeshBasicMaterial:Nn,MeshMatcapMaterial:Vc,LineDashedMaterial:Hc,LineBasicMaterial:Ot,Material:Lt};return new t[e]}},Qa=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},tu=class extends Xe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},nu=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Tn(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],p=s(f,g.buffer),x=ns(g.type,p),v=new ms(x,g.stride);return v.uuid=g.uuid,t[m]=v,v}function s(f,m){if(i[m]!==void 0)return i[m];let g=f.arrayBuffers[m],p=new Uint32Array(g).buffer;return i[m]=p,p}let a=e.isInstancedBufferGeometry?new tu:new Xe,o=e.data.index;if(o!==void 0){let f=ns(o.type,o.array);a.setIndex(new tt(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],y;if(m.isInterleavedBufferAttribute){let g=r(e.data,m.data);y=new hr(g,m.itemSize,m.offset,m.normalized)}else{let g=ns(m.type,m.array),p=m.isInstancedBufferAttribute?Ci:tt;y=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),m.usage!==void 0&&y.setUsage(m.usage),a.setAttribute(f,y)}let c=e.data.morphAttributes;if(c)for(let f in c){let m=c[f],y=[];for(let g=0,p=m.length;g<p;g++){let x=m[g],v;if(x.isInterleavedBufferAttribute){let b=r(e.data,x.data);v=new hr(b,x.itemSize,x.offset,x.normalized)}else{let b=ns(x.type,x.array);v=new tt(b,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),y.push(v)}a.morphAttributes[f]=y}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,m=d.length;f!==m;++f){let y=d[f];a.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new R;h.center!==void 0&&f.fromArray(h.center),a.boundingSphere=new Pt(f,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},$h=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=this.path===""?Qa.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let o=new Tn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?Qa.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Tn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let d=!1;for(let h in a)if(a[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new ii().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){let o=new oc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new nu;for(let s=0,a=e.length;s<a;s++){let o,l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in xg?o=xg[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new eu;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){let l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=vr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){let c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:ns(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){let l=new Ja(t);s=new xr(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){let d=e[c],h=d.url;if(Array.isArray(h)){let f=[];for(let m=0,y=h.length;m<y;m++){let g=h[m],p=o(g);p!==null&&(p instanceof HTMLImageElement?f.push(p):f.push(new On(p.data,p.width,p.height)))}r[d.uuid]=new Kn(f)}else{let f=o(d.url);r[d.uuid]=new Kn(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(a){if(typeof a=="string"){let o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:ns(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new xr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){let l=e[a],c=l.url;if(Array.isArray(c)){let u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d],m=await s(f);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new On(m.data,m.width,m.height)))}i[l.uuid]=new Kn(u)}else{let u=await s(l.url);i[l.uuid]=new Kn(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}let r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){let o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);let l=t[o.image],c=l.data,u;Array.isArray(c)?(u=new ur,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new On:u=new wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,cT)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],Mg),u.wrapT=i(o.wrap[1],Mg)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,Sg)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,Sg)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function l(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let m=0,y=h.length;m<y;m++){let g=h[m];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function c(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":a=new ic,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new we(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new nc(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new tc(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new At(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new ps(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Zc(e.color,e.intensity);break;case"DirectionalLight":a=new qc(e.color,e.intensity);break;case"PointLight":a=new Yc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Jc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Xc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new jc(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Qc().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),d=l(e.material),a=new ac(u,d),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":u=o(e.geometry),d=l(e.material),a=new yt(u,d);break;case"InstancedMesh":u=o(e.geometry),d=l(e.material);let h=e.count,f=e.instanceMatrix,m=e.instanceColor;a=new lc(u,d,h),a.instanceMatrix=new Ci(new Float32Array(f.array),16),m!==void 0&&(a.instanceColor=new Ci(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),d=l(e.material),a=new cc(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(y=>{let g=new Dt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let p=new Pt;return p.radius=y.sphereRadius,p.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:p}}),a._maxGeometryCount=e.maxGeometryCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid);break;case"LOD":a=new sc;break;case"Line":a=new Fn(o(e.geometry),l(e.material));break;case"LineLoop":a=new hc(o(e.geometry),l(e.material));break;case"LineSegments":a=new vn(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new fc(o(e.geometry),l(e.material));break;case"Sprite":a=new rc(l(e.material));break;case"Group":a=new Ei;break;case"Bone":a=new Ua;break;default:a=new it}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)a.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let m=h[f];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let m=h[f],y=a.getObjectByProperty("uuid",m.object);y!==void 0&&a.addLevel(y,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},cT={UVMapping:ou,CubeReflectionMapping:si,CubeRefractionMapping:Ti,EquirectangularReflectionMapping:pa,EquirectangularRefractionMapping:ma,CubeUVReflectionMapping:xs},Mg={RepeatWrapping:ga,ClampToEdgeWrapping:gn,MirroredRepeatWrapping:ya},Sg={NearestFilter:Rt,NearestMipmapNearestFilter:Tf,NearestMipmapLinearFilter:ts,LinearFilter:bt,LinearMipmapNearestFilter:la,LinearMipmapLinearFilter:Ln},Wh=class extends Ht{constructor(e){super(e),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"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=ei.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;let l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return ei.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ei.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ei.add(e,l),s.manager.itemStart(e)}},eo=class{static getContext(){return Ul===void 0&&(Ul=new(window.AudioContext||window.webkitAudioContext)),Ul}static setContext(e){Ul=e}},jh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Tn(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{let c=l.slice(0);eo.getContext().decodeAudioData(c,function(d){t(d)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}},Ag=new Ne,Eg=new Ne,Yi=new Ne,Xh=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new At,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new At,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Yi.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(or*t.fov*.5)/t.zoom,o,l;Eg.elements[12]=-r,Ag.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,Yi.elements[0]=2*t.near/(l-o),Yi.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Yi),o=-a*t.aspect-s,l=a*t.aspect-s,Yi.elements[0]=2*t.near/(l-o),Yi.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Yi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Eg),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ag)}},iu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Tg(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Tg();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};qi=new R,Ig=new Vt,uT=new R,Zi=new R,Yh=class extends it{constructor(){super(),this.type="AudioListener",this.context=eo.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new iu}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(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qi,Ig,uT),Zi.set(0,0,-1).applyQuaternion(Ig),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qi.x,r),t.positionY.linearRampToValueAtTime(qi.y,r),t.positionZ.linearRampToValueAtTime(qi.z,r),t.forwardX.linearRampToValueAtTime(Zi.x,r),t.forwardY.linearRampToValueAtTime(Zi.y,r),t.forwardZ.linearRampToValueAtTime(Zi.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(qi.x,qi.y,qi.z),t.setOrientation(Zi.x,Zi.y,Zi.z,i.x,i.y,i.z)}},ru=class extends it{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(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+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,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(){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.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,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(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Ji=new R,Cg=new Vt,dT=new R,Ki=new R,qh=class extends ru{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ji,Cg,dT),Ki.set(0,0,1).applyQuaternion(Cg);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ji.x,i),t.positionY.linearRampToValueAtTime(Ji.y,i),t.positionZ.linearRampToValueAtTime(Ji.z,i),t.orientationX.linearRampToValueAtTime(Ki.x,i),t.orientationY.linearRampToValueAtTime(Ki.y,i),t.orientationZ.linearRampToValueAtTime(Ki.z,i)}else t.setPosition(Ji.x,Ji.y,Ji.z),t.setOrientation(Ki.x,Ki.y,Ki.z)}},Zh=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},su=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;let o=t/a;this._mixBufferRegion(i,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Vt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;Vt.multiplyQuaternionsFlat(e,a,e,t,e,i),Vt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let o=0;o!==s;++o){let l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]+e[i+a]*r}}},Hf="\\[\\]\\.:\\/",hT=new RegExp("["+Hf+"]","g"),Gf="[^"+Hf+"]",fT="[^"+Hf.replace("\\.","")+"]",pT=/((?:WC+[\/:])*)/.source.replace("WC",Gf),mT=/(WCOD+)?/.source.replace("WCOD",fT),gT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gf),yT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gf),vT=new RegExp("^"+pT+mT+gT+yT+"$"),xT=["material","materials","bones","map"],Jh=class{constructor(e,t,i){let r=i||st.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},st=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hT,"")}static parseTrackName(e){let t=vT.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);xT.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a<s.length;a++){let o=s[a];if(o.name===t||o.uuid===t)return o;let l=i(o.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let a=e[r];if(a===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};st.Composite=Jh;st.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};st.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};st.prototype.GetterByBindingType=[st.prototype._getValue_direct,st.prototype._getValue_array,st.prototype._getValue_arrayElement,st.prototype._getValue_toArray];st.prototype.SetterByBindingTypeAndVersioning=[[st.prototype._setValue_direct,st.prototype._setValue_direct_setNeedsUpdate,st.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[st.prototype._setValue_array,st.prototype._setValue_array_setNeedsUpdate,st.prototype._setValue_array_setMatrixWorldNeedsUpdate],[st.prototype._setValue_arrayElement,st.prototype._setValue_arrayElement_setNeedsUpdate,st.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[st.prototype._setValue_fromArray,st.prototype._setValue_fromArray_setNeedsUpdate,st.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Kh=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=tn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length,o,l=e.length,c=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,m=t[f];if(m===void 0){m=l++,t[f]=m,e.push(h);for(let y=0,g=a;y!==g;++y)s[y].push(new st(h,i[y],r[y]))}else if(m<c){o=e[m];let y=--c,g=e[y];t[g.uuid]=m,e[m]=g,t[f]=y,e[y]=h;for(let p=0,x=a;p!==x;++p){let v=s[p],b=v[y],L=v[m];v[m]=b,L===void 0&&(L=new st(h,i[p],r[p])),v[y]=L}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){let l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[c]=d,e[d]=l;for(let f=0,m=r;f!==m;++f){let y=i[f],g=y[d],p=y[u];y[u]=g,y[d]=p}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){let c=arguments[o],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],m=--a,y=e[m];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,p=r;g!==p;++g){let x=i[g],v=x[h],b=x[m];x[d]=v,x[h]=b,x.pop()}}else{let h=--a,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let m=0,y=r;m!==y;++m){let g=i[m];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(d);for(let h=u,f=l.length;h!==f;++h){let m=l[h];d[h]=new st(m,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}},au=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,o=new Array(a),l={endingStart:nr,endingEnd:nr};for(let c=0;c!==a;++c){let u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=O0,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Nf:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case lu:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(a),c[u].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===U0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===D0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=ir,r.endingEnd=ir):(e?r.endingStart=this.zeroSlopeAtStart?ir:nr:r.endingStart=_a,t?r.endingEnd=this.zeroSlopeAtEnd?ir:nr:r.endingEnd=_a)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}},_T=new Float32Array(1),Qh=class extends En{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,m=u[f];if(m!==void 0)++m.referenceCount,a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;m=new su(st.create(i,f,y),h.ValueTypeName,h.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),a[d]=m}o[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;let d=o.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new qa(new Float32Array(2),new Float32Array(2),1,_T),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?vr.findByName(r,e):e,o=a!==null?a.uuid:e,l=this._actionsByClip[o],c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=lu),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let u=new au(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?vr.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);let o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){let c=a[o];this._deactivateAction(c);let u=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},ef=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},bT=0,tf=class extends En{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:bT++}),this.name="",this.usage=Sa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}},nf=class extends ms{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},rf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Rg=new Ne,sf=class{constructor(e,t,i=0,r=1/0){this.ray=new Ii(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new us,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Rg.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rg),this}intersectObject(e,t=!0,i=[]){return af(e,this,i,t),i.sort(Pg),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)af(e[r],this,i,t);return i.sort(Pg),i}};of=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(gt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},lf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},Lg=new te,cf=class{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Lg.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Lg).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Dg=new R,Nl=new R,uf=class{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Dg.subVectors(e,this.start),Nl.subVectors(this.end,this.start);let i=Nl.dot(Nl),s=Nl.dot(Dg)/i;return t&&(s=gt(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Og=new R,df=class extends it{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Xe,r=[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 a=0,o=1,l=32;a<l;a++,o++){let c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new Te(r,3));let s=new Ot({fog:!1,toneMapped:!1});this.cone=new vn(i,s),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Og.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Og),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Si=new R,Fl=new Ne,Td=new Ne,hf=class extends vn{constructor(e){let t=hy(e),i=new Xe,r=[],s=[],a=new we(0,0,1),o=new we(0,1,0);for(let c=0;c<t.length;c++){let u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new Te(r,3)),i.setAttribute("color",new Te(s,3));let l=new Ot({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");Td.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){let o=t[s];o.parent&&o.parent.isBone&&(Fl.multiplyMatrices(Td,o.matrixWorld),Si.setFromMatrixPosition(Fl),r.setXYZ(a,Si.x,Si.y,Si.z),Fl.multiplyMatrices(Td,o.parent.matrixWorld),Si.setFromMatrixPosition(Fl),r.setXYZ(a+1,Si.x,Si.y,Si.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};ff=class extends yt{constructor(e,t,i){let r=new Xa(t,4,2),s=new Nn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},wT=new R,Ug=new we,Ng=new we,pf=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new ja(t);r.rotateY(Math.PI*.5),this.material=new Nn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new tt(a,3)),this.add(new yt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Ug.copy(this.light.color),Ng.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Ug:Ng;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(wT.setFromMatrixPosition(this.light.matrixWorld).negate())}},mf=class extends vn{constructor(e=10,t=10,i=4473924,r=8947848){i=new we(i),r=new we(r);let s=t/2,a=e/t,o=e/2,l=[],c=[];for(let h=0,f=0,m=-o;h<=t;h++,m+=a){l.push(-o,0,m,o,0,m),l.push(m,0,-o,m,0,o);let y=h===s?i:r;y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3}let u=new Xe;u.setAttribute("position",new Te(l,3)),u.setAttribute("color",new Te(c,3));let d=new Ot({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},gf=class extends vn{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new we(s),a=new we(a);let o=[],l=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,m=Math.cos(h)*e;o.push(0,0,0),o.push(f,0,m);let y=d&1?s:a;l.push(y.r,y.g,y.b),l.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:a,f=e-e/i*d;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*f,p=Math.cos(y)*f;o.push(g,0,p),l.push(h.r,h.g,h.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*f,p=Math.cos(y)*f,o.push(g,0,p),l.push(h.r,h.g,h.b)}}let c=new Xe;c.setAttribute("position",new Te(o,3)),c.setAttribute("color",new Te(l,3));let u=new Ot({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Fg=new R,kl=new R,kg=new R,yf=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Xe;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Ot({fog:!1,toneMapped:!1});this.lightPlane=new Fn(r,s),this.add(this.lightPlane),r=new Xe,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Fn(r,s),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),Fg.setFromMatrixPosition(this.light.matrixWorld),kl.setFromMatrixPosition(this.light.target.matrixWorld),kg.subVectors(kl,Fg),this.lightPlane.lookAt(kl),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(kl),this.targetLine.scale.z=kg.length()}},Bl=new R,mt=new hs,vf=class extends vn{constructor(e){let t=new Xe,i=new Ot({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,y){l(m),l(y)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let c=new we(16755200),u=new we(16711680),d=new we(43775),h=new we(16777215),f=new we(3355443);this.setColors(c,u,d,h,f)}setColors(e,t,i,r,s){let o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,i.r,i.g,i.b),o.setXYZ(33,i.r,i.g,i.b),o.setXYZ(34,i.r,i.g,i.b),o.setXYZ(35,i.r,i.g,i.b),o.setXYZ(36,i.r,i.g,i.b),o.setXYZ(37,i.r,i.g,i.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;mt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),vt("c",t,e,mt,0,0,-1),vt("t",t,e,mt,0,0,1),vt("n1",t,e,mt,-i,-r,-1),vt("n2",t,e,mt,i,-r,-1),vt("n3",t,e,mt,-i,r,-1),vt("n4",t,e,mt,i,r,-1),vt("f1",t,e,mt,-i,-r,1),vt("f2",t,e,mt,i,-r,1),vt("f3",t,e,mt,-i,r,1),vt("f4",t,e,mt,i,r,1),vt("u1",t,e,mt,i*.7,r*1.1,-1),vt("u2",t,e,mt,-i*.7,r*1.1,-1),vt("u3",t,e,mt,0,r*2,-1),vt("cf1",t,e,mt,-i,0,1),vt("cf2",t,e,mt,i,0,1),vt("cf3",t,e,mt,0,-r,1),vt("cf4",t,e,mt,0,r,1),vt("cn1",t,e,mt,-i,0,-1),vt("cn2",t,e,mt,i,0,-1),vt("cn3",t,e,mt,0,-r,-1),vt("cn4",t,e,mt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};zl=new Dt,xf=class extends vn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new Xe;s.setIndex(new tt(i,1)),s.setAttribute("position",new tt(r,3)),super(s,new Ot({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&zl.setFromObject(this.object),zl.isEmpty())return;let t=zl.min,i=zl.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},_f=class extends vn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Xe;s.setIndex(new tt(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new Ot({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},bf=class extends Fn{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Xe;a.setAttribute("position",new Te(s,3)),a.computeBoundingSphere(),super(a,new Ot({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Xe;l.setAttribute("position",new Te(o,3)),l.computeBoundingSphere(),this.add(new yt(l,new Nn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},Bg=new R,wf=class extends it{constructor(e=new R(0,0,1),t=new R(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Vl===void 0&&(Vl=new Xe,Vl.setAttribute("position",new Te([0,0,0,0,1,0],3)),Id=new vs(0,.5,1,5,1),Id.translate(0,-.5,0)),this.position.copy(t),this.line=new Fn(Vl,new Ot({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new yt(Id,new Nn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Bg.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bg,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Mf=class extends vn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Xe;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new Ot({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new we,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Sf=class{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new fr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){let x=[];for(let v=0,b=p.length;v<b;v++){let L=p[v],A=new ii;A.curves=L.curves,x.push(A)}return x}function i(p,x){let v=x.length,b=!1;for(let L=v-1,A=0;A<v;L=A++){let E=x[L],D=x[A],M=D.x-E.x,w=D.y-E.y;if(Math.abs(w)>Number.EPSILON){if(w<0&&(E=x[A],M=-M,D=x[L],w=-w),p.y<E.y||p.y>D.y)continue;if(p.y===E.y){if(p.x===E.x)return!0}else{let T=w*(p.x-E.x)-M*(p.y-E.y);if(T===0)return!0;if(T<0)continue;b=!b}}else{if(p.y!==E.y)continue;if(D.x<=p.x&&p.x<=E.x||E.x<=p.x&&p.x<=D.x)return!0}}return b}let r=Un.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l,c=[];if(s.length===1)return o=s[0],l=new ii,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],m=0,y;h[m]=void 0,f[m]=[];for(let p=0,x=s.length;p<x;p++)o=s[p],y=o.getPoints(),a=r(y),a=e?!a:a,a?(!u&&h[m]&&m++,h[m]={s:new ii,p:y},h[m].s.curves=o.curves,u&&m++,f[m]=[]):f[m].push({h:o,p:y[0]});if(!h[0])return t(s);if(h.length>1){let p=!1,x=0;for(let v=0,b=h.length;v<b;v++)d[v]=[];for(let v=0,b=h.length;v<b;v++){let L=f[v];for(let A=0;A<L.length;A++){let E=L[A],D=!0;for(let M=0;M<h.length;M++)i(E.p,h[M].p)&&(v!==M&&x++,D?(D=!1,d[M].push(E)):p=!0);D&&d[v].push(E)}}x>0&&p===!1&&(f=d)}let g;for(let p=0,x=h.length;p<x;p++){l=h[p].s,c.push(l),g=f[p];for(let v=0,b=g.length;v<b;v++)l.holes.push(g[v].h)}return c}},Af=class extends nn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var rI={};Jf(rI,{DEFAULT_VIEWER_STATE:()=>fn,WORLD_LAYER_ID:()=>qo,WorldOrbit3DUnavailableError:()=>cn,WorldOrbitViewerError:()=>Cs,clampScale:()=>js,composeViewerTransform:()=>jo,createAtlasViewer:()=>mu,createEmbedPayload:()=>Py,createInteractiveViewer:()=>Di,createWorldOrbitEmbedMarkup:()=>Ly,defineWorldOrbitViewerElement:()=>Ny,deserializeViewerAtlasState:()=>yo,deserializeWorldOrbitEmbedPayload:()=>Xf,fitViewerState:()=>Bi,focusViewerState:()=>Wo,getSceneCenter:()=>zi,getThemePreset:()=>Kf,getViewerVisibleBounds:()=>Xo,invertViewerPoint:()=>Rr,mountWorldOrbitEmbeds:()=>Dy,normalizeRotation:()=>Vu,normalizeViewerFilter:()=>Zt,panViewerState:()=>ki,renderDocumentToSvg:()=>$u,renderSceneToSvg:()=>_n,renderSourceToSvg:()=>im,resolveLayers:()=>fo,resolveTheme:()=>Ui,rotateViewerState:()=>$o,sceneViewpointToLayerOptions:()=>vo,searchSceneObjects:()=>mo,serializeViewerAtlasState:()=>go,serializeWorldOrbitEmbedPayload:()=>jf,viewpointToViewerFilter:()=>xo,zoomViewerStateAt:()=>Cr});var Cs=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},cn=class extends Cs{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var $y={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},Rs={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",spaceFog:"#07131d",starfield:"rgba(226, 239, 255, 0.9)",starfieldDim:"rgba(164, 194, 228, 0.45)",objectSpecular:"#f5f8ff",orbitOpacity:.34,orbitBandOpacity:.24,selectionHalo:"rgba(255, 214, 139, 0.9)",atmosphere:"rgba(143, 202, 255, 0.4)",cometTail:"rgba(193, 243, 255, 0.7)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",spaceFog:"#071723",starfield:"rgba(220, 255, 245, 0.9)",starfieldDim:"rgba(124, 212, 195, 0.42)",objectSpecular:"#ecfffb",orbitOpacity:.3,orbitBandOpacity:.22,selectionHalo:"rgba(120, 255, 215, 0.85)",atmosphere:"rgba(120, 255, 215, 0.32)",cometTail:"rgba(181, 255, 236, 0.68)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",spaceFog:"#1c0d12",starfield:"rgba(255, 232, 214, 0.88)",starfieldDim:"rgba(255, 176, 138, 0.38)",objectSpecular:"#fff0e6",orbitOpacity:.3,orbitBandOpacity:.24,selectionHalo:"rgba(255, 178, 125, 0.85)",atmosphere:"rgba(255, 190, 140, 0.26)",cometTail:"rgba(255, 214, 173, 0.62)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Ui(n){return n?typeof n=="string"?Rs[n]??Rs.atlas:{...Rs.atlas,...n}:Rs.atlas}function fo(n){return{...$y,...n}}function Kf(n){return Rs[n]}function Zt(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:bu(n.objectTypes??[]),tags:bu((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:bu((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return Wy(e)?e:null}function Wy(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function po(n,e){let t=Zt(e),i=new Set;for(let r of n.objects)if(!r.hidden&&jy(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function mo(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Xy(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>Qf(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>Qf(r,1))}function ep(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:Zt(t)}}function go(n){return encodeURIComponent(JSON.stringify(n))}function yo(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:Zt(e.filter??null)}}function tp(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function vo(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function xo(n){return n?.filter?Zt({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function Qf(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function jy(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=np(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Xy(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=np(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(l=>r.includes(l))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(l=>typeof l=="string"):[]).some(l=>l.toLowerCase()===e)&&(s+=18),s}function np(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function bu(n){return[...new Set(n)]}var Y=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var Ps=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],un=Ps.filter(n=>n!=="system"),Yy=["star","planet","moon","asteroid","comet","structure","phenomenon"],ip=["structure","phenomenon"],hi=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],qy=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function Qe(n,e){return{key:n,...e}}var _o=new Set(Ps),rp=new Map([Qe("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:hi}),Qe("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"distance"}),Qe("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"distance"}),Qe("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:hi}),Qe("period",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"duration"}),Qe("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("at",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),Qe("surface",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),Qe("free",{kind:"string",placement:!0,arity:"single",objectTypes:qy}),Qe("kind",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("class",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("culture",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:Ps}),Qe("color",{kind:"string",placement:!1,arity:"single",objectTypes:Ps}),Qe("image",{kind:"string",placement:!1,arity:"single",objectTypes:Yy}),Qe("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:Ps}),Qe("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"radius"}),Qe("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"mass"}),Qe("density",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:un}),Qe("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),Qe("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),Qe("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),Qe("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("on",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("source",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"duration"})].map(n=>[n.key,n])),Zy=new Set(rp.keys());function Jt(n){return rp.get(n)}function sp(n){return Zy.has(n)}function ap(n,e){return n.objectTypes.includes(e)}function bo(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function Ls(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,a=!1,o=!1,l=null,c=()=>{s!==null&&(t.push({value:r,column:s,quoted:a}),r="",s=null,a=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(o&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){o?o=!1:(s===null&&(s=h),a=!0,l=h,o=!0);continue}if(!o&&/\s/.test(d)){c();continue}s===null&&(s=h),r+=d}if(o)throw new Y("Unclosed quote in line",e.line,l??i+n.length);return c(),t}function wo(n){return n.match(/^\s*/)?.[0].length??0}function Ds(n){let e=n.split(/\r?\n/),t=[],i=null,r=!1,s=null;for(let a=0;a<e.length;a++){let o=e[a],l=a+1;if(!o.trim())continue;let c=wo(o),u=Ls(o.slice(c),{line:l,columnOffset:c});if(u.length!==0){if(c===0){r=!1,s=null;let d=Jy(u,l);t.push(d),i=d;continue}if(!i)throw new Y("Indented line without parent object",l,c+1);if(u.length===1&&u[0].value==="info"){r=!0,s=c;continue}r&&c<=(s??0)&&(r=!1),r?i.infoEntries.push(ev(u,l)):i.blockFields.push(Qy(u,l))}}return{type:"document",objects:t}}function Jy(n,e){if(n.length<2)throw new Y("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!_o.has(t.value))throw new Y(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:Ky(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function Ky(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=Jt(r.value);if(!s)throw new Y(`Unknown field "${r.value}"`,e,r.column);i++;let a=[];if(s.arity==="multiple")for(;i<n.length&&!sp(n[i].value);)a.push(n[i]),i++;else{let o=n[i];o&&(a.push(o),i++)}if(a.length===0)throw new Y(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:a.map(o=>o.value),location:{line:e,column:r.column}})}return t}function Qy(n,e){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);if(!Jt(n[0].value))throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function ev(n,e){if(n.length<2)throw new Y("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var op=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,tv=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),nv=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Os(n){let e=null,t=[];for(let i of n.objects){let r=iv(i);if(i.objectType==="system"){if(e)throw Y.fromLocation("Only one system object is allowed",i.location);e=r}else t.push(r)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",system:e,groups:[],relations:[],events:[],objects:t}}function iv(n){let e=[...n.inlineFields,...n.blockFields];rv(n.objectType,e);let t=sv(e),i=av(n.objectType,t),r=ov(t),s=uv(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function rv(n,e){for(let t of e){let i=Jt(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(!ap(i,n))throw Y.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function sv(n){let e=new Map;for(let t of n){if(e.has(t.key))throw Y.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function av(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),a=[t,i,r,s].filter(Boolean).length;if(a>1){let o=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw Y.fromLocation("Object has multiple placement modes",o?.location)}if(n==="system"&&a>0)throw Y.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Mo(e,"orbit"),distance:Sr(e,"distance"),semiMajor:Sr(e,"semiMajor"),eccentricity:fv(e,"eccentricity"),period:Sr(e,"period"),angle:Sr(e,"angle"),inclination:Sr(e,"inclination"),phase:Sr(e,"phase")};if(i){let o=So(e,"at"),l=Mo(e,"at");return{mode:"at",target:l,reference:dv(l,o.location)}}if(r)return{mode:"surface",target:Mo(e,"surface")};if(s){let o=Mo(e,"free"),l=hv(o);return{mode:"free",distance:l??void 0,descriptor:l?void 0:o}}return null}function ov(n){let e={};for(let[t,i]of n.entries()){let r=Jt(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=pv(i);break;case"number":e[t]=cp(Ar(i),t,i.location);break;case"unit":e[t]=lp(Ar(i),i.location,t);break;case"string":e[t]=lv(t,i);break}}return e}function lv(n,e){let t=e.values.join(" ").trim();return n==="image"&&cv(t,e.location),t}function cv(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(nv);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function uv(n){let e={};for(let t of n){if(t.key in e)throw Y.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function dv(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function lp(n,e,t){let i=n.match(op);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Jt(t);if(s?.unitFamily&&!bo(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function hv(n){let e=n.match(op);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Sr(n,e){if(!n.has(e))return;let t=So(n,e);return lp(Ar(t),t.location,e)}function fv(n,e){if(!n.has(e))return;let t=So(n,e);return cp(Ar(t),e,t.location)}function cp(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function pv(n){let e=Ar(n).toLowerCase(),t=tv.get(e);if(t===void 0)throw Y.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function So(n,e){let t=n.get(e);if(!t)throw new Y(`Missing value for key "${e}"`);return t}function Mo(n,e){return Ar(So(n,e))}function Ar(n){if(n.values.length!==1)throw Y.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var mv=new Set(["star","planet","moon","asteroid","comet"]);function Us(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new Y(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new Y(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!mv.has(r.type))throw new Y(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&gv(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&yv(i,i.placement.reference,e))}}function gv(n,e,t){if(!t.has(e.primary))throw new Y(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new Y(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function yv(n,e,t){if(!t.has(e.objectId))throw new Y(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function Ni(n,e,t=`${e}.failed`){return n instanceof Y?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var Ns=1495978707e-1,vv=6371,xv=71492,_v=695700,bv=63241.077,wv=206264.806,Mv=206264806,gp=.68,Sv=.2,yp=28;function dn(n,e={}){let t=Tv(e),i=t.width,r=t.height,s=t.padding,a=Ev(n),o=Cv(n,e.projection),l=Tu(e.camera??null),c=Eu(o,l),u=Lv(a,e.scaleModel),d=Ov(a),h=n.system?.id??null,f=e.activeEventId??null,m=Av(n.objects,n.events??[],f),y=new Map(m.map(q=>[q.id,q])),g=yx(m,y),p=new Map,x=[],v=[],b=[],L=[],A=[],E=new Map,D=new Map;for(let q of m){let pe=q.placement;if(!pe){b.push(q);continue}if(pe.mode==="orbit"){fp(D,pe.target,q);continue}if(pe.mode==="surface"){fp(E,pe.target,q);continue}if(pe.mode==="at"){A.push(q);continue}L.push(q)}let M=L.length>0?i*.42:i/2,w=r/2,T={orbitChildren:D,surfaceChildren:E,objectMap:y,spacingFactor:d,projection:c,scaleModel:u},U=b.find(q=>q.type==="star")??b[0]??null;U&&Mu(U,M,w,0,p,x,v,T);let I=b.filter(q=>q.id!==U?.id);if(I.length>0){let q=Math.min(i,r)*.28*d*u.orbitDistanceMultiplier;I.forEach((pe,ne)=>{let Fe=Vs(ne,I.length,-Math.PI/2),_e=Hs(Fe,q,c,1);Mu(pe,M+_e.x,w+_e.y,0,p,x,v,T)})}L.forEach((q,pe)=>{let ne=i-s-140-Mx(q.placement?.mode==="free"?q.placement.distance:void 0,u),Fe=Math.max(76,(r-s*2-180)/Math.max(1,L.length)*d)*u.freePlacementMultiplier,_e=s+92+pe*Fe;p.set(q.id,{object:q,x:ne,y:_e,radius:Co(q,0,u),sortKey:Po(ne,_e,0)}),v.push({object:q,groupId:g.groupIds.get(q.id)??null,x1:ne-60,y1:_e,x2:ne-18,y2:_e,mode:"free"}),To(q,p,x,v,T,1)}),A.forEach((q,pe)=>{if(p.has(q.id)||!q.placement||q.placement.mode!=="at")return;let ne=mx(q.placement.reference,p,y,pe,A.length,i,r,s,T);p.set(q.id,{object:q,x:ne.x,y:ne.y,radius:Co(q,2,u),sortKey:Po(ne.x,ne.y,2),anchorX:ne.anchorX,anchorY:ne.anchorY}),ne.anchorX!==void 0&&ne.anchorY!==void 0&&v.push({object:q,groupId:g.groupIds.get(q.id)??null,x1:ne.anchorX,y1:ne.anchorY,x2:ne.x,y2:ne.y,mode:"at"}),To(q,p,x,v,T,2)});let B=[...p.values()].map(q=>Uv(q,u,g)),W=x.map(q=>Nv(q,g.groupIds.get(q.object.id)??null)),F=v.map(q=>Fv(q)),X=kv(B,i,r,u.labelMultiplier),k=jv(n,B),re=Xv(n.events??[],B,f),se=Gv(W,k,re,F,B,X),ve=$v(B,W,F,X,g,u.labelMultiplier),Le=Wv(n,B),Je=Yv(n,o,t.preset,g,y),Z=ax(i,r,B,W,F,X,u.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:o,renderProjection:c,camera:l,scaleModel:u,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:Pv(o,c,a,l),systemId:h,viewMode:o,layoutPreset:a,metadata:{format:n.format,version:n.version,view:o,renderProjection:c,scale:String(n.system?.properties.scale??a),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom",...l?.azimuth!==null?{"camera.azimuth":String(l?.azimuth)}:{},...l?.elevation!==null?{"camera.elevation":String(l?.elevation)}:{},...l?.roll!==null?{"camera.roll":String(l?.roll)}:{},...l?.distance!==null?{"camera.distance":String(l?.distance)}:{}},contentBounds:Z,layers:se,groups:ve,semanticGroups:Le,viewpoints:Je,events:re,activeEventId:f,objects:B,orbitVisuals:W,relations:k,leaders:F,labels:X}}function Vn(n,e,t){let i=Lo(t),r=Math.cos(i),s=Math.sin(i),a=n.x-e.x,o=n.y-e.y;return{x:e.x+a*r-o*s,y:e.y+a*s+o*r}}function Av(n,e,t){let i=n.map(o=>structuredClone(o));if(!t)return i;let r=e.find(o=>o.id===t);if(!r)return i;let s=new Map(i.map(o=>[o.id,o])),a=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(o=>o.objectId)]);for(let o of a){let l=s.get(o);l&&(r.epoch&&(l.epoch=r.epoch),r.referencePlane&&(l.referencePlane=r.referencePlane))}for(let o of r.positions){let l=s.get(o.objectId);l&&(o.placement&&(l.placement=structuredClone(o.placement)),o.inner&&(l.properties.inner={...o.inner}),o.outer&&(l.properties.outer={...o.outer}),o.epoch&&(l.epoch=o.epoch),o.referencePlane&&(l.referencePlane=o.referencePlane))}return i}function Ev(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function Tv(n){let e=Iv(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function Iv(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function Cv(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return _p(t)??"topdown"}function Eu(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function Tu(n){if(!n)return null;let e={azimuth:wu(n.azimuth),elevation:wu(n.elevation),roll:wu(n.roll),distance:Rv(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function wu(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Rv(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Pv(n,e,t,i){let r=[`${pp(n)} view`,`${pp(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function Lv(n,e){return{...Dv(n),...e}}function Dv(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function Ov(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function Uv(n,e,t){let{object:i,x:r,y:s,radius:a,sortKey:o,anchorX:l,anchorY:c}=n,u=i.renderHints?.renderPriority??0;return{renderId:Er(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:a,visualRadius:wx(i,a,e),sortKey:o+u*.001,anchorX:l,anchorY:c,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:Ax(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function Nv(n,e){return{renderId:`${Er(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function Fv(n){return{renderId:`${Er(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function kv(n,e,t,i){let r=[],s=[],a=new Map(n.map(l=>[l.objectId,l])),o=[...n].filter(l=>!l.hidden&&l.object.renderHints?.renderLabel!==!1).sort(Bv);for(let l of o){let c=zv(l,a,s,e,t,i)??xp(l,vp(l,a.get(l.parentId??"")??null,t),0,i);s.push(Ap(l,c,i)),r.push({renderId:`${l.renderId}-label`,objectId:l.objectId,object:l.object,groupId:l.groupId,semanticGroupIds:[...l.semanticGroupIds],label:l.label,secondaryLabel:l.secondaryLabel,x:c.x,y:c.labelY,secondaryY:c.secondaryY,textAnchor:c.textAnchor,direction:c.direction,hidden:l.hidden})}return r}function Bv(n,e){let t=up(n)-up(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function up(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function zv(n,e,t,i,r,s){for(let a of Vv(n,e,i,r)){let o=a==="left"||a==="right"?4:6;for(let l=0;l<=o;l+=1){let c=xp(n,a,l,s),u=Ap(n,c,s);if(!t.some(d=>_x(d,u)))return c}}return null}function Vv(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=vp(n,r,i),a=s==="below"?"above":"below",o=Hv(n,r,t),l=o==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[o,s,l,a]:[s,o,a,l]}function vp(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function Hv(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function xp(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),a=n.y-4*i;return{x:s,labelY:a,secondaryY:a+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,a=n.y-4*i;return{x:s,labelY:a,secondaryY:a+16*i,textAnchor:"start",direction:e}}}}function Gv(n,e,t,i,r,s){let a=n.filter(l=>!l.hidden&&!!l.backArcPath).map(l=>l.renderId),o=n.filter(l=>!l.hidden).map(l=>l.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"orbits-back",renderIds:a},{id:"orbits-front",renderIds:o},{id:"relations",renderIds:e.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"events",renderIds:t.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"objects",renderIds:r.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"labels",renderIds:s.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function $v(n,e,t,i,r,s){let a=new Map,o=l=>{if(!l)return null;let c=a.get(l);if(c)return c;let u=r.groupRoots.get(l)??null,d={renderId:l,rootObjectId:u,label:u??l,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:zs(0,0,0,0)};return a.set(l,d),d};for(let l of n){let c=o(l.groupId);c&&!l.hidden&&c.objectIds.push(l.objectId)}for(let l of e){let c=o(l.groupId);c&&!l.hidden&&c.orbitIds.push(l.objectId)}for(let l of t){let c=o(l.groupId);c&&!l.hidden&&c.leaderIds.push(l.objectId)}for(let l of i){let c=o(l.groupId);c&&!l.hidden&&c.labelIds.push(l.objectId)}for(let l of a.values())l.contentBounds=vx(l,n,e,t,i,s);return[...a.values()].sort((l,c)=>l.label.localeCompare(c.label))}function Wv(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function jv(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${Er(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function Xv(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],a=s.map(c=>i.get(c)).filter(Boolean),o=a.length>0?a.reduce((c,u)=>c+u.x,0)/a.length:0,l=a.length>0?a.reduce((c,u)=>c+u.y,0)/a.length:0;return{renderId:`${Er(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:o,y:l,hidden:r.hidden||a.length===0||a.every(c=>c.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function Yv(n,e,t,i,r){let s=qv(n,e,t),a=new Map;for(let[c,u]of Object.entries(n.system?.info??{})){if(!c.startsWith("viewpoint."))continue;let[d,h,...f]=c.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let m=ix(h);if(!m)continue;let y=f.join(".").toLowerCase(),g=a.get(m)??{id:m};Zv(g,y,u,n,e,t,i,r),a.set(m,g)}let o=[...a.values()].map(c=>Jv(c,e,t,r)).filter(Boolean),l=o.findIndex(c=>c.id===s.id);return l>=0?o.splice(l,1,{...s,...o[l],layers:{...s.layers,...o[l].layers},filter:o[l].filter??s.filter,generated:!1}):o.unshift(s),o.sort((c,u)=>c.id==="overview"?-1:u.id==="overview"?1:c.label.localeCompare(u.label))}function qv(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=Tu(null),a=Eu(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:a,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Zv(n,e,t,i,r,s,a,o){let l=t.trim();switch(e){case"label":case"title":l&&(n.label=l);return;case"summary":case"description":l&&(n.summary=l);return;case"focus":case"object":l&&(n.focus=l);return;case"select":case"selection":l&&(n.select=l);return;case"events":n.eventIds=Bs(l);return;case"projection":case"view":n.projection=_p(l)??r;return;case"preset":n.preset=Qv(l)??s;return;case"rotation":case"angle":n.rotationDeg=Fs(l)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??Eo(),azimuth:Fs(l)};return;case"camera.elevation":n.camera={...n.camera??Eo(),elevation:Fs(l)};return;case"camera.roll":n.camera={...n.camera??Eo(),roll:Fs(l)};return;case"camera.distance":n.camera={...n.camera??Eo(),distance:dp(l)};return;case"zoom":case"scale":n.scale=dp(l);return;case"layers":n.layers=ex(l);return;case"query":n.filter={...n.filter??Ao(),query:l||null};return;case"types":case"objecttypes":n.filter={...n.filter??Ao(),objectTypes:tx(l)};return;case"tags":n.filter={...n.filter??Ao(),tags:Bs(l)};return;case"groups":n.filter={...n.filter??Ao(),groupIds:nx(l,i,a,o)};return}}function Jv(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,a=Kv(n.filter),o=n.label?.trim()||rx(n.id),l=n.projection??e,c=Tu(n.camera??null),u=Eu(l,c);return{id:n.id,label:o,summary:n.summary?.trim()||sx(o,r,a),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:l,renderProjection:u,camera:c,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:a,generated:!1}}function Ao(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Eo(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Kv(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function _p(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Qv(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function Fs(n){let e=Number(n);return Number.isFinite(e)?e:null}function dp(n){let e=Fs(n);return e!==null&&e>0?e:null}function ex(n){let e={};for(let t of Bs(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function tx(n){return Bs(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function nx(n,e,t,i){return Bs(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??ks(r):(i.has(r),ks(r)))}function Bs(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function ix(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function rx(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function sx(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function ax(n,e,t,i,r,s,a){let o=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{o=Math.min(o,h),l=Math.min(l,f),c=Math.max(c,h),u=Math.max(u,f)};for(let h of i)h.hidden||bp(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||wp(h,d);for(let h of s)h.hidden||Mp(h,d,a);return!Number.isFinite(o)||!Number.isFinite(l)?zs(0,0,n,e):zs(o,l,c,u)}function bp(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=Tp(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,yp*2);for(let a of s)e(a.x-t,a.y-t),e(a.x+t,a.y+t)}function zs(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function wp(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function Mp(n,e,t){let i=Ep(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function Mu(n,e,t,i,r,s,a,o){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:Co(n,i,o.scaleModel),sortKey:Po(e,t,i)}),To(n,r,s,a,o,i+1))}function To(n,e,t,i,r,s){let a=e.get(n.id);if(!a)return;let o=[...r.orbitChildren.get(n.id)??[]].sort(ox),l=lx(o,a.radius,r.spacingFactor,r.scaleModel),c=dx(o,l);o.forEach((d,h)=>{let f=cx(d,h,o.length,a,l,c[h]??l.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),Mu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=Vs(h,u.length,-Math.PI/3),m=28*r.spacingFactor,y=Hs(f,a.radius,r.projection,r.projection==="isometric"?.9:1),g=Hs(f,a.radius+m,r.projection,r.projection==="isometric"?.9:1),p=a.x+y.x,x=a.y+y.y,v=a.x+g.x,b=a.y+g.y;e.set(d.id,{object:d,x:v,y:b,radius:Co(d,s+1,r.scaleModel),sortKey:Po(v,b,s+1),anchorX:p,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?ks(xx(d,r.objectMap)):null,x1:p,y1:x,x2:v,y2:b,mode:"surface"}),To(d,e,t,i,r,s+1)})}function ox(n,e){let t=Io(n),i=Io(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function lx(n,e,t,i){let r=n.map(d=>Io(d)),s=r.filter(d=>d!==null),a=e+56*t*i.orbitDistanceMultiplier,o=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(s.length===0)return{metrics:r,minMetric:0,maxMetric:0,metricSpread:0,innerPx:a,stepPx:o,pixelSpread:Math.max(o*Math.max(n.length-1,1),o),minimumGapPx:o*.42};let l=Math.min(...s),c=Math.max(...s),u=c-l;return{metrics:r,minMetric:l,maxMetric:c,metricSpread:u,innerPx:a,stepPx:o,pixelSpread:Math.max(o*Math.max(n.length-1,1),o),minimumGapPx:o*.42}}function cx(n,e,t,i,r,s,a){let o=n.placement,l=n.type==="belt"||n.type==="ring";if(!o||o.mode!=="orbit"){let D=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:D,rotationDeg:0,band:l,bandThickness:l?12*a.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-D}}let c=St(typeof o.eccentricity=="number"?o.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-c*c),u*.18),h=Au(o.inclination)??0,f=a.projection==="isometric"?Math.max(Sv,Math.cos(Lo(h)))*gp:1,m=Math.max(d*f,u*.14),y=Au(o.angle)??0,g=u*c,p=Cp(-g,0,y),x=i.x+p.x,v=i.y+p.y,b=fx(o.phase,e,t),L=Ip(x,v,u,m,y,b),A=a.projection==="topdown"&&c<=1e-4&&Math.abs(y)<=1e-4,E=l?px(n,u,r,a.scaleModel):void 0;return{kind:A?"circle":"ellipse",cx:A?i.x:x,cy:A?i.y:v,radius:A?u:void 0,rx:A?void 0:u,ry:A?void 0:m,rotationDeg:y,band:l,bandThickness:E,frontArcPath:a.projection==="isometric"||l?hp(x,v,u,m,y,0,Math.PI):void 0,backArcPath:a.projection==="isometric"||l?hp(x,v,u,m,y,Math.PI,Math.PI*2):void 0,objectX:L.x,objectY:L.y}}function ux(n,e){return e.innerPx+e.stepPx*hx(Math.max(n,0)+1)}function dx(n,e){let t=[];return n.forEach((i,r)=>{let s=Io(i),a=e.innerPx+r*e.stepPx,o=s===null?a:ux(s,e),l=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(o,l))}),t}function Io(n){return!n.placement||n.placement.mode!=="orbit"?null:Ro(n.placement.semiMajor??n.placement.distance??null)}function hx(n){return Math.log(n)/Math.log(2)}function fx(n,e,t){let i=n?Au(n):null;return i!==null?Lo(i-90):Vs(e,t,-Math.PI/2)}function px(n,e,t,i){let r=Ro(Su(n.properties.inner)),s=Ro(Su(n.properties.outer));if(r!==null&&s!==null){let o=Math.abs(s-r);if(t.metricSpread>0)return St(o/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let l=Math.max(Math.max(r,s),1e-4);return St(o/l*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function mx(n,e,t,i,r,s,a,o,l){if(n.kind==="lagrange")return gx(n,e,t,s,a);if(n.kind==="anchor"){let c=e.get(n.objectId);if(c){let u=Vs(i,r,Math.PI/5),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Hs(u,d,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+h.x,y:c.y+h.y,anchorX:c.x,anchorY:c.y}}}if(n.kind==="named"){let c=e.get(n.name);if(c){let u=Vs(i,r,Math.PI/6),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Hs(u,d,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+h.x,y:c.y+h.y,anchorX:c.x,anchorY:c.y}}}return{x:s-o-170,y:a-o-86-i*58*l.scaleModel.freePlacementMultiplier}}function gx(n,e,t,i,r){let s=n.secondary?e.get(n.primary):bx(n.primary,e,t),a=e.get(n.secondary??n.primary);if(!s||!a)return{x:i*.7,y:r*.25};let o=a.x-s.x,l=a.y-s.y,c=Math.hypot(o,l)||1,u=o/c,d=l/c,h=-d,f=u,m=St(c*.25,24,68);switch(n.point){case"L1":return{x:a.x-u*m,y:a.y-d*m,anchorX:a.x,anchorY:a.y};case"L2":return{x:a.x+u*m,y:a.y+d*m,anchorX:a.x,anchorY:a.y};case"L3":return{x:s.x-u*m,y:s.y-d*m,anchorX:s.x,anchorY:s.y};case"L4":return{x:a.x+(u*.5-h*.8660254)*m,y:a.y+(d*.5-f*.8660254)*m,anchorX:a.x,anchorY:a.y};case"L5":return{x:a.x+(u*.5+h*.8660254)*m,y:a.y+(d*.5+f*.8660254)*m,anchorX:a.x,anchorY:a.y}}}function yx(n,e){let t=new Map,i=new Map;for(let c of n){let u=Sp(c,e);if(t.set(c.id,u),u){let d=i.get(u);d?d.push(c.id):i.set(u,[c.id])}i.has(c.id)||i.set(c.id,[])}let r=new Map,s=new Map,a=new Map,o=c=>{let u=r.get(c);if(u)return u;let d=new Set,h=[],f=t.get(c)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(c,h),h},l=c=>{let u=a.get(s.get(c)??"");if(u)return u;let d=t.get(c)??null,h=e.get(c),f=c;return h?.placement&&h.placement.mode!=="free"&&d&&(f=l(d)),f};for(let c of n){o(c.id);let u=l(c.id),d=ks(u);s.set(c.id,d),a.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:a}}function Sp(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function vx(n,e,t,i,r,s){let a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=(d,h)=>{a=Math.min(a,d),o=Math.min(o,h),l=Math.max(l,d),c=Math.max(c,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&wp(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&bp(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&Mp(d,u,s);return!Number.isFinite(a)||!Number.isFinite(o)?zs(0,0,0,0):zs(a,o,l,c)}function xx(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=Sp(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function Ap(n,e,t){return Ep(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function Ep(n,e,t,i,r,s,a,o){let l=Ex(s,a,o),c=l*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-l,f=n+l;return i==="start"?(h=n,f=n+c):i==="end"&&(h=n-c,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function _x(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function bx(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function Co(n,e,t){let i=Sx(n.properties.radius,t);if(i!==null)return i;let r=t.bodyRadiusMultiplier;switch(n.type){case"star":return St((e===0?28:20)*r,t.minBodyRadius,t.maxBodyRadius);case"planet":return St(12*r,t.minBodyRadius,t.maxBodyRadius);case"moon":return St(7*r,t.minBodyRadius,t.maxBodyRadius);case"belt":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"comet":return St(6*r,t.minBodyRadius,t.maxBodyRadius);case"ring":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"structure":return St(6*r,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return St(8*r,t.minBodyRadius,t.maxBodyRadius)}}function wx(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function Ro(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/Ns;case"m":return n.value/1e3/Ns;case"ly":return n.value*bv;case"pc":return n.value*wv;case"kpc":return n.value*Mv;case"re":return n.value*vv/Ns;case"rj":return n.value*xv/Ns;case"sol":return n.value*_v/Ns;default:return n.value}}function Mx(n,e){let t=Ro(n??null);return t===null||t<=0?0:St(t*96*e.freePlacementMultiplier,0,420)}function Sx(n,e){let t=Su(n);if(!t)return null;let i;switch(t.unit){case"sol":i=St(t.value*22,14,40);break;case"re":i=St(t.value*10,6,18);break;case"km":i=St(Math.log10(Math.max(t.value,1))*2.6,4,16);break;default:i=St(t.value*4,4,20);break}return St(i*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function Su(n){return!n||typeof n!="object"||!("value"in n)?null:n}function Au(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Vs(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function hp(n,e,t,i,r,s,a){let o=Tp(n,e,t,i,r,s,a,yp);return o.length===0?"":o.map((l,c)=>`${c===0?"M":"L"} ${mp(l.x)} ${mp(l.y)}`).join(" ")}function Tp(n,e,t,i,r,s,a,o){let l=[];for(let c=0;c<=o;c+=1){let u=s+(a-s)*c/o;l.push(Ip(n,e,t,i,r,u))}return l}function Ip(n,e,t,i,r,s){let a=t*Math.cos(s),o=i*Math.sin(s),l=Cp(a,o,r);return{x:n+l.x,y:e+l.y}}function Cp(n,e,t){let i=Lo(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function Hs(n,e,t,i){let r=t==="isometric"?gp*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function Po(n,e,t){return e*1e3+n+t*.01}function St(n,e,t){return Math.min(Math.max(n,e),t)}function fp(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Er(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function ks(n){return`${Er(n)}-group`}function Ax(n){return typeof n=="string"&&n.trim()?n:void 0}function Ex(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function pp(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function Lo(n){return n*Math.PI/180}function mp(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Lp=86400,Do=Lp*365.25,Oo=18,Rp=180;function Fo(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,activeEventId:e.activeEventId},i=dn(n,t),r=Rx(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},a=new Map(i.objects.map(y=>[y.objectId,y])),o=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),l=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||l.set(y.objectId,Cu(g))}let c=Math.min(...[...l.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>Tx(y,i,s,a,o,r,u,c)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>Ix(y,h,c,i.activeEventId!==null)),m=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:Lx(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:m}}function Tx(n,e,t,i,r,s,a,o){let l=Uo(n,e,t,i,r,a),c=Pu(n.object,r.get(n.objectId),o,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:l,radius:Tr(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Tr(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:c}}function Ix(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??No(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??Pu(n.object,n,t,i)}}function Uo(n,e,t,i,r,s){let a=s.get(n.objectId);if(a)return a;let o=n.object.placement,l;if(o?.mode==="orbit"&&n.parentId){let c=i.get(n.parentId),u=c?Uo(c,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=Pu(n.object,d,1,e.activeEventId!==null),f=h?Dp(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};l=Op(u,f)}else if(o?.mode==="surface"&&n.parentId){let c=i.get(n.parentId),u=c?Uo(c,e,t,i,r,s):{x:0,y:0,z:0},d=c?.visualRadius??16,h=Dx(n.objectId),f=h*Math.PI*2;l={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(o?.mode==="at"&&n.parentId){let c=i.get(n.parentId),u=c?Uo(c,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??c?.x??t.x,h=n.anchorY??c?.y??t.y;l={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else l={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,l),l}function Ru(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let a=i.get(s);if(a)return a;let o=t.get(s);if(!o)return{x:0,y:0,z:0};let l={...o.position};if(o.motion&&o.parentId){let c=r(o.parentId),u=Dp(o.motion,n.timeFrozen?0:e);l=Op(c,u)}return i.set(s,l),l};for(let s of n.objects)r(s.objectId);return i}function Dp(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=Iu(t),r=Iu(n.rotationDeg),s=Iu(n.inclinationDeg),a=Math.cos(i)*n.semiMajor,o=Math.sin(i)*n.semiMinor,l=a*Math.cos(r)-o*Math.sin(r),c=a*Math.sin(r)+o*Math.cos(r);return{x:l,y:c*Math.sin(s),z:c*Math.cos(s)}}function Pu(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Tr(Cu(r)*48,24,1200),a=e?.radius??e?.ry??s,o=Cx(r.period),l=Cu(r),c=Tr(l/Math.max(t,1e-4),1,20),u=Tr(o?Oo*c:Oo*Math.pow(c,.75),Oo,Rp);return{phase0Deg:No(r.phase)??0,rotationDeg:No(r.angle)??e?.rotationDeg??0,inclinationDeg:No(r.inclination)??0,semiMajor:s,semiMinor:a,eccentricity:r.eccentricity??0,periodSeconds:o,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:o===null,frozen:i}}function Cu(n){let e=Pp(n.semiMajor)??Pp(n.distance)??1;return Math.max(e,.01)}function Pp(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function Cx(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Lp;case"y":return n.value*Do;case"ky":return n.value*Do*1e3;case"my":return n.value*Do*1e6;case"gy":return n.value*Do*1e9;default:return null}}function No(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Rx(n,e){return{...Px(n),...e}}function Px(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function Lx(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let o of n)e=Math.min(e,o.position.x-o.visualRadius),t=Math.min(t,o.position.y-o.visualRadius),i=Math.min(i,o.position.z-o.visualRadius),r=Math.max(r,o.position.x+o.visualRadius),s=Math.max(s,o.position.y+o.visualRadius),a=Math.max(a,o.position.z+o.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:a,width:r-e,height:s-t,depth:a-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+a)/2}}}function Op(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Dx(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function Tr(n,e,t){return Math.min(Math.max(n,e),t)}function Iu(n){return n*Math.PI/180}function Lu(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:Bx(n.system),info:zx(n.system)}:null,i=n.objects.map(Ox);return Fx(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(Ux),objects:i}}function Ox(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:kx(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function Ux(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(Nx)}}function Nx(n){return{objectId:n.objectId,placement:Up(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Up(n){return n?structuredClone(n):null}function Fx(n,e,t){if(!t)return;let i=e.find(a=>a.id===t);if(!i)return;let r=new Map(n.map(a=>[a.id,a])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(a=>a.objectId)]);for(let a of s){let o=r.get(a);o&&(i.epoch&&(o.epoch=i.epoch),i.referencePlane&&(o.referencePlane=i.referencePlane))}for(let a of i.positions){let o=r.get(a.objectId);o&&(a.placement&&(o.placement=Up(a.placement)),a.inner&&(o.properties.inner={...a.inner}),a.outer&&(o.properties.outer={...a.outer}),a.epoch&&(o.epoch=a.epoch),a.referencePlane&&(o.referencePlane=a.referencePlane))}}function kx(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function Bx(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function zx(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=Vx(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function Vx(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}var Np=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,$x=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Wx=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Ir(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function $s(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Du(n,e,t){let i=n.match(Np);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Jt(t);if(s?.unitFamily&&!bo(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Ou(n){let e=n.match(Np);return e?{value:Number(e[1]),unit:e[2]??null}:null}function ko(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function fi(n,e,t){let i=$x.get(n.toLowerCase());if(i===void 0)throw Y.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function Fp(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function jx(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Wx);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function kp(n,e,t){let i=Jt(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw Y.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return fi(Gs(e,n,t),n,t);case"number":return ko(Gs(e,n,t),n,t);case"unit":return Du(Gs(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&jx(r,t),r}}}function Uu(n,e,t){let i=Jt(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw Y.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function Gs(n,e,t){if(n.length!==1)throw Y.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var zp=new Set(["star","planet","moon","asteroid","comet"]),Xx=332946.0487,Yx=1047.3486,Bo=1495978707e-1,qx=6371,Zx=695700,Jx=63241.077,Kx=206264.806,Qx=206264806;function zo(n,e){let t=[],i=new Map(n.objects.map(o=>[o.id,o])),r=new Set(n.groups.map(o=>o.id)),s=new Set(n.events.map(o=>o.id));n.system||t.push(Ze("validate.system.required","Atlas documents must declare exactly one system."));let a=new Map;for(let[o,l]of[["group",n.groups.map(c=>c.id)],["viewpoint",n.system?.viewpoints.map(c=>c.id)??[]],["annotation",n.system?.annotations.map(c=>c.id)??[]],["relation",n.relations.map(c=>c.id)],["event",n.events.map(c=>c.id)],["object",n.objects.map(c=>c.id)]])for(let c of l){let u=a.get(c);u?t.push(Ze("validate.id.duplicate",`Duplicate ${o} id "${c}" already used by ${u}.`)):a.set(c,o)}for(let o of n.relations)e_(o,i,t);for(let o of n.system?.viewpoints??[])t_(o,r,s,e,t,i);for(let o of n.objects)n_(o,n.system,i,r,t);for(let o of n.events)i_(o,n.system,i,t);return t}function e_(n,e,t){n.from?e.has(n.from)||t.push(Ze("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(Ze("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(Ze("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(Ze("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(Ze("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function t_(n,e,t,i,r,s){let a=n.filter;if(i==="2.1"||i==="2.5"){if(a)for(let o of a.groupIds)e.has(o)||r.push(ct("validate.viewpoint.group.unknown",`Unknown group "${o}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let o of n.events??[])t.has(o)||r.push(ct("validate.viewpoint.event.unknown",`Unknown event "${o}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}o_(n.projection,r,`viewpoint.${n.id}.projection`,n.id),l_(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,a,s)}function n_(n,e,t,i,r){let s=n.placement,a=s?.mode==="orbit"?s:null,o=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let l of n.groups)i.has(l)||r.push(ct("validate.group.unknown",`Unknown group "${l}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(ct("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(ct("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),a&&(t.has(a.target)||r.push(Ze("validate.orbit.target.unknown",`Unknown placement target "${a.target}" on "${n.id}".`,n.id,"orbit")),a.distance&&a.semiMajor&&r.push(Ze("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),a.phase&&!n.epoch&&!e?.epoch&&r.push(ct("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),a.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(ct("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),a.period&&!Fu(o?.properties.mass)&&r.push(ct("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let l=t.get(s.target);l?zp.has(l.type)||r.push(Ze("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(Ze("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(Ze("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),s_(n,t,r)||r.push(Ze("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let l=t.get(n.resonance.targetObjectId);l?(n.placement?.mode!=="orbit"||l.placement?.mode!=="orbit"||n.placement.target!==l.placement.target)&&r.push(ct("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(Ze("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let l of n.deriveRules??[]){if(l.field!=="period"||l.strategy!=="kepler"){r.push(ct("validate.derive.unsupported",`Unsupported derive rule "${l.field} ${l.strategy}" on "${n.id}".`,n.id,"derive"));continue}let c=Bp(n,o);if(c===null){r.push(ct("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}a?.period||r.push(Nu("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${h_(c)}.`,n.id,"derive"))}for(let l of n.validationRules??[]){if(l.rule!=="kepler"){r.push(ct("validate.rule.unsupported",`Unsupported validation rule "${l.rule}" on "${n.id}".`,n.id,"validate"));continue}let c=Vp(a?.period),u=Bp(n,o);if(c===null||u===null)continue;let d=d_(n,"period");Math.abs(c-u)>d&&r.push(Ze("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function i_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(Ze("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(ct("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(ct("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(Ze("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(Ze("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let a=new Set;for(let c of n.participantObjectIds){if(s.add(c),a.has(c)){i.push(ct("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${c}".`,void 0,`${r}.participants`));continue}a.add(c),t.has(c)||i.push(Ze("validate.event.participants.unknown",`Unknown event participant "${c}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(ct("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(ct("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(ct("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let o=new Set;for(let c of n.positions){let u=`${r}.pose.${c.objectId}`;if(o.has(c.objectId)){i.push(Ze("validate.event.pose.duplicate",`Event "${n.id}" defines "${c.objectId}" more than once in positions.`,void 0,u));continue}o.add(c.objectId);let d=t.get(c.objectId);if(!d){i.push(Ze("validate.event.pose.object.unknown",`Unknown event pose object "${c.objectId}" on "${n.id}".`,void 0,u));continue}s.has(c.objectId)||i.push(ct("validate.event.pose.unreferenced",`Event pose "${c.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),r_(c,d,n,e,t,i,u,n.id)}let l=[...s].filter(c=>!o.has(c));n.positions.length>0&&l.length>0&&i.push(ct("validate.event.positions.partial",`Event "${n.id}" leaves ${l.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function r_(n,e,t,i,r,s,a,o){let l=n.placement;if(!l){s.push(Ze("validate.event.pose.placement.required",`Event "${o}" pose "${n.objectId}" is missing a placement mode.`,void 0,a));return}if(l.mode==="orbit"){r.has(l.target)||s.push(Ze("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${l.target}" on "${o}:${n.objectId}".`,void 0,`${a}.orbit`)),l.distance&&l.semiMajor&&s.push(Ze("validate.event.pose.orbit.distanceConflict",`Event "${o}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${a}.distance`)),l.phase&&!c_(i,e,t,n)&&s.push(ct("validate.event.pose.phase.epochMissing",`Event "${o}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${a}.phase`)),l.inclination&&!u_(i,e,t,n)&&s.push(ct("validate.event.pose.inclination.referencePlaneMissing",`Event "${o}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${a}.inclination`)),l.period&&!Fu(r.get(l.target)?.properties.mass)&&s.push(ct("validate.event.pose.period.massMissing",`Event "${o}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${a}.period`));return}if(l.mode==="surface"){let c=r.get(l.target);c?zp.has(c.type)||s.push(Ze("validate.event.pose.surface.target.invalid",`Event surface target "${l.target}" on "${o}:${n.objectId}" is not surface-capable.`,void 0,`${a}.surface`)):s.push(Ze("validate.event.pose.surface.target.unknown",`Unknown event surface target "${l.target}" on "${o}:${n.objectId}".`,void 0,`${a}.surface`));return}if(l.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(Ze("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${o}:${n.objectId}".`,void 0,`${a}.at`));let c=l.reference;c.kind==="named"&&!r.has(c.name)?s.push(Ze("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${l.target}" on "${o}:${n.objectId}".`,void 0,`${a}.at`)):c.kind==="anchor"&&!r.has(c.objectId)?s.push(Ze("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${c.objectId}" on "${o}:${n.objectId}".`,void 0,`${a}.at`)):c.kind==="lagrange"&&(r.has(c.primary)?c.secondary&&!r.has(c.secondary)&&s.push(Ze("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${c.secondary}" on "${o}:${n.objectId}".`,void 0,`${a}.at`)):s.push(Ze("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${c.primary}" on "${o}:${n.objectId}".`,void 0,`${a}.at`)))}}function s_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(Ze("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(Ze("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(Ze("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function Bp(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=a_(t.semiMajor??t.distance),r=Fu(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function a_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/Bo;case"m":return n.value/(Bo*1e3);case"ly":return n.value*Jx;case"pc":return n.value*Kx;case"kpc":return n.value*Qx;case"re":return n.value*qx/Bo;case"sol":return n.value*Zx/Bo;default:return null}}function Fu(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/Xx;case"mj":return e.value/Yx;default:return null}}function Vp(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function o_(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(Ze("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function l_(n,e,t,i,r,s,a,o,l){if(!n)return;let c=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(Ze("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${c}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(ct("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${c}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(ct("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,c)),e==="isometric"&&n.elevation!==null&&i.push(Nu("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${c}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(ct("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${c}.azimuth`)),s!==null&&l.has(s)||a!==null&&l.has(a)||o||i.push(Nu("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,c))}function c_(n,e,t,i){return pi(i?.epoch)??pi(t?.epoch)??pi(e.epoch)??pi(n?.epoch)??null}function u_(n,e,t,i){return pi(i?.referencePlane)??pi(t?.referencePlane)??pi(e.referencePlane)??pi(n?.referencePlane)??null}function pi(n){return typeof n=="string"&&n.trim()?n.trim():null}function d_(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Vp(t)??0:0}function h_(n){return`${Math.round(n*100)/100}d`}function Ze(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function ct(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function Nu(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var f_=new Set(["climate","habitability","settlement"]),Ho=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=Jt(n);e&&Ho.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])Ho.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var p_=new Set(Ho.keys()),Gp=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function ku(n){return m_(n)}function m_(n,e){let t=tb(n),i=t.source.split(/\r?\n/),r=[],s=!1,a="2.0",o=null,l=null,c=[],u=[],d=[],h=[],f=new Map,m=!1,y=!1,g=new Set,p=new Set,x=new Set,v=new Set,b=new Set;for(let w=0;w<i.length;w++){let T=i[w],U=w+1;if(!T.trim())continue;let I=wo(T),B=Ls(T.slice(I),{line:U,columnOffset:I});if(B.length!==0){if(!s){a=g_(B,U),s=!0,t.comments.length>0&&Go(a,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${a}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(I===0){l=y_(B,U,a,r,o,c,u,d,h,f,g,p,x,v,b,{sawDefaults:m,sawAtlas:y}),l.kind==="system"?o=l.system:l.kind==="defaults"?m=!0:l.kind==="atlas"&&(y=!0);continue}if(!l)throw new Y("Indented line without parent atlas section",U,I+1);A_(l,I,B,U)}}if(!s)throw new Y('Missing required atlas schema header "schema 2.0"');let L=c.map(w=>$_(w,a,r)),A=h.map(w=>W_(w,f.get(w.id)??[])),E=e??(a==="2.0-draft"?"2.0":a),D={format:"worldorbit",sourceVersion:"1.0",system:o,groups:u,relations:d,events:A,objects:L,diagnostics:r};if(E==="2.0-draft"){let w={...D,version:"2.0-draft",schemaVersion:"2.0-draft"};return w.diagnostics.push(...zo(w,a)),w}let M={...D,version:E,schemaVersion:E};return a==="2.0-draft"&&M.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),M.diagnostics.push(...zo(M,a)),M}function g_(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5"].includes(n[1].value.toLowerCase()))throw new Y('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function y_(n,e,t,i,r,s,a,o,l,c,u,d,h,f,m,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new Y('Atlas section "system" may only appear once',e,n[0].column);return v_(n,e,t,i);case"defaults":if(!r)throw new Y('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new Y('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new Y('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new Y('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new Y('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return x_(n,e,r,u,t,i);case"annotation":if(!r)throw new Y('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return __(n,e,r,d);case"group":return hn(t,i,"group",{line:e,column:n[0].column}),b_(n,e,a,h);case"relation":return hn(t,i,"relation",{line:e,column:n[0].column}),w_(n,e,o,f);case"event":return hn(t,i,"event",{line:e,column:n[0].column}),M_(n,e,l,c,m,t,i);case"object":return S_(n,e,t,i,s);default:throw new Y(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function v_(n,e,t,i){if(n.length!==2)throw new Y("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function x_(n,e,t,i,r,s){if(n.length!==2)throw new Y("Invalid viewpoint declaration",e,n[0]?.column??1);let a=Ir(n[1].value);if(!a)throw new Y("Viewpoint id must not be empty",e,n[1].column);if(i.has(a))throw new Y(`Duplicate viewpoint id "${a}"`,e,n[1].column);let o={id:a,label:$s(a),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(o),i.add(a),{kind:"viewpoint",viewpoint:o,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function __(n,e,t,i){if(n.length!==2)throw new Y("Invalid annotation declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:$s(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function b_(n,e,t,i){if(n.length!==2)throw new Y("Invalid group declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Group id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:$s(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function w_(n,e,t,i){if(n.length!==2)throw new Y("Invalid relation declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function M_(n,e,t,i,r,s,a){if(n.length!==2)throw new Y("Invalid event declaration",e,n[0]?.column??1);let o=Ir(n[1].value);if(!o)throw new Y("Event id must not be empty",e,n[1].column);if(r.has(o))throw new Y(`Duplicate event id "${o}"`,e,n[1].column);let l={id:o,kind:"",label:$s(o),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},c=[];return t.push(l),i.set(o,c),r.add(o),{kind:"event",event:l,sourceSchemaVersion:s,diagnostics:a,seenFields:new Set,rawPoses:c,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function S_(n,e,t,i,r){if(n.length<3)throw new Y("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],a=n[2],o=s.value;if(!_o.has(o)||o==="system")throw new Y(`Unknown object type "${s.value}"`,e,s.column);let l={objectType:o,id:a.value,fields:H_(n.slice(3),e,o,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(l),{kind:"object",objectNode:l,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function A_(n,e,t,i){switch(n.kind){case"system":E_(n,t,i);return;case"defaults":T_(n,t,i);return;case"atlas":I_(n,e,t,i);return;case"viewpoint":C_(n,e,t,i);return;case"annotation":L_(n,t,i);return;case"group":D_(n,t,i);return;case"relation":O_(n,t,i);return;case"event":U_(n,e,t,i);return;case"object":F_(n,e,t,i);return}}function E_(n,e,t){let i=Hn(e,n.seenFields,t),r=rt(e,t);switch(i){case"title":n.system.title=r;return;case"description":hn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":hn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":hn(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new Y(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function T_(n,e,t){let i=Hn(e,n.seenFields,t),r=rt(e,t);switch(i){case"view":Wp(r)&&Fi(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=$p(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=jp(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new Y(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function I_(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Xp(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new Y(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new Y(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function C_(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){R_(n,t,i);return}if(n.inFilter){P_(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(Fi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new Y('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??zu();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new Y('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=Hn(t,n.seenFields,i),s=rt(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":Wp(s)&&Fi(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=$p(s,i,t[0].column);return;case"preset":n.viewpoint.preset=jp(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=Bu(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=gi(s,i,t[0].column,"rotation");return;case"camera":Fi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=V_(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=B_(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":hn(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=In(t.slice(1),i,"events");return;default:throw new Y(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function R_(n,e,t){let i=Hn(e,n.seenCameraFields,t),r=rt(e,t),s=n.viewpoint.camera??zu();switch(i){case"azimuth":s.azimuth=gi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=gi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=gi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=Bu(r,t,e[0].column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function P_(n,e,t){let i=Hn(e,n.seenFilterFields,t),r=n.viewpoint.filter??z_();switch(i){case"query":r.query=rt(e,t);break;case"objecttypes":r.objectTypes=k_(e.slice(1),t);break;case"tags":r.tags=In(e.slice(1),t,"tags");break;case"groups":r.groupIds=In(e.slice(1),t,"groups");break;default:throw new Y(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function L_(n,e,t){switch(Hn(e,n.seenFields,t)){case"label":n.annotation.label=rt(e,t);return;case"target":n.annotation.targetObjectId=rt(e,t);return;case"body":n.annotation.body=rt(e,t);return;case"tags":n.annotation.tags=In(e.slice(1),t,"tags");return;default:throw new Y(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function D_(n,e,t){switch(Hn(e,n.seenFields,t)){case"label":n.group.label=rt(e,t);return;case"summary":n.group.summary=rt(e,t);return;case"color":n.group.color=rt(e,t);return;case"tags":n.group.tags=In(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=fi(rt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function O_(n,e,t){switch(Hn(e,n.seenFields,t)){case"from":n.relation.from=rt(e,t);return;case"to":n.relation.to=rt(e,t);return;case"kind":n.relation.kind=rt(e,t);return;case"label":n.relation.label=rt(e,t);return;case"summary":n.relation.summary=rt(e,t);return;case"tags":n.relation.tags=In(e.slice(1),t,"tags");return;case"color":n.relation.color=rt(e,t);return;case"hidden":n.relation.hidden=fi(rt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function U_(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&Fi(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(N_(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new Y(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new Y("Event pose object id must not be empty",i,t[1].column);let a={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(a),n.activePose=a,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new Y('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(Hn(t,n.seenFields,i)){case"kind":n.event.kind=rt(t,i);return;case"label":n.event.label=rt(t,i);return;case"summary":n.event.summary=rt(t,i);return;case"target":n.event.targetObjectId=rt(t,i);return;case"participants":n.event.participantObjectIds=In(t.slice(1),i,"participants");return;case"timing":n.event.timing=rt(t,i);return;case"visibility":n.event.visibility=rt(t,i);return;case"epoch":Fi(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=rt(t,i);return;case"referenceplane":Fi(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=rt(t,i);return;case"tags":n.event.tags=In(t.slice(1),i,"tags");return;case"color":n.event.color=rt(t,i);return;case"hidden":n.event.hidden=fi(rt(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new Y(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function N_(n,e,t){if(n.length<2)throw new Y("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Gp.has(i))throw new Y(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new Y(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function F_(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||f_.has(r)){r!=="info"&&hn(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Xp(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new Y(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,a=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(a.has(r.key))throw new Y(`Duplicate ${s} key "${r.key}"`,i,t[0].column);a.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(G_(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function Hn(n,e,t){if(n.length<2)throw new Y("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new Y(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function rt(n,e){if(n.length<2)throw new Y("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function k_(n,e){return In(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function B_(n,e,t,i){let r={};for(let s of In(n,e,"layers")){let a=!s.startsWith("-")&&!s.startsWith("!"),o=s.replace(/^[-!]+/,"").toLowerCase();if(o==="orbits"){r["orbits-back"]=a,r["orbits-front"]=a;continue}(o==="background"||o==="guides"||o==="orbits-back"||o==="orbits-front"||o==="relations"||o==="events"||o==="objects"||o==="labels"||o==="metadata")&&(o==="events"&&t&&i&&hn(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[o]=a)}return r}function In(n,e,t){if(n.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function $p(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new Y(`Unknown projection "${n}"`,e,t);return i}function Wp(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function jp(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new Y(`Unknown render preset "${n}"`,e,t)}function Bu(n,e,t,i){let r=gi(n,e,t,i);if(r<=0)throw new Y(`Field "${i}" must be greater than zero`,e,t);return r}function gi(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new Y(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function z_(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function zu(){return{azimuth:null,elevation:null,roll:null,distance:null}}function V_(n,e,t){if(n.length===0||n.length%2!==0)throw new Y('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:zu(),r=new Set;for(let s=0;s<n.length;s+=2){let a=n[s],o=n[s+1],l=a.value.toLowerCase();if(r.has(l))throw new Y(`Duplicate viewpoint camera field "${a.value}"`,e,a.column);r.add(l);let c=o.value;switch(l){case"azimuth":i.azimuth=gi(c,e,a.column,"camera.azimuth");break;case"elevation":i.elevation=gi(c,e,a.column,"camera.elevation");break;case"roll":i.roll=gi(c,e,a.column,"camera.roll");break;case"distance":i.distance=Bu(c,e,a.column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${a.value}"`,e,a.column)}}return i}function H_(n,e,t,i,r){let s=[],a=0;for(;a<n.length;){let o=n[a],l=Ws(o.value);if(!l)throw new Y(`Unknown field "${o.value}"`,e,o.column);l.version==="2.1"&&hn(i,r,o.value,{line:e,column:o.column}),a++;let c=[];if(l.inlineMode==="single"){let u=n[a];u&&(c.push(u),a++)}else if(l.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[a];if(!d)break;c.push(d),a++}else for(;a<n.length&&!p_.has(n[a].value);)c.push(n[a]),a++;if(c.length===0)throw new Y(`Missing value for field "${o.value}"`,e,o.column);s.push({type:"field",key:o.value,values:c.map(u=>u.value),location:{line:e,column:o.column}})}return Jp(s,t),s}function G_(n,e,t,i,r){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);let s=Ws(n[0].value);if(!s)throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&hn(i,r,n[0].value,{line:e,column:n[0].column});let a={type:"field",key:n[0].value,values:n.slice(1).map(o=>o.value),location:{line:e,column:n[0].column}};return Jp([a],t),a}function Xp(n,e,t){if(n.length<2)throw new Y(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function $_(n,e,t){let i=Yp(n.fields),r=qp(i),s=X_(n.objectType,i),a=Q_(i.get("groups")?.[0]),o=Vo(i.get("epoch")?.[0]),l=Vo(i.get("referencePlane")?.[0]),c=i.has("tidalLock")?fi(xn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Z_(i.get("resonance")[0]):void 0,d=q_(i),h=i.get("derive")?.map(v=>J_(v)),f=i.get("validate")?.map(v=>({rule:xn(v)})),m=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>K_(v)),g=Y_(n.typedBlockEntries),p=Zp(n.infoEntries,"info"),x={type:n.objectType,id:n.id,properties:s,placement:r,info:p};return a.length>0&&(x.groups=a),o&&(x.epoch=o),l&&(x.referencePlane=l),c!==void 0&&(x.tidalLock=c),u&&(x.resonance=u),d&&(x.renderHints=d),h?.length&&(x.deriveRules=h),f?.length&&(x.validationRules=f),m?.length&&(x.lockedFields=m),y?.length&&(x.tolerances=y),g&&Object.keys(g).length>0&&(x.typedBlocks=g),Go(e,"2.1")&&(x.groups||x.epoch||x.referencePlane||x.tidalLock!==void 0||x.resonance||x.renderHints||x.deriveRules?.length||x.validationRules?.length||x.lockedFields?.length||x.tolerances?.length||x.typedBlocks)&&hn(e,t,n.id,n.location),x}function W_(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>j_(t))}}function j_(n){let e=Yp(n.fields,"event-pose"),t=qp(e);return{objectId:n.objectId,placement:t,inner:mi(e.get("inner")?.[0],"inner"),outer:mi(e.get("outer")?.[0],"outer"),epoch:Vo(e.get("epoch")?.[0]),referencePlane:Vo(e.get("referencePlane")?.[0])}}function Yp(n,e="object"){let t=new Map;for(let i of n){let r=Ws(i.key);if(!r&&!Gp.has(i.key))throw Y.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw Y.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function qp(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let a=e??t??i??r;throw Y.fromLocation("Object has multiple placement modes",a?.location)}if(e)return{mode:"orbit",target:xn(e),distance:mi(n.get("distance")?.[0],"distance"),semiMajor:mi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:eb(n.get("eccentricity")?.[0],"eccentricity"),period:mi(n.get("period")?.[0],"period"),angle:mi(n.get("angle")?.[0],"angle"),inclination:mi(n.get("inclination")?.[0],"inclination"),phase:mi(n.get("phase")?.[0],"phase")};if(t){let a=xn(t);return{mode:"at",target:a,reference:Fp(a,t.location)}}if(i)return{mode:"surface",target:xn(i)};if(r){let a=xn(r),o=Ou(a);return{mode:"free",distance:o??void 0,descriptor:o?void 0:a}}return null}function X_(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],a=Ws(i);!s||!a?.legacySchema||a.legacySchema.placement||(Uu(i,n,s.location),t[i]=kp(i,s.values,s.location))}return t}function Zp(n,e){let t={};for(let i of n){if(i.key in t)throw Y.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function Y_(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=Zp(i,t))}return e}function q_(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=fi(xn(t),"renderLabel",t.location)),i&&(e.renderOrbit=fi(xn(i),"renderOrbit",i.location)),r&&(e.renderPriority=ko(xn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Z_(n){if(n.values.length!==2)throw Y.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw Y.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function J_(n){if(n.values.length!==2)throw Y.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function K_(n){if(n.values.length!==2)throw Y.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=Ou(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function Q_(n){return n?[...new Set(n.values)]:[]}function Vo(n){return n&&n.values.join(" ").trim()||null}function mi(n,e){return n?Du(xn(n),n.location,e):void 0}function eb(n,e){return n?ko(xn(n),e,n.location):void 0}function xn(n){return Gs(n.values,n.key,n.location)}function Ws(n){return Ho.get(n)}function Jp(n,e){for(let t of n){let i=Ws(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){Uu(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function hn(n,e,t,i){Go(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function Fi(n,e,t,i){Go(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function Go(n,e){return Hp(n)<Hp(e)}function Hp(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3}}function tb(n){let e=[...n],t=[],i=!1,r=!1,s=null,a=1,o=1;for(let l=0;l<e.length;l++){let c=e[l],u=e[l+1];if(r){if(c==="*"&&u==="/"){e[l]=" ",e[l+1]=" ",r=!1,s=null,l++,o+=2;continue}c!==`
3821
+ }`,wh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new sn({vertexShader:wE,fragmentShader:ME,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new yt(new fs(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},Mh=class extends En{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null,y=new wh,g=t.getContextAttributes(),m=null,x=null,v=[],b=[],L=new te,A=null,E=new At;E.layers.enable(1),E.viewport=new at;let D=new At;D.layers.enable(2),D.viewport=new at;let M=[E,D],w=new ec;w.layers.enable(1),w.layers.enable(2);let T=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let q=v[Z];return q===void 0&&(q=new uo,v[Z]=q),q.getTargetRaySpace()},this.getControllerGrip=function(Z){let q=v[Z];return q===void 0&&(q=new uo,v[Z]=q),q.getGripSpace()},this.getHand=function(Z){let q=v[Z];return q===void 0&&(q=new uo,v[Z]=q),q.getHandSpace()};function I(Z){let q=b.indexOf(Z.inputSource);if(q===-1)return;let pe=v[q];pe!==void 0&&(pe.update(Z.inputSource,Z.frame,c||o),pe.dispatchEvent({type:Z.type,data:Z.inputSource}))}function B(){r.removeEventListener("select",I),r.removeEventListener("selectstart",I),r.removeEventListener("selectend",I),r.removeEventListener("squeeze",I),r.removeEventListener("squeezestart",I),r.removeEventListener("squeezeend",I),r.removeEventListener("end",B),r.removeEventListener("inputsourceschange",W);for(let Z=0;Z<v.length;Z++){let q=b[Z];q!==null&&(b[Z]=null,v[Z].disconnect(q))}T=null,U=null,y.reset(),e.setRenderTarget(m),f=null,h=null,d=null,r=null,x=null,Je.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(L.width,L.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",I),r.addEventListener("selectstart",I),r.addEventListener("selectend",I),r.addEventListener("squeeze",I),r.addEventListener("squeezestart",I),r.addEventListener("squeezeend",I),r.addEventListener("end",B),r.addEventListener("inputsourceschange",W),g.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(L),r.renderState.layers===void 0){let q={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,q),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new nn(f.framebufferWidth,f.framebufferHeight,{format:en,type:oi,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let q=null,pe=null,ne=null;g.depth&&(ne=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,q=g.stencil?as:or,pe=g.stencil?_s:lr);let Fe={colorFormat:t.RGBA8,depthFormat:ne,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(Fe),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),x=new nn(h.textureWidth,h.textureHeight,{format:en,type:oi,depthTexture:new Lo(h.textureWidth,h.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),Je.setContext(r),Je.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function W(Z){for(let q=0;q<Z.removed.length;q++){let pe=Z.removed[q],ne=b.indexOf(pe);ne>=0&&(b[ne]=null,v[ne].disconnect(pe))}for(let q=0;q<Z.added.length;q++){let pe=Z.added[q],ne=b.indexOf(pe);if(ne===-1){for(let _e=0;_e<v.length;_e++)if(_e>=b.length){b.push(pe),ne=_e;break}else if(b[_e]===null){b[_e]=pe,ne=_e;break}if(ne===-1)break}let Fe=v[ne];Fe&&Fe.connect(pe)}}let F=new R,X=new R;function k(Z,q,pe){F.setFromMatrixPosition(q.matrixWorld),X.setFromMatrixPosition(pe.matrixWorld);let ne=F.distanceTo(X),Fe=q.projectionMatrix.elements,_e=pe.projectionMatrix.elements,H=Fe[14]/(Fe[10]-1),Ue=Fe[14]/(Fe[10]+1),J=(Fe[9]+1)/Fe[5],ce=(Fe[9]-1)/Fe[5],K=(Fe[8]-1)/Fe[0],de=(_e[8]+1)/_e[0],le=H*K,he=H*de,Ae=ne/(-K+de),P=Ae*-K;q.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(P),Z.translateZ(Ae),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();let S=H+Ae,j=Ue+Ae,ee=le-P,oe=he+(ne-P),ie=J*Ue/j*S,Ce=ce*Ue/j*S;Z.projectionMatrix.makePerspective(ee,oe,ie,Ce,S,j),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function re(Z,q){q===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(q.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;y.texture!==null&&(Z.near=y.depthNear,Z.far=y.depthFar),w.near=D.near=E.near=Z.near,w.far=D.far=E.far=Z.far,(T!==w.near||U!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,U=w.far,E.near=T,E.far=U,D.near=T,D.far=U,E.updateProjectionMatrix(),D.updateProjectionMatrix(),Z.updateProjectionMatrix());let q=Z.parent,pe=w.cameras;re(w,q);for(let ne=0;ne<pe.length;ne++)re(pe[ne],q);pe.length===2?k(w,E,D):w.projectionMatrix.copy(E.projectionMatrix),se(Z,w,q)};function se(Z,q,pe){pe===null?Z.matrix.copy(q.matrixWorld):(Z.matrix.copy(pe.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(q.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(q.projectionMatrix),Z.projectionMatrixInverse.copy(q.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=ls*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return w},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(Z){l=Z,h!==null&&(h.fixedFoveation=Z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Z)},this.hasDepthSensing=function(){return y.texture!==null};let ve=null;function Le(Z,q){if(u=q.getViewerPose(c||o),p=q,u!==null){let pe=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let ne=!1;pe.length!==w.cameras.length&&(w.cameras.length=0,ne=!0);for(let _e=0;_e<pe.length;_e++){let H=pe[_e],Ue=null;if(f!==null)Ue=f.getViewport(H);else{let ce=d.getViewSubImage(h,H);Ue=ce.viewport,_e===0&&(e.setRenderTargetTextures(x,ce.colorTexture,h.ignoreDepthValues?void 0:ce.depthStencilTexture),e.setRenderTarget(x))}let J=M[_e];J===void 0&&(J=new At,J.layers.enable(_e),J.viewport=new at,M[_e]=J),J.matrix.fromArray(H.transform.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale),J.projectionMatrix.fromArray(H.projectionMatrix),J.projectionMatrixInverse.copy(J.projectionMatrix).invert(),J.viewport.set(Ue.x,Ue.y,Ue.width,Ue.height),_e===0&&(w.matrix.copy(J.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),ne===!0&&w.cameras.push(J)}let Fe=r.enabledFeatures;if(Fe&&Fe.includes("depth-sensing")){let _e=d.getDepthInformation(pe[0]);_e&&_e.isValid&&_e.texture&&y.init(e,_e,r.renderState)}}for(let pe=0;pe<v.length;pe++){let ne=b[pe],Fe=v[pe];ne!==null&&Fe!==void 0&&Fe.update(ne,q,c||o)}y.render(e,w),ve&&ve(Z,q),q.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:q}),p=null}let Je=new Q0;Je.setAnimationLoop(Le),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}},ji=new rn,SE=new Ne;Sh=class{constructor(e={}){let{canvas:t=Y0(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;let f=new Uint32Array(4),p=new Int32Array(4),y=null,g=null,m=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=mn,this._useLegacyLights=!1,this.toneMapping=ni,this.toneMappingExposure=1;let v=this,b=!1,L=0,A=0,E=null,D=-1,M=null,w=new at,T=new at,U=null,I=new we(0),B=0,W=t.width,F=t.height,X=1,k=null,re=null,se=new at(0,0,W,F),ve=new at(0,0,W,F),Le=!1,Je=new dr,Z=!1,q=!1,pe=new Ne,ne=new R,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return E===null?X:1}let H=i;function Ue(_,O){return t.getContext(_,O)}try{let _={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",z,!1),t.addEventListener("webglcontextrestored",ae,!1),t.addEventListener("webglcontextcreationerror",Q,!1),H===null){let O="webgl2";if(H=Ue(O,_),H===null)throw Ue(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(_){throw console.error("THREE.WebGLRenderer: "+_.message),_}let J,ce,K,de,le,he,Ae,P,S,j,ee,oe,ie,Ce,me,ge,ke,fe,Re,We,Pe,Me,De,qe;function ht(){J=new j1(H),J.init(),Me=new sy(H,J),ce=new z1(H,J,e,Me),K=new xE(H),de=new q1(H),le=new aE,he=new _E(H,J,K,le,ce,Me,de),Ae=new H1(v),P=new W1(v),S=new nM(H),De=new k1(H,S),j=new X1(H,S,de,De),ee=new J1(H,j,S,de),Re=new Z1(H,ce,he),ge=new V1(le),oe=new oE(v,Ae,P,J,ce,De,ge),ie=new AE(v,le),Ce=new cE,me=new mE(J),fe=new F1(v,Ae,P,K,ee,h,l),ke=new vE(v,ee,ce),qe=new EE(H,de,ce,K),We=new B1(H,J,de),Pe=new Y1(H,J,de),de.programs=oe.programs,v.capabilities=ce,v.extensions=J,v.properties=le,v.renderLists=Ce,v.shadowMap=ke,v.state=K,v.info=de}ht();let Ge=new Mh(v,H);this.xr=Ge,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let _=J.get("WEBGL_lose_context");_&&_.loseContext()},this.forceContextRestore=function(){let _=J.get("WEBGL_lose_context");_&&_.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(_){_!==void 0&&(X=_,this.setSize(W,F,!1))},this.getSize=function(_){return _.set(W,F)},this.setSize=function(_,O,V=!0){if(Ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=_,F=O,t.width=Math.floor(_*X),t.height=Math.floor(O*X),V===!0&&(t.style.width=_+"px",t.style.height=O+"px"),this.setViewport(0,0,_,O)},this.getDrawingBufferSize=function(_){return _.set(W*X,F*X).floor()},this.setDrawingBufferSize=function(_,O,V){W=_,F=O,X=V,t.width=Math.floor(_*V),t.height=Math.floor(O*V),this.setViewport(0,0,_,O)},this.getCurrentViewport=function(_){return _.copy(w)},this.getViewport=function(_){return _.copy(se)},this.setViewport=function(_,O,V,N){_.isVector4?se.set(_.x,_.y,_.z,_.w):se.set(_,O,V,N),K.viewport(w.copy(se).multiplyScalar(X).round())},this.getScissor=function(_){return _.copy(ve)},this.setScissor=function(_,O,V,N){_.isVector4?ve.set(_.x,_.y,_.z,_.w):ve.set(_,O,V,N),K.scissor(T.copy(ve).multiplyScalar(X).round())},this.getScissorTest=function(){return Le},this.setScissorTest=function(_){K.setScissorTest(Le=_)},this.setOpaqueSort=function(_){k=_},this.setTransparentSort=function(_){re=_},this.getClearColor=function(_){return _.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(_=!0,O=!0,V=!0){let N=0;if(_){let $=!1;if(E!==null){let ue=E.texture.format;$=ue===Uf||ue===Of||ue===Df}if($){let ue=E.texture.type,Ee=ue===oi||ue===lr||ue===If||ue===_s||ue===Rf||ue===Pf,Ie=fe.getClearColor(),Oe=fe.getClearAlpha(),Be=Ie.r,je=Ie.g,Ye=Ie.b;Ee?(f[0]=Be,f[1]=je,f[2]=Ye,f[3]=Oe,H.clearBufferuiv(H.COLOR,0,f)):(p[0]=Be,p[1]=je,p[2]=Ye,p[3]=Oe,H.clearBufferiv(H.COLOR,0,p))}else N|=H.COLOR_BUFFER_BIT}O&&(N|=H.DEPTH_BUFFER_BIT),V&&(N|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(N)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",z,!1),t.removeEventListener("webglcontextrestored",ae,!1),t.removeEventListener("webglcontextcreationerror",Q,!1),Ce.dispose(),me.dispose(),le.dispose(),Ae.dispose(),P.dispose(),ee.dispose(),De.dispose(),qe.dispose(),oe.dispose(),Ge.dispose(),Ge.removeEventListener("sessionstart",et),Ge.removeEventListener("sessionend",Xt),Mt.stop()};function z(_){_.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function ae(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let _=de.autoReset,O=ke.enabled,V=ke.autoUpdate,N=ke.needsUpdate,$=ke.type;ht(),de.autoReset=_,ke.enabled=O,ke.autoUpdate=V,ke.needsUpdate=N,ke.type=$}function Q(_){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_.statusMessage)}function xe(_){let O=_.target;O.removeEventListener("dispose",xe),be(O)}function be(_){Se(_),le.remove(_)}function Se(_){let O=le.get(_).programs;O!==void 0&&(O.forEach(function(V){oe.releaseProgram(V)}),_.isShaderMaterial&&oe.releaseShaderCache(_))}this.renderBufferDirect=function(_,O,V,N,$,ue){O===null&&(O=Fe);let Ee=$.isMesh&&$.matrixWorld.determinant()<0,Ie=gu(_,O,V,N,$);K.setMaterial(N,Ee);let Oe=V.index,Be=1;if(N.wireframe===!0){if(Oe=j.getWireframeAttribute(V),Oe===void 0)return;Be=2}let je=V.drawRange,Ye=V.attributes.position,xt=je.start*Be,Ut=(je.start+je.count)*Be;ue!==null&&(xt=Math.max(xt,ue.start*Be),Ut=Math.min(Ut,(ue.start+ue.count)*Be)),Oe!==null?(xt=Math.max(xt,0),Ut=Math.min(Ut,Oe.count)):Ye!=null&&(xt=Math.max(xt,0),Ut=Math.min(Ut,Ye.count));let qt=Ut-xt;if(qt<0||qt===1/0)return;De.setup($,N,Ie,V,Oe);let zn,nt=We;if(Oe!==null&&(zn=S.get(Oe),nt=Pe,nt.setIndex(zn)),$.isMesh)N.wireframe===!0?(K.setLineWidth(N.wireframeLinewidth*_e()),nt.setMode(H.LINES)):nt.setMode(H.TRIANGLES);else if($.isLine){let ze=N.linewidth;ze===void 0&&(ze=1),K.setLineWidth(ze*_e()),$.isLineSegments?nt.setMode(H.LINES):$.isLineLoop?nt.setMode(H.LINE_LOOP):nt.setMode(H.LINE_STRIP)}else $.isPoints?nt.setMode(H.POINTS):$.isSprite&&nt.setMode(H.TRIANGLES);if($.isBatchedMesh)$._multiDrawInstances!==null?nt.renderMultiDrawInstances($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount,$._multiDrawInstances):nt.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else if($.isInstancedMesh)nt.renderInstances(xt,qt,$.count);else if(V.isInstancedBufferGeometry){let ze=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Ts=Math.min(V.instanceCount,ze);nt.renderInstances(xt,qt,Ts)}else nt.render(xt,qt)};function Ke(_,O,V){_.transparent===!0&&_.side===Pn&&_.forceSinglePass===!1?(_.side=jt,_.needsUpdate=!0,Mr(_,O,V),_.side=ri,_.needsUpdate=!0,Mr(_,O,V),_.side=Pn):Mr(_,O,V)}this.compile=function(_,O,V=null){V===null&&(V=_),g=me.get(V),g.init(O),x.push(g),V.traverseVisible(function($){$.isLight&&$.layers.test(O.layers)&&(g.pushLight($),$.castShadow&&g.pushShadow($))}),_!==V&&_.traverseVisible(function($){$.isLight&&$.layers.test(O.layers)&&(g.pushLight($),$.castShadow&&g.pushShadow($))}),g.setupLights(v._useLegacyLights);let N=new Set;return _.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let Ee=0;Ee<ue.length;Ee++){let Ie=ue[Ee];Ke(Ie,V,$),N.add(Ie)}else Ke(ue,V,$),N.add(ue)}),x.pop(),g=null,N},this.compileAsync=function(_,O,V=null){let N=this.compile(_,O,V);return new Promise($=>{function ue(){if(N.forEach(function(Ee){le.get(Ee).currentProgram.isReady()&&N.delete(Ee)}),N.size===0){$(_);return}setTimeout(ue,10)}J.get("KHR_parallel_shader_compile")!==null?ue():setTimeout(ue,10)})};let lt=null;function ft(_){lt&&lt(_)}function et(){Mt.stop()}function Xt(){Mt.start()}let Mt=new Q0;Mt.setAnimationLoop(ft),typeof self<"u"&&Mt.setContext(self),this.setAnimationLoop=function(_){lt=_,Ge.setAnimationLoop(_),_===null?Mt.stop():Mt.start()},Ge.addEventListener("sessionstart",et),Ge.addEventListener("sessionend",Xt),this.render=function(_,O){if(O!==void 0&&O.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Ge.enabled===!0&&Ge.isPresenting===!0&&(Ge.cameraAutoUpdate===!0&&Ge.updateCamera(O),O=Ge.getCamera()),_.isScene===!0&&_.onBeforeRender(v,_,O,E),g=me.get(_,x.length),g.init(O),x.push(g),pe.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Je.setFromProjectionMatrix(pe),q=this.localClippingEnabled,Z=ge.init(this.clippingPlanes,q),y=Ce.get(_,m.length),y.init(),m.push(y),ca(_,O,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,re);let V=Ge.enabled===!1||Ge.isPresenting===!1||Ge.hasDepthSensing()===!1;V&&fe.addToRenderList(y,_),this.info.render.frame++,Z===!0&&ge.beginShadows();let N=g.state.shadowsArray;ke.render(N,_,O),Z===!0&&ge.endShadows(),this.info.autoReset===!0&&this.info.reset();let $=y.opaque,ue=y.transmissive;if(g.setupLights(v._useLegacyLights),O.isArrayCamera){let Ee=O.cameras;if(ue.length>0)for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];ua($,ue,_,Be)}V&&fe.render(_);for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];As(y,_,Be,Be.viewport)}}else ue.length>0&&ua($,ue,_,O),V&&fe.render(_),As(y,_,O);E!==null&&(he.updateMultisampleRenderTarget(E),he.updateRenderTargetMipmap(E)),_.isScene===!0&&_.onAfterRender(v,_,O),De.resetDefaultState(),D=-1,M=null,x.pop(),x.length>0?(g=x[x.length-1],Z===!0&&ge.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,m.pop(),m.length>0?y=m[m.length-1]:y=null};function ca(_,O,V,N){if(_.visible===!1)return;if(_.layers.test(O.layers)){if(_.isGroup)V=_.renderOrder;else if(_.isLOD)_.autoUpdate===!0&&_.update(O);else if(_.isLight)g.pushLight(_),_.castShadow&&g.pushShadow(_);else if(_.isSprite){if(!_.frustumCulled||Je.intersectsSprite(_)){N&&ne.setFromMatrixPosition(_.matrixWorld).applyMatrix4(pe);let Ee=ee.update(_),Ie=_.material;Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}else if((_.isMesh||_.isLine||_.isPoints)&&(!_.frustumCulled||Je.intersectsObject(_))){let Ee=ee.update(_),Ie=_.material;if(N&&(_.boundingSphere!==void 0?(_.boundingSphere===null&&_.computeBoundingSphere(),ne.copy(_.boundingSphere.center)):(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),ne.copy(Ee.boundingSphere.center)),ne.applyMatrix4(_.matrixWorld).applyMatrix4(pe)),Array.isArray(Ie)){let Oe=Ee.groups;for(let Be=0,je=Oe.length;Be<je;Be++){let Ye=Oe[Be],xt=Ie[Ye.materialIndex];xt&&xt.visible&&y.push(_,Ee,xt,V,ne.z,Ye)}}else Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}let ue=_.children;for(let Ee=0,Ie=ue.length;Ee<Ie;Ee++)ca(ue[Ee],O,V,N)}function As(_,O,V,N){let $=_.opaque,ue=_.transmissive,Ee=_.transparent;g.setupLightsView(V),Z===!0&&ge.setGlobalState(v.clippingPlanes,V),N&&K.viewport(w.copy(N)),$.length>0&&wr($,O,V),ue.length>0&&wr(ue,O,V),Ee.length>0&&wr(Ee,O,V),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function ua(_,O,V,N){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[N.id]===void 0&&(g.state.transmissionRenderTarget[N.id]=new nn(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?ia:oi,minFilter:Ln,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let ue=g.state.transmissionRenderTarget[N.id],Ee=N.viewport||w;ue.setSize(Ee.z,Ee.w);let Ie=v.getRenderTarget();v.setRenderTarget(ue),v.getClearColor(I),B=v.getClearAlpha(),B<1&&v.setClearColor(16777215,.5),v.clear();let Oe=v.toneMapping;v.toneMapping=ni;let Be=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),g.setupLightsView(N),Z===!0&&ge.setGlobalState(v.clippingPlanes,N),wr(_,V,N),he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue),J.has("WEBGL_multisampled_render_to_texture")===!1){let je=!1;for(let Ye=0,xt=O.length;Ye<xt;Ye++){let Ut=O[Ye],qt=Ut.object,zn=Ut.geometry,nt=Ut.material,ze=Ut.group;if(nt.side===Pn&&qt.layers.test(N.layers)){let Ts=nt.side;nt.side=jt,nt.needsUpdate=!0,da(qt,V,N,zn,nt,ze),nt.side=Ts,nt.needsUpdate=!0,je=!0}}je===!0&&(he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue))}v.setRenderTarget(Ie),v.setClearColor(I,B),Be!==void 0&&(N.viewport=Be),v.toneMapping=Oe}function wr(_,O,V){let N=O.isScene===!0?O.overrideMaterial:null;for(let $=0,ue=_.length;$<ue;$++){let Ee=_[$],Ie=Ee.object,Oe=Ee.geometry,Be=N===null?Ee.material:N,je=Ee.group;Ie.layers.test(V.layers)&&da(Ie,O,V,Oe,Be,je)}}function da(_,O,V,N,$,ue){_.onBeforeRender(v,O,V,N,$,ue),_.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,_.matrixWorld),_.normalMatrix.getNormalMatrix(_.modelViewMatrix),$.onBeforeRender(v,O,V,N,_,ue),$.transparent===!0&&$.side===Pn&&$.forceSinglePass===!1?($.side=jt,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=ri,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=Pn):v.renderBufferDirect(V,O,N,$,_,ue),_.onAfterRender(v,O,V,N,$,ue)}function Mr(_,O,V){O.isScene!==!0&&(O=Fe);let N=le.get(_),$=g.state.lights,ue=g.state.shadowsArray,Ee=$.state.version,Ie=oe.getParameters(_,$.state,ue,O,V),Oe=oe.getProgramCacheKey(Ie),Be=N.programs;N.environment=_.isMeshStandardMaterial?O.environment:null,N.fog=O.fog,N.envMap=(_.isMeshStandardMaterial?P:Ae).get(_.envMap||N.environment),N.envMapRotation=N.environment!==null&&_.envMap===null?O.environmentRotation:_.envMapRotation,Be===void 0&&(_.addEventListener("dispose",xe),Be=new Map,N.programs=Be);let je=Be.get(Oe);if(je!==void 0){if(N.currentProgram===je&&N.lightsStateVersion===Ee)return ha(_,Ie),je}else Ie.uniforms=oe.getUniforms(_),_.onBuild(V,Ie,v),_.onBeforeCompile(Ie,v),je=oe.acquireProgram(Ie,Oe),Be.set(Oe,je),N.uniforms=Ie.uniforms;let Ye=N.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(Ye.clippingPlanes=ge.uniform),ha(_,Ie),N.needsLights=G(_),N.lightsStateVersion=Ee,N.needsLights&&(Ye.ambientLightColor.value=$.state.ambient,Ye.lightProbe.value=$.state.probe,Ye.directionalLights.value=$.state.directional,Ye.directionalLightShadows.value=$.state.directionalShadow,Ye.spotLights.value=$.state.spot,Ye.spotLightShadows.value=$.state.spotShadow,Ye.rectAreaLights.value=$.state.rectArea,Ye.ltc_1.value=$.state.rectAreaLTC1,Ye.ltc_2.value=$.state.rectAreaLTC2,Ye.pointLights.value=$.state.point,Ye.pointLightShadows.value=$.state.pointShadow,Ye.hemisphereLights.value=$.state.hemi,Ye.directionalShadowMap.value=$.state.directionalShadowMap,Ye.directionalShadowMatrix.value=$.state.directionalShadowMatrix,Ye.spotShadowMap.value=$.state.spotShadowMap,Ye.spotLightMatrix.value=$.state.spotLightMatrix,Ye.spotLightMap.value=$.state.spotLightMap,Ye.pointShadowMap.value=$.state.pointShadowMap,Ye.pointShadowMatrix.value=$.state.pointShadowMatrix),N.currentProgram=je,N.uniformsList=null,je}function Es(_){if(_.uniformsList===null){let O=_.currentProgram.getUniforms();_.uniformsList=os.seqWithValue(O.seq,_.uniforms)}return _.uniformsList}function ha(_,O){let V=le.get(_);V.outputColorSpace=O.outputColorSpace,V.batching=O.batching,V.instancing=O.instancing,V.instancingColor=O.instancingColor,V.instancingMorph=O.instancingMorph,V.skinning=O.skinning,V.morphTargets=O.morphTargets,V.morphNormals=O.morphNormals,V.morphColors=O.morphColors,V.morphTargetsCount=O.morphTargetsCount,V.numClippingPlanes=O.numClippingPlanes,V.numIntersection=O.numClipIntersection,V.vertexAlphas=O.vertexAlphas,V.vertexTangents=O.vertexTangents,V.toneMapping=O.toneMapping}function gu(_,O,V,N,$){O.isScene!==!0&&(O=Fe),he.resetTextureUnits();let ue=O.fog,Ee=N.isMeshStandardMaterial?O.environment:null,Ie=E===null?v.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:ci,Oe=(N.isMeshStandardMaterial?P:Ae).get(N.envMap||Ee),Be=N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,je=!!V.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),Ye=!!V.morphAttributes.position,xt=!!V.morphAttributes.normal,Ut=!!V.morphAttributes.color,qt=ni;N.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(qt=v.toneMapping);let zn=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,nt=zn!==void 0?zn.length:0,ze=le.get(N),Ts=g.state.lights;if(Z===!0&&(q===!0||_!==M)){let ln=_===M&&N.id===D;ge.setState(N,_,ln)}let dt=!1;N.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Ts.state.version||ze.outputColorSpace!==Ie||$.isBatchedMesh&&ze.batching===!1||!$.isBatchedMesh&&ze.batching===!0||$.isInstancedMesh&&ze.instancing===!1||!$.isInstancedMesh&&ze.instancing===!0||$.isSkinnedMesh&&ze.skinning===!1||!$.isSkinnedMesh&&ze.skinning===!0||$.isInstancedMesh&&ze.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&ze.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&ze.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&ze.instancingMorph===!1&&$.morphTexture!==null||ze.envMap!==Oe||N.fog===!0&&ze.fog!==ue||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==ge.numPlanes||ze.numIntersection!==ge.numIntersection)||ze.vertexAlphas!==Be||ze.vertexTangents!==je||ze.morphTargets!==Ye||ze.morphNormals!==xt||ze.morphColors!==Ut||ze.toneMapping!==qt||ze.morphTargetsCount!==nt)&&(dt=!0):(dt=!0,ze.__version=N.version);let Oi=ze.currentProgram;dt===!0&&(Oi=Mr(N,O,$));let qf=!1,Is=!1,yu=!1,Nt=Oi.getUniforms(),di=ze.uniforms;if(K.useProgram(Oi.program)&&(qf=!0,Is=!0,yu=!0),N.id!==D&&(D=N.id,Is=!0),qf||M!==_){Nt.setValue(H,"projectionMatrix",_.projectionMatrix),Nt.setValue(H,"viewMatrix",_.matrixWorldInverse);let ln=Nt.map.cameraPosition;ln!==void 0&&ln.setValue(H,ne.setFromMatrixPosition(_.matrixWorld)),ce.logarithmicDepthBuffer&&Nt.setValue(H,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&Nt.setValue(H,"isOrthographic",_.isOrthographicCamera===!0),M!==_&&(M=_,Is=!0,yu=!0)}if($.isSkinnedMesh){Nt.setOptional(H,$,"bindMatrix"),Nt.setOptional(H,$,"bindMatrixInverse");let ln=$.skeleton;ln&&(ln.boneTexture===null&&ln.computeBoneTexture(),Nt.setValue(H,"boneTexture",ln.boneTexture,he))}$.isBatchedMesh&&(Nt.setOptional(H,$,"batchingTexture"),Nt.setValue(H,"batchingTexture",$._matricesTexture,he));let vu=V.morphAttributes;if((vu.position!==void 0||vu.normal!==void 0||vu.color!==void 0)&&Re.update($,V,Oi),(Is||ze.receiveShadow!==$.receiveShadow)&&(ze.receiveShadow=$.receiveShadow,Nt.setValue(H,"receiveShadow",$.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(di.envMap.value=Oe,di.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&O.environment!==null&&(di.envMapIntensity.value=O.environmentIntensity),Is&&(Nt.setValue(H,"toneMappingExposure",v.toneMappingExposure),ze.needsLights&&C(di,yu),ue&&N.fog===!0&&ie.refreshFogUniforms(di,ue),ie.refreshMaterialUniforms(di,N,X,F,g.state.transmissionRenderTarget[_.id]),os.upload(H,Es(ze),di,he)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(os.upload(H,Es(ze),di,he),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&Nt.setValue(H,"center",$.center),Nt.setValue(H,"modelViewMatrix",$.modelViewMatrix),Nt.setValue(H,"normalMatrix",$.normalMatrix),Nt.setValue(H,"modelMatrix",$.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){let ln=N.uniformsGroups;for(let xu=0,ky=ln.length;xu<ky;xu++){let Zf=ln[xu];qe.update(Zf,Oi),qe.bind(Zf,Oi)}}return Oi}function C(_,O){_.ambientLightColor.needsUpdate=O,_.lightProbe.needsUpdate=O,_.directionalLights.needsUpdate=O,_.directionalLightShadows.needsUpdate=O,_.pointLights.needsUpdate=O,_.pointLightShadows.needsUpdate=O,_.spotLights.needsUpdate=O,_.spotLightShadows.needsUpdate=O,_.rectAreaLights.needsUpdate=O,_.hemisphereLights.needsUpdate=O}function G(_){return _.isMeshLambertMaterial||_.isMeshToonMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isShadowMaterial||_.isShaderMaterial&&_.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(_,O,V){le.get(_.texture).__webglTexture=O,le.get(_.depthTexture).__webglTexture=V;let N=le.get(_);N.__hasExternalTextures=!0,N.__autoAllocateDepthBuffer=V===void 0,N.__autoAllocateDepthBuffer||J.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),N.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(_,O){let V=le.get(_);V.__webglFramebuffer=O,V.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(_,O=0,V=0){E=_,L=O,A=V;let N=!0,$=null,ue=!1,Ee=!1;if(_){let Oe=le.get(_);Oe.__useDefaultFramebuffer!==void 0?(K.bindFramebuffer(H.FRAMEBUFFER,null),N=!1):Oe.__webglFramebuffer===void 0?he.setupRenderTarget(_):Oe.__hasExternalTextures&&he.rebindTextures(_,le.get(_.texture).__webglTexture,le.get(_.depthTexture).__webglTexture);let Be=_.texture;(Be.isData3DTexture||Be.isDataArrayTexture||Be.isCompressedArrayTexture)&&(Ee=!0);let je=le.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(je[O])?$=je[O][V]:$=je[O],ue=!0):_.samples>0&&he.useMultisampledRTT(_)===!1?$=le.get(_).__webglMultisampledFramebuffer:Array.isArray(je)?$=je[V]:$=je,w.copy(_.viewport),T.copy(_.scissor),U=_.scissorTest}else w.copy(se).multiplyScalar(X).floor(),T.copy(ve).multiplyScalar(X).floor(),U=Le;if(K.bindFramebuffer(H.FRAMEBUFFER,$)&&N&&K.drawBuffers(_,$),K.viewport(w),K.scissor(T),K.setScissorTest(U),ue){let Oe=le.get(_.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+O,Oe.__webglTexture,V)}else if(Ee){let Oe=le.get(_.texture),Be=O||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,Oe.__webglTexture,V||0,Be)}D=-1},this.readRenderTargetPixels=function(_,O,V,N,$,ue,Ee){if(!(_&&_.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=le.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&Ee!==void 0&&(Ie=Ie[Ee]),Ie){K.bindFramebuffer(H.FRAMEBUFFER,Ie);try{let Oe=_.texture,Be=Oe.format,je=Oe.type;if(!ce.textureFormatReadable(Be)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ce.textureTypeReadable(je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=_.width-N&&V>=0&&V<=_.height-$&&H.readPixels(O,V,N,$,Me.convert(Be),Me.convert(je),ue)}finally{let Oe=E!==null?le.get(E).__webglFramebuffer:null;K.bindFramebuffer(H.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(_,O,V=0){let N=Math.pow(2,-V),$=Math.floor(O.image.width*N),ue=Math.floor(O.image.height*N);he.setTexture2D(O,0),H.copyTexSubImage2D(H.TEXTURE_2D,V,0,0,_.x,_.y,$,ue),K.unbindTexture()},this.copyTextureToTexture=function(_,O,V,N=0){let $=O.image.width,ue=O.image.height,Ee=Me.convert(V.format),Ie=Me.convert(V.type);he.setTexture2D(V,0),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,V.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,V.unpackAlignment),O.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,N,_.x,_.y,$,ue,Ee,Ie,O.image.data):O.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,N,_.x,_.y,O.mipmaps[0].width,O.mipmaps[0].height,Ee,O.mipmaps[0].data):H.texSubImage2D(H.TEXTURE_2D,N,_.x,_.y,Ee,Ie,O.image),N===0&&V.generateMipmaps&&H.generateMipmap(H.TEXTURE_2D),K.unbindTexture()},this.copyTextureToTexture3D=function(_,O,V,N,$=0){let ue=_.max.x-_.min.x,Ee=_.max.y-_.min.y,Ie=_.max.z-_.min.z,Oe=Me.convert(N.format),Be=Me.convert(N.type),je;if(N.isData3DTexture)he.setTexture3D(N,0),je=H.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)he.setTexture2DArray(N,0),je=H.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,N.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,N.unpackAlignment);let Ye=H.getParameter(H.UNPACK_ROW_LENGTH),xt=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Ut=H.getParameter(H.UNPACK_SKIP_PIXELS),qt=H.getParameter(H.UNPACK_SKIP_ROWS),zn=H.getParameter(H.UNPACK_SKIP_IMAGES),nt=V.isCompressedTexture?V.mipmaps[$]:V.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,nt.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,nt.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,_.min.x),H.pixelStorei(H.UNPACK_SKIP_ROWS,_.min.y),H.pixelStorei(H.UNPACK_SKIP_IMAGES,_.min.z),V.isDataTexture||V.isData3DTexture?H.texSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,nt.data):N.isCompressedArrayTexture?H.compressedTexSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,nt.data):H.texSubImage3D(je,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,nt),H.pixelStorei(H.UNPACK_ROW_LENGTH,Ye),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,xt),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ut),H.pixelStorei(H.UNPACK_SKIP_ROWS,qt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,zn),$===0&&N.generateMipmaps&&H.generateMipmap(je),K.unbindTexture()},this.initTexture=function(_){_.isCubeTexture?he.setTextureCube(_,0):_.isData3DTexture?he.setTexture3D(_,0):_.isDataArrayTexture||_.isCompressedArrayTexture?he.setTexture2DArray(_,0):he.setTexture2D(_,0),K.unbindTexture()},this.resetState=function(){L=0,A=0,E=null,K.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Dn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===cu?"display-p3":"srgb",t.unpackColorSpace=ot.workingColorSpace===ra?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},tc=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new we(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},nc=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new we(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ic=class extends it{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(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},ms=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ao,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=tn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return q0("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Gt=new R,hr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Wt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=He(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=He(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Wt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Wt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Wt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Wt(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=He(t,this.array),i=He(i,this.array),r=He(r,this.array),s=He(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Uo=class extends Lt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ks=new R,Zr=new R,Jr=new R,Kr=new te,Qs=new te,oy=new Ne,yl=new R,eo=new R,vl=new R,Zm=new te,md=new te,Jm=new te,rc=class extends it{constructor(e=new Uo){if(super(),this.isSprite=!0,this.type="Sprite",qr===void 0){qr=new Xe;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new ms(t,5);qr.setIndex([0,1,2,0,2,3]),qr.setAttribute("position",new hr(i,3,0,!1)),qr.setAttribute("uv",new hr(i,2,3,!1))}this.geometry=qr,this.material=e,this.center=new te(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zr.setFromMatrixScale(this.matrixWorld),oy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Jr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zr.multiplyScalar(-Jr.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;xl(yl.set(-.5,-.5,0),Jr,o,Zr,r,s),xl(eo.set(.5,-.5,0),Jr,o,Zr,r,s),xl(vl.set(.5,.5,0),Jr,o,Zr,r,s),Zm.set(0,0),md.set(1,0),Jm.set(1,1);let a=e.ray.intersectTriangle(yl,eo,vl,!1,Ks);if(a===null&&(xl(eo.set(-.5,.5,0),Jr,o,Zr,r,s),md.set(0,1),a=e.ray.intersectTriangle(yl,vl,eo,!1,Ks),a===null))return;let l=e.ray.origin.distanceTo(Ks);l<e.near||l>e.far||t.push({distance:l,point:Ks.clone(),uv:Qn.getInterpolation(Ks,yl,eo,vl,Zm,md,Jm,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};_l=new R,Km=new R,sc=class extends it{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){_l.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(_l);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){_l.setFromMatrixPosition(e.matrixWorld),Km.setFromMatrixPosition(this.matrixWorld);let i=_l.distanceTo(Km)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},Qm=new R,eg=new at,tg=new at,TE=new R,ng=new Ne,bl=new R,gd=new Pt,ig=new Ne,yd=new Ii,oc=class extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Dd,this.bindMatrix=new Ne,this.bindMatrixInverse=new Ne,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Dt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,bl),this.boundingBox.expandByPoint(bl)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Pt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,bl),this.boundingSphere.expandByPoint(bl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gd.copy(this.boundingSphere),gd.applyMatrix4(r),e.ray.intersectsSphere(gd)!==!1&&(ig.copy(r).invert(),yd.copy(e.ray).applyMatrix4(ig),!(this.boundingBox!==null&&yd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,yd)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new at,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Dd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===S0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;eg.fromBufferAttribute(r.attributes.skinIndex,e),tg.fromBufferAttribute(r.attributes.skinWeight,e),Qm.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=tg.getComponent(s);if(o!==0){let a=eg.getComponent(s);ng.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(TE.copy(Qm).applyMatrix4(ng),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},No=class extends it{constructor(){super(),this.isBone=!0,this.type="Bone"}},On=class extends wt{constructor(e=null,t=1,i=1,r,s,o,a,l,c=Rt,u=Rt,d,h){super(null,o,a,l,c,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},rg=new Ne,IE=new Ne,ac=class n{constructor(e=[],t=[]){this.uuid=tn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ne)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Ne;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:IE;rg.multiplyMatrices(a,t[s]),rg.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new On(t,e,e,en,yn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new No),this.bones.push(o),this.boneInverses.push(new Ne().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Ci=class extends tt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Qr=new Ne,sg=new Ne,wl=[],og=new Dt,CE=new Ne,to=new yt,no=new Pt,lc=class extends yt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ci(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,CE)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Dt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qr),og.copy(e.boundingBox).applyMatrix4(Qr),this.boundingBox.union(og)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Pt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qr),no.copy(e.boundingSphere).applyMatrix4(Qr),this.boundingSphere.union(no)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(to.geometry=this.geometry,to.material=this.material,to.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),no.copy(this.boundingSphere),no.applyMatrix4(i),e.ray.intersectsSphere(no)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Qr),sg.multiplyMatrices(i,Qr),to.matrixWorld=sg,to.raycast(e,wl);for(let o=0,a=wl.length;o<a;o++){let l=wl[o];l.instanceId=s,l.object=this,t.push(l)}wl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ci(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new On(new Float32Array(r*this.count),r,this.count,Lf,yn));let s=this.morphTexture.source.data.data,o=0;for(let c=0;c<i.length;c++)o+=i[c];let a=this.geometry.morphTargetsRelative?1:1-o,l=r*e;s[l]=a,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};Ah=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},es="batchId",Mi=new Ne,ag=new Ne,LE=new Ne,lg=new Ne,vd=new dr,Ml=new Dt,Xi=new Pt,io=new R,xd=new Ah,zt=new yt,Sl=[];cc=class extends yt{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new Xe,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new On(t,e,e,en,yn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let l=e.getAttribute(a),{array:c,itemSize:u,normalized:d}=l,h=new c.constructor(i*u),f=new tt(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new tt(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(es,new tt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(es))throw new Error(`BatchedMesh: Geometry cannot use attribute "${es}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===es)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Mi),this.getBoundingBoxAt(r,Ml).applyMatrix4(Mi),t.union(Ml))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Pt);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Mi),this.getBoundingSphereAt(r,Xi).applyMatrix4(Mi),t.union(Xi))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,LE.toArray(p,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Dt,sphereInitialized:!1,sphere:new Pt});let g=this.geometry.getAttribute(es);for(let m=0;m<r.vertexCount;m++)g.setX(r.vertexStart+m,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let l=a.vertexStart,c=a.vertexCount;for(let f in i.attributes){if(f===es)continue;let p=t.getAttribute(f),y=i.getAttribute(f);DE(p,y,l);let g=p.itemSize;for(let m=p.count,x=c;m<x;m++){let v=l+m;for(let b=0;b<g;b++)y.setComponent(v,b,0)}y.needsUpdate=!0,y.addUpdateRange(l*g,c*g)}if(r){let f=a.indexStart;for(let p=0;p<o.count;p++)s.setX(f+p,l+o.getX(p));for(let p=o.count,y=a.indexCount;p<y;p++)s.setX(f+p,l);s.needsUpdate=!0,s.addUpdateRange(f,a.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,l=o.attributes.position,c=this._drawRanges[e];for(let u=c.start,d=c.start+c.count;u<d;u++){let h=u;a&&(h=a.getX(h)),s.expandByPoint(io.fromBufferAttribute(l,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Ml),Ml.getCenter(s.center);let a=o.index,l=o.attributes.position,c=this._drawRanges[e],u=0;for(let d=c.start,h=c.start+c.count;d<h;d++){let f=d;a&&(f=a.getX(f)),io.fromBufferAttribute(l,f),u=Math.max(u,s.center.distanceToSquared(io))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,l=this.geometry;zt.material=this.material,zt.geometry.index=l.index,zt.geometry.attributes=l.attributes,zt.geometry.boundingBox===null&&(zt.geometry.boundingBox=new Dt),zt.geometry.boundingSphere===null&&(zt.geometry.boundingSphere=new Pt);for(let c=0;c<o;c++){if(!i[c]||!r[c])continue;let u=s[c];zt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,zt.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,zt.geometry.boundingBox),this.getBoundingSphereAt(c,zt.geometry.boundingSphere),zt.raycast(e,Sl);for(let d=0,h=Sl.length;d<h;d++){let f=Sl[d];f.object=this,f.batchId=c,t.push(f)}Sl.length=0}zt.material=null,zt.geometry.index=null,zt.geometry.attributes={},zt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(lg.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vd.setFromProjectionMatrix(lg,e.coordinateSystem));let p=0;if(this.sortObjects){ag.copy(this.matrixWorld).invert(),io.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ag);for(let m=0,x=c.length;m<x;m++)if(c[m]&&l[m]){this.getMatrixAt(m,Mi),this.getBoundingSphereAt(m,Xi).applyMatrix4(Mi);let v=!1;if(f&&(v=!vd.intersectsSphere(Xi)),!v){let b=io.distanceTo(Xi.center);xd.push(h[m],b)}}let y=xd.list,g=this.customSort;g===null?y.sort(s.transparent?PE:RE):g.call(this,y,i);for(let m=0,x=y.length;m<x;m++){let v=y[m];u[p]=v.start*a,d[p]=v.count,p++}xd.reset()}else for(let y=0,g=c.length;y<g;y++)if(c[y]&&l[y]){let m=!1;if(f&&(this.getMatrixAt(y,Mi),this.getBoundingSphereAt(y,Xi).applyMatrix4(Mi),m=!vd.intersectsSphere(Xi)),!m){let x=h[y];u[p]=x.start*a,d[p]=x.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Ot=class extends Lt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new we(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},uc=new R,dc=new R,cg=new Ne,ro=new Ii,Al=new Pt,_d=new R,ug=new R,Fn=class extends it{constructor(e=new Xe,t=new Ot){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)uc.fromBufferAttribute(t,r-1),dc.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=uc.distanceTo(dc);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Al.copy(i.boundingSphere),Al.applyMatrix4(r),Al.radius+=s,e.ray.intersectsSphere(Al)===!1)return;cg.copy(r).invert(),ro.copy(e.ray).applyMatrix4(cg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=c){let m=u.getX(y),x=u.getX(y+1),v=El(this,e,ro,l,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=El(this,e,ro,l,y,g);m&&t.push(m)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=c){let m=El(this,e,ro,l,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=El(this,e,ro,l,p-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};dg=new R,hg=new R,vn=class extends Fn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)dg.fromBufferAttribute(t,r),hg.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+dg.distanceTo(hg);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hc=class extends Fn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Fo=class extends Lt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},fg=new Ne,Eh=new Ii,Tl=new Pt,Il=new R,fc=class extends it{constructor(e=new Xe,t=new Fo){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Tl.copy(i.boundingSphere),Tl.applyMatrix4(r),Tl.radius+=s,e.ray.intersectsSphere(Tl)===!1)return;fg.copy(r).invert(),Eh.copy(e.ray).applyMatrix4(fg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){let h=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let p=h,y=f;p<y;p++){let g=c.getX(p);Il.fromBufferAttribute(d,g),pg(Il,g,l,r,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let p=h,y=f;p<y;p++)Il.fromBufferAttribute(d,p),pg(Il,p,l,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};Th=class extends wt{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:bt,this.magFilter=s!==void 0?s:bt,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Ih=class extends wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Rt,this.minFilter=Rt,this.generateMipmaps=!1,this.needsUpdate=!0}},gs=class extends wt{constructor(e,t,i,r,s,o,a,l,c,u,d,h){super(null,o,a,l,c,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Ch=class extends gs{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gn}},Rh=class extends gs{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,si),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Ph=class extends wt{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},on=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),c=i[r]-o,c<0)a=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===o)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(o-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=t||(o.isVector2?new te:new R);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new R,r=[],s=[],o=[],a=new R,l=new Ne;for(let f=0;f<=e;f++){let p=f/e;r[f]=this.getTangentAt(p,new R)}s[0]=new R,o[0]=new R;let c=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(gt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(gt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(l.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ys=class extends on{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new te){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=c-this.aY;l=h*u-f*d+this.aX,c=h*d+f*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},pc=class extends ys{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};Cl=new R,bd=new zf,wd=new zf,Md=new zf,mc=class extends on{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new R){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=r[(a-1)%s]:(Cl.subVectors(r[0],r[1]).add(r[0]),c=Cl);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Cl.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Cl),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),p<1e-4&&(p=y),g<1e-4&&(g=y),bd.initNonuniformCatmullRom(c.x,d.x,h.x,u.x,p,y,g),wd.initNonuniformCatmullRom(c.y,d.y,h.y,u.y,p,y,g),Md.initNonuniformCatmullRom(c.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(bd.initCatmullRom(c.x,d.x,h.x,u.x,this.tension),wd.initCatmullRom(c.y,d.y,h.y,u.y,this.tension),Md.initCatmullRom(c.z,d.z,h.z,u.z,this.tension));return i.set(bd.calc(l),wd.calc(l),Md.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new R().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ko=class extends on{constructor(e=new te,t=new te,i=new te,r=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new te){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(fo(e,r.x,s.x,o.x,a.x),fo(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},gc=class extends on{constructor(e=new R,t=new R,i=new R,r=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new R){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(fo(e,r.x,s.x,o.x,a.x),fo(e,r.y,s.y,o.y,a.y),fo(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Bo=class extends on{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},yc=class extends on{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},zo=class extends on{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(ho(e,r.x,s.x,o.x),ho(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Vo=class extends on{constructor(e=new R,t=new R,i=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new R){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(ho(e,r.x,s.x,o.x),ho(e,r.y,s.y,o.y),ho(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ho=class extends on{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],c=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(mg(a,l.x,c.x,u.x,d.x),mg(a,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new te().fromArray(r))}return this}},vc=Object.freeze({__proto__:null,ArcCurve:pc,CatmullRomCurve3:mc,CubicBezierCurve:ko,CubicBezierCurve3:gc,EllipseCurve:ys,LineCurve:Bo,LineCurve3:yc,QuadraticBezierCurve:zo,QuadraticBezierCurve3:Vo,SplineCurve:Ho}),xc=class extends on{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new vc[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new vc[r.type]().fromJSON(r))}return this}},fr=class extends xc{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Bo(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new zo(this.currentPoint.clone(),new te(e,t),new te(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new ko(this.currentPoint.clone(),new te(e,t),new te(i,r),new te(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Ho(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,o,a,l),this}absellipse(e,t,i,r,s,o,a,l){let c=new ys(e,t,i,r,s,o,a,l);if(this.curves.length>0){let d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Go=class n extends Xe{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=gt(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/t,d=new R,h=new te,f=new R,p=new R,y=new R,g=0,m=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,y.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),l.push(f.x,f.y,f.z),y.copy(p)}for(let x=0;x<=t;x++){let v=i+x*u*r,b=Math.sin(v),L=Math.cos(v);for(let A=0;A<=e.length-1;A++){d.x=e[A].x*b,d.y=e[A].y,d.z=e[A].x*L,o.push(d.x,d.y,d.z),h.x=x/t,h.y=A/(e.length-1),a.push(h.x,h.y);let E=l[3*A+0]*b,D=l[3*A+1],M=l[3*A+0]*L;c.push(E,D,M)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){let b=v+x*e.length,L=b,A=b+e.length,E=b+e.length+1,D=b+1;s.push(L,A,D),s.push(E,D,A)}this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("uv",new Te(a,2)),this.setAttribute("normal",new Te(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},_c=class n extends Go{constructor(e=1,t=1,i=4,r=8){let s=new fr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},bc=class n extends Xe{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],l=[],c=new R,u=new te;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;c.x=e*Math.cos(f),c.y=e*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,l.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(a,3)),this.setAttribute("uv",new Te(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},vs=class n extends Xe{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],p=0,y=[],g=i/2,m=0;x(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(f,2));function x(){let b=new R,L=new R,A=0,E=(t-e)/i;for(let D=0;D<=s;D++){let M=[],w=D/s,T=w*(t-e)+e;for(let U=0;U<=r;U++){let I=U/r,B=I*l+a,W=Math.sin(B),F=Math.cos(B);L.x=T*W,L.y=-w*i+g,L.z=T*F,d.push(L.x,L.y,L.z),b.set(W,E,F).normalize(),h.push(b.x,b.y,b.z),f.push(I,1-w),M.push(p++)}y.push(M)}for(let D=0;D<r;D++)for(let M=0;M<s;M++){let w=y[M][D],T=y[M+1][D],U=y[M+1][D+1],I=y[M][D+1];u.push(w,T,I),u.push(T,U,I),A+=6}c.addGroup(m,A,0),m+=A}function v(b){let L=p,A=new te,E=new R,D=0,M=b===!0?e:t,w=b===!0?1:-1;for(let U=1;U<=r;U++)d.push(0,g*w,0),h.push(0,w,0),f.push(.5,.5),p++;let T=p;for(let U=0;U<=r;U++){let B=U/r*l+a,W=Math.cos(B),F=Math.sin(B);E.x=M*F,E.y=g*w,E.z=M*W,d.push(E.x,E.y,E.z),h.push(0,w,0),A.x=W*.5+.5,A.y=F*.5*w+.5,f.push(A.x,A.y),p++}for(let U=0;U<r;U++){let I=L+U,B=T+U;b===!0?u.push(B,B+1,I):u.push(B+1,B,I),D+=3}c.addGroup(m,D,b===!0?1:2),m+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},wc=class n extends vs{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ri=class n extends Xe{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),c(i),u(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new R,b=new R,L=new R;for(let A=0;A<t.length;A+=3)f(t[A+0],v),f(t[A+1],b),f(t[A+2],L),l(v,b,L,x)}function l(x,v,b,L){let A=L+1,E=[];for(let D=0;D<=A;D++){E[D]=[];let M=x.clone().lerp(b,D/A),w=v.clone().lerp(b,D/A),T=A-D;for(let U=0;U<=T;U++)U===0&&D===A?E[D][U]=M:E[D][U]=M.clone().lerp(w,U/T)}for(let D=0;D<A;D++)for(let M=0;M<2*(A-D)-1;M++){let w=Math.floor(M/2);M%2===0?(h(E[D][w+1]),h(E[D+1][w]),h(E[D][w])):(h(E[D][w+1]),h(E[D+1][w+1]),h(E[D+1][w]))}}function c(x){let v=new R;for(let b=0;b<s.length;b+=3)v.x=s[b+0],v.y=s[b+1],v.z=s[b+2],v.normalize().multiplyScalar(x),s[b+0]=v.x,s[b+1]=v.y,s[b+2]=v.z}function u(){let x=new R;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let b=g(x)/2/Math.PI+.5,L=m(x)/Math.PI+.5;o.push(b,1-L)}p(),d()}function d(){for(let x=0;x<o.length;x+=6){let v=o[x+0],b=o[x+2],L=o[x+4],A=Math.max(v,b,L),E=Math.min(v,b,L);A>.9&&E<.1&&(v<.2&&(o[x+0]+=1),b<.2&&(o[x+2]+=1),L<.2&&(o[x+4]+=1))}}function h(x){s.push(x.x,x.y,x.z)}function f(x,v){let b=x*3;v.x=e[b+0],v.y=e[b+1],v.z=e[b+2]}function p(){let x=new R,v=new R,b=new R,L=new R,A=new te,E=new te,D=new te;for(let M=0,w=0;M<s.length;M+=9,w+=6){x.set(s[M+0],s[M+1],s[M+2]),v.set(s[M+3],s[M+4],s[M+5]),b.set(s[M+6],s[M+7],s[M+8]),A.set(o[w+0],o[w+1]),E.set(o[w+2],o[w+3]),D.set(o[w+4],o[w+5]),L.copy(x).add(v).add(b).divideScalar(3);let T=g(L);y(A,w+0,x,T),y(E,w+2,v,T),y(D,w+4,b,T)}}function y(x,v,b,L){L<0&&x.x===1&&(o[v]=x.x-1),b.x===0&&b.z===0&&(o[v]=L/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function m(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},Mc=class n extends Ri{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],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(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Rl=new R,Pl=new R,Sd=new R,Ll=new Qn,Sc=class extends Xe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(ar*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let p=0;p<l;p+=3){o?(c[0]=o.getX(p),c[1]=o.getX(p+1),c[2]=o.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);let{a:y,b:g,c:m}=Ll;if(y.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),Ll.getNormal(Sd),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let x=0;x<3;x++){let v=(x+1)%3,b=d[x],L=d[v],A=Ll[u[x]],E=Ll[u[v]],D=`${b}_${L}`,M=`${L}_${b}`;M in h&&h[M]?(Sd.dot(h[M].normal)<=s&&(f.push(A.x,A.y,A.z),f.push(E.x,E.y,E.z)),h[M]=null):D in h||(h[D]={index0:c[x],index1:c[v],normal:Sd.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];Rl.fromBufferAttribute(a,y),Pl.fromBufferAttribute(a,g),f.push(Rl.x,Rl.y,Rl.z),f.push(Pl.x,Pl.y,Pl.z)}this.setAttribute("position",new Te(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ii=class extends fr{constructor(e){super(e),this.uuid=tn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new fr().fromJSON(r))}return this}},VE={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=ay(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,d,h,f;if(i&&(s=jE(n,e,s,t)),n.length>80*t){a=c=n[0],l=u=n[1];for(let p=t;p<r;p+=t)d=n[p],h=n[p+1],d<a&&(a=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return $o(s,o,t,a,l,f,0),o}};Un=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];yg(e),vg(i,e);let o=e.length;t.forEach(yg);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,vg(i,t[l]);let a=VE.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};Ac=class n extends Xe{constructor(e=new ii([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,l=e.length;a<l;a++){let c=e[a];o(c)}this.setAttribute("position",new Te(r,3)),this.setAttribute("uv",new Te(s,2)),this.computeVertexNormals();function o(a){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:rT,v,b=!1,L,A,E,D;m&&(v=m.getSpacedPoints(u),b=!0,h=!1,L=m.computeFrenetFrames(u,!1),A=new R,E=new R,D=new R),h||(g=0,f=0,p=0,y=0);let M=a.extractPoints(c),w=M.shape,T=M.holes;if(!Un.isClockWise(w)){w=w.reverse();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];Un.isClockWise(K)&&(T[J]=K.reverse())}}let I=Un.triangulateShape(w,T),B=w;for(let J=0,ce=T.length;J<ce;J++){let K=T[J];w=w.concat(K)}function W(J,ce,K){return ce||console.error("THREE.ExtrudeGeometry: vec does not exist"),J.clone().addScaledVector(ce,K)}let F=w.length,X=I.length;function k(J,ce,K){let de,le,he,Ae=J.x-ce.x,P=J.y-ce.y,S=K.x-J.x,j=K.y-J.y,ee=Ae*Ae+P*P,oe=Ae*j-P*S;if(Math.abs(oe)>Number.EPSILON){let ie=Math.sqrt(ee),Ce=Math.sqrt(S*S+j*j),me=ce.x-P/ie,ge=ce.y+Ae/ie,ke=K.x-j/Ce,fe=K.y+S/Ce,Re=((ke-me)*j-(fe-ge)*S)/(Ae*j-P*S);de=me+Ae*Re-J.x,le=ge+P*Re-J.y;let We=de*de+le*le;if(We<=2)return new te(de,le);he=Math.sqrt(We/2)}else{let ie=!1;Ae>Number.EPSILON?S>Number.EPSILON&&(ie=!0):Ae<-Number.EPSILON?S<-Number.EPSILON&&(ie=!0):Math.sign(P)===Math.sign(j)&&(ie=!0),ie?(de=-P,le=Ae,he=Math.sqrt(ee)):(de=Ae,le=P,he=Math.sqrt(ee/2))}return new te(de/he,le/he)}let re=[];for(let J=0,ce=B.length,K=ce-1,de=J+1;J<ce;J++,K++,de++)K===ce&&(K=0),de===ce&&(de=0),re[J]=k(B[J],B[K],B[de]);let se=[],ve,Le=re.concat();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];ve=[];for(let de=0,le=K.length,he=le-1,Ae=de+1;de<le;de++,he++,Ae++)he===le&&(he=0),Ae===le&&(Ae=0),ve[de]=k(K[de],K[he],K[Ae]);se.push(ve),Le=Le.concat(ve)}for(let J=0;J<g;J++){let ce=J/g,K=f*Math.cos(ce*Math.PI/2),de=p*Math.sin(ce*Math.PI/2)+y;for(let le=0,he=B.length;le<he;le++){let Ae=W(B[le],re[le],de);ne(Ae.x,Ae.y,-K)}for(let le=0,he=T.length;le<he;le++){let Ae=T[le];ve=se[le];for(let P=0,S=Ae.length;P<S;P++){let j=W(Ae[P],ve[P],de);ne(j.x,j.y,-K)}}}let Je=p+y;for(let J=0;J<F;J++){let ce=h?W(w[J],Le[J],Je):w[J];b?(E.copy(L.normals[0]).multiplyScalar(ce.x),A.copy(L.binormals[0]).multiplyScalar(ce.y),D.copy(v[0]).add(E).add(A),ne(D.x,D.y,D.z)):ne(ce.x,ce.y,0)}for(let J=1;J<=u;J++)for(let ce=0;ce<F;ce++){let K=h?W(w[ce],Le[ce],Je):w[ce];b?(E.copy(L.normals[J]).multiplyScalar(K.x),A.copy(L.binormals[J]).multiplyScalar(K.y),D.copy(v[J]).add(E).add(A),ne(D.x,D.y,D.z)):ne(K.x,K.y,d/u*J)}for(let J=g-1;J>=0;J--){let ce=J/g,K=f*Math.cos(ce*Math.PI/2),de=p*Math.sin(ce*Math.PI/2)+y;for(let le=0,he=B.length;le<he;le++){let Ae=W(B[le],re[le],de);ne(Ae.x,Ae.y,d+K)}for(let le=0,he=T.length;le<he;le++){let Ae=T[le];ve=se[le];for(let P=0,S=Ae.length;P<S;P++){let j=W(Ae[P],ve[P],de);b?ne(j.x,j.y+v[u-1].y,v[u-1].x+K):ne(j.x,j.y,d+K)}}}Z(),q();function Z(){let J=r.length/3;if(h){let ce=0,K=F*ce;for(let de=0;de<X;de++){let le=I[de];Fe(le[2]+K,le[1]+K,le[0]+K)}ce=u+g*2,K=F*ce;for(let de=0;de<X;de++){let le=I[de];Fe(le[0]+K,le[1]+K,le[2]+K)}}else{for(let ce=0;ce<X;ce++){let K=I[ce];Fe(K[2],K[1],K[0])}for(let ce=0;ce<X;ce++){let K=I[ce];Fe(K[0]+F*u,K[1]+F*u,K[2]+F*u)}}i.addGroup(J,r.length/3-J,0)}function q(){let J=r.length/3,ce=0;pe(B,ce),ce+=B.length;for(let K=0,de=T.length;K<de;K++){let le=T[K];pe(le,ce),ce+=le.length}i.addGroup(J,r.length/3-J,1)}function pe(J,ce){let K=J.length;for(;--K>=0;){let de=K,le=K-1;le<0&&(le=J.length-1);for(let he=0,Ae=u+g*2;he<Ae;he++){let P=F*he,S=F*(he+1),j=ce+de+P,ee=ce+le+P,oe=ce+le+S,ie=ce+de+S;_e(j,ee,oe,ie)}}}function ne(J,ce,K){l.push(J),l.push(ce),l.push(K)}function Fe(J,ce,K){H(J),H(ce),H(K);let de=r.length/3,le=x.generateTopUV(i,r,de-3,de-2,de-1);Ue(le[0]),Ue(le[1]),Ue(le[2])}function _e(J,ce,K,de){H(J),H(ce),H(de),H(ce),H(K),H(de);let le=r.length/3,he=x.generateSideWallUV(i,r,le-6,le-3,le-2,le-1);Ue(he[0]),Ue(he[1]),Ue(he[3]),Ue(he[1]),Ue(he[2]),Ue(he[3])}function H(J){r.push(l[J*3+0]),r.push(l[J*3+1]),r.push(l[J*3+2])}function Ue(J){s.push(J.x),s.push(J.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return sT(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new vc[r.type]().fromJSON(r)),new n(i,e.options)}},rT={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new te(s,o),new te(a,l),new te(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],p=e[r*3+2],y=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new te(o,1-l),new te(c,1-d),new te(h,1-p),new te(y,1-m)]:[new te(a,1-l),new te(u,1-d),new te(f,1-p),new te(g,1-m)]}};Ec=class n extends Ri{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[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(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Xo=class n extends Ri{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[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(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Tc=class n extends Xe{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],l=[],c=[],u=[],d=e,h=(t-e)/r,f=new R,p=new te;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let m=s+g/i*o;f.x=d*Math.cos(m),f.y=d*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,u.push(p.x,p.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let m=0;m<i;m++){let x=m+g,v=x,b=x+i+1,L=x+i+2,A=x+1;a.push(v,b,A),a.push(b,L,A)}}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Ic=class n extends Xe{constructor(e=new ii([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new Te(r,3)),this.setAttribute("normal",new Te(s,3)),this.setAttribute("uv",new Te(o,2));function c(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,p=h.holes;Un.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Un.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Un.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){let x=p[g];f=f.concat(x)}for(let g=0,m=f.length;g<m;g++){let x=f[g];r.push(x.x,x.y,0),s.push(0,0,1),o.push(x.x,x.y)}for(let g=0,m=y.length;g<m;g++){let x=y[g],v=x[0]+d,b=x[1]+d,L=x[2]+d;i.push(v,b,L),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return oT(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Yo=class n extends Xe{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let l=Math.min(o+a,Math.PI),c=0,u=[],d=new R,h=new R,f=[],p=[],y=[],g=[];for(let m=0;m<=i;m++){let x=[],v=m/i,b=0;m===0&&o===0?b=.5/t:m===i&&l===Math.PI&&(b=-.5/t);for(let L=0;L<=t;L++){let A=L/t;d.x=-e*Math.cos(r+A*s)*Math.sin(o+v*a),d.y=e*Math.cos(o+v*a),d.z=e*Math.sin(r+A*s)*Math.sin(o+v*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(A+b,1-v),x.push(c++)}u.push(x)}for(let m=0;m<i;m++)for(let x=0;x<t;x++){let v=u[m][x+1],b=u[m][x],L=u[m+1][x],A=u[m+1][x+1];(m!==0||o>0)&&f.push(v,b,A),(m!==i-1||l<Math.PI)&&f.push(b,L,A)}this.setIndex(f),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(y,3)),this.setAttribute("uv",new Te(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},Cc=class n extends Ri{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Rc=class n extends Xe{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],l=[],c=[],u=new R,d=new R,h=new R;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),l.push(h.x,h.y,h.z),c.push(p/r),c.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,g=(r+1)*(f-1)+p-1,m=(r+1)*(f-1)+p,x=(r+1)*f+p;o.push(y,g,x),o.push(g,m,x)}this.setIndex(o),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},Pc=class n extends Xe{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],l=[],c=[],u=[],d=new R,h=new R,f=new R,p=new R,y=new R,g=new R,m=new R;for(let v=0;v<=i;++v){let b=v/i*s*Math.PI*2;x(b,s,o,e,f),x(b+.01,s,o,e,p),g.subVectors(p,f),m.addVectors(p,f),y.crossVectors(g,m),m.crossVectors(y,g),y.normalize(),m.normalize();for(let L=0;L<=r;++L){let A=L/r*Math.PI*2,E=-t*Math.cos(A),D=t*Math.sin(A);d.x=f.x+(E*m.x+D*y.x),d.y=f.y+(E*m.y+D*y.y),d.z=f.z+(E*m.z+D*y.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),c.push(h.x,h.y,h.z),u.push(v/i),u.push(L/r)}}for(let v=1;v<=i;v++)for(let b=1;b<=r;b++){let L=(r+1)*(v-1)+(b-1),A=(r+1)*v+(b-1),E=(r+1)*v+b,D=(r+1)*(v-1)+b;a.push(L,A,D),a.push(A,E,D)}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function x(v,b,L,A,E){let D=Math.cos(v),M=Math.sin(v),w=L/b*v,T=Math.cos(w);E.x=A*(2+T)*.5*D,E.y=A*(2+T)*M*.5,E.z=A*Math.sin(w)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},Lc=class n extends Xe{constructor(e=new Vo(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new R,l=new R,c=new te,u=new R,d=[],h=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(f,2));function y(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),x(),m()}function g(v){u=e.getPointAt(v/t,u);let b=o.normals[v],L=o.binormals[v];for(let A=0;A<=r;A++){let E=A/r*Math.PI*2,D=Math.sin(E),M=-Math.cos(E);l.x=M*b.x+D*L.x,l.y=M*b.y+D*L.y,l.z=M*b.z+D*L.z,l.normalize(),h.push(l.x,l.y,l.z),a.x=u.x+i*l.x,a.y=u.y+i*l.y,a.z=u.z+i*l.z,d.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=t;v++)for(let b=1;b<=r;b++){let L=(r+1)*(v-1)+(b-1),A=(r+1)*v+(b-1),E=(r+1)*v+b,D=(r+1)*(v-1)+b;p.push(L,A,D),p.push(A,E,D)}}function x(){for(let v=0;v<=t;v++)for(let b=0;b<=r;b++)c.x=v/t,c.y=b/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new vc[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},Dc=class extends Xe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new R,s=new R;if(e.index!==null){let o=e.attributes.position,a=e.index,l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){let d=l[c],h=d.start,f=d.count;for(let p=h,y=h+f;p<y;p+=3)for(let g=0;g<3;g++){let m=a.getX(p+g),x=a.getX(p+(g+1)%3);r.fromBufferAttribute(o,m),s.fromBufferAttribute(o,x),xg(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){let u=3*a+c,d=3*a+(c+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),xg(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Te(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};_g=Object.freeze({__proto__:null,BoxGeometry:cr,CapsuleGeometry:_c,CircleGeometry:bc,ConeGeometry:wc,CylinderGeometry:vs,DodecahedronGeometry:Mc,EdgesGeometry:Sc,ExtrudeGeometry:Ac,IcosahedronGeometry:Ec,LatheGeometry:Go,OctahedronGeometry:Xo,PlaneGeometry:fs,PolyhedronGeometry:Ri,RingGeometry:Tc,ShapeGeometry:Ic,SphereGeometry:Yo,TetrahedronGeometry:Cc,TorusGeometry:Rc,TorusKnotGeometry:Pc,TubeGeometry:Lc,WireframeGeometry:Dc}),Oc=class extends Lt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new we(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Uc=class extends sn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},qo=class extends Lt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new we(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 we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Nc=class extends qo{constructor(e){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 te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new we(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 we(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new we(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Fc=class extends Lt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new we(16777215),this.specular=new we(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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=na,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},kc=class extends Lt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new we(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Bc=class extends Lt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},zc=class extends Lt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new we(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(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=na,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Vc=class extends Lt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new we(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Li,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Hc=class extends Ot{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};cT={convertArray:rr,isTypedArray:uy,getKeyframeOrder:dy,sortedArray:Oh,flattenJSON:Vf,subclip:aT,makeClipAdditive:lT},mr=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Gc=class extends mr{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:nr,endingEnd:nr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case ir:s=e,a=2*t-i;break;case bo:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case ir:o=e,l=2*i-t;break;case bo:o=1,l=i+r[1]-r[0];break;default:o=e-1,l=t}let c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(i-t)/(r-t),y=p*p,g=y*p,m=-h*g+2*h*y-h*p,x=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*p+1,v=(-1-f)*g+(1.5+f)*y+.5*p,b=f*g-f*y;for(let L=0;L!==a;++L)s[L]=m*o[u+L]+x*o[c+L]+v*o[l+L]+b*o[d+L];return s}},Zo=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[c+h]*d+o[l+h]*u;return s}},$c=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},an=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=rr(t,this.TimeBufferType),this.values=rr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:rr(e.times,Array),values:rr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $c(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Zo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Gc(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case xo:t=this.InterpolantFactoryMethodDiscrete;break;case _o:t=this.InterpolantFactoryMethodLinear;break;case Xl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xo;case this.InterpolantFactoryMethodLinear:return _o;case this.InterpolantFactoryMethodSmooth:return Xl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&uy(r))for(let a=0,l=r.length;a!==l;++a){let c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Xl,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(r)l=!0;else{let d=a*i,h=d-i,f=d+i;for(let p=0;p!==i;++p){let y=t[d+p];if(y!==t[h+p]||y!==t[f+p]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let d=a*i,h=o*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};an.prototype.TimeBufferType=Float32Array;an.prototype.ValueBufferType=Float32Array;an.prototype.DefaultInterpolation=_o;ai=class extends an{};ai.prototype.ValueTypeName="bool";ai.prototype.ValueBufferType=Array;ai.prototype.DefaultInterpolation=xo;ai.prototype.InterpolantFactoryMethodLinear=void 0;ai.prototype.InterpolantFactoryMethodSmooth=void 0;Jo=class extends an{};Jo.prototype.ValueTypeName="color";gr=class extends an{};gr.prototype.ValueTypeName="number";Wc=class extends mr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t),c=e*a;for(let u=c+a;c!==u;c+=4)Vt.slerpFlat(s,0,o,c-a,o,c,l);return s}},Pi=class extends an{InterpolantFactoryMethodLinear(e){return new Wc(this.times,this.values,this.getValueSize(),e)}};Pi.prototype.ValueTypeName="quaternion";Pi.prototype.DefaultInterpolation=_o;Pi.prototype.InterpolantFactoryMethodSmooth=void 0;li=class extends an{};li.prototype.ValueTypeName="string";li.prototype.ValueBufferType=Array;li.prototype.DefaultInterpolation=xo;li.prototype.InterpolantFactoryMethodLinear=void 0;li.prototype.InterpolantFactoryMethodSmooth=void 0;yr=class extends an{};yr.prototype.ValueTypeName="vector";vr=class{constructor(e="",t=-1,i=[],r=lu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=tn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(dT(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(an.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=dy(l);l=Oh(l,1,u),c=Oh(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new gr(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],u=c.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(c)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,p,y){if(f.length!==0){let g=[],m=[];Vf(f,g,m,p),g.length!==0&&y.push(new d(h,g,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let d=0;d<c.length;d++){let h=c[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let y=0;y<h[p].morphTargets.length;y++)f[h[p].morphTargets[y]]=-1;for(let y in f){let g=[],m=[];for(let x=0;x!==h[p].morphTargets.length;++x){let v=h[p];g.push(v.time),m.push(v.morphTarget===y?1:0)}r.push(new gr(".morphTargetInfluence["+y+"]",g,m))}l=f.length*o}else{let f=".bones["+t[d].name+"]";i(yr,f+".position",h,"pos",r),i(Pi,f+".quaternion",h,"rot",r),i(yr,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};ei={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Ko=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){let d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;d<h;d+=2){let f=c[d],p=c[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},hy=new Ko,Ht=class{constructor(e){this.manager=e!==void 0?e:hy,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Ht.DEFAULT_MATERIAL_NAME="__DEFAULT";qn={},Uh=class extends Error{constructor(e,t){super(e),this.response=t}},Tn=class extends Ht{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=ei.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(qn[e]!==void 0){qn[e].push({onLoad:t,onProgress:i,onError:r});return}qn[e]=[],qn[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=qn[e],d=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=h?parseInt(h):0,p=f!==0,y=0,g=new ReadableStream({start(m){x();function x(){d.read().then(({done:v,value:b})=>{if(v)m.close();else{y+=b.byteLength;let L=new ProgressEvent("progress",{lengthComputable:p,loaded:y,total:f});for(let A=0,E=u.length;A<E;A++){let D=u[A];D.onProgress&&D.onProgress(L)}m.enqueue(b),x()}})}}});return new Response(g)}else throw new Uh(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{ei.add(e,c);let u=qn[e];delete qn[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=qn[e];if(u===void 0)throw this.manager.itemError(e),c;delete qn[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Nh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Tn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=vr.parse(e[i]);t.push(r)}return t}},Fh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new gs,l=new Tn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(d){l.load(e[d],function(h){let f=s.parse(h,!0);o[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(a.minFilter=bt),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else l.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[p].mipmaps.push(h.mipmaps[p*h.mipmapCount+y]),o[p].format=h.format,o[p].width=h.width,o[p].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=bt),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},xr=class extends Ht{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=ei.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=To("img");function l(){u(),ei.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},kh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=new ur;s.colorSpace=mn;let o=new xr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}},Bh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new On,a=new Tn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:gn,o.wrapT=c.wrapT!==void 0?c.wrapT:gn,o.magFilter=c.magFilter!==void 0?c.magFilter:bt,o.minFilter=c.minFilter!==void 0?c.minFilter:bt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Ln),c.mipmapCount===1&&(o.minFilter=bt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}},zh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=new wt,o=new xr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},kn=class extends it{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new we(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},jc=class extends kn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.groundColor=new we(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Ad=new Ne,bg=new R,wg=new R,Qo=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.map=null,this.mapPass=null,this.matrix=new Ne,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new dr,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;bg.setFromMatrixPosition(e.matrixWorld),t.position.copy(bg),wg.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(wg),t.updateMatrixWorld(),Ad.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ad),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ad)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Vh=class extends Qo{constructor(){super(new At(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ls*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Xc=class extends kn{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Vh}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Mg=new Ne,so=new R,Ed=new R,Hh=class extends Qo{constructor(){super(new At(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(4,2),this._viewportCount=6,this._viewports=[new at(2,1,1,1),new at(0,1,1,1),new at(3,1,1,1),new at(1,1,1,1),new at(3,0,1,1),new at(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),so.setFromMatrixPosition(e.matrixWorld),i.position.copy(so),Ed.copy(i.position),Ed.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Ed),i.updateMatrixWorld(),r.makeTranslation(-so.x,-so.y,-so.z),Mg.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mg)}},Yc=class extends kn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Hh}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Gh=class extends Qo{constructor(){super(new ps(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qc=class extends kn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.shadow=new Gh}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Zc=class extends kn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Jc=class extends kn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Kc=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new R)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Qc=class extends kn{constructor(e=new Kc,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},eu=class n extends Ht{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Tn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new we().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new we().setHex(o.value);break;case"v2":r.uniforms[s].value=new te().fromArray(o.value);break;case"v3":r.uniforms[s].value=new R().fromArray(o.value);break;case"v4":r.uniforms[s].value=new at().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ve().fromArray(o.value);break;case"m4":r.uniforms[s].value=new Ne().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new te().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:Oc,SpriteMaterial:Uo,RawShaderMaterial:Uc,ShaderMaterial:sn,PointsMaterial:Fo,MeshPhysicalMaterial:Nc,MeshStandardMaterial:qo,MeshPhongMaterial:Fc,MeshToonMaterial:kc,MeshNormalMaterial:Bc,MeshLambertMaterial:zc,MeshDepthMaterial:Do,MeshDistanceMaterial:Oo,MeshBasicMaterial:Nn,MeshMatcapMaterial:Vc,LineDashedMaterial:Hc,LineBasicMaterial:Ot,Material:Lt};return new t[e]}},ea=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},tu=class extends Xe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},nu=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Tn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,p){if(t[p]!==void 0)return t[p];let g=f.interleavedBuffers[p],m=s(f,g.buffer),x=ns(g.type,m),v=new ms(x,g.stride);return v.uuid=g.uuid,t[p]=v,v}function s(f,p){if(i[p]!==void 0)return i[p];let g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return i[p]=m,m}let o=e.isInstancedBufferGeometry?new tu:new Xe,a=e.data.index;if(a!==void 0){let f=ns(a.type,a.array);o.setIndex(new tt(f,1))}let l=e.data.attributes;for(let f in l){let p=l[f],y;if(p.isInterleavedBufferAttribute){let g=r(e.data,p.data);y=new hr(g,p.itemSize,p.offset,p.normalized)}else{let g=ns(p.type,p.array),m=p.isInstancedBufferAttribute?Ci:tt;y=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(y.name=p.name),p.usage!==void 0&&y.setUsage(p.usage),o.setAttribute(f,y)}let c=e.data.morphAttributes;if(c)for(let f in c){let p=c[f],y=[];for(let g=0,m=p.length;g<m;g++){let x=p[g],v;if(x.isInterleavedBufferAttribute){let b=r(e.data,x.data);v=new hr(b,x.itemSize,x.offset,x.normalized)}else{let b=ns(x.type,x.array);v=new tt(b,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),y.push(v)}o.morphAttributes[f]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let y=d[f];o.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new R;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Pt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},$h=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?ea.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Tn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?ea.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Tn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,s,l,a,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let d=!1;for(let h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,r,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new ii().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new ac().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new nu;for(let s=0,o=e.length;s<o;s++){let a,l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(l);break;default:l.type in _g?a=_g[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),i[l.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new eu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let l=e[o];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=vr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){let c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(u)}else return l.data?{data:ns(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){let l=new Ko(t);s=new xr(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){let d=e[c],h=d.url;if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new On(m.data,m.width,m.height)))}r[d.uuid]=new Kn(f)}else{let f=a(d.url);r[d.uuid]=new Kn(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(l)}else return o.data?{data:ns(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new xr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let l=e[o],c=l.url;if(Array.isArray(c)){let u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d],p=await s(f);p!==null&&(p instanceof HTMLImageElement?u.push(p):u.push(new On(p.data,p.width,p.height)))}i[l.uuid]=new Kn(u)}else{let u=await s(l.url);i[l.uuid]=new Kn(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let l=t[a.image],c=l.data,u;Array.isArray(c)?(u=new ur,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new On:u=new wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,hT)),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=i(a.wrap[0],Sg),u.wrapT=i(a.wrap[1],Sg)),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=i(a.minFilter,Ag)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Ag)),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),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function l(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function c(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new ic,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new we(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new nc(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new tc(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new At(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new ps(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Zc(e.color,e.intensity);break;case"DirectionalLight":o=new qc(e.color,e.intensity);break;case"PointLight":o=new Yc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Jc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Xc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new jc(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Qc().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new oc(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=l(e.material),o=new yt(u,d);break;case"InstancedMesh":u=a(e.geometry),d=l(e.material);let h=e.count,f=e.instanceMatrix,p=e.instanceColor;o=new lc(u,d,h),o.instanceMatrix=new Ci(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new Ci(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new cc(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new Dt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let m=new Pt;return m.radius=y.sphereRadius,m.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid);break;case"LOD":o=new sc;break;case"Line":o=new Fn(a(e.geometry),l(e.material));break;case"LineLoop":o=new hc(a(e.geometry),l(e.material));break;case"LineSegments":o=new vn(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new fc(a(e.geometry),l(e.material));break;case"Sprite":o=new rc(l(e.material));break;case"Group":o=new Ei;break;case"Bone":o=new No;break;default:o=new it}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)o.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let p=h[f];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let p=h[f],y=o.getObjectByProperty("uuid",p.object);y!==void 0&&o.addLevel(y,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},hT={UVMapping:au,CubeReflectionMapping:si,CubeRefractionMapping:Ti,EquirectangularReflectionMapping:mo,EquirectangularRefractionMapping:go,CubeUVReflectionMapping:xs},Sg={RepeatWrapping:yo,ClampToEdgeWrapping:gn,MirroredRepeatWrapping:vo},Ag={NearestFilter:Rt,NearestMipmapNearestFilter:Tf,NearestMipmapLinearFilter:ts,LinearFilter:bt,LinearMipmapNearestFilter:lo,LinearMipmapLinearFilter:Ln},Wh=class extends Ht{constructor(e){super(e),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"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=ei.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return ei.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ei.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ei.add(e,l),s.manager.itemStart(e)}},ta=class{static getContext(){return Ul===void 0&&(Ul=new(window.AudioContext||window.webkitAudioContext)),Ul}static setContext(e){Ul=e}},jh=class extends Ht{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Tn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{let c=l.slice(0);ta.getContext().decodeAudioData(c,function(d){t(d)}).catch(a)}catch(c){a(c)}},i,r);function a(l){r?r(l):console.error(l),s.manager.itemError(e)}}},Eg=new Ne,Tg=new Ne,Yi=new Ne,Xh=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new At,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new At,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Yi.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(ar*t.fov*.5)/t.zoom,a,l;Tg.elements[12]=-r,Eg.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,Yi.elements[0]=2*t.near/(l-a),Yi.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Yi),a=-o*t.aspect-s,l=o*t.aspect-s,Yi.elements[0]=2*t.near/(l-a),Yi.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Yi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Tg),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Eg)}},iu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ig(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Ig();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};qi=new R,Cg=new Vt,fT=new R,Zi=new R,Yh=class extends it{constructor(){super(),this.type="AudioListener",this.context=ta.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new iu}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(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qi,Cg,fT),Zi.set(0,0,-1).applyQuaternion(Cg),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qi.x,r),t.positionY.linearRampToValueAtTime(qi.y,r),t.positionZ.linearRampToValueAtTime(qi.z,r),t.forwardX.linearRampToValueAtTime(Zi.x,r),t.forwardY.linearRampToValueAtTime(Zi.y,r),t.forwardZ.linearRampToValueAtTime(Zi.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(qi.x,qi.y,qi.z),t.setOrientation(Zi.x,Zi.y,Zi.z,i.x,i.y,i.z)}},ru=class extends it{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(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+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,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(){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.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,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(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Ji=new R,Rg=new Vt,pT=new R,Ki=new R,qh=class extends ru{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ji,Rg,pT),Ki.set(0,0,1).applyQuaternion(Rg);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ji.x,i),t.positionY.linearRampToValueAtTime(Ji.y,i),t.positionZ.linearRampToValueAtTime(Ji.z,i),t.orientationX.linearRampToValueAtTime(Ki.x,i),t.orientationY.linearRampToValueAtTime(Ki.y,i),t.orientationZ.linearRampToValueAtTime(Ki.z,i)}else t.setPosition(Ji.x,Ji.y,Ji.z),t.setOrientation(Ki.x,Ki.y,Ki.z)}},Zh=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},su=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Vt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Vt.multiplyQuaternionsFlat(e,o,e,t,e,i),Vt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=t+a;e[l]=e[l]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Hf="\\[\\]\\.:\\/",mT=new RegExp("["+Hf+"]","g"),Gf="[^"+Hf+"]",gT="[^"+Hf.replace("\\.","")+"]",yT=/((?:WC+[\/:])*)/.source.replace("WC",Gf),vT=/(WCOD+)?/.source.replace("WCOD",gT),xT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gf),_T=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gf),bT=new RegExp("^"+yT+vT+xT+_T+"$"),wT=["material","materials","bones","map"],Jh=class{constructor(e,t,i){let r=i||st.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},st=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(mT,"")}static parseTrackName(e){let t=bT.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);wT.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=i(a.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[r];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};st.Composite=Jh;st.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};st.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};st.prototype.GetterByBindingType=[st.prototype._getValue_direct,st.prototype._getValue_array,st.prototype._getValue_arrayElement,st.prototype._getValue_toArray];st.prototype.SetterByBindingTypeAndVersioning=[[st.prototype._setValue_direct,st.prototype._setValue_direct_setNeedsUpdate,st.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[st.prototype._setValue_array,st.prototype._setValue_array_setNeedsUpdate,st.prototype._setValue_array_setMatrixWorldNeedsUpdate],[st.prototype._setValue_arrayElement,st.prototype._setValue_arrayElement_setNeedsUpdate,st.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[st.prototype._setValue_fromArray,st.prototype._setValue_fromArray_setNeedsUpdate,st.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Kh=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=tn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,l=e.length,c=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,p=t[f];if(p===void 0){p=l++,t[f]=p,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new st(h,i[y],r[y]))}else if(p<c){a=e[p];let y=--c,g=e[y];t[g.uuid]=p,e[p]=g,t[f]=y,e[y]=h;for(let m=0,x=o;m!==x;++m){let v=s[m],b=v[y],L=v[p];v[p]=b,L===void 0&&(L=new st(h,i[m],r[m])),v[y]=L}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[c]=d,e[d]=l;for(let f=0,p=r;f!==p;++f){let y=i[f],g=y[d],m=y[u];y[u]=g,y[d]=m}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],p=--o,y=e[p];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,m=r;g!==m;++g){let x=i[g],v=x[h],b=x[p];x[d]=v,x[h]=b,x.pop()}}else{let h=--o,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,y=r;p!==y;++p){let g=i[p];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,f=l.length;h!==f;++h){let p=l[h];d[h]=new st(p,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},ou=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),l={endingStart:nr,endingEnd:nr};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=U0,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Nf:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case lu:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===N0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===O0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=ir,r.endingEnd=ir):(e?r.endingStart=this.zeroSlopeAtStart?ir:nr:r.endingStart=bo,t?r.endingEnd=this.zeroSlopeAtEnd?ir:nr:r.endingEnd=bo)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}},MT=new Float32Array(1),Qh=class extends En{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=u[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;p=new su(st.create(i,f,y),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Zo(new Float32Array(2),new Float32Array(2),1,MT),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?vr.findByName(r,e):e,a=o!==null?o.uuid:e,l=this._actionsByClip[a],c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=lu),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new ou(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?vr.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},ef=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},ST=0,tf=class extends En{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:ST++}),this.name="",this.usage=Ao,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},nf=class extends ms{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},rf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Pg=new Ne,sf=class{constructor(e,t,i=0,r=1/0){this.ray=new Ii(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new us,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Pg.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Pg),this}intersectObject(e,t=!0,i=[]){return of(e,this,i,t),i.sort(Lg),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)of(e[r],this,i,t);return i.sort(Lg),i}};af=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(gt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},lf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},Dg=new te,cf=class{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Dg.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dg).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Og=new R,Nl=new R,uf=class{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Og.subVectors(e,this.start),Nl.subVectors(this.end,this.start);let i=Nl.dot(Nl),s=Nl.dot(Og)/i;return t&&(s=gt(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Ug=new R,df=class extends it{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Xe,r=[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,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new Te(r,3));let s=new Ot({fog:!1,toneMapped:!1});this.cone=new vn(i,s),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Ug.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ug),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Si=new R,Fl=new Ne,Td=new Ne,hf=class extends vn{constructor(e){let t=fy(e),i=new Xe,r=[],s=[],o=new we(0,0,1),a=new we(0,1,0);for(let c=0;c<t.length;c++){let u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new Te(r,3)),i.setAttribute("color",new Te(s,3));let l=new Ot({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");Td.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(Fl.multiplyMatrices(Td,a.matrixWorld),Si.setFromMatrixPosition(Fl),r.setXYZ(o,Si.x,Si.y,Si.z),Fl.multiplyMatrices(Td,a.parent.matrixWorld),Si.setFromMatrixPosition(Fl),r.setXYZ(o+1,Si.x,Si.y,Si.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};ff=class extends yt{constructor(e,t,i){let r=new Yo(t,4,2),s=new Nn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},AT=new R,Ng=new we,Fg=new we,pf=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Xo(t);r.rotateY(Math.PI*.5),this.material=new Nn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new tt(o,3)),this.add(new yt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Ng.copy(this.light.color),Fg.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Ng:Fg;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(AT.setFromMatrixPosition(this.light.matrixWorld).negate())}},mf=class extends vn{constructor(e=10,t=10,i=4473924,r=8947848){i=new we(i),r=new we(r);let s=t/2,o=e/t,a=e/2,l=[],c=[];for(let h=0,f=0,p=-a;h<=t;h++,p+=o){l.push(-a,0,p,a,0,p),l.push(p,0,-a,p,0,a);let y=h===s?i:r;y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3}let u=new Xe;u.setAttribute("position",new Te(l,3)),u.setAttribute("color",new Te(c,3));let d=new Ot({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},gf=class extends vn{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new we(s),o=new we(o);let a=[],l=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,p=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,p);let y=d&1?s:o;l.push(y.r,y.g,y.b),l.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:o,f=e-e/i*d;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f;a.push(g,0,m),l.push(h.r,h.g,h.b),y=(p+1)/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f,a.push(g,0,m),l.push(h.r,h.g,h.b)}}let c=new Xe;c.setAttribute("position",new Te(a,3)),c.setAttribute("color",new Te(l,3));let u=new Ot({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},kg=new R,kl=new R,Bg=new R,yf=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Xe;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Ot({fog:!1,toneMapped:!1});this.lightPlane=new Fn(r,s),this.add(this.lightPlane),r=new Xe,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Fn(r,s),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),kg.setFromMatrixPosition(this.light.matrixWorld),kl.setFromMatrixPosition(this.light.target.matrixWorld),Bg.subVectors(kl,kg),this.lightPlane.lookAt(kl),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(kl),this.targetLine.scale.z=Bg.length()}},Bl=new R,mt=new hs,vf=class extends vn{constructor(e){let t=new Xe,i=new Ot({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],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(p,y){l(p),l(y)}function l(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new we(16755200),u=new we(16711680),d=new we(43775),h=new we(16777215),f=new we(3355443);this.setColors(c,u,d,h,f)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;mt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),vt("c",t,e,mt,0,0,-1),vt("t",t,e,mt,0,0,1),vt("n1",t,e,mt,-i,-r,-1),vt("n2",t,e,mt,i,-r,-1),vt("n3",t,e,mt,-i,r,-1),vt("n4",t,e,mt,i,r,-1),vt("f1",t,e,mt,-i,-r,1),vt("f2",t,e,mt,i,-r,1),vt("f3",t,e,mt,-i,r,1),vt("f4",t,e,mt,i,r,1),vt("u1",t,e,mt,i*.7,r*1.1,-1),vt("u2",t,e,mt,-i*.7,r*1.1,-1),vt("u3",t,e,mt,0,r*2,-1),vt("cf1",t,e,mt,-i,0,1),vt("cf2",t,e,mt,i,0,1),vt("cf3",t,e,mt,0,-r,1),vt("cf4",t,e,mt,0,r,1),vt("cn1",t,e,mt,-i,0,-1),vt("cn2",t,e,mt,i,0,-1),vt("cn3",t,e,mt,0,-r,-1),vt("cn4",t,e,mt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};zl=new Dt,xf=class extends vn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new Xe;s.setIndex(new tt(i,1)),s.setAttribute("position",new tt(r,3)),super(s,new Ot({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&zl.setFromObject(this.object),zl.isEmpty())return;let t=zl.min,i=zl.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},_f=class extends vn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Xe;s.setIndex(new tt(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new Ot({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},bf=class extends Fn{constructor(e,t=1,i=16776960){let r=i,s=[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 Xe;o.setAttribute("position",new Te(s,3)),o.computeBoundingSphere(),super(o,new Ot({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Xe;l.setAttribute("position",new Te(a,3)),l.computeBoundingSphere(),this.add(new yt(l,new Nn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},zg=new R,wf=class extends it{constructor(e=new R(0,0,1),t=new R(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",Vl===void 0&&(Vl=new Xe,Vl.setAttribute("position",new Te([0,0,0,0,1,0],3)),Id=new vs(0,.5,1,5,1),Id.translate(0,-.5,0)),this.position.copy(t),this.line=new Fn(Vl,new Ot({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new yt(Id,new Nn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{zg.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(zg,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Mf=class extends vn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Xe;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new Ot({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new we,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Sf=class{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new fr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let x=[];for(let v=0,b=m.length;v<b;v++){let L=m[v],A=new ii;A.curves=L.curves,x.push(A)}return x}function i(m,x){let v=x.length,b=!1;for(let L=v-1,A=0;A<v;L=A++){let E=x[L],D=x[A],M=D.x-E.x,w=D.y-E.y;if(Math.abs(w)>Number.EPSILON){if(w<0&&(E=x[A],M=-M,D=x[L],w=-w),m.y<E.y||m.y>D.y)continue;if(m.y===E.y){if(m.x===E.x)return!0}else{let T=w*(m.x-E.x)-M*(m.y-E.y);if(T===0)return!0;if(T<0)continue;b=!b}}else{if(m.y!==E.y)continue;if(D.x<=m.x&&m.x<=E.x||E.x<=m.x&&m.x<=D.x)return!0}}return b}let r=Un.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new ii,l.curves=a.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],p=0,y;h[p]=void 0,f[p]=[];for(let m=0,x=s.length;m<x;m++)a=s[m],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[p]&&p++,h[p]={s:new ii,p:y},h[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let m=!1,x=0;for(let v=0,b=h.length;v<b;v++)d[v]=[];for(let v=0,b=h.length;v<b;v++){let L=f[v];for(let A=0;A<L.length;A++){let E=L[A],D=!0;for(let M=0;M<h.length;M++)i(E.p,h[M].p)&&(v!==M&&x++,D?(D=!1,d[M].push(E)):m=!0);D&&d[v].push(E)}}x>0&&m===!1&&(f=d)}let g;for(let m=0,x=h.length;m<x;m++){l=h[m].s,c.push(l),g=f[m];for(let v=0,b=g.length;v<b;v++)l.holes.push(g[v].h)}return c}},Af=class extends nn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var aI={};Jf(aI,{DEFAULT_VIEWER_STATE:()=>fn,WORLD_LAYER_ID:()=>qa,WorldOrbit3DUnavailableError:()=>cn,WorldOrbitViewerError:()=>Cs,clampScale:()=>js,composeViewerTransform:()=>ja,createAtlasViewer:()=>mu,createEmbedPayload:()=>Ly,createInteractiveViewer:()=>Di,createWorldOrbitEmbedMarkup:()=>Dy,defineWorldOrbitViewerElement:()=>Fy,deserializeViewerAtlasState:()=>ya,deserializeWorldOrbitEmbedPayload:()=>Xf,fitViewerState:()=>Bi,focusViewerState:()=>Wa,getSceneCenter:()=>zi,getThemePreset:()=>Kf,getViewerVisibleBounds:()=>Xa,invertViewerPoint:()=>Rr,mountWorldOrbitEmbeds:()=>Oy,normalizeRotation:()=>Vu,normalizeViewerFilter:()=>Zt,panViewerState:()=>ki,renderDocumentToSvg:()=>$u,renderSceneToSvg:()=>_n,renderSourceToSvg:()=>rm,resolveLayers:()=>fa,resolveTheme:()=>Ui,rotateViewerState:()=>$a,sceneViewpointToLayerOptions:()=>va,searchSceneObjects:()=>ma,serializeViewerAtlasState:()=>ga,serializeWorldOrbitEmbedPayload:()=>jf,viewpointToViewerFilter:()=>xa,zoomViewerStateAt:()=>Cr});var Cs=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},cn=class extends Cs{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var Wy={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},Rs={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",spaceFog:"#07131d",starfield:"rgba(226, 239, 255, 0.9)",starfieldDim:"rgba(164, 194, 228, 0.45)",objectSpecular:"#f5f8ff",orbitOpacity:.34,orbitBandOpacity:.24,selectionHalo:"rgba(255, 214, 139, 0.9)",atmosphere:"rgba(143, 202, 255, 0.4)",cometTail:"rgba(193, 243, 255, 0.7)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",spaceFog:"#071723",starfield:"rgba(220, 255, 245, 0.9)",starfieldDim:"rgba(124, 212, 195, 0.42)",objectSpecular:"#ecfffb",orbitOpacity:.3,orbitBandOpacity:.22,selectionHalo:"rgba(120, 255, 215, 0.85)",atmosphere:"rgba(120, 255, 215, 0.32)",cometTail:"rgba(181, 255, 236, 0.68)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",spaceFog:"#1c0d12",starfield:"rgba(255, 232, 214, 0.88)",starfieldDim:"rgba(255, 176, 138, 0.38)",objectSpecular:"#fff0e6",orbitOpacity:.3,orbitBandOpacity:.24,selectionHalo:"rgba(255, 178, 125, 0.85)",atmosphere:"rgba(255, 190, 140, 0.26)",cometTail:"rgba(255, 214, 173, 0.62)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Ui(n){return n?typeof n=="string"?Rs[n]??Rs.atlas:{...Rs.atlas,...n}:Rs.atlas}function fa(n){return{...Wy,...n}}function Kf(n){return Rs[n]}function Zt(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:bu(n.objectTypes??[]),tags:bu((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:bu((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return jy(e)?e:null}function jy(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function pa(n,e){let t=Zt(e),i=new Set;for(let r of n.objects)if(!r.hidden&&Xy(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function ma(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Yy(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>Qf(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>Qf(r,1))}function ep(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:Zt(t)}}function ga(n){return encodeURIComponent(JSON.stringify(n))}function ya(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:Zt(e.filter??null)}}function tp(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function va(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function xa(n){return n?.filter?Zt({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function Qf(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function Xy(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=np(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Yy(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=np(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(l=>r.includes(l))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(l=>typeof l=="string"):[]).some(l=>l.toLowerCase()===e)&&(s+=18),s}function np(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function bu(n){return[...new Set(n)]}var Y=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var Ps=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],un=Ps.filter(n=>n!=="system"),qy=["star","planet","moon","asteroid","comet","structure","phenomenon"],ip=["structure","phenomenon"],hi=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],Zy=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function Qe(n,e){return{key:n,...e}}var _a=new Set(Ps),rp=new Map([Qe("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:hi}),Qe("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"distance"}),Qe("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"distance"}),Qe("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:hi}),Qe("period",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"duration"}),Qe("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:hi,unitFamily:"angle"}),Qe("at",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),Qe("surface",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),Qe("free",{kind:"string",placement:!0,arity:"single",objectTypes:Zy}),Qe("kind",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("class",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("culture",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:Ps}),Qe("color",{kind:"string",placement:!1,arity:"single",objectTypes:Ps}),Qe("image",{kind:"string",placement:!1,arity:"single",objectTypes:qy}),Qe("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:Ps}),Qe("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"radius"}),Qe("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"mass"}),Qe("density",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"generic"}),Qe("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:un}),Qe("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),Qe("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),Qe("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),Qe("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),Qe("on",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("source",{kind:"string",placement:!1,arity:"single",objectTypes:un}),Qe("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:un,unitFamily:"duration"})].map(n=>[n.key,n])),Jy=new Set(rp.keys());function Jt(n){return rp.get(n)}function sp(n){return Jy.has(n)}function op(n,e){return n.objectTypes.includes(e)}function ba(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function Ls(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,o=!1,a=!1,l=null,c=()=>{s!==null&&(t.push({value:r,column:s,quoted:o}),r="",s=null,o=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(a&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){a?a=!1:(s===null&&(s=h),o=!0,l=h,a=!0);continue}if(!a&&/\s/.test(d)){c();continue}s===null&&(s=h),r+=d}if(a)throw new Y("Unclosed quote in line",e.line,l??i+n.length);return c(),t}function wa(n){return n.match(/^\s*/)?.[0].length??0}function Ds(n){let e=n.split(/\r?\n/),t=[],i=null,r=null,s=!1,o=!1,a=null,l=null,c=null,u=null;for(let d=0;d<e.length;d++){let h=e[d],f=d+1;if(!h.trim())continue;let p=wa(h),y=Ls(h.slice(p),{line:f,columnOffset:p});if(y.length!==0){if(p===0){if(s=!1,o=!1,a=null,l=null,c=null,u=null,y.length>=1&&y[0].value==="theme"){o=!0,l=0,i={type:"theme",preset:y.length>=2?y[1].value:null,blocks:[],location:{line:f,column:y[0].column}};continue}let g=Ky(y,f);t.push(g),r=g;continue}if(o){if(y.length>=2&&y[0].value==="preset"&&(!c||p<=c)){i&&(i.preset=y[1].value);continue}u&&c!==null&&p>c?u.fields.push(tv(y,f)):(c=p,u={type:"theme-block",target:y[0].value,fields:[],location:{line:f,column:y[0].column}},i?.blocks.push(u));continue}if(!r)throw new Y("Indented line without parent object",f,p+1);if(y.length===1&&y[0].value==="info"){s=!0,a=p;continue}s&&p<=(a??0)&&(s=!1),s?r.infoEntries.push(nv(y,f)):r.blockFields.push(ev(y,f))}}return{type:"document",theme:i,objects:t}}function Ky(n,e){if(n.length<2)throw new Y("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!_a.has(t.value))throw new Y(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:Qy(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function Qy(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=Jt(r.value);if(!s)throw new Y(`Unknown field "${r.value}"`,e,r.column);i++;let o=[];if(s.arity==="multiple")for(;i<n.length&&!sp(n[i].value);)o.push(n[i]),i++;else{let a=n[i];a&&(o.push(a),i++)}if(o.length===0)throw new Y(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:o.map(a=>a.value),location:{line:e,column:r.column}})}return t}function ev(n,e){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);if(!Jt(n[0].value))throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function tv(n,e){if(n.length<2)throw new Y("Invalid theme field line",e,n[0]?.column??1);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function nv(n,e){if(n.length<2)throw new Y("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var ap=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,iv=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),rv=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Os(n){let e=null,t=[],i=n.theme?sv(n.theme):null;for(let r of n.objects){let s=av(r);if(r.objectType==="system"){if(e)throw Y.fromLocation("Only one system object is allowed",r.location);e=s}else t.push(s)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",theme:i,system:e,groups:[],relations:[],events:[],objects:t}}function sv(n){let e={};for(let t of n.blocks){let i=lp(t.fields);e[t.target]=ov(i)}return{preset:n.preset,styles:e}}function ov(n){let e={};for(let[t,i]of n.entries()){if(i.values.length===1){let r=i.values[0];if(r==="true"){e[t]=!0;continue}if(r==="false"){e[t]=!1;continue}let s=Number(r);if(!Number.isNaN(s)&&r.trim()!==""){e[t]=s;continue}}e[t]=i.values.join(" ")}return e}function av(n){let e=[...n.inlineFields,...n.blockFields];lv(n.objectType,e);let t=lp(e),i=cv(n.objectType,t),r=uv(t),s=fv(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function lv(n,e){for(let t of e){let i=Jt(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(!op(i,n))throw Y.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function lp(n){let e=new Map;for(let t of n){if(e.has(t.key))throw Y.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function cv(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),o=[t,i,r,s].filter(Boolean).length;if(o>1){let a=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw Y.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw Y.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Ma(e,"orbit"),distance:Sr(e,"distance"),semiMajor:Sr(e,"semiMajor"),eccentricity:gv(e,"eccentricity"),period:Sr(e,"period"),angle:Sr(e,"angle"),inclination:Sr(e,"inclination"),phase:Sr(e,"phase")};if(i){let a=Sa(e,"at"),l=Ma(e,"at");return{mode:"at",target:l,reference:pv(l,a.location)}}if(r)return{mode:"surface",target:Ma(e,"surface")};if(s){let a=Ma(e,"free"),l=mv(a);return{mode:"free",distance:l??void 0,descriptor:l?void 0:a}}return null}function uv(n){let e={};for(let[t,i]of n.entries()){let r=Jt(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=yv(i);break;case"number":e[t]=up(Ar(i),t,i.location);break;case"unit":e[t]=cp(Ar(i),i.location,t);break;case"string":e[t]=dv(t,i);break}}return e}function dv(n,e){let t=e.values.join(" ").trim();return n==="image"&&hv(t,e.location),t}function hv(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(rv);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function fv(n){let e={};for(let t of n){if(t.key in e)throw Y.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function pv(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function cp(n,e,t){let i=n.match(ap);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Jt(t);if(s?.unitFamily&&!ba(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function mv(n){let e=n.match(ap);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Sr(n,e){if(!n.has(e))return;let t=Sa(n,e);return cp(Ar(t),t.location,e)}function gv(n,e){if(!n.has(e))return;let t=Sa(n,e);return up(Ar(t),e,t.location)}function up(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function yv(n){let e=Ar(n).toLowerCase(),t=iv.get(e);if(t===void 0)throw Y.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Sa(n,e){let t=n.get(e);if(!t)throw new Y(`Missing value for key "${e}"`);return t}function Ma(n,e){return Ar(Sa(n,e))}function Ar(n){if(n.values.length!==1)throw Y.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var vv=new Set(["star","planet","moon","asteroid","comet"]);function Us(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new Y(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new Y(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!vv.has(r.type))throw new Y(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&xv(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&_v(i,i.placement.reference,e))}}function xv(n,e,t){if(!t.has(e.primary))throw new Y(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new Y(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function _v(n,e,t){if(!t.has(e.objectId))throw new Y(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function Ni(n,e,t=`${e}.failed`){return n instanceof Y?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var Ns=1495978707e-1,bv=6371,wv=71492,Mv=695700,Sv=63241.077,Av=206264.806,Ev=206264806,yp=.68,Tv=.2,vp=28;function dn(n,e={}){let t=Rv(e),i=t.width,r=t.height,s=t.padding,o=Cv(n),a=Lv(n,e.projection),l=Tu(e.camera??null),c=Eu(a,l),u=Uv(o,e.scaleModel),d=Fv(o),h=n.system?.id??null,f=e.activeEventId??null,p=Iv(n.objects,n.events??[],f),y=new Map(p.map(q=>[q.id,q])),g=_x(p,y),m=new Map,x=[],v=[],b=[],L=[],A=[],E=new Map,D=new Map;for(let q of p){let pe=q.placement;if(!pe){b.push(q);continue}if(pe.mode==="orbit"){pp(D,pe.target,q);continue}if(pe.mode==="surface"){pp(E,pe.target,q);continue}if(pe.mode==="at"){A.push(q);continue}L.push(q)}let M=L.length>0?i*.42:i/2,w=r/2,T={orbitChildren:D,surfaceChildren:E,objectMap:y,spacingFactor:d,projection:c,scaleModel:u},U=b.find(q=>q.type==="star")??b[0]??null;U&&Mu(U,M,w,0,m,x,v,T);let I=b.filter(q=>q.id!==U?.id);if(I.length>0){let q=Math.min(i,r)*.28*d*u.orbitDistanceMultiplier;I.forEach((pe,ne)=>{let Fe=Vs(ne,I.length,-Math.PI/2),_e=Hs(Fe,q,c,1);Mu(pe,M+_e.x,w+_e.y,0,m,x,v,T)})}L.forEach((q,pe)=>{let ne=i-s-140-Ex(q.placement?.mode==="free"?q.placement.distance:void 0,u),Fe=Math.max(76,(r-s*2-180)/Math.max(1,L.length)*d)*u.freePlacementMultiplier,_e=s+92+pe*Fe;m.set(q.id,{object:q,x:ne,y:_e,radius:Ca(q,0,u),sortKey:Pa(ne,_e,0)}),v.push({object:q,groupId:g.groupIds.get(q.id)??null,x1:ne-60,y1:_e,x2:ne-18,y2:_e,mode:"free"}),Ta(q,m,x,v,T,1)}),A.forEach((q,pe)=>{if(m.has(q.id)||!q.placement||q.placement.mode!=="at")return;let ne=vx(q.placement.reference,m,y,pe,A.length,i,r,s,T);m.set(q.id,{object:q,x:ne.x,y:ne.y,radius:Ca(q,2,u),sortKey:Pa(ne.x,ne.y,2),anchorX:ne.anchorX,anchorY:ne.anchorY}),ne.anchorX!==void 0&&ne.anchorY!==void 0&&v.push({object:q,groupId:g.groupIds.get(q.id)??null,x1:ne.anchorX,y1:ne.anchorY,x2:ne.x,y2:ne.y,mode:"at"}),Ta(q,m,x,v,T,2)});let B=[...m.values()].map(q=>kv(q,u,g)),W=x.map(q=>Bv(q,g.groupIds.get(q.object.id)??null)),F=v.map(q=>zv(q)),X=Vv(B,i,r,u.labelMultiplier),k=qv(n,B),re=Zv(n.events??[],B,f),se=jv(W,k,re,F,B,X),ve=Xv(B,W,F,X,g,u.labelMultiplier),Le=Yv(n,B),Je=Jv(n,a,t.preset,g,y),Z=cx(i,r,B,W,F,X,u.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:a,renderProjection:c,camera:l,scaleModel:u,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:Ov(a,c,o,l),systemId:h,viewMode:a,layoutPreset:o,metadata:{format:n.format,version:n.version,view:a,renderProjection:c,scale:String(n.system?.properties.scale??o),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom",...l?.azimuth!==null?{"camera.azimuth":String(l?.azimuth)}:{},...l?.elevation!==null?{"camera.elevation":String(l?.elevation)}:{},...l?.roll!==null?{"camera.roll":String(l?.roll)}:{},...l?.distance!==null?{"camera.distance":String(l?.distance)}:{}},contentBounds:Z,layers:se,groups:ve,semanticGroups:Le,viewpoints:Je,events:re,activeEventId:f,objects:B,orbitVisuals:W,relations:k,leaders:F,labels:X}}function Vn(n,e,t){let i=La(t),r=Math.cos(i),s=Math.sin(i),o=n.x-e.x,a=n.y-e.y;return{x:e.x+o*r-a*s,y:e.y+o*s+a*r}}function Iv(n,e,t){let i=n.map(a=>structuredClone(a));if(!t)return i;let r=e.find(a=>a.id===t);if(!r)return i;let s=new Map(i.map(a=>[a.id,a])),o=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(a=>a.objectId)]);for(let a of o){let l=s.get(a);l&&(r.epoch&&(l.epoch=r.epoch),r.referencePlane&&(l.referencePlane=r.referencePlane))}for(let a of r.positions){let l=s.get(a.objectId);l&&(a.placement&&(l.placement=structuredClone(a.placement)),a.inner&&(l.properties.inner={...a.inner}),a.outer&&(l.properties.outer={...a.outer}),a.epoch&&(l.epoch=a.epoch),a.referencePlane&&(l.referencePlane=a.referencePlane))}return i}function Cv(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function Rv(n){let e=Pv(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function Pv(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function Lv(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return bp(t)??"topdown"}function Eu(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function Tu(n){if(!n)return null;let e={azimuth:wu(n.azimuth),elevation:wu(n.elevation),roll:wu(n.roll),distance:Dv(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function wu(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Dv(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Ov(n,e,t,i){let r=[`${mp(n)} view`,`${mp(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function Uv(n,e){return{...Nv(n),...e}}function Nv(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function Fv(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function kv(n,e,t){let{object:i,x:r,y:s,radius:o,sortKey:a,anchorX:l,anchorY:c}=n,u=i.renderHints?.renderPriority??0;return{renderId:Er(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:o,visualRadius:Ax(i,o,e),sortKey:a+u*.001,anchorX:l,anchorY:c,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:Ix(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function Bv(n,e){return{renderId:`${Er(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function zv(n){return{renderId:`${Er(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function Vv(n,e,t,i){let r=[],s=[],o=new Map(n.map(l=>[l.objectId,l])),a=[...n].filter(l=>!l.hidden&&l.object.renderHints?.renderLabel!==!1).sort(Hv);for(let l of a){let c=Gv(l,o,s,e,t,i)??_p(l,xp(l,o.get(l.parentId??"")??null,t),0,i);s.push(Ep(l,c,i)),r.push({renderId:`${l.renderId}-label`,objectId:l.objectId,object:l.object,groupId:l.groupId,semanticGroupIds:[...l.semanticGroupIds],label:l.label,secondaryLabel:l.secondaryLabel,x:c.x,y:c.labelY,secondaryY:c.secondaryY,textAnchor:c.textAnchor,direction:c.direction,hidden:l.hidden})}return r}function Hv(n,e){let t=dp(n)-dp(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function dp(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function Gv(n,e,t,i,r,s){for(let o of $v(n,e,i,r)){let a=o==="left"||o==="right"?4:6;for(let l=0;l<=a;l+=1){let c=_p(n,o,l,s),u=Ep(n,c,s);if(!t.some(d=>Mx(d,u)))return c}}return null}function $v(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=xp(n,r,i),o=s==="below"?"above":"below",a=Wv(n,r,t),l=a==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[a,s,l,o]:[s,a,o,l]}function xp(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function Wv(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function _p(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"start",direction:e}}}}function jv(n,e,t,i,r,s){let o=n.filter(l=>!l.hidden&&!!l.backArcPath).map(l=>l.renderId),a=n.filter(l=>!l.hidden).map(l=>l.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:a},{id:"relations",renderIds:e.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"events",renderIds:t.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"objects",renderIds:r.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"labels",renderIds:s.filter(l=>!l.hidden).map(l=>l.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function Xv(n,e,t,i,r,s){let o=new Map,a=l=>{if(!l)return null;let c=o.get(l);if(c)return c;let u=r.groupRoots.get(l)??null,d={renderId:l,rootObjectId:u,label:u??l,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:zs(0,0,0,0)};return o.set(l,d),d};for(let l of n){let c=a(l.groupId);c&&!l.hidden&&c.objectIds.push(l.objectId)}for(let l of e){let c=a(l.groupId);c&&!l.hidden&&c.orbitIds.push(l.objectId)}for(let l of t){let c=a(l.groupId);c&&!l.hidden&&c.leaderIds.push(l.objectId)}for(let l of i){let c=a(l.groupId);c&&!l.hidden&&c.labelIds.push(l.objectId)}for(let l of o.values())l.contentBounds=bx(l,n,e,t,i,s);return[...o.values()].sort((l,c)=>l.label.localeCompare(c.label))}function Yv(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function qv(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${Er(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function Zv(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],o=s.map(c=>i.get(c)).filter(Boolean),a=o.length>0?o.reduce((c,u)=>c+u.x,0)/o.length:0,l=o.length>0?o.reduce((c,u)=>c+u.y,0)/o.length:0;return{renderId:`${Er(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:a,y:l,hidden:r.hidden||o.length===0||o.every(c=>c.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function Jv(n,e,t,i,r){let s=Kv(n,e,t),o=new Map;for(let[c,u]of Object.entries(n.system?.info??{})){if(!c.startsWith("viewpoint."))continue;let[d,h,...f]=c.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let p=ox(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};Qv(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(c=>ex(c,e,t,r)).filter(Boolean),l=a.findIndex(c=>c.id===s.id);return l>=0?a.splice(l,1,{...s,...a[l],layers:{...s.layers,...a[l].layers},filter:a[l].filter??s.filter,generated:!1}):a.unshift(s),a.sort((c,u)=>c.id==="overview"?-1:u.id==="overview"?1:c.label.localeCompare(u.label))}function Kv(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=Tu(null),o=Eu(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:o,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Qv(n,e,t,i,r,s,o,a){let l=t.trim();switch(e){case"label":case"title":l&&(n.label=l);return;case"summary":case"description":l&&(n.summary=l);return;case"focus":case"object":l&&(n.focus=l);return;case"select":case"selection":l&&(n.select=l);return;case"events":n.eventIds=Bs(l);return;case"projection":case"view":n.projection=bp(l)??r;return;case"preset":n.preset=nx(l)??s;return;case"rotation":case"angle":n.rotationDeg=Fs(l)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??Ea(),azimuth:Fs(l)};return;case"camera.elevation":n.camera={...n.camera??Ea(),elevation:Fs(l)};return;case"camera.roll":n.camera={...n.camera??Ea(),roll:Fs(l)};return;case"camera.distance":n.camera={...n.camera??Ea(),distance:hp(l)};return;case"zoom":case"scale":n.scale=hp(l);return;case"layers":n.layers=ix(l);return;case"query":n.filter={...n.filter??Aa(),query:l||null};return;case"types":case"objecttypes":n.filter={...n.filter??Aa(),objectTypes:rx(l)};return;case"tags":n.filter={...n.filter??Aa(),tags:Bs(l)};return;case"groups":n.filter={...n.filter??Aa(),groupIds:sx(l,i,o,a)};return}}function ex(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,o=tx(n.filter),a=n.label?.trim()||ax(n.id),l=n.projection??e,c=Tu(n.camera??null),u=Eu(l,c);return{id:n.id,label:a,summary:n.summary?.trim()||lx(a,r,o),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:l,renderProjection:u,camera:c,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:o,generated:!1}}function Aa(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Ea(){return{azimuth:null,elevation:null,roll:null,distance:null}}function tx(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function bp(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function nx(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function Fs(n){let e=Number(n);return Number.isFinite(e)?e:null}function hp(n){let e=Fs(n);return e!==null&&e>0?e:null}function ix(n){let e={};for(let t of Bs(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function rx(n){return Bs(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function sx(n,e,t,i){return Bs(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.schemaVersion==="2.6.1"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??ks(r):(i.has(r),ks(r)))}function Bs(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function ox(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function ax(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function lx(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function cx(n,e,t,i,r,s,o){let a=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{a=Math.min(a,h),l=Math.min(l,f),c=Math.max(c,h),u=Math.max(u,f)};for(let h of i)h.hidden||wp(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||Mp(h,d);for(let h of s)h.hidden||Sp(h,d,o);return!Number.isFinite(a)||!Number.isFinite(l)?zs(0,0,n,e):zs(a,l,c,u)}function wp(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=Ip(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,vp*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function zs(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function Mp(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function Sp(n,e,t){let i=Tp(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function Mu(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:Ca(n,i,a.scaleModel),sortKey:Pa(e,t,i)}),Ta(n,r,s,o,a,i+1))}function Ta(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(ux),l=dx(a,o.radius,r.spacingFactor,r.scaleModel),c=px(a,l);a.forEach((d,h)=>{let f=hx(d,h,a.length,o,l,c[h]??l.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),Mu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=Vs(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=Hs(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=Hs(f,o.radius+p,r.projection,r.projection==="isometric"?.9:1),m=o.x+y.x,x=o.y+y.y,v=o.x+g.x,b=o.y+g.y;e.set(d.id,{object:d,x:v,y:b,radius:Ca(d,s+1,r.scaleModel),sortKey:Pa(v,b,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?ks(wx(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:b,mode:"surface"}),Ta(d,e,t,i,r,s+1)})}function ux(n,e){let t=Ia(n),i=Ia(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function dx(n,e,t,i){let r=n.map(d=>Ia(d)),s=r.filter(d=>d!==null),o=e+56*t*i.orbitDistanceMultiplier,a=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(s.length===0)return{metrics:r,minMetric:0,maxMetric:0,metricSpread:0,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42};let l=Math.min(...s),c=Math.max(...s),u=c-l;return{metrics:r,minMetric:l,maxMetric:c,metricSpread:u,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42}}function hx(n,e,t,i,r,s,o){let a=n.placement,l=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let D=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:D,rotationDeg:0,band:l,bandThickness:l?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-D}}let c=St(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-c*c),u*.18),h=Au(a.inclination)??0,f=o.projection==="isometric"?Math.max(Tv,Math.cos(La(h)))*yp:1,p=Math.max(d*f,u*.14),y=Au(a.angle)??0,g=u*c,m=Rp(-g,0,y),x=i.x+m.x,v=i.y+m.y,b=gx(a.phase,e,t),L=Cp(x,v,u,p,y,b),A=o.projection==="topdown"&&c<=1e-4&&Math.abs(y)<=1e-4,E=l?yx(n,u,r,o.scaleModel):void 0;return{kind:A?"circle":"ellipse",cx:A?i.x:x,cy:A?i.y:v,radius:A?u:void 0,rx:A?void 0:u,ry:A?void 0:p,rotationDeg:y,band:l,bandThickness:E,frontArcPath:o.projection==="isometric"||l?fp(x,v,u,p,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||l?fp(x,v,u,p,y,Math.PI,Math.PI*2):void 0,objectX:L.x,objectY:L.y}}function fx(n,e){return e.innerPx+e.stepPx*mx(Math.max(n,0)+1)}function px(n,e){let t=[];return n.forEach((i,r)=>{let s=Ia(i),o=e.innerPx+r*e.stepPx,a=s===null?o:fx(s,e),l=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,l))}),t}function Ia(n){return!n.placement||n.placement.mode!=="orbit"?null:Ra(n.placement.semiMajor??n.placement.distance??null)}function mx(n){return Math.log(n)/Math.log(2)}function gx(n,e,t){let i=n?Au(n):null;return i!==null?La(i-90):Vs(e,t,-Math.PI/2)}function yx(n,e,t,i){let r=Ra(Su(n.properties.inner)),s=Ra(Su(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.metricSpread>0)return St(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let l=Math.max(Math.max(r,s),1e-4);return St(a/l*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function vx(n,e,t,i,r,s,o,a,l){if(n.kind==="lagrange")return xx(n,e,t,s,o);if(n.kind==="anchor"){let c=e.get(n.objectId);if(c){let u=Vs(i,r,Math.PI/5),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Hs(u,d,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+h.x,y:c.y+h.y,anchorX:c.x,anchorY:c.y}}}if(n.kind==="named"){let c=e.get(n.name);if(c){let u=Vs(i,r,Math.PI/6),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Hs(u,d,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+h.x,y:c.y+h.y,anchorX:c.x,anchorY:c.y}}}return{x:s-a-170,y:o-a-86-i*58*l.scaleModel.freePlacementMultiplier}}function xx(n,e,t,i,r){let s=n.secondary?e.get(n.primary):Sx(n.primary,e,t),o=e.get(n.secondary??n.primary);if(!s||!o)return{x:i*.7,y:r*.25};let a=o.x-s.x,l=o.y-s.y,c=Math.hypot(a,l)||1,u=a/c,d=l/c,h=-d,f=u,p=St(c*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*p,y:o.y-d*p,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*p,y:o.y+d*p,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*p,y:s.y-d*p,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*p,y:o.y+(d*.5-f*.8660254)*p,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*p,y:o.y+(d*.5+f*.8660254)*p,anchorX:o.x,anchorY:o.y}}}function _x(n,e){let t=new Map,i=new Map;for(let c of n){let u=Ap(c,e);if(t.set(c.id,u),u){let d=i.get(u);d?d.push(c.id):i.set(u,[c.id])}i.has(c.id)||i.set(c.id,[])}let r=new Map,s=new Map,o=new Map,a=c=>{let u=r.get(c);if(u)return u;let d=new Set,h=[],f=t.get(c)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(c,h),h},l=c=>{let u=o.get(s.get(c)??"");if(u)return u;let d=t.get(c)??null,h=e.get(c),f=c;return h?.placement&&h.placement.mode!=="free"&&d&&(f=l(d)),f};for(let c of n){a(c.id);let u=l(c.id),d=ks(u);s.set(c.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function Ap(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function bx(n,e,t,i,r,s){let o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=(d,h)=>{o=Math.min(o,d),a=Math.min(a,h),l=Math.max(l,d),c=Math.max(c,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&Mp(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&wp(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&Sp(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?zs(0,0,0,0):zs(o,a,l,c)}function wx(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=Ap(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function Ep(n,e,t){return Tp(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function Tp(n,e,t,i,r,s,o,a){let l=Cx(s,o,a),c=l*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-l,f=n+l;return i==="start"?(h=n,f=n+c):i==="end"&&(h=n-c,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function Mx(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function Sx(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function Ca(n,e,t){let i=Tx(n.properties.radius,t);if(i!==null)return i;let r=t.bodyRadiusMultiplier;switch(n.type){case"star":return St((e===0?28:20)*r,t.minBodyRadius,t.maxBodyRadius);case"planet":return St(12*r,t.minBodyRadius,t.maxBodyRadius);case"moon":return St(7*r,t.minBodyRadius,t.maxBodyRadius);case"belt":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"comet":return St(6*r,t.minBodyRadius,t.maxBodyRadius);case"ring":return St(5*r,t.minBodyRadius,t.maxBodyRadius);case"structure":return St(6*r,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return St(8*r,t.minBodyRadius,t.maxBodyRadius)}}function Ax(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function Ra(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/Ns;case"m":return n.value/1e3/Ns;case"ly":return n.value*Sv;case"pc":return n.value*Av;case"kpc":return n.value*Ev;case"re":return n.value*bv/Ns;case"rj":return n.value*wv/Ns;case"sol":return n.value*Mv/Ns;default:return n.value}}function Ex(n,e){let t=Ra(n??null);return t===null||t<=0?0:St(t*96*e.freePlacementMultiplier,0,420)}function Tx(n,e){let t=Su(n);if(!t)return null;let i;switch(t.unit){case"sol":i=St(t.value*22,14,40);break;case"re":i=St(t.value*10,6,18);break;case"km":i=St(Math.log10(Math.max(t.value,1))*2.6,4,16);break;default:i=St(t.value*4,4,20);break}return St(i*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function Su(n){return!n||typeof n!="object"||!("value"in n)?null:n}function Au(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Vs(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function fp(n,e,t,i,r,s,o){let a=Ip(n,e,t,i,r,s,o,vp);return a.length===0?"":a.map((l,c)=>`${c===0?"M":"L"} ${gp(l.x)} ${gp(l.y)}`).join(" ")}function Ip(n,e,t,i,r,s,o,a){let l=[];for(let c=0;c<=a;c+=1){let u=s+(o-s)*c/a;l.push(Cp(n,e,t,i,r,u))}return l}function Cp(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),l=Rp(o,a,r);return{x:n+l.x,y:e+l.y}}function Rp(n,e,t){let i=La(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function Hs(n,e,t,i){let r=t==="isometric"?yp*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function Pa(n,e,t){return e*1e3+n+t*.01}function St(n,e,t){return Math.min(Math.max(n,e),t)}function pp(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Er(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function ks(n){return`${Er(n)}-group`}function Ix(n){return typeof n=="string"&&n.trim()?n:void 0}function Cx(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function mp(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function La(n){return n*Math.PI/180}function gp(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Dp=86400,Da=Dp*365.25,Oa=18,Pp=180;function Fa(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,activeEventId:e.activeEventId},i=dn(n,t),r=Dx(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},o=new Map(i.objects.map(y=>[y.objectId,y])),a=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),l=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||l.set(y.objectId,Cu(g))}let c=Math.min(...[...l.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>Rx(y,i,s,o,a,r,u,c)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>Px(y,h,c,i.activeEventId!==null)),p=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:Ux(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function Rx(n,e,t,i,r,s,o,a){let l=Ua(n,e,t,i,r,o),c=Pu(n.object,r.get(n.objectId),a,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:l,radius:Tr(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Tr(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:c}}function Px(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??Na(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??Pu(n.object,n,t,i)}}function Ua(n,e,t,i,r,s){let o=s.get(n.objectId);if(o)return o;let a=n.object.placement,l;if(a?.mode==="orbit"&&n.parentId){let c=i.get(n.parentId),u=c?Ua(c,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=Pu(n.object,d,1,e.activeEventId!==null),f=h?Op(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};l=Up(u,f)}else if(a?.mode==="surface"&&n.parentId){let c=i.get(n.parentId),u=c?Ua(c,e,t,i,r,s):{x:0,y:0,z:0},d=c?.visualRadius??16,h=Nx(n.objectId),f=h*Math.PI*2;l={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(a?.mode==="at"&&n.parentId){let c=i.get(n.parentId),u=c?Ua(c,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??c?.x??t.x,h=n.anchorY??c?.y??t.y;l={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else l={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,l),l}function Ru(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let o=i.get(s);if(o)return o;let a=t.get(s);if(!a)return{x:0,y:0,z:0};let l={...a.position};if(a.motion&&a.parentId){let c=r(a.parentId),u=Op(a.motion,n.timeFrozen?0:e);l=Up(c,u)}return i.set(s,l),l};for(let s of n.objects)r(s.objectId);return i}function Op(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=Iu(t),r=Iu(n.rotationDeg),s=Iu(n.inclinationDeg),o=Math.cos(i)*n.semiMajor,a=Math.sin(i)*n.semiMinor,l=o*Math.cos(r)-a*Math.sin(r),c=o*Math.sin(r)+a*Math.cos(r);return{x:l,y:c*Math.sin(s),z:c*Math.cos(s)}}function Pu(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Tr(Cu(r)*48,24,1200),o=e?.radius??e?.ry??s,a=Lx(r.period),l=Cu(r),c=Tr(l/Math.max(t,1e-4),1,20),u=Tr(a?Oa*c:Oa*Math.pow(c,.75),Oa,Pp);return{phase0Deg:Na(r.phase)??0,rotationDeg:Na(r.angle)??e?.rotationDeg??0,inclinationDeg:Na(r.inclination)??0,semiMajor:s,semiMinor:o,eccentricity:r.eccentricity??0,periodSeconds:a,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:a===null,frozen:i}}function Cu(n){let e=Lp(n.semiMajor)??Lp(n.distance)??1;return Math.max(e,.01)}function Lp(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function Lx(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Dp;case"y":return n.value*Da;case"ky":return n.value*Da*1e3;case"my":return n.value*Da*1e6;case"gy":return n.value*Da*1e9;default:return null}}function Na(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Dx(n,e){return{...Ox(n),...e}}function Ox(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function Ux(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of n)e=Math.min(e,a.position.x-a.visualRadius),t=Math.min(t,a.position.y-a.visualRadius),i=Math.min(i,a.position.z-a.visualRadius),r=Math.max(r,a.position.x+a.visualRadius),s=Math.max(s,a.position.y+a.visualRadius),o=Math.max(o,a.position.z+a.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:o,width:r-e,height:s-t,depth:o-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+o)/2}}}function Up(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Nx(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function Tr(n,e,t){return Math.min(Math.max(n,e),t)}function Iu(n){return n*Math.PI/180}function Lu(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:Hx(n.system),info:Gx(n.system)}:null,i=n.objects.map(Fx);return zx(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,theme:n.theme??null,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(kx),objects:i}}function Fx(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:Vx(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function kx(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(Bx)}}function Bx(n){return{objectId:n.objectId,placement:Np(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Np(n){return n?structuredClone(n):null}function zx(n,e,t){if(!t)return;let i=e.find(o=>o.id===t);if(!i)return;let r=new Map(n.map(o=>[o.id,o])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(o=>o.objectId)]);for(let o of s){let a=r.get(o);a&&(i.epoch&&(a.epoch=i.epoch),i.referencePlane&&(a.referencePlane=i.referencePlane))}for(let o of i.positions){let a=r.get(o.objectId);a&&(o.placement&&(a.placement=Np(o.placement)),o.inner&&(a.properties.inner={...o.inner}),o.outer&&(a.properties.outer={...o.outer}),o.epoch&&(a.epoch=o.epoch),o.referencePlane&&(a.referencePlane=o.referencePlane))}}function Vx(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function Hx(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function Gx(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=$x(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function $x(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}var Fp=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Xx=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Yx=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Ir(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function $s(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Du(n,e,t){let i=n.match(Fp);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Jt(t);if(s?.unitFamily&&!ba(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Ou(n){let e=n.match(Fp);return e?{value:Number(e[1]),unit:e[2]??null}:null}function ka(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function fi(n,e,t){let i=Xx.get(n.toLowerCase());if(i===void 0)throw Y.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function kp(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function qx(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Yx);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function Bp(n,e,t){let i=Jt(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw Y.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return fi(Gs(e,n,t),n,t);case"number":return ka(Gs(e,n,t),n,t);case"unit":return Du(Gs(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&qx(r,t),r}}}function Uu(n,e,t){let i=Jt(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw Y.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function Gs(n,e,t){if(n.length!==1)throw Y.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Vp=new Set(["star","planet","moon","asteroid","comet"]),Zx=332946.0487,Jx=1047.3486,Ba=1495978707e-1,Kx=6371,Qx=695700,e_=63241.077,t_=206264.806,n_=206264806;function za(n,e){let t=[],i=new Map(n.objects.map(a=>[a.id,a])),r=new Set(n.groups.map(a=>a.id)),s=new Set(n.events.map(a=>a.id));n.system||t.push(Ze("validate.system.required","Atlas documents must declare exactly one system."));let o=new Map;for(let[a,l]of[["group",n.groups.map(c=>c.id)],["viewpoint",n.system?.viewpoints.map(c=>c.id)??[]],["annotation",n.system?.annotations.map(c=>c.id)??[]],["relation",n.relations.map(c=>c.id)],["event",n.events.map(c=>c.id)],["object",n.objects.map(c=>c.id)]])for(let c of l){let u=o.get(c);u?t.push(Ze("validate.id.duplicate",`Duplicate ${a} id "${c}" already used by ${u}.`)):o.set(c,a)}for(let a of n.relations)i_(a,i,t);for(let a of n.system?.viewpoints??[])r_(a,r,s,e,t,i);for(let a of n.objects)s_(a,n.system,i,r,t);for(let a of n.events)o_(a,n.system,i,t);return t}function i_(n,e,t){n.from?e.has(n.from)||t.push(Ze("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(Ze("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(Ze("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(Ze("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(Ze("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function r_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"||i==="2.6.1"){if(o)for(let a of o.groupIds)e.has(a)||r.push(ct("validate.viewpoint.group.unknown",`Unknown group "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let a of n.events??[])t.has(a)||r.push(ct("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}u_(n.projection,r,`viewpoint.${n.id}.projection`,n.id),d_(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function s_(n,e,t,i,r){let s=n.placement,o=s?.mode==="orbit"?s:null,a=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let l of n.groups)i.has(l)||r.push(ct("validate.group.unknown",`Unknown group "${l}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(ct("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(ct("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(Ze("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(Ze("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(ct("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),o.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(ct("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),o.period&&!Fu(a?.properties.mass)&&r.push(ct("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let l=t.get(s.target);l?Vp.has(l.type)||r.push(Ze("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(Ze("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(Ze("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),l_(n,t,r)||r.push(Ze("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let l=t.get(n.resonance.targetObjectId);l?(n.placement?.mode!=="orbit"||l.placement?.mode!=="orbit"||n.placement.target!==l.placement.target)&&r.push(ct("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(Ze("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let l of n.deriveRules??[]){if(l.field!=="period"||l.strategy!=="kepler"){r.push(ct("validate.derive.unsupported",`Unsupported derive rule "${l.field} ${l.strategy}" on "${n.id}".`,n.id,"derive"));continue}let c=zp(n,a);if(c===null){r.push(ct("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}o?.period||r.push(Nu("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${m_(c)}.`,n.id,"derive"))}for(let l of n.validationRules??[]){if(l.rule!=="kepler"){r.push(ct("validate.rule.unsupported",`Unsupported validation rule "${l.rule}" on "${n.id}".`,n.id,"validate"));continue}let c=Hp(o?.period),u=zp(n,a);if(c===null||u===null)continue;let d=p_(n,"period");Math.abs(c-u)>d&&r.push(Ze("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function o_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(Ze("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(ct("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(ct("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(Ze("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(Ze("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let o=new Set;for(let c of n.participantObjectIds){if(s.add(c),o.has(c)){i.push(ct("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${c}".`,void 0,`${r}.participants`));continue}o.add(c),t.has(c)||i.push(Ze("validate.event.participants.unknown",`Unknown event participant "${c}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(ct("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(ct("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(ct("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let a=new Set;for(let c of n.positions){let u=`${r}.pose.${c.objectId}`;if(a.has(c.objectId)){i.push(Ze("validate.event.pose.duplicate",`Event "${n.id}" defines "${c.objectId}" more than once in positions.`,void 0,u));continue}a.add(c.objectId);let d=t.get(c.objectId);if(!d){i.push(Ze("validate.event.pose.object.unknown",`Unknown event pose object "${c.objectId}" on "${n.id}".`,void 0,u));continue}s.has(c.objectId)||i.push(ct("validate.event.pose.unreferenced",`Event pose "${c.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),a_(c,d,n,e,t,i,u,n.id)}let l=[...s].filter(c=>!a.has(c));n.positions.length>0&&l.length>0&&i.push(ct("validate.event.positions.partial",`Event "${n.id}" leaves ${l.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function a_(n,e,t,i,r,s,o,a){let l=n.placement;if(!l){s.push(Ze("validate.event.pose.placement.required",`Event "${a}" pose "${n.objectId}" is missing a placement mode.`,void 0,o));return}if(l.mode==="orbit"){r.has(l.target)||s.push(Ze("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${l.target}" on "${a}:${n.objectId}".`,void 0,`${o}.orbit`)),l.distance&&l.semiMajor&&s.push(Ze("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),l.phase&&!h_(i,e,t,n)&&s.push(ct("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),l.inclination&&!f_(i,e,t,n)&&s.push(ct("validate.event.pose.inclination.referencePlaneMissing",`Event "${a}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${o}.inclination`)),l.period&&!Fu(r.get(l.target)?.properties.mass)&&s.push(ct("validate.event.pose.period.massMissing",`Event "${a}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${o}.period`));return}if(l.mode==="surface"){let c=r.get(l.target);c?Vp.has(c.type)||s.push(Ze("validate.event.pose.surface.target.invalid",`Event surface target "${l.target}" on "${a}:${n.objectId}" is not surface-capable.`,void 0,`${o}.surface`)):s.push(Ze("validate.event.pose.surface.target.unknown",`Unknown event surface target "${l.target}" on "${a}:${n.objectId}".`,void 0,`${o}.surface`));return}if(l.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(Ze("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${a}:${n.objectId}".`,void 0,`${o}.at`));let c=l.reference;c.kind==="named"&&!r.has(c.name)?s.push(Ze("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${l.target}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):c.kind==="anchor"&&!r.has(c.objectId)?s.push(Ze("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${c.objectId}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):c.kind==="lagrange"&&(r.has(c.primary)?c.secondary&&!r.has(c.secondary)&&s.push(Ze("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${c.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(Ze("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${c.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function l_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(Ze("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(Ze("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(Ze("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function zp(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=c_(t.semiMajor??t.distance),r=Fu(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function c_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/Ba;case"m":return n.value/(Ba*1e3);case"ly":return n.value*e_;case"pc":return n.value*t_;case"kpc":return n.value*n_;case"re":return n.value*Kx/Ba;case"sol":return n.value*Qx/Ba;default:return null}}function Fu(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/Zx;case"mj":return e.value/Jx;default:return null}}function Hp(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function u_(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(Ze("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function d_(n,e,t,i,r,s,o,a,l){if(!n)return;let c=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(Ze("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${c}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(ct("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${c}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(ct("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,c)),e==="isometric"&&n.elevation!==null&&i.push(Nu("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${c}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(ct("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${c}.azimuth`)),s!==null&&l.has(s)||o!==null&&l.has(o)||a||i.push(Nu("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,c))}function h_(n,e,t,i){return pi(i?.epoch)??pi(t?.epoch)??pi(e.epoch)??pi(n?.epoch)??null}function f_(n,e,t,i){return pi(i?.referencePlane)??pi(t?.referencePlane)??pi(e.referencePlane)??pi(n?.referencePlane)??null}function pi(n){return typeof n=="string"&&n.trim()?n.trim():null}function p_(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Hp(t)??0:0}function m_(n){return`${Math.round(n*100)/100}d`}function Ze(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function ct(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function Nu(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var g_=new Set(["climate","habitability","settlement"]),Ha=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=Jt(n);e&&Ha.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])Ha.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var y_=new Set(Ha.keys()),$p=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function ku(n){return v_(n)}function v_(n,e){let t=rb(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,l=null,c=[],u=[],d=[],h=[],f=new Map,p=!1,y=!1,g=new Set,m=new Set,x=new Set,v=new Set,b=new Set;for(let w=0;w<i.length;w++){let T=i[w],U=w+1;if(!T.trim())continue;let I=wa(T),B=Ls(T.slice(I),{line:U,columnOffset:I});if(B.length!==0){if(!s){o=x_(B,U),s=!0,t.comments.length>0&&Ga(o,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${o}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(I===0){l=__(B,U,o,r,a,c,u,d,h,f,g,m,x,v,b,{sawDefaults:p,sawAtlas:y}),l.kind==="system"?a=l.system:l.kind==="defaults"?p=!0:l.kind==="atlas"&&(y=!0);continue}if(!l)throw new Y("Indented line without parent atlas section",U,I+1);I_(l,I,B,U)}}if(!s)throw new Y('Missing required atlas schema header "schema 2.0"');let L=c.map(w=>X_(w,o,r)),A=h.map(w=>Y_(w,f.get(w.id)??[])),E=e??(o==="2.0-draft"?"2.0":o),D={format:"worldorbit",sourceVersion:"1.0",theme:null,system:a,groups:u,relations:d,events:A,objects:L,diagnostics:r};if(E==="2.0-draft"){let w={...D,version:"2.0-draft",schemaVersion:"2.0-draft"};return w.diagnostics.push(...za(w,o)),w}let M={...D,version:E,schemaVersion:E};return o==="2.0-draft"&&M.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),M.diagnostics.push(...za(M,o)),M}function x_(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5","2.6.1"].includes(n[1].value.toLowerCase()))throw new Y('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", "schema 2.6.1", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.6.1"?"2.6.1":t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function __(n,e,t,i,r,s,o,a,l,c,u,d,h,f,p,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new Y('Atlas section "system" may only appear once',e,n[0].column);return b_(n,e,t,i);case"defaults":if(!r)throw new Y('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new Y('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new Y('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new Y('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new Y('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return w_(n,e,r,u,t,i);case"annotation":if(!r)throw new Y('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return M_(n,e,r,d);case"group":return hn(t,i,"group",{line:e,column:n[0].column}),S_(n,e,o,h);case"relation":return hn(t,i,"relation",{line:e,column:n[0].column}),A_(n,e,a,f);case"event":return hn(t,i,"event",{line:e,column:n[0].column}),E_(n,e,l,c,p,t,i);case"object":return T_(n,e,t,i,s);default:throw new Y(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function b_(n,e,t,i){if(n.length!==2)throw new Y("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function w_(n,e,t,i,r,s){if(n.length!==2)throw new Y("Invalid viewpoint declaration",e,n[0]?.column??1);let o=Ir(n[1].value);if(!o)throw new Y("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new Y(`Duplicate viewpoint id "${o}"`,e,n[1].column);let a={id:o,label:$s(o),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(a),i.add(o),{kind:"viewpoint",viewpoint:a,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function M_(n,e,t,i){if(n.length!==2)throw new Y("Invalid annotation declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:$s(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function S_(n,e,t,i){if(n.length!==2)throw new Y("Invalid group declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Group id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:$s(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function A_(n,e,t,i){if(n.length!==2)throw new Y("Invalid relation declaration",e,n[0]?.column??1);let r=Ir(n[1].value);if(!r)throw new Y("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function E_(n,e,t,i,r,s,o){if(n.length!==2)throw new Y("Invalid event declaration",e,n[0]?.column??1);let a=Ir(n[1].value);if(!a)throw new Y("Event id must not be empty",e,n[1].column);if(r.has(a))throw new Y(`Duplicate event id "${a}"`,e,n[1].column);let l={id:a,kind:"",label:$s(a),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},c=[];return t.push(l),i.set(a,c),r.add(a),{kind:"event",event:l,sourceSchemaVersion:s,diagnostics:o,seenFields:new Set,rawPoses:c,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function T_(n,e,t,i,r){if(n.length<3)throw new Y("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!_a.has(a)||a==="system")throw new Y(`Unknown object type "${s.value}"`,e,s.column);let l={objectType:a,id:o.value,fields:W_(n.slice(3),e,a,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(l),{kind:"object",objectNode:l,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function I_(n,e,t,i){switch(n.kind){case"system":C_(n,t,i);return;case"defaults":R_(n,t,i);return;case"atlas":P_(n,e,t,i);return;case"viewpoint":L_(n,e,t,i);return;case"annotation":U_(n,t,i);return;case"group":N_(n,t,i);return;case"relation":F_(n,t,i);return;case"event":k_(n,e,t,i);return;case"object":z_(n,e,t,i);return}}function C_(n,e,t){let i=Hn(e,n.seenFields,t),r=rt(e,t);switch(i){case"title":n.system.title=r;return;case"description":hn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":hn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":hn(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new Y(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function R_(n,e,t){let i=Hn(e,n.seenFields,t),r=rt(e,t);switch(i){case"view":jp(r)&&Fi(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Wp(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=Xp(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new Y(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function P_(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Yp(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new Y(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new Y(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function L_(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){D_(n,t,i);return}if(n.inFilter){O_(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(Fi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new Y('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??zu();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new Y('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=Hn(t,n.seenFields,i),s=rt(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":jp(s)&&Fi(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Wp(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Xp(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=Bu(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=gi(s,i,t[0].column,"rotation");return;case"camera":Fi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=$_(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=H_(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":hn(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=In(t.slice(1),i,"events");return;default:throw new Y(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function D_(n,e,t){let i=Hn(e,n.seenCameraFields,t),r=rt(e,t),s=n.viewpoint.camera??zu();switch(i){case"azimuth":s.azimuth=gi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=gi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=gi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=Bu(r,t,e[0].column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function O_(n,e,t){let i=Hn(e,n.seenFilterFields,t),r=n.viewpoint.filter??G_();switch(i){case"query":r.query=rt(e,t);break;case"objecttypes":r.objectTypes=V_(e.slice(1),t);break;case"tags":r.tags=In(e.slice(1),t,"tags");break;case"groups":r.groupIds=In(e.slice(1),t,"groups");break;default:throw new Y(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function U_(n,e,t){switch(Hn(e,n.seenFields,t)){case"label":n.annotation.label=rt(e,t);return;case"target":n.annotation.targetObjectId=rt(e,t);return;case"body":n.annotation.body=rt(e,t);return;case"tags":n.annotation.tags=In(e.slice(1),t,"tags");return;default:throw new Y(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function N_(n,e,t){switch(Hn(e,n.seenFields,t)){case"label":n.group.label=rt(e,t);return;case"summary":n.group.summary=rt(e,t);return;case"color":n.group.color=rt(e,t);return;case"tags":n.group.tags=In(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=fi(rt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function F_(n,e,t){switch(Hn(e,n.seenFields,t)){case"from":n.relation.from=rt(e,t);return;case"to":n.relation.to=rt(e,t);return;case"kind":n.relation.kind=rt(e,t);return;case"label":n.relation.label=rt(e,t);return;case"summary":n.relation.summary=rt(e,t);return;case"tags":n.relation.tags=In(e.slice(1),t,"tags");return;case"color":n.relation.color=rt(e,t);return;case"hidden":n.relation.hidden=fi(rt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function k_(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&Fi(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(B_(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new Y(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new Y("Event pose object id must not be empty",i,t[1].column);let o={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(o),n.activePose=o,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new Y('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(Hn(t,n.seenFields,i)){case"kind":n.event.kind=rt(t,i);return;case"label":n.event.label=rt(t,i);return;case"summary":n.event.summary=rt(t,i);return;case"target":n.event.targetObjectId=rt(t,i);return;case"participants":n.event.participantObjectIds=In(t.slice(1),i,"participants");return;case"timing":n.event.timing=rt(t,i);return;case"visibility":n.event.visibility=rt(t,i);return;case"epoch":Fi(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=rt(t,i);return;case"referenceplane":Fi(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=rt(t,i);return;case"tags":n.event.tags=In(t.slice(1),i,"tags");return;case"color":n.event.color=rt(t,i);return;case"hidden":n.event.hidden=fi(rt(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new Y(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function B_(n,e,t){if(n.length<2)throw new Y("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!$p.has(i))throw new Y(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new Y(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function z_(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||g_.has(r)){r!=="info"&&hn(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Yp(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new Y(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,o=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(o.has(r.key))throw new Y(`Duplicate ${s} key "${r.key}"`,i,t[0].column);o.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(j_(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function Hn(n,e,t){if(n.length<2)throw new Y("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new Y(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function rt(n,e){if(n.length<2)throw new Y("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function V_(n,e){return In(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function H_(n,e,t,i){let r={};for(let s of In(n,e,"layers")){let o=!s.startsWith("-")&&!s.startsWith("!"),a=s.replace(/^[-!]+/,"").toLowerCase();if(a==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}(a==="background"||a==="guides"||a==="orbits-back"||a==="orbits-front"||a==="relations"||a==="events"||a==="objects"||a==="labels"||a==="metadata")&&(a==="events"&&t&&i&&hn(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function In(n,e,t){if(n.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function Wp(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new Y(`Unknown projection "${n}"`,e,t);return i}function jp(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Xp(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new Y(`Unknown render preset "${n}"`,e,t)}function Bu(n,e,t,i){let r=gi(n,e,t,i);if(r<=0)throw new Y(`Field "${i}" must be greater than zero`,e,t);return r}function gi(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new Y(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function G_(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function zu(){return{azimuth:null,elevation:null,roll:null,distance:null}}function $_(n,e,t){if(n.length===0||n.length%2!==0)throw new Y('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:zu(),r=new Set;for(let s=0;s<n.length;s+=2){let o=n[s],a=n[s+1],l=o.value.toLowerCase();if(r.has(l))throw new Y(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(l);let c=a.value;switch(l){case"azimuth":i.azimuth=gi(c,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=gi(c,e,o.column,"camera.elevation");break;case"roll":i.roll=gi(c,e,o.column,"camera.roll");break;case"distance":i.distance=Bu(c,e,o.column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function W_(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],l=Ws(a.value);if(!l)throw new Y(`Unknown field "${a.value}"`,e,a.column);l.version==="2.1"&&hn(i,r,a.value,{line:e,column:a.column}),o++;let c=[];if(l.inlineMode==="single"){let u=n[o];u&&(c.push(u),o++)}else if(l.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[o];if(!d)break;c.push(d),o++}else for(;o<n.length&&!y_.has(n[o].value);)c.push(n[o]),o++;if(c.length===0)throw new Y(`Missing value for field "${a.value}"`,e,a.column);s.push({type:"field",key:a.value,values:c.map(u=>u.value),location:{line:e,column:a.column}})}return Kp(s,t),s}function j_(n,e,t,i,r){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);let s=Ws(n[0].value);if(!s)throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&hn(i,r,n[0].value,{line:e,column:n[0].column});let o={type:"field",key:n[0].value,values:n.slice(1).map(a=>a.value),location:{line:e,column:n[0].column}};return Kp([o],t),o}function Yp(n,e,t){if(n.length<2)throw new Y(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function X_(n,e,t){let i=qp(n.fields),r=Zp(i),s=Z_(n.objectType,i),o=nb(i.get("groups")?.[0]),a=Va(i.get("epoch")?.[0]),l=Va(i.get("referencePlane")?.[0]),c=i.has("tidalLock")?fi(xn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Q_(i.get("resonance")[0]):void 0,d=K_(i),h=i.get("derive")?.map(v=>eb(v)),f=i.get("validate")?.map(v=>({rule:xn(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>tb(v)),g=J_(n.typedBlockEntries),m=Jp(n.infoEntries,"info"),x={type:n.objectType,id:n.id,properties:s,placement:r,info:m};return o.length>0&&(x.groups=o),a&&(x.epoch=a),l&&(x.referencePlane=l),c!==void 0&&(x.tidalLock=c),u&&(x.resonance=u),d&&(x.renderHints=d),h?.length&&(x.deriveRules=h),f?.length&&(x.validationRules=f),p?.length&&(x.lockedFields=p),y?.length&&(x.tolerances=y),g&&Object.keys(g).length>0&&(x.typedBlocks=g),Ga(e,"2.1")&&(x.groups||x.epoch||x.referencePlane||x.tidalLock!==void 0||x.resonance||x.renderHints||x.deriveRules?.length||x.validationRules?.length||x.lockedFields?.length||x.tolerances?.length||x.typedBlocks)&&hn(e,t,n.id,n.location),x}function Y_(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>q_(t))}}function q_(n){let e=qp(n.fields,"event-pose"),t=Zp(e);return{objectId:n.objectId,placement:t,inner:mi(e.get("inner")?.[0],"inner"),outer:mi(e.get("outer")?.[0],"outer"),epoch:Va(e.get("epoch")?.[0]),referencePlane:Va(e.get("referencePlane")?.[0])}}function qp(n,e="object"){let t=new Map;for(let i of n){let r=Ws(i.key);if(!r&&!$p.has(i.key))throw Y.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw Y.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function Zp(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let o=e??t??i??r;throw Y.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:xn(e),distance:mi(n.get("distance")?.[0],"distance"),semiMajor:mi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:ib(n.get("eccentricity")?.[0],"eccentricity"),period:mi(n.get("period")?.[0],"period"),angle:mi(n.get("angle")?.[0],"angle"),inclination:mi(n.get("inclination")?.[0],"inclination"),phase:mi(n.get("phase")?.[0],"phase")};if(t){let o=xn(t);return{mode:"at",target:o,reference:kp(o,t.location)}}if(i)return{mode:"surface",target:xn(i)};if(r){let o=xn(r),a=Ou(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function Z_(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=Ws(i);!s||!o?.legacySchema||o.legacySchema.placement||(Uu(i,n,s.location),t[i]=Bp(i,s.values,s.location))}return t}function Jp(n,e){let t={};for(let i of n){if(i.key in t)throw Y.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function J_(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=Jp(i,t))}return e}function K_(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=fi(xn(t),"renderLabel",t.location)),i&&(e.renderOrbit=fi(xn(i),"renderOrbit",i.location)),r&&(e.renderPriority=ka(xn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Q_(n){if(n.values.length!==2)throw Y.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw Y.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function eb(n){if(n.values.length!==2)throw Y.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function tb(n){if(n.values.length!==2)throw Y.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=Ou(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function nb(n){return n?[...new Set(n.values)]:[]}function Va(n){return n&&n.values.join(" ").trim()||null}function mi(n,e){return n?Du(xn(n),n.location,e):void 0}function ib(n,e){return n?ka(xn(n),e,n.location):void 0}function xn(n){return Gs(n.values,n.key,n.location)}function Ws(n){return Ha.get(n)}function Kp(n,e){for(let t of n){let i=Ws(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){Uu(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function hn(n,e,t,i){Ga(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function Fi(n,e,t,i){Ga(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function Ga(n,e){return Gp(n)<Gp(e)}function Gp(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3;case"2.6.1":return 4}}function rb(n){let e=[...n],t=[],i=!1,r=!1,s=null,o=1,a=1;for(let l=0;l<e.length;l++){let c=e[l],u=e[l+1];if(r){if(c==="*"&&u==="/"){e[l]=" ",e[l+1]=" ",r=!1,s=null,l++,a+=2;continue}c!==`
3822
3822
  `&&c!=="\r"&&(e[l]=" "),c===`
3823
- `?(a++,o=1):o++;continue}if(!i&&c==="/"&&u==="*"){t.push({kind:"block",line:a,column:o}),e[l]=" ",e[l+1]=" ",r=!0,s={line:a,column:o},l++,o+=2;continue}if(!i&&c==="#"&&!nb(e,l)){t.push({kind:"line",line:a,column:o}),e[l]=" ";let d=l+1;for(;d<e.length&&e[d]!==`
3824
- `&&e[d]!=="\r";)e[d]=" ",d++;o+=d-l,l=d-1;continue}c==='"'&&e[l-1]!=="\\"&&(i=!i),c===`
3825
- `?(a++,o=1):o++}if(r)throw Y.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function nb(n,e){let t=e+1,i=0;for(;t<n.length&&/[0-9a-f]/i.test(n[t]??"");)t++,i++;if(![3,4,6,8].includes(i))return!1;let r=n[t];return r===void 0||r===" "||r===" "||r==="\r"||r===`
3826
- `}var ib=/^schema\s+2(?:\.0|\.1|\.5)?$/i,rb=/^schema\s+2\.1$/i,sb=/^schema\s+2\.5$/i,ab=/^schema\s+2\.0-draft$/i;function Kp(n){for(let e of ob(n).split(/\r?\n/)){let t=e.trim();if(t)return ab.test(t)?"2.0-draft":rb.test(t)?"2.1":sb.test(t)?"2.5":ib.test(t)?"2.0":"1.0"}return"1.0"}function ob(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],a=e[r+1];if(i){if(s==="*"&&a==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3827
- `&&s!=="\r"&&(e[r]=" ");continue}if(!t&&s==="/"&&a==="*"){e[r]=" ",e[r+1]=" ",i=!0,r++;continue}if(!t&&s==="#"){e[r]=" ";let o=r+1;for(;o<e.length&&e[o]!==`
3828
- `&&e[o]!=="\r";)e[o]=" ",o++;r=o-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function Gn(n){let e=Qp(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new Y(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function Qp(n){let e=Kp(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5")return lb(n,e);let t;try{t=Ds(n)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"parse")]}}let i;try{i=Os(t)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"normalize")]}}try{Us(i)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function lb(n,e){let t;try{t=ku(n)}catch(a){return{ok:!1,value:null,diagnostics:[Ni(a,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(a=>a.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=Lu(t)}catch(a){return{ok:!1,value:null,diagnostics:[Ni(a,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var fn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function Vu(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function js(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function ki(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function $o(n,e){return{...n,rotationDeg:Vu(n.rotationDeg+e)}}function Cr(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=zi(n),a=js(e.scale*t,r);if(a===e.scale)return e;let o=a/e.scale,l=i.x-s.x,c=i.y-s.y;return{...e,scale:a,translateX:(1-o)*l+o*e.translateX,translateY:(1-o)*c+o*e.translateY}}function Bi(n,e,t){let i=zi(n),r=db(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),a=Math.max(n.height-t.fitPadding*2,1),o=Math.max(r.width,1),l=Math.max(r.height,1),c=js(Math.min(s/o,a/l),t),u=Vn({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:c,translateX:i.x-(i.x+(u.x-i.x)*c),translateY:i.y-(i.y+(u.y-i.y)*c)}}function Wo(n,e,t,i){let r=n.objects.find(l=>l.objectId===t&&!l.hidden);if(!r)return e;let s=zi(n),a=js(Math.max(e.scale,1.8),i),o=Vn({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:a,translateX:s.x-(s.x+(o.x-s.x)*a),translateY:s.y-(s.y+(o.y-s.y)*a),selectedObjectId:t}}function jo(n,e){let t=zi(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function Rr(n,e,t){let i=zi(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},a={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},o=Vn({x:a.x,y:a.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+o.x,y:i.y+o.y}}function Xo(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(o=>Rr(n,e,o)),i=Math.min(...t.map(o=>o.x)),r=Math.min(...t.map(o=>o.y)),s=Math.max(...t.map(o=>o.x)),a=Math.max(...t.map(o=>o.y));return{minX:i,minY:r,maxX:s,maxY:a,width:s-i,height:a-r,centerX:i+(s-i)/2,centerY:r+(a-r)/2}}function zi(n){return{x:n.width/2,y:n.height/2}}function db(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(l=>Vn(l,e,t)),r=Math.min(...i.map(l=>l.x)),s=Math.min(...i.map(l=>l.y)),a=Math.max(...i.map(l=>l.x)),o=Math.max(...i.map(l=>l.y));return{minX:r,minY:s,maxX:a,maxY:o,width:a-r,height:o-s,centerX:r+(a-r)/2,centerY:s+(o-s)/2}}var qo="worldorbit-camera-root";function _n(n,e={}){let t=Ui(e.theme),i=Ib(e.preset??n.renderPreset??void 0),r=fo({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,a=po(n,e.filter??null),o=n.objects.filter(x=>!x.hidden).filter(x=>a.has(x.objectId)).filter(x=>r.structures||!Yo(x.object)).sort((x,v)=>x.sortKey-v.sortKey),l=n.labels.filter(x=>!x.hidden).filter(x=>a.has(x.objectId)).filter(x=>r.structures||!Yo(x.object)),c=mb(o),u=r.orbits?pb(n,a,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(x=>!x.hidden).filter(x=>a.has(x.objectId)).filter(x=>r.structures||!Yo(x.object)).map(x=>`<line class="wo-leader wo-leader-${x.mode}" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${It(x.renderId)}" data-group-id="${Ft(x.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(x=>!x.hidden).filter(x=>a.has(x.fromObjectId)&&a.has(x.toObjectId)).map(x=>`<line class="wo-relation" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${It(x.renderId)}" data-relation-id="${Ft(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>hb(n,x,a,t)).join(""):"",m=r.objects?o.map(x=>gb(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?l.map(x=>yb(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${It(n.title)}</text>
3823
+ `?(o++,a=1):a++;continue}if(!i&&c==="/"&&u==="*"){t.push({kind:"block",line:o,column:a}),e[l]=" ",e[l+1]=" ",r=!0,s={line:o,column:a},l++,a+=2;continue}if(!i&&c==="#"&&!sb(e,l)){t.push({kind:"line",line:o,column:a}),e[l]=" ";let d=l+1;for(;d<e.length&&e[d]!==`
3824
+ `&&e[d]!=="\r";)e[d]=" ",d++;a+=d-l,l=d-1;continue}c==='"'&&e[l-1]!=="\\"&&(i=!i),c===`
3825
+ `?(o++,a=1):a++}if(r)throw Y.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function sb(n,e){let t=e+1,i=0;for(;t<n.length&&/[0-9a-f]/i.test(n[t]??"");)t++,i++;if(![3,4,6,8].includes(i))return!1;let r=n[t];return r===void 0||r===" "||r===" "||r==="\r"||r===`
3826
+ `}var ob=/^schema\s+2(?:\.0|\.1|\.5)?$/i,ab=/^schema\s+2\.1$/i,lb=/^schema\s+2\.5$/i,cb=/^schema\s+2\.0-draft$/i;function Qp(n){for(let e of ub(n).split(/\r?\n/)){let t=e.trim();if(t)return cb.test(t)?"2.0-draft":ab.test(t)?"2.1":lb.test(t)?"2.6.1":ob.test(t)?"2.0":"1.0"}return"1.0"}function ub(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],o=e[r+1];if(i){if(s==="*"&&o==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3827
+ `&&s!=="\r"&&(e[r]=" ");continue}if(!t&&s==="/"&&o==="*"){e[r]=" ",e[r+1]=" ",i=!0,r++;continue}if(!t&&s==="#"){e[r]=" ";let a=r+1;for(;a<e.length&&e[a]!==`
3828
+ `&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function Gn(n){let e=em(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new Y(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function em(n){let e=Qp(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5"||e==="2.6.1")return db(n,e);let t;try{t=Ds(n)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"parse")]}}let i;try{i=Os(t)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"normalize")]}}try{Us(i)}catch(r){return{ok:!1,value:null,diagnostics:[Ni(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function db(n,e){let t;try{t=ku(n)}catch(o){return{ok:!1,value:null,diagnostics:[Ni(o,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(o=>o.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=Lu(t)}catch(o){return{ok:!1,value:null,diagnostics:[Ni(o,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var fn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function Vu(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function js(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function ki(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function $a(n,e){return{...n,rotationDeg:Vu(n.rotationDeg+e)}}function Cr(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=zi(n),o=js(e.scale*t,r);if(o===e.scale)return e;let a=o/e.scale,l=i.x-s.x,c=i.y-s.y;return{...e,scale:o,translateX:(1-a)*l+a*e.translateX,translateY:(1-a)*c+a*e.translateY}}function Bi(n,e,t){let i=zi(n),r=pb(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),o=Math.max(n.height-t.fitPadding*2,1),a=Math.max(r.width,1),l=Math.max(r.height,1),c=js(Math.min(s/a,o/l),t),u=Vn({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:c,translateX:i.x-(i.x+(u.x-i.x)*c),translateY:i.y-(i.y+(u.y-i.y)*c)}}function Wa(n,e,t,i){let r=n.objects.find(l=>l.objectId===t&&!l.hidden);if(!r)return e;let s=zi(n),o=js(Math.max(e.scale,1.8),i),a=Vn({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:o,translateX:s.x-(s.x+(a.x-s.x)*o),translateY:s.y-(s.y+(a.y-s.y)*o),selectedObjectId:t}}function ja(n,e){let t=zi(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function Rr(n,e,t){let i=zi(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},o={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},a=Vn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Xa(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(a=>Rr(n,e,a)),i=Math.min(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x)),o=Math.max(...t.map(a=>a.y));return{minX:i,minY:r,maxX:s,maxY:o,width:s-i,height:o-r,centerX:i+(s-i)/2,centerY:r+(o-r)/2}}function zi(n){return{x:n.width/2,y:n.height/2}}function pb(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(l=>Vn(l,e,t)),r=Math.min(...i.map(l=>l.x)),s=Math.min(...i.map(l=>l.y)),o=Math.max(...i.map(l=>l.x)),a=Math.max(...i.map(l=>l.y));return{minX:r,minY:s,maxX:o,maxY:a,width:o-r,height:a-s,centerX:r+(o-r)/2,centerY:s+(a-s)/2}}var qa="worldorbit-camera-root";function _n(n,e={}){let t=Ui(e.theme),i=Pb(e.preset??n.renderPreset??void 0),r=fa({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=pa(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ya(x.object)).sort((x,v)=>x.sortKey-v.sortKey),l=n.labels.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ya(x.object)),c=vb(a),u=r.orbits?yb(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ya(x.object)).map(x=>`<line class="wo-leader wo-leader-${x.mode}" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${It(x.renderId)}" data-group-id="${Ft(x.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(x=>!x.hidden).filter(x=>o.has(x.fromObjectId)&&o.has(x.toObjectId)).map(x=>`<line class="wo-relation" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${It(x.renderId)}" data-relation-id="${Ft(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>mb(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>xb(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?l.map(x=>_b(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${It(n.title)}</text>
3829
3829
  <text class="wo-subtitle" x="56" y="88">${It(s)}</text>
3830
- <text class="wo-meta" x="56" y="${n.height-42}">${It(Rb(n))}</text>`:"",p=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3830
+ <text class="wo-meta" x="56" y="${n.height-42}">${It(Db(n))}</text>`:"",m=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3831
3831
  <rect class="wo-bg-glow" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3832
- ${r.guides?Cb(n.width,n.height):""}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" data-worldorbit-svg="true" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" preserveAspectRatio="xMidYMid meet" role="img" aria-labelledby="worldorbit-title worldorbit-desc">
3832
+ ${r.guides?Lb(n.width,n.height):""}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" data-worldorbit-svg="true" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" preserveAspectRatio="xMidYMid meet" role="img" aria-labelledby="worldorbit-title worldorbit-desc">
3833
3833
  <title id="worldorbit-title">${It(n.title)}</title>
3834
- <desc id="worldorbit-desc">A ${It(n.viewMode)} WorldOrbit render with ${o.length} visible objects.</desc>
3834
+ <desc id="worldorbit-desc">A ${It(n.viewMode)} WorldOrbit render with ${a.length} visible objects.</desc>
3835
3835
  <defs>
3836
3836
  <linearGradient id="wo-bg" x1="0%" y1="0%" x2="100%" y2="100%">
3837
3837
  <stop offset="0%" stop-color="${t.backgroundStart}" />
@@ -3885,51 +3885,51 @@ void main() {
3885
3885
  .wo-selection-ring { display: none; fill: none; stroke-width: 2; stroke-dasharray: 6 5; }
3886
3886
  .wo-object-image { pointer-events: none; }
3887
3887
  </style>
3888
- ${p}
3888
+ ${m}
3889
3889
  ${g}
3890
3890
  <g data-worldorbit-world="true">
3891
- <g data-worldorbit-camera-root="${qo}" id="${qo}">
3891
+ <g data-worldorbit-camera-root="${qa}" id="${qa}">
3892
3892
  <g data-worldorbit-world-content="true">
3893
3893
  ${r.orbits?`<g data-layer-id="orbits-back">${u.back}</g>`:""}
3894
3894
  ${r.guides?`<g data-layer-id="guides">${d}</g>`:""}
3895
3895
  ${r.relations?`<g data-layer-id="relations">${h}</g>`:""}
3896
3896
  ${r.events?`<g data-layer-id="events">${f}</g>`:""}
3897
- ${r.objects?`<g data-layer-id="objects">${m}</g>`:""}
3897
+ ${r.objects?`<g data-layer-id="objects">${p}</g>`:""}
3898
3898
  ${r.orbits?`<g data-layer-id="orbits-front">${u.front}</g>`:""}
3899
3899
  ${r.labels?`<g data-layer-id="labels">${y}</g>`:""}
3900
3900
  </g>
3901
3901
  </g>
3902
3902
  </g>
3903
- </svg>`}function hb(n,e,t,i){let r=e.objectIds.filter(l=>t.has(l)).map(l=>n.objects.find(c=>c.objectId===l&&!c.hidden)).filter(Boolean);if(r.length===0)return"";let s=e.event.color||i.accent,a=e.event.label||e.event.id,o=r.map(l=>`<line class="wo-event-line" x1="${e.x}" y1="${e.y}" x2="${l.x}" y2="${l.y}" stroke="${Ft(s)}" data-event-id="${Ft(e.eventId)}" data-object-id="${Ft(l.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${It(e.renderId)}" data-event-id="${Ft(e.eventId)}">
3904
- ${o}
3903
+ </svg>`}function mb(n,e,t,i){let r=e.objectIds.filter(l=>t.has(l)).map(l=>n.objects.find(c=>c.objectId===l&&!c.hidden)).filter(Boolean);if(r.length===0)return"";let s=e.event.color||i.accent,o=e.event.label||e.event.id,a=r.map(l=>`<line class="wo-event-line" x1="${e.x}" y1="${e.y}" x2="${l.x}" y2="${l.y}" stroke="${Ft(s)}" data-event-id="${Ft(e.eventId)}" data-object-id="${Ft(l.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${It(e.renderId)}" data-event-id="${Ft(e.eventId)}">
3904
+ ${a}
3905
3905
  <circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${Ft(s)}" />
3906
- <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${It(a)}</text>
3907
- </g>`}function $u(n,e={}){return _n(dn(n,e),e)}function im(n,e={}){let t=Gn(n);return $u(t.document,fb(t,e))}function fb(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function pb(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(a=>!a.hidden&&e.has(a.objectId)&&(t||!Yo(a.object)))){let a=s.bandThickness??(s.band?10:1.5),o=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",l=`data-render-id="${It(s.renderId)}" data-orbit-object-id="${Ft(s.objectId)}" data-parent-id="${Ft(s.parentId)}" data-group-id="${Ft(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${o} wo-orbit-back" d="${s.backArcPath}" stroke-width="${a}" ${l} />`),s.frontArcPath&&r.push(`<path class="${o} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${a}" ${l} />`);continue}if(s.kind==="ellipse"){let c=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${o} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${c}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${a}" ${l} />`);continue}r.push(`<circle class="${o} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${a}" ${l} />`)}return{back:i.join(""),front:r.join("")}}function mb(n){return n.filter(e=>!!e.imageHref).map(e=>_b(e)).join("")}function gb(n,e,t){let{object:i,x:r,y:s,radius:a,visualRadius:o}=n,l=e===n.objectId?" wo-object-selected":"",c=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=wb(n,t),d=xb(n),h=d?em(i,r,s,a,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${c}${l}" data-object-id="${It(n.objectId)}" data-parent-id="${Ft(n.parentId??"")}" data-group-id="${Ft(n.groupId??"")}" data-render-id="${It(n.renderId)}" tabindex="0" role="button" aria-label="${It(`${i.type} ${n.objectId}`)}">
3908
- <circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${o+8}" />
3909
- ${vb(n,u)}
3910
- ${em(i,r,s,a,u)}
3906
+ <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${It(o)}</text>
3907
+ </g>`}function $u(n,e={}){return _n(dn(n,e),e)}function rm(n,e={}){let t=Gn(n);return $u(t.document,gb(t,e))}function gb(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function yb(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!Ya(o.object)))){let o=s.bandThickness??(s.band?10:1.5),a=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",l=`data-render-id="${It(s.renderId)}" data-orbit-object-id="${Ft(s.objectId)}" data-parent-id="${Ft(s.parentId)}" data-group-id="${Ft(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${a} wo-orbit-back" d="${s.backArcPath}" stroke-width="${o}" ${l} />`),s.frontArcPath&&r.push(`<path class="${a} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${o}" ${l} />`);continue}if(s.kind==="ellipse"){let c=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${c}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${o}" ${l} />`);continue}r.push(`<circle class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${o}" ${l} />`)}return{back:i.join(""),front:r.join("")}}function vb(n){return n.filter(e=>!!e.imageHref).map(e=>Mb(e)).join("")}function xb(n,e,t){let{object:i,x:r,y:s,radius:o,visualRadius:a}=n,l=e===n.objectId?" wo-object-selected":"",c=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=Ab(n,t),d=wb(n),h=d?tm(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${c}${l}" data-object-id="${It(n.objectId)}" data-parent-id="${Ft(n.parentId??"")}" data-group-id="${Ft(n.groupId??"")}" data-render-id="${It(n.renderId)}" tabindex="0" role="button" aria-label="${It(`${i.type} ${n.objectId}`)}">
3908
+ <circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${a+8}" />
3909
+ ${bb(n,u)}
3910
+ ${tm(i,r,s,o,u)}
3911
3911
  ${d}
3912
3912
  ${h}
3913
- </g>`}function yb(n,e,t){let i=t===e.objectId?" wo-object-label-selected":"",r=n.scaleModel.labelMultiplier;return`<g class="wo-object-label${i}" data-object-id="${It(e.objectId)}" data-group-id="${Ft(e.groupId??"")}" data-render-id="${It(e.renderId)}">
3913
+ </g>`}function _b(n,e,t){let i=t===e.objectId?" wo-object-label-selected":"",r=n.scaleModel.labelMultiplier;return`<g class="wo-object-label${i}" data-object-id="${It(e.objectId)}" data-group-id="${Ft(e.groupId??"")}" data-render-id="${It(e.renderId)}">
3914
3914
  <text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${It(e.label)}</text>
3915
3915
  <text class="wo-label-secondary" x="${e.x}" y="${e.secondaryY}" text-anchor="${e.textAnchor}" font-size="${11*r}">${It(e.secondaryLabel)}</text>
3916
- </g>`}function em(n,e,t,i,r,s={}){let a=s.outlineOnly?"transparent":r.fill,o=r.tail??r.fill;switch(n.type){case"star":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="2" />`:`<circle cx="${e}" cy="${t}" r="${i*2.4}" fill="${r.glow??"url(#wo-star-glow)"}" opacity="0.84" />
3917
- <circle cx="${e}" cy="${t}" r="${i}" fill="${a}" stroke="${r.stroke}" stroke-width="2" />`;case"planet":case"moon":case"belt":case"asteroid":case"ring":return`<circle cx="${e}" cy="${t}" r="${i}" fill="${a}" stroke="${r.stroke}" stroke-width="${s.outlineOnly?1.5:1.4}" />`;case"comet":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<path d="M ${e-i*2} ${t+i*1.3} Q ${e-i*.7} ${t+i*.3} ${e-i*.45} ${t}" fill="none" stroke="${o}" stroke-width="${Math.max(2,i*.8)}" stroke-linecap="round" opacity="0.85" />
3918
- <circle cx="${e}" cy="${t}" r="${i}" fill="${a}" stroke="${r.stroke}" stroke-width="1.4" />`;case"structure":return`<polygon points="${sm(e,t,i)}" fill="${a}" stroke="${r.stroke}" stroke-width="1.4" />`;case"phenomenon":{let l=String(n.properties.kind??"").toLowerCase().replace(/_/g,"-");return s.outlineOnly?l==="black-hole"||l==="nebula"||l==="galaxy"||l==="dwarf-galaxy"?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<polygon points="${Hu(e,t,i)}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:l==="black-hole"?`<ellipse cx="${e}" cy="${t}" rx="${i*2.4}" ry="${i*.55}" fill="none" stroke="${r.accentRing??r.stroke}" stroke-width="3.5" />
3919
- <circle cx="${e}" cy="${t}" r="${i}" fill="${a}" stroke="${r.stroke}" stroke-width="2" />`:l==="galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*2.6}" ry="${i}" fill="${r.halo??"none"}" stroke="none" />
3920
- <ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${a}" stroke="${r.stroke}" stroke-width="1.2" />
3921
- <circle cx="${e}" cy="${t}" r="${i*.28}" fill="${r.core??"#fff"}" stroke="none" />`:l==="dwarf-galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*1.6}" ry="${i*.55}" fill="${a}" stroke="${r.stroke}" stroke-width="1" />
3916
+ </g>`}function tm(n,e,t,i,r,s={}){let o=s.outlineOnly?"transparent":r.fill,a=r.tail??r.fill;switch(n.type){case"star":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="2" />`:`<circle cx="${e}" cy="${t}" r="${i*2.4}" fill="${r.glow??"url(#wo-star-glow)"}" opacity="0.84" />
3917
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="2" />`;case"planet":case"moon":case"belt":case"asteroid":case"ring":return`<circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="${s.outlineOnly?1.5:1.4}" />`;case"comet":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<path d="M ${e-i*2} ${t+i*1.3} Q ${e-i*.7} ${t+i*.3} ${e-i*.45} ${t}" fill="none" stroke="${a}" stroke-width="${Math.max(2,i*.8)}" stroke-linecap="round" opacity="0.85" />
3918
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`;case"structure":return`<polygon points="${om(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`;case"phenomenon":{let l=String(n.properties.kind??"").toLowerCase().replace(/_/g,"-");return s.outlineOnly?l==="black-hole"||l==="nebula"||l==="galaxy"||l==="dwarf-galaxy"?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<polygon points="${Hu(e,t,i)}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:l==="black-hole"?`<ellipse cx="${e}" cy="${t}" rx="${i*2.4}" ry="${i*.55}" fill="none" stroke="${r.accentRing??r.stroke}" stroke-width="3.5" />
3919
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="2" />`:l==="galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*2.6}" ry="${i}" fill="${r.halo??"none"}" stroke="none" />
3920
+ <ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${o}" stroke="${r.stroke}" stroke-width="1.2" />
3921
+ <circle cx="${e}" cy="${t}" r="${i*.28}" fill="${r.core??"#fff"}" stroke="none" />`:l==="dwarf-galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*1.6}" ry="${i*.55}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />
3922
3922
  <circle cx="${e}" cy="${t}" r="${i*.25}" fill="${r.core??"#fff"}" stroke="none" />`:l==="nebula"?`<circle cx="${e}" cy="${t}" r="${i*2.2}" fill="${r.halo??"none"}" stroke="none" />
3923
- <circle cx="${e}" cy="${t}" r="${i}" fill="${a}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Hu(e,t,i)}" fill="${a}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function vb(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function xb(n){if(!n.imageHref)return"";let e=bb(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Ft(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Ft(rm(n))})" />`}function _b(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${sm(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Hu(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Ft(rm(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function bb(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function wb(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=Mb(n.object.type,t,e),r=n.fillColor&&Lb(n.fillColor)?n.fillColor:i.fill,s=tm(n.object.properties.albedo),a=tm(n.object.properties.temperature),o=Ab(r,a,s,n.object.type),l=Xs(o,"#ffffff",.4)??i.stroke,c=Tb(n.object.properties.atmosphere),u=n.object.type==="star"?nm(Xs(o,"#fff2cb",.4)??o,.82):void 0;return{fill:o,stroke:l,glow:u,atmosphere:c,tail:n.object.type==="comet"?nm(Xs(o,"#ffffff",.5)??o,.72):void 0}}function Mb(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return Sb(e)}}function Sb(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function Ab(n,e,t,i){let r=n;if(e!==null){let s=Eb(e,i);r=Xs(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=Xs(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function Eb(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function Tb(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function Ib(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function tm(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function rm(n){return`${n.renderId}-clip`}function sm(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Hu(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function Cb(n,e){let t=Array.from({length:10},(r,s)=>{let a=90+s*((n-180)/9);return`<line class="wo-grid" x1="${a}" y1="120" x2="${a}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let a=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${a}" x2="${n-56}" y2="${a}" />`}).join("");return`${t}${i}`}function Rb(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Yo(n){return n.type==="structure"||n.type==="phenomenon"}function Xs(n,e,t){let i=Gu(n),r=Gu(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return Pb({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function nm(n,e){let t=Gu(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Gu(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function Pb(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function Lb(n){return!!n.trim()}function It(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Ft(n){return It(n)}var Pr=180,Lr=120,am=10;function om(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((Pr-am*2)/Math.max(i.width,1),(Lr-am*2)/Math.max(i.height,1)),s=(Pr-i.width*r)/2-i.minX*r,a=(Lr-i.height*r)/2-i.minY*r,o=Xo(n,e),l=t.map(c=>{let u=c.x*r+s,d=c.y*r+a,h=Math.max(1.4,Math.min(c.visualRadius*r,5.2)),f=c.fillColor??Db(c.object.type);return`<circle cx="${bn(u)}" cy="${bn(d)}" r="${bn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${Pr}px;height:${Lr}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3923
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Hu(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function bb(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function wb(n){if(!n.imageHref)return"";let e=Sb(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Ft(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Ft(sm(n))})" />`}function Mb(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${om(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Hu(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Ft(sm(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function Sb(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function Ab(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=Eb(n.object.type,t,e),r=n.fillColor&&Ub(n.fillColor)?n.fillColor:i.fill,s=nm(n.object.properties.albedo),o=nm(n.object.properties.temperature),a=Ib(r,o,s,n.object.type),l=Xs(a,"#ffffff",.4)??i.stroke,c=Rb(n.object.properties.atmosphere),u=n.object.type==="star"?im(Xs(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:l,glow:u,atmosphere:c,tail:n.object.type==="comet"?im(Xs(a,"#ffffff",.5)??a,.72):void 0}}function Eb(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return Tb(e)}}function Tb(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function Ib(n,e,t,i){let r=n;if(e!==null){let s=Cb(e,i);r=Xs(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=Xs(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function Cb(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function Rb(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function Pb(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function nm(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function sm(n){return`${n.renderId}-clip`}function om(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Hu(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function Lb(n,e){let t=Array.from({length:10},(r,s)=>{let o=90+s*((n-180)/9);return`<line class="wo-grid" x1="${o}" y1="120" x2="${o}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let o=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${o}" x2="${n-56}" y2="${o}" />`}).join("");return`${t}${i}`}function Db(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Ya(n){return n.type==="structure"||n.type==="phenomenon"}function Xs(n,e,t){let i=Gu(n),r=Gu(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return Ob({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function im(n,e){let t=Gu(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Gu(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function Ob(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function Ub(n){return!!n.trim()}function It(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Ft(n){return It(n)}var Pr=180,Lr=120,am=10;function lm(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((Pr-am*2)/Math.max(i.width,1),(Lr-am*2)/Math.max(i.height,1)),s=(Pr-i.width*r)/2-i.minX*r,o=(Lr-i.height*r)/2-i.minY*r,a=Xa(n,e),l=t.map(c=>{let u=c.x*r+s,d=c.y*r+o,h=Math.max(1.4,Math.min(c.visualRadius*r,5.2)),f=c.fillColor??Nb(c.object.type);return`<circle cx="${bn(u)}" cy="${bn(d)}" r="${bn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${Pr}px;height:${Lr}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3924
3924
  <svg width="${Pr}" height="${Lr}" viewBox="0 0 ${Pr} ${Lr}" role="presentation" aria-hidden="true">
3925
3925
  <rect x="0.5" y="0.5" width="${Pr-1}" height="${Lr-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3926
- <rect x="${bn(i.minX*r+s)}" y="${bn(i.minY*r+a)}" width="${bn(i.width*r)}" height="${bn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3926
+ <rect x="${bn(i.minX*r+s)}" y="${bn(i.minY*r+o)}" width="${bn(i.width*r)}" height="${bn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3927
3927
  ${l}
3928
- <rect x="${bn(o.minX*r+s)}" y="${bn(o.minY*r+a)}" width="${bn(o.width*r)}" height="${bn(o.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3928
+ <rect x="${bn(a.minX*r+s)}" y="${bn(a.minY*r+o)}" width="${bn(a.width*r)}" height="${bn(a.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3929
3929
  </svg>
3930
- </div>`}function Db(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function bn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var MT="wo-viewer-3d-root",$f=null;function xy(n){UT();let e=document.createElement("div");e.className=MT,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,a=new Set,o=null,l=null,c=new Map,u=null,d=!1,h=null,f=null,m="",y=new Map,g=new Map,p=[];return kT().then(T=>{if(d)return;let U=new T.Scene,I=new T.PerspectiveCamera(46,1,.1,24e3),B=new T.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});B.domElement.classList.add("wo-viewer-3d-canvas"),B.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(B.domElement);let W=new T.AmbientLight(16777215,.24),F=new T.DirectionalLight(13625855,.36),X=new T.DirectionalLight(8304895,.24),k=new T.PointLight(16773327,2.6,0,2);F.position.set(-360,260,220),X.position.set(340,180,-280);let re=new T.Group,se=new T.Group,ve=LT(T,320),Le=new T.Raycaster;Le.params.Line={threshold:7},U.add(W),U.add(F),U.add(X),U.add(k),U.add(ve),U.add(re),U.add(se),t={THREE:T,scene3d:U,camera:I,renderer:B,ambientLight:W,fillLight:F,rimLight:X,keyLight:k,starfield:ve,orbitLayer:re,objectLayer:se,raycaster:Le,pointer:new T.Vector2},my(B,T,"balanced"),u&&x(u)}).catch(T=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${FT(T instanceof Error?T.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(T){u=T,x(T)},hitTest(T,U){if(!t||!i)return null;let I=t.renderer.domElement.getBoundingClientRect();if(!I.width||!I.height)return null;t.pointer.x=(T-I.left)/I.width*2-1,t.pointer.y=-((U-I.top)/I.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let B=t.raycaster.intersectObjects(p,!0);for(let W of B){let F=NT(W.object);if(F)return F}return null},projectObjectToContainer(T){if(!t)return null;let U=c.get(T);if(!U)return null;let I=new t.THREE.Vector3(U.x,U.y,U.z);if(I.project(t.camera),I.z>1)return null;let B=t.renderer.domElement.getBoundingClientRect(),W=n.getBoundingClientRect();return{x:B.left-W.left+(I.x+1)/2*B.width,y:B.top-W.top+(1-I.y)/2*B.height}},destroy(){d=!0,u=null,t?.renderer.dispose(),t?.starfield?.geometry?.dispose?.(),t?.starfield?.material?.dispose?.(),e.remove(),y.clear(),g.clear(),p.length=0,t=null}};function x(T){if(!t)return;let U=i!==T.spatialScene;i=T.spatialScene,r=T.renderOptions,s=T.state,a=T.visibleObjectIds,o=T.selectedObjectId,l=T.hoveredObjectId,my(t.renderer,t.THREE,r?.quality??"balanced");let I=JSON.stringify({theme:r?.theme??null,quality:r?.quality??"balanced",style3d:r?.style3d??"symbolic"});I!==m&&(DT(t,r),m=I),U&&v(T.spatialScene),w(T.spatialScene),c=Ru(T.spatialScene,T.timeSeconds),b(),L(),A(),E(),D(),M(),t.renderer.render(t.scene3d,t.camera)}function v(T){if(!t)return;vy(t.orbitLayer),vy(t.objectLayer),y.clear(),g.clear(),p.length=0,h=null,f=null;let U=Ui(r?.theme);for(let I of T.orbits){let B=AT(t.THREE,I,U);t.orbitLayer.add(B.root),g.set(I.objectId,B),p.push(B.root)}for(let I of T.objects){let B=ST(t.THREE,I,U);t.objectLayer.add(B.root),y.set(I.objectId,B),p.push(B.root)}}function b(){for(let T of i?.objects??[]){let U=y.get(T.objectId),I=c.get(T.objectId);U&&I&&U.root.position.set(I.x,I.y,I.z)}}function L(){for(let T of i?.orbits??[]){let U=g.get(T.objectId);if(!U)continue;let I=c.get(T.parentId);U.root.position.set(I?.x??T.center.x,I?.y??T.center.y,I?.z??T.center.z)}}function A(){let T=r?.layers??{};for(let U of i?.objects??[]){let I=y.get(U.objectId);if(!I)continue;let B=T.structures===!1&&(U.object.type==="structure"||U.object.type==="phenomenon");I.root.visible=!U.hidden&&a.has(U.objectId)&&T.objects!==!1&&!B}for(let U of i?.orbits??[]){let I=g.get(U.objectId);if(!I)continue;let B=T.structures===!1&&(U.object.type==="structure"||U.object.type==="phenomenon");I.root.visible=!U.hidden&&a.has(U.objectId)&&T.orbits!==!1&&!B}}function E(){if(t){for(let T of y.values()){let U=o===T.objectId,I=l===T.objectId;gy(t.THREE,T.materials,U,I);let B=U?1.16:I?1.08:1;T.root.scale.set(B,B,B),T.halo&&(T.halo.visible=U||I)}for(let T of g.values())gy(t.THREE,T.materials,o===T.objectId,l===T.objectId)}}function D(){if(!t||!i)return;let T=i.objects.find(I=>I.object.type==="star"&&!I.hidden)??null,U=T?c.get(T.objectId)??T.position:{x:0,y:40,z:0};t.keyLight.position.set(U.x,U.y+20,U.z)}function M(){if(!t||!i||!s)return;let T=r?.camera??i.camera,U=i.contentBounds,I=Math.max(U.width,U.depth,U.height,160),B=ro((T?.azimuth??30)+s.rotationDeg),W=ro(hu(T?.elevation??22,-75,75)),F=hu(2.2/Math.max(s.scale,.1),.35,7.2),X=hu(T?.distance??5.4,2,24),k=hu(I*F*(X/5.4),24,8e3),re=Math.max(I/900,.12),se=new t.THREE.Vector3(U.center.x-s.translateX*re,U.center.y,U.center.z-s.translateY*re),ve=new t.THREE.Vector3(se.x+k*Math.cos(W)*Math.sin(B),se.y+k*Math.sin(W),se.z+k*Math.cos(W)*Math.cos(B)),Le=(r?.style3d??"symbolic")==="cinematic"?.16:.32;!h||!f?(h=ve.clone(),f=se.clone()):(h.lerp(ve,Le),f.lerp(se,Le)),t.camera.position.copy(h),t.camera.lookAt(f),T?.roll&&(t.camera.rotation.z=ro(T.roll))}function w(T){if(!t)return;let U=Math.max(1,Math.round(n.clientWidth||T.width||960)),I=Math.max(1,Math.round(n.clientHeight||T.height||560));t.renderer.setSize(U,I,!1),t.camera.aspect=U/I,t.camera.updateProjectionMatrix()}}function ST(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??OT(e),s=[],a=ET(n,e,r,t),o=new n.Mesh(TT(n,e),a.material);if(o.userData.objectId=e.objectId,i.add(o),s.push(a),RT(e)){let c={material:new n.MeshBasicMaterial({color:t.atmosphere,transparent:!0,opacity:.24,depthWrite:!1,side:2}),baseColor:t.atmosphere,baseOpacity:.24,hoveredOpacity:.34,selectedOpacity:.42},u=new n.Mesh(new n.SphereGeometry(Math.max(e.visualRadius,2)*1.16,20,14),c.material);u.userData.objectId=e.objectId,i.add(u),s.push(c)}if(e.object.type==="comet"){let c={material:new n.MeshBasicMaterial({color:t.cometTail,transparent:!0,opacity:.36,depthWrite:!1}),baseColor:t.cometTail,baseOpacity:.36,hoveredOpacity:.48,selectedOpacity:.56},u=new n.Mesh(new n.ConeGeometry(Math.max(e.visualRadius*.55,2),Math.max(e.visualRadius*2.8,8),12,1,!0),c.material);u.position.set(-Math.max(e.visualRadius*1.4,4),0,0),u.rotation.z=-Math.PI/2,u.userData.objectId=e.objectId,i.add(u),s.push(c)}let l=CT(n,e,t);return l&&(l.visible=!1,l.userData.objectId=e.objectId,i.add(l)),{objectId:e.objectId,root:i,halo:l,materials:s}}function AT(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=ro(e.rotationDeg),i.rotation.x=ro(e.inclinationDeg);let r=e.object.properties.color??t.orbit;if(e.band){let l={material:new n.MeshBasicMaterial({color:r,transparent:!0,opacity:t.orbitBandOpacity,side:2,depthWrite:!1}),baseColor:r,baseOpacity:t.orbitBandOpacity,hoveredOpacity:Math.min(t.orbitBandOpacity+.1,.58),selectedOpacity:Math.min(t.orbitBandOpacity+.18,.72),hoveredColor:t.accent,selectedColor:t.accentStrong},c=new n.Mesh(PT(n,e),l.material);return c.userData.objectId=e.objectId,i.add(c),{objectId:e.objectId,root:i,materials:[l]}}let s={material:new n.LineBasicMaterial({color:r,transparent:!0,opacity:t.orbitOpacity}),baseColor:r,baseOpacity:t.orbitOpacity,hoveredOpacity:Math.min(t.orbitOpacity+.18,.72),selectedOpacity:Math.min(t.orbitOpacity+.3,.88),hoveredColor:t.accent,selectedColor:t.accentStrong},a=new n.BufferGeometry().setFromPoints(_y(n,e,120)),o=new n.LineLoop(a,s.material);return o.userData.objectId=e.objectId,i.add(o),{objectId:e.objectId,root:i,materials:[s]}}function ET(n,e,t,i){if(e.object.type==="star")return{material:new n.MeshStandardMaterial({color:t,emissive:new n.Color(i.starGlow),emissiveIntensity:1.2,roughness:.35,metalness:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:i.starCore,selectedColor:"#fff2c4",baseEmissive:i.starGlow,hoveredEmissive:i.starGlow,selectedEmissive:"#fff6cc",baseEmissiveIntensity:1.2,hoveredEmissiveIntensity:1.5,selectedEmissiveIntensity:1.8};if(e.object.type==="phenomenon")return{material:new n.MeshPhongMaterial({color:t,transparent:!0,opacity:.7,emissive:new n.Color(t),emissiveIntensity:.32,shininess:90}),baseColor:t,baseOpacity:.7,hoveredOpacity:.82,selectedOpacity:.9,hoveredColor:i.accent,selectedColor:i.selectionHalo,baseEmissive:t,hoveredEmissive:i.accent,selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.32,hoveredEmissiveIntensity:.52,selectedEmissiveIntensity:.74};let r=e.object.type==="structure"?70:e.object.type==="ring"?42:e.object.type==="belt"?26:36;return{material:new n.MeshPhongMaterial({color:t,specular:new n.Color(i.objectSpecular),shininess:r,transparent:!1,opacity:1,emissive:new n.Color(0),emissiveIntensity:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:yy(n,t,.08),selectedColor:yy(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function TT(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.14,34,24);case"structure":return IT(n,e,t);case"phenomenon":return new n.IcosahedronGeometry(t*1.12,1);case"belt":return new n.TorusGeometry(Math.max(t*1.15,4),Math.max(t*.28,1),10,24);case"ring":return new n.TorusGeometry(Math.max(t,4),Math.max(t*.18,.8),10,30);case"asteroid":return new n.DodecahedronGeometry(t,0);case"comet":return new n.SphereGeometry(t*.94,18,14);default:return new n.SphereGeometry(t,24,18)}}function IT(n,e,t){let i=String(e.object.properties.kind??"").toLowerCase();return i.includes("relay")?new n.OctahedronGeometry(t*1.15,0):i.includes("elevator")||i.includes("skyhook")?new n.CylinderGeometry(t*.36,t*.52,t*2.4,10):i.includes("station")?new n.TorusKnotGeometry(t*.6,Math.max(t*.18,.6),42,8):new n.BoxGeometry(t*1.45,t*1.2,t*1.45)}function CT(n,e,t){let i=Math.max(e.visualRadius,2),r=e.object.type==="structure"?new n.BoxGeometry(i*2.2,i*2.2,i*2.2):new n.SphereGeometry(i*1.38,18,14);return new n.Mesh(r,new n.MeshBasicMaterial({color:t.selectionHalo,transparent:!0,opacity:.18,depthWrite:!1,side:1}))}function RT(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function PT(n,e){let t=Math.max(e.bandThickness??8,3),i=_y(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function _y(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let a=0;a<t;a+=1){let o=a/t*Math.PI*2;i.push(new n.Vector3(Math.cos(o)*r,0,Math.sin(o)*s))}return i}function LT(n,e){let t=new n.BufferGeometry,i=new Float32Array(e*3),r=new Float32Array(e*3);for(let s=0;s<e;s+=1){let a=s*3,o=1800+Math.random()*2600,l=Math.random()*Math.PI*2,c=Math.acos(2*Math.random()-1);i[a]=o*Math.sin(c)*Math.cos(l),i[a+1]=o*Math.cos(c)*.45,i[a+2]=o*Math.sin(c)*Math.sin(l)}return t.setAttribute("position",new n.BufferAttribute(i,3)),t.setAttribute("color",new n.BufferAttribute(r,3)),new n.Points(t,new n.PointsMaterial({size:5,transparent:!0,opacity:.84,depthWrite:!1,vertexColors:!0,sizeAttenuation:!0}))}function my(n,e,t){let i=t==="high"?2.4:t==="low"?1.2:1.8;n.setPixelRatio?.(Math.min(globalThis.window?.devicePixelRatio??1,i)),"outputColorSpace"in n&&"SRGBColorSpace"in e?n.outputColorSpace=e.SRGBColorSpace:"outputEncoding"in n&&"sRGBEncoding"in e&&(n.outputEncoding=e.sRGBEncoding),"ACESFilmicToneMapping"in e&&(n.toneMapping=e.ACESFilmicToneMapping)}function DT(n,e){let t=Ui(e?.theme),i=e?.quality??"balanced",r=e?.style3d??"symbolic",s=i==="high"?520:i==="low"?180:320,a=new Float32Array(s*3),o=new Float32Array(s*3),l=new n.THREE.Color(t.starfield),c=new n.THREE.Color(t.starfieldDim);for(let u=0;u<s;u+=1){let d=u*3,h=1800+Math.random()*2600,f=Math.random()*Math.PI*2,m=Math.acos(2*Math.random()-1);a[d]=h*Math.sin(m)*Math.cos(f),a[d+1]=h*Math.cos(m)*.45,a[d+2]=h*Math.sin(m)*Math.sin(f);let y=Math.random()>.72?l:c;o[d]=y.r,o[d+1]=y.g,o[d+2]=y.b}n.scene3d.background=new n.THREE.Color(t.backgroundStart),n.scene3d.fog=new n.THREE.FogExp2(t.spaceFog,85e-5),n.ambientLight.intensity=r==="cinematic"?.18:.26,n.fillLight.intensity=r==="cinematic"?.32:.4,n.rimLight.intensity=r==="cinematic"?.28:.22,n.renderer.toneMappingExposure=r==="cinematic"?1.18:1.08,n.starfield.geometry.setAttribute("position",new n.THREE.BufferAttribute(a,3)),n.starfield.geometry.setAttribute("color",new n.THREE.BufferAttribute(o,3)),n.starfield.material.opacity=i==="high"?.96:i==="low"?.72:.84,n.starfield.material.size=i==="high"?5.5:i==="low"?4.25:5}function gy(n,e,t,i){for(let r of e){let s=r.material;if(!s)continue;let a=t?r.selectedColor??r.baseColor:i?r.hoveredColor??r.baseColor:r.baseColor;s.color?.set?.(new n.Color(a)),typeof s.opacity=="number"&&(s.opacity=t?r.selectedOpacity:i?r.hoveredOpacity:r.baseOpacity,s.transparent=s.opacity<.999);let o=t?r.selectedEmissive??r.baseEmissive:i?r.hoveredEmissive??r.baseEmissive:r.baseEmissive;s.emissive?.set?.(o?new n.Color(o):new n.Color(0)),"emissiveIntensity"in s&&(s.emissiveIntensity=t?r.selectedEmissiveIntensity??r.baseEmissiveIntensity??0:i?r.hoveredEmissiveIntensity??r.baseEmissiveIntensity??0:r.baseEmissiveIntensity??0)}}function OT(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function yy(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function vy(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.traverse?.(t=>{t.geometry?.dispose?.(),Array.isArray(t.material)?t.material.forEach(i=>i?.dispose?.()):t.material?.dispose?.()})}}function UT(){if(typeof document>"u")throw new cn;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new cn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new cn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function NT(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function hu(n,e,t){return Math.min(Math.max(n,e),t)}function ro(n){return n*Math.PI/180}function FT(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kT(){return $f||($f=Promise.resolve().then(()=>(py(),fy))),$f}var BT=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function wy(n){return{objectId:n.objectId,title:n.objectId,typeLabel:$T(n.object.type),imageHref:n.renderObject.imageHref??null,description:HT(n),tags:VT(n.object.properties.tags),fields:zT(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function My(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Bn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Bn(s.label)}</dt><dd>${Bn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Bn(n.objectId)}">
3930
+ </div>`}function Nb(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function bn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var ET="wo-viewer-3d-root",$f=null;function _y(n){kT();let e=document.createElement("div");e.className=ET,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,o=new Set,a=null,l=null,c=new Map,u=null,d=!1,h=null,f=null,p="",y=new Map,g=new Map,m=[];return VT().then(T=>{if(d)return;let U=new T.Scene,I=new T.PerspectiveCamera(46,1,.1,24e3),B=new T.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});B.domElement.classList.add("wo-viewer-3d-canvas"),B.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(B.domElement);let W=new T.AmbientLight(16777215,.24),F=new T.DirectionalLight(13625855,.36),X=new T.DirectionalLight(8304895,.24),k=new T.PointLight(16773327,2.6,0,2);F.position.set(-360,260,220),X.position.set(340,180,-280);let re=new T.Group,se=new T.Group,ve=UT(T,320),Le=new T.Raycaster;Le.params.Line={threshold:7},U.add(W),U.add(F),U.add(X),U.add(k),U.add(ve),U.add(re),U.add(se),t={THREE:T,scene3d:U,camera:I,renderer:B,ambientLight:W,fillLight:F,rimLight:X,keyLight:k,starfield:ve,orbitLayer:re,objectLayer:se,raycaster:Le,pointer:new T.Vector2},gy(B,T,"balanced"),u&&x(u)}).catch(T=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${zT(T instanceof Error?T.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(T){u=T,x(T)},hitTest(T,U){if(!t||!i)return null;let I=t.renderer.domElement.getBoundingClientRect();if(!I.width||!I.height)return null;t.pointer.x=(T-I.left)/I.width*2-1,t.pointer.y=-((U-I.top)/I.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let B=t.raycaster.intersectObjects(m,!0);for(let W of B){let F=BT(W.object);if(F)return F}return null},projectObjectToContainer(T){if(!t)return null;let U=c.get(T);if(!U)return null;let I=new t.THREE.Vector3(U.x,U.y,U.z);if(I.project(t.camera),I.z>1)return null;let B=t.renderer.domElement.getBoundingClientRect(),W=n.getBoundingClientRect();return{x:B.left-W.left+(I.x+1)/2*B.width,y:B.top-W.top+(1-I.y)/2*B.height}},destroy(){d=!0,u=null,t?.renderer.dispose(),t?.starfield?.geometry?.dispose?.(),t?.starfield?.material?.dispose?.(),e.remove(),y.clear(),g.clear(),m.length=0,t=null}};function x(T){if(!t)return;let U=i!==T.spatialScene;i=T.spatialScene,r=T.renderOptions,s=T.state,o=T.visibleObjectIds,a=T.selectedObjectId,l=T.hoveredObjectId,gy(t.renderer,t.THREE,r?.quality??"balanced");let I=JSON.stringify({theme:r?.theme??null,quality:r?.quality??"balanced",style3d:r?.style3d??"symbolic"});I!==p&&(NT(t,r),p=I),U&&v(T.spatialScene),w(T.spatialScene),c=Ru(T.spatialScene,T.timeSeconds),b(),L(),A(),E(),D(),M(),t.renderer.render(t.scene3d,t.camera)}function v(T){if(!t)return;xy(t.orbitLayer),xy(t.objectLayer),y.clear(),g.clear(),m.length=0,h=null,f=null;let U=Ui(r?.theme);for(let I of T.orbits){let B=IT(t.THREE,I,U);t.orbitLayer.add(B.root),g.set(I.objectId,B),m.push(B.root)}for(let I of T.objects){let B=TT(t.THREE,I,U);t.objectLayer.add(B.root),y.set(I.objectId,B),m.push(B.root)}}function b(){for(let T of i?.objects??[]){let U=y.get(T.objectId),I=c.get(T.objectId);U&&I&&U.root.position.set(I.x,I.y,I.z)}}function L(){for(let T of i?.orbits??[]){let U=g.get(T.objectId);if(!U)continue;let I=c.get(T.parentId);U.root.position.set(I?.x??T.center.x,I?.y??T.center.y,I?.z??T.center.z)}}function A(){let T=r?.layers??{};for(let U of i?.objects??[]){let I=y.get(U.objectId);if(!I)continue;let B=T.structures===!1&&(U.object.type==="structure"||U.object.type==="phenomenon");I.root.visible=!U.hidden&&o.has(U.objectId)&&T.objects!==!1&&!B}for(let U of i?.orbits??[]){let I=g.get(U.objectId);if(!I)continue;let B=T.structures===!1&&(U.object.type==="structure"||U.object.type==="phenomenon");I.root.visible=!U.hidden&&o.has(U.objectId)&&T.orbits!==!1&&!B}}function E(){if(t){for(let T of y.values()){let U=a===T.objectId,I=l===T.objectId;yy(t.THREE,T.materials,U,I);let B=U?1.16:I?1.08:1;T.root.scale.set(B,B,B),T.halo&&(T.halo.visible=U||I)}for(let T of g.values())yy(t.THREE,T.materials,a===T.objectId,l===T.objectId)}}function D(){if(!t||!i)return;let T=i.objects.find(I=>I.object.type==="star"&&!I.hidden)??null,U=T?c.get(T.objectId)??T.position:{x:0,y:40,z:0};t.keyLight.position.set(U.x,U.y+20,U.z)}function M(){if(!t||!i||!s)return;let T=r?.camera??i.camera,U=i.contentBounds,I=Math.max(U.width,U.depth,U.height,160),B=sa((T?.azimuth??30)+s.rotationDeg),W=sa(hu(T?.elevation??22,-75,75)),F=hu(2.2/Math.max(s.scale,.1),.35,7.2),X=hu(T?.distance??5.4,2,24),k=hu(I*F*(X/5.4),24,8e3),re=Math.max(I/900,.12),se=new t.THREE.Vector3(U.center.x-s.translateX*re,U.center.y,U.center.z-s.translateY*re),ve=new t.THREE.Vector3(se.x+k*Math.cos(W)*Math.sin(B),se.y+k*Math.sin(W),se.z+k*Math.cos(W)*Math.cos(B)),Le=(r?.style3d??"symbolic")==="cinematic"?.16:.32;!h||!f?(h=ve.clone(),f=se.clone()):(h.lerp(ve,Le),f.lerp(se,Le)),t.camera.position.copy(h),t.camera.lookAt(f),T?.roll&&(t.camera.rotation.z=sa(T.roll))}function w(T){if(!t)return;let U=Math.max(1,Math.round(n.clientWidth||T.width||960)),I=Math.max(1,Math.round(n.clientHeight||T.height||560));t.renderer.setSize(U,I,!1),t.camera.aspect=U/I,t.camera.updateProjectionMatrix()}}function TT(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??FT(e),s=[],o=CT(n,e,r,t),a=new n.Mesh(RT(n,e),o.material);if(a.userData.objectId=e.objectId,i.add(a),s.push(o),DT(e)){let c={material:new n.MeshBasicMaterial({color:t.atmosphere,transparent:!0,opacity:.24,depthWrite:!1,side:2}),baseColor:t.atmosphere,baseOpacity:.24,hoveredOpacity:.34,selectedOpacity:.42},u=new n.Mesh(new n.SphereGeometry(Math.max(e.visualRadius,2)*1.16,20,14),c.material);u.userData.objectId=e.objectId,i.add(u),s.push(c)}if(e.object.type==="comet"){let c={material:new n.MeshBasicMaterial({color:t.cometTail,transparent:!0,opacity:.36,depthWrite:!1}),baseColor:t.cometTail,baseOpacity:.36,hoveredOpacity:.48,selectedOpacity:.56},u=new n.Mesh(new n.ConeGeometry(Math.max(e.visualRadius*.55,2),Math.max(e.visualRadius*2.8,8),12,1,!0),c.material);u.position.set(-Math.max(e.visualRadius*1.4,4),0,0),u.rotation.z=-Math.PI/2,u.userData.objectId=e.objectId,i.add(u),s.push(c)}let l=LT(n,e,t);return l&&(l.visible=!1,l.userData.objectId=e.objectId,i.add(l)),{objectId:e.objectId,root:i,halo:l,materials:s}}function IT(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=sa(e.rotationDeg),i.rotation.x=sa(e.inclinationDeg);let r=e.object.properties.color??t.orbit;if(e.band){let l={material:new n.MeshBasicMaterial({color:r,transparent:!0,opacity:t.orbitBandOpacity,side:2,depthWrite:!1}),baseColor:r,baseOpacity:t.orbitBandOpacity,hoveredOpacity:Math.min(t.orbitBandOpacity+.1,.58),selectedOpacity:Math.min(t.orbitBandOpacity+.18,.72),hoveredColor:t.accent,selectedColor:t.accentStrong},c=new n.Mesh(OT(n,e),l.material);return c.userData.objectId=e.objectId,i.add(c),{objectId:e.objectId,root:i,materials:[l]}}let s={material:new n.LineBasicMaterial({color:r,transparent:!0,opacity:t.orbitOpacity}),baseColor:r,baseOpacity:t.orbitOpacity,hoveredOpacity:Math.min(t.orbitOpacity+.18,.72),selectedOpacity:Math.min(t.orbitOpacity+.3,.88),hoveredColor:t.accent,selectedColor:t.accentStrong},o=new n.BufferGeometry().setFromPoints(by(n,e,120)),a=new n.LineLoop(o,s.material);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,materials:[s]}}function CT(n,e,t,i){if(e.object.type==="star")return{material:new n.MeshStandardMaterial({color:t,emissive:new n.Color(i.starGlow),emissiveIntensity:1.2,roughness:.35,metalness:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:i.starCore,selectedColor:"#fff2c4",baseEmissive:i.starGlow,hoveredEmissive:i.starGlow,selectedEmissive:"#fff6cc",baseEmissiveIntensity:1.2,hoveredEmissiveIntensity:1.5,selectedEmissiveIntensity:1.8};if(e.object.type==="phenomenon")return{material:new n.MeshPhongMaterial({color:t,transparent:!0,opacity:.7,emissive:new n.Color(t),emissiveIntensity:.32,shininess:90}),baseColor:t,baseOpacity:.7,hoveredOpacity:.82,selectedOpacity:.9,hoveredColor:i.accent,selectedColor:i.selectionHalo,baseEmissive:t,hoveredEmissive:i.accent,selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.32,hoveredEmissiveIntensity:.52,selectedEmissiveIntensity:.74};let r=e.object.type==="structure"?70:e.object.type==="ring"?42:e.object.type==="belt"?26:36;return{material:new n.MeshPhongMaterial({color:t,specular:new n.Color(i.objectSpecular),shininess:r,transparent:!1,opacity:1,emissive:new n.Color(0),emissiveIntensity:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:vy(n,t,.08),selectedColor:vy(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function RT(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.14,34,24);case"structure":return PT(n,e,t);case"phenomenon":return new n.IcosahedronGeometry(t*1.12,1);case"belt":return new n.TorusGeometry(Math.max(t*1.15,4),Math.max(t*.28,1),10,24);case"ring":return new n.TorusGeometry(Math.max(t,4),Math.max(t*.18,.8),10,30);case"asteroid":return new n.DodecahedronGeometry(t,0);case"comet":return new n.SphereGeometry(t*.94,18,14);default:return new n.SphereGeometry(t,24,18)}}function PT(n,e,t){let i=String(e.object.properties.kind??"").toLowerCase();return i.includes("relay")?new n.OctahedronGeometry(t*1.15,0):i.includes("elevator")||i.includes("skyhook")?new n.CylinderGeometry(t*.36,t*.52,t*2.4,10):i.includes("station")?new n.TorusKnotGeometry(t*.6,Math.max(t*.18,.6),42,8):new n.BoxGeometry(t*1.45,t*1.2,t*1.45)}function LT(n,e,t){let i=Math.max(e.visualRadius,2),r=e.object.type==="structure"?new n.BoxGeometry(i*2.2,i*2.2,i*2.2):new n.SphereGeometry(i*1.38,18,14);return new n.Mesh(r,new n.MeshBasicMaterial({color:t.selectionHalo,transparent:!0,opacity:.18,depthWrite:!1,side:1}))}function DT(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function OT(n,e){let t=Math.max(e.bandThickness??8,3),i=by(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function by(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let o=0;o<t;o+=1){let a=o/t*Math.PI*2;i.push(new n.Vector3(Math.cos(a)*r,0,Math.sin(a)*s))}return i}function UT(n,e){let t=new n.BufferGeometry,i=new Float32Array(e*3),r=new Float32Array(e*3);for(let s=0;s<e;s+=1){let o=s*3,a=1800+Math.random()*2600,l=Math.random()*Math.PI*2,c=Math.acos(2*Math.random()-1);i[o]=a*Math.sin(c)*Math.cos(l),i[o+1]=a*Math.cos(c)*.45,i[o+2]=a*Math.sin(c)*Math.sin(l)}return t.setAttribute("position",new n.BufferAttribute(i,3)),t.setAttribute("color",new n.BufferAttribute(r,3)),new n.Points(t,new n.PointsMaterial({size:5,transparent:!0,opacity:.84,depthWrite:!1,vertexColors:!0,sizeAttenuation:!0}))}function gy(n,e,t){let i=t==="high"?2.4:t==="low"?1.2:1.8;n.setPixelRatio?.(Math.min(globalThis.window?.devicePixelRatio??1,i)),"outputColorSpace"in n&&"SRGBColorSpace"in e?n.outputColorSpace=e.SRGBColorSpace:"outputEncoding"in n&&"sRGBEncoding"in e&&(n.outputEncoding=e.sRGBEncoding),"ACESFilmicToneMapping"in e&&(n.toneMapping=e.ACESFilmicToneMapping)}function NT(n,e){let t=Ui(e?.theme),i=e?.quality??"balanced",r=e?.style3d??"symbolic",s=i==="high"?520:i==="low"?180:320,o=new Float32Array(s*3),a=new Float32Array(s*3),l=new n.THREE.Color(t.starfield),c=new n.THREE.Color(t.starfieldDim);for(let u=0;u<s;u+=1){let d=u*3,h=1800+Math.random()*2600,f=Math.random()*Math.PI*2,p=Math.acos(2*Math.random()-1);o[d]=h*Math.sin(p)*Math.cos(f),o[d+1]=h*Math.cos(p)*.45,o[d+2]=h*Math.sin(p)*Math.sin(f);let y=Math.random()>.72?l:c;a[d]=y.r,a[d+1]=y.g,a[d+2]=y.b}n.scene3d.background=new n.THREE.Color(t.backgroundStart),n.scene3d.fog=new n.THREE.FogExp2(t.spaceFog,85e-5),n.ambientLight.intensity=r==="cinematic"?.18:.26,n.fillLight.intensity=r==="cinematic"?.32:.4,n.rimLight.intensity=r==="cinematic"?.28:.22,n.renderer.toneMappingExposure=r==="cinematic"?1.18:1.08,n.starfield.geometry.setAttribute("position",new n.THREE.BufferAttribute(o,3)),n.starfield.geometry.setAttribute("color",new n.THREE.BufferAttribute(a,3)),n.starfield.material.opacity=i==="high"?.96:i==="low"?.72:.84,n.starfield.material.size=i==="high"?5.5:i==="low"?4.25:5}function yy(n,e,t,i){for(let r of e){let s=r.material;if(!s)continue;let o=t?r.selectedColor??r.baseColor:i?r.hoveredColor??r.baseColor:r.baseColor;s.color?.set?.(new n.Color(o)),typeof s.opacity=="number"&&(s.opacity=t?r.selectedOpacity:i?r.hoveredOpacity:r.baseOpacity,s.transparent=s.opacity<.999);let a=t?r.selectedEmissive??r.baseEmissive:i?r.hoveredEmissive??r.baseEmissive:r.baseEmissive;s.emissive?.set?.(a?new n.Color(a):new n.Color(0)),"emissiveIntensity"in s&&(s.emissiveIntensity=t?r.selectedEmissiveIntensity??r.baseEmissiveIntensity??0:i?r.hoveredEmissiveIntensity??r.baseEmissiveIntensity??0:r.baseEmissiveIntensity??0)}}function FT(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function vy(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function xy(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.traverse?.(t=>{t.geometry?.dispose?.(),Array.isArray(t.material)?t.material.forEach(i=>i?.dispose?.()):t.material?.dispose?.()})}}function kT(){if(typeof document>"u")throw new cn;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new cn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new cn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function BT(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function hu(n,e,t){return Math.min(Math.max(n,e),t)}function sa(n){return n*Math.PI/180}function zT(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function VT(){return $f||($f=Promise.resolve().then(()=>(my(),py))),$f}var HT=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function My(n){return{objectId:n.objectId,title:n.objectId,typeLabel:XT(n.object.type),imageHref:n.renderObject.imageHref??null,description:WT(n),tags:$T(n.object.properties.tags),fields:GT(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function Sy(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Bn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Bn(s.label)}</dt><dd>${Bn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Bn(n.objectId)}">
3931
3931
  <div class="wo-tooltip-head">
3932
- ${n.imageHref?`<img class="wo-tooltip-image" src="${jT(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Bn(n.typeLabel.slice(0,1))}</div>`}
3932
+ ${n.imageHref?`<img class="wo-tooltip-image" src="${qT(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Bn(n.typeLabel.slice(0,1))}</div>`}
3933
3933
  <div class="wo-tooltip-heading">
3934
3934
  <strong>${Bn(n.title)}</strong>
3935
3935
  <span>${Bn(n.typeLabel)}</span>
@@ -3939,7 +3939,7 @@ void main() {
3939
3939
  ${t}
3940
3940
  ${i}
3941
3941
  ${r.length?`<p class="wo-tooltip-relations">${Bn(r.join(" - "))}</p>`:""}
3942
- </article>`}function zT(n){let e=new Map;for(let i of BT){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:WT(i),value:by(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${by(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function VT(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function HT(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function by(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):GT(n)}function GT(n){return`${n.value}${n.unit??""}`}function $T(n){return n.charAt(0).toUpperCase()+n.slice(1)}function WT(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Bn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function jT(n){return Bn(n)}var ws={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Sy="worldorbit-viewer-tooltip-style";function Di(n,e){if(ZT(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??ws.minScale,maxScale:e.maxScale??ws.maxScale,fitPadding:e.fitPadding??ws.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??ws.panStep,zoomStep:e.zoomStep??ws.zoomStep,rotationStep:e.rotationStep??ws.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,viewMode:e.viewMode??"2d",quality:e.quality??"balanced",style3d:e.style3d??"symbolic",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:Zt(e.initialFilter),subtitle:e.subtitle},a=n.getAttribute("tabindex"),o=n.style.touchAction,l=n.style.position,c=XT(e),u=so(c,s),d=e.spatialScene??null,h=s.viewMode==="3d"?_r(c,s,d):null,f={...fn},m=null,y=null,g=null,p=null,x=null,v=null,b=!1,L=null,A=null,E=0,D=!1,M=new Map,w=null,T=null,U=null,I=null,B=null,W=null,F=null,X=null,k={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};a===null&&(n.tabIndex=0),JT(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":o,n.style.position||(n.style.position="relative"),Ke();let re=C=>{if(!r.pointer||D)return;if(C.preventDefault(),n.focus(),Se()){let O=br(Math.exp(-C.deltaY*.002),.6,1.6);_e.zoomBy(O);return}let G=ee(C.clientX,C.clientY),_=br(Math.exp(-C.deltaY*.002),.6,1.6);Ue(Cr(u,f,_,G,i))},se=C=>{if(D)return;let G=C.pointerType==="touch";if(G&&!r.touch||!G&&!r.pointer||!G&&C.button!==0&&!Se())return;n.focus(),n.setPointerCapture?.(C.pointerId);let _=j(C.clientX,C.clientY);if(G){M.set(C.pointerId,_),M.size===2?w=Ey(u,f,M):M.size===1&&(E=0,b=!1);return}L=C.pointerId,A=_,E=0,b=!1},ve=C=>{if(D)return;if(C.pointerType==="touch"){if(Se()||!r.touch||!M.has(C.pointerId))return;let N=M.get(C.pointerId),$=j(C.clientX,C.clientY);if(M.set(C.pointerId,$),M.size===2){w||(w=Ey(u,f,M));let ue=Cy(M),Ee=ue.distance/Math.max(w.startDistance,1),Ie=Cr(u,w.startState,Ee,w.startCenter,i),Oe=ue.center.x-w.startViewportCenter.x,Be=ue.center.y-w.startViewportCenter.y;Ue(ki(Ie,Oe,Be))}else if(M.size===1){let ue=$.x-N.x,Ee=$.y-N.y;E+=Math.abs(ue)+Math.abs(Ee),E>2&&(b=!0),Ue(ki(f,ue,Ee))}return}if(Se()&&r.pointer&&L===null){de(g?.hitTest(C.clientX,C.clientY)??null);return}if(Se()&&r.pointer&&L===C.pointerId&&A){let N=j(C.clientX,C.clientY),$=N.x-A.x,ue=N.y-A.y;E+=Math.abs($)+Math.abs(ue),A=N,E>2&&(b=!0),C.shiftKey||C.buttons===2?_e.panBy($,ue):(_e.rotateBy($*.35),_e.panBy(0,ue*.35)),de(g?.hitTest(C.clientX,C.clientY)??null);return}if(!r.pointer||L!==C.pointerId||!A)return;let _=j(C.clientX,C.clientY),O=_.x-A.x,V=_.y-A.y;E+=Math.abs(O)+Math.abs(V),A=_,E>2&&(b=!0),Ue(ki(f,O,V))},Le=C=>{if(C.pointerType==="touch"){M.delete(C.pointerId),M.size<2&&(w=null);return}L===C.pointerId&&(L=null,A=null)},Je=C=>{if(!r.selection||D)return;if(b){b=!1;return}let G=Se()?g?.hitTest(C.clientX,C.clientY)??null:fu(C.target);K(G),r.tooltipMode==="pinned"&&(U=G,De())},Z=C=>{if(Se())return;let G=fu(C.target);de(G)},q=()=>{de(null)},pe=C=>{if(Se())return;let G=fu(C.target);G&&de(G)},ne=()=>{de(null)},Fe=C=>{if(!r.keyboard||D)return;let G=Se()?f.selectedObjectId:fu(C.target);if((C.key==="Enter"||C.key===" ")&&G){C.preventDefault(),K(G),r.tooltipMode==="pinned"&&(U=G,De());return}switch(C.key){case"Escape":r.tooltipMode==="pinned"&&U&&(C.preventDefault(),U=null,De());return;case"+":case"=":C.preventDefault(),_e.zoomBy(r.zoomStep);return;case"-":C.preventDefault(),_e.zoomBy(1/r.zoomStep);return;case"ArrowLeft":C.preventDefault(),_e.panBy(-r.panStep,0);return;case"ArrowRight":C.preventDefault(),_e.panBy(r.panStep,0);return;case"ArrowUp":C.preventDefault(),_e.panBy(0,-r.panStep);return;case"ArrowDown":C.preventDefault(),_e.panBy(0,r.panStep);return;case"[":C.preventDefault(),_e.rotateBy(-r.rotationStep);return;case"]":C.preventDefault(),_e.rotateBy(r.rotationStep);return;case"f":case"F":C.preventDefault(),_e.fitToSystem();return;case"0":C.preventDefault(),_e.resetView();return}};n.addEventListener("wheel",re,{passive:!1}),n.addEventListener("pointerdown",se),n.addEventListener("pointermove",ve),n.addEventListener("pointerup",Le),n.addEventListener("pointercancel",Le),n.addEventListener("click",Je),n.addEventListener("mouseover",Z),n.addEventListener("mouseleave",q),n.addEventListener("focusin",pe),n.addEventListener("focusout",ne),n.addEventListener("keydown",Fe);let _e={setSource(C){c={kind:"source",value:C},u=so(c,s),d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},setDocument(C){c={kind:"document",value:C},u=so(c,s),d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},setScene(C){c={kind:"scene",value:C},u=C,d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},getScene(){return u},getRenderOptions(){return YT(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(C){let G=s,_=h,O=Wf(s,{viewMode:C}),V=C==="3d"?_r(c,O,d):null;s=O,h=V,Ke();try{H(!1)}catch(N){throw s=G,h=_,Ke(),H(!1),N}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return me(W)},goToViewpoint(C){let G=me(C);if(!G)return!1;let _={},O=vo(G);if(G.preset!==null&&(_.preset=G.preset),c.kind!=="scene"&&G.projection!==u.projection&&(_.projection=G.projection),G.camera?_.camera={...G.camera}:s.camera&&(_.camera=null),O&&(_.layers=O),W=G.id,Object.keys(_).length>0){let N=Ay(_);s=Wf(s,_),c.kind!=="scene"&&N&&(u=so(c,s)),H(N)}fe(xo(G),!1,!1);let V=ge(G);return Ue(V),K(G.selectedObjectId??G.objectId??null,!1),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),We(),Pe(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(C){_e.setRenderOptions({activeEventId:C})},playAnimation(){if(!Se()){k={...k,playing:!1},ft();return}if(k.frozenByEvent){k={...k,playing:!1};return}k={...k,playing:!0},lt()},pauseAnimation(){k={...k,playing:!1},ft()},resetAnimation(){k={...k,playing:!1,timeSeconds:0},ft(),Xt()},setAnimationSpeed(C){k={...k,speed:br(C,.1,64)}},getAnimationState(){return{...k}},search(C,G=12){return mo(u,C,G)},getFilter(){return s.filter?{...s.filter}:null},setFilter(C){fe(C,!0,!0)},getVisibleObjects(){return ie()},getFocusPath(C){return Ce(C)},getObjectDetails(C){return Ae(C)},getSelectionDetails(){return Ae(f.selectedObjectId)},getTooltipDetails(){return B},getAtlasState(){return ep(f,s,s.filter??null,W)},setAtlasState(C){let G=typeof C=="string"?yo(C):C;G.viewpointId&&_e.goToViewpoint(G.viewpointId),_e.setRenderOptions(G.renderOptions),fe(G.filter??null,!1,!1),Ue(J({...f,...G.viewerState})),K(G.viewerState.selectedObjectId??null,!1),We(),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),Pe()},serializeAtlasState(){return go(_e.getAtlasState())},captureBookmark(C,G){return tp(C,G,_e.getAtlasState())},applyBookmark(C){return typeof C=="string"?(_e.setAtlasState(C),!0):(_e.setAtlasState(C.atlasState),!0)},setRenderOptions(C){let G=Ay(C),_=s,O=u,V=h,N=Wf(s,C),$=u;c.kind!=="scene"&&G&&($=so(c,N));let ue=N.viewMode==="3d"?_r(c,N,d):null;s=N,u=$,h=ue,Ke();try{H(G)}catch(Ee){throw s=_,u=O,h=V,Ke(),H(G),Ee}},getState(){return{...f}},setState(C){Ue(J({...f,...C}))},zoomBy(C,G){Ue(Cr(u,f,C,G??{x:u.width/2,y:u.height/2},i))},panBy(C,G){Ue(ki(f,C,G))},rotateBy(C){Ue($o(f,C))},fitToSystem(){Ue(Se()?{...fn,selectedObjectId:f.selectedObjectId}:Bi(u,f,i))},focusObject(C){W=null,Ue(Se()?gu(C):Wo(u,f,C,i)),K(C),r.tooltipMode==="pinned"&&(U=he(C)?.objectId??null,De())},pinTooltip(C){U=he(C)?.objectId??null,De()},resetView(){let C=Se()?{...fn}:Bi(u,{...fn},i);W=null,Ue(C),K(null),U=null,De()},exportSvg(){return _n(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){D||(D=!0,n.removeEventListener("wheel",re),n.removeEventListener("pointerdown",se),n.removeEventListener("pointermove",ve),n.removeEventListener("pointerup",Le),n.removeEventListener("pointercancel",Le),n.removeEventListener("click",Je),n.removeEventListener("mouseover",Z),n.removeEventListener("mouseleave",q),n.removeEventListener("focusin",pe),n.removeEventListener("focusout",ne),n.removeEventListener("keydown",Fe),ft(),g?.destroy(),g=null,x?.remove(),x=null,v?.remove(),v=null,p?.remove(),p=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=o,n.style.position=l,a===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",a))}};return H(!0),e.initialViewpointId?_e.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?_e.focusObject(e.initialSelectionObjectId):Pe(),_e;function H(C){if(g?.destroy(),g=null,n.innerHTML="",m=null,y=null,p=null,x=null,v=null,Se()?(h=h??_r(c,s,d),g=xy(n)):(n.innerHTML=_n(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),m=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(p=document.createElement("div"),p.dataset.worldorbitMinimapRoot="true",n.append(p)),x=document.createElement("div"),x.className="wo-viewer-label-root",x.dataset.worldorbitLabelRoot="true",n.append(x),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",xe),n.append(v)),!Se()&&(!m||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");lo(),f=C?Se()?{...fn}:Bi(u,{...fn},i):J(f),K(f.selectedObjectId&&he(f.selectedObjectId)?f.selectedObjectId:null,!1),de(T&&he(T)?T:null,!1),U=U&&he(U)?U:null,Xt(),Re(),We(),e.onViewChange?.({...f}),Pe()}function Ue(C){f=J(C),Xt(),e.onViewChange?.({...f}),Pe()}function J(C){return{scale:br(C.scale,i.minScale,i.maxScale),rotationDeg:Ty(C.rotationDeg),translateX:Number.isFinite(C.translateX)?C.translateX:f.translateX,translateY:Number.isFinite(C.translateY)?C.translateY:f.translateY,selectedObjectId:C.selectedObjectId&&he(C.selectedObjectId)?C.selectedObjectId:null}}function ce(){if(Se()){Mt();return}y&&(y.setAttribute("transform",jo(u,f)),As(),Me(),De())}function K(C,G=!0){if(!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${ao(f.selectedObjectId)}"]`))_.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:C&&he(C)?C:null},!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${ao(f.selectedObjectId)}"]`))_.classList.add("wo-object-selected");P(),De(),G&&(e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),e.onViewChange?.({...f}),Pe())}function de(C,G=!0){T===C&&G||(T=C&&he(C)?C:null,P(),De(),G&&(e.onHoverChange?.(he(T)),e.onHoverDetailsChange?.(Ae(T))))}function le(){return he(f.selectedObjectId)}function he(C){if(!C)return null;let G=ae();return u.objects.find(_=>_.objectId===C&&!_.hidden&&G.has(_.objectId))??null}function Ae(C){let G=he(C);return G?{objectId:G.objectId,object:G.object,renderObject:G,label:u.labels.find(_=>_.objectId===G.objectId&&!_.hidden)??null,group:u.groups.find(_=>_.renderId===G.groupId)??null,semanticGroups:u.semanticGroups.filter(_=>G.semanticGroupIds.includes(_.id)),orbit:u.orbitVisuals.find(_=>_.objectId===G.objectId&&!_.hidden)??null,relatedOrbits:u.orbitVisuals.filter(_=>!_.hidden&&(_.objectId===G.objectId||G.ancestorIds.includes(_.objectId)||G.childIds.includes(_.objectId))),relations:u.relations.filter(_=>!_.hidden&&(_.fromObjectId===G.objectId||_.toObjectId===G.objectId)),relatedEvents:u.events.filter(_=>!_.hidden&&(_.targetObjectId===G.objectId||_.objectIds.includes(G.objectId))),parent:he(G.parentId),children:G.childIds.map(_=>he(_)).filter(Boolean),ancestors:G.ancestorIds.map(_=>he(_)).filter(Boolean),focusPath:Ce(G.objectId)}:null}function P(){if(Se()){Mt();return}for(let C of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))C.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");S(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),S(T,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function S(C,G){let _=Ae(C);if(!_)return;let O=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]);for(let V of O)for(let N of n.querySelectorAll(`[data-object-id="${ao(V)}"]`))N.classList.add(G.objectClass);for(let V of _.ancestors)for(let N of n.querySelectorAll(`[data-object-id="${ao(V.objectId)}"]`))N.classList.add(G.ancestorClass);for(let V of _.relatedOrbits)for(let N of n.querySelectorAll(`[data-orbit-object-id="${ao(V.objectId)}"]`))N.classList.add(G.orbitClass)}function j(C,G){if(Se()){let O=n.getBoundingClientRect();return!O.width||!O.height?{x:u.width/2,y:u.height/2}:{x:C-O.left,y:G-O.top}}if(!m)return{x:u.width/2,y:u.height/2};let _=m.getBoundingClientRect();return!_.width||!_.height?{x:u.width/2,y:u.height/2}:{x:(C-_.left)/_.width*u.width,y:(G-_.top)/_.height*u.height}}function ee(C,G){return Rr(u,f,j(C,G))}function ae(){return po(u,s.filter??null)}function ie(){let C=ae();return u.objects.filter(G=>!G.hidden&&C.has(G.objectId))}function Ce(C){let G=u.objects.find(_=>_.objectId===C&&!_.hidden);return G?[...G.ancestorIds,G.objectId].map(_=>he(_)).filter(Boolean):[]}function me(C){return u.viewpoints.find(G=>G.id===C)??null}function ge(C){let G=Ty(C.rotationDeg),_=C.scale!==null&&C.scale!==void 0?br(C.scale,i.minScale,i.maxScale):null;if(Se()){let N=C.objectId??C.selectedObjectId??null,$=N?h?.focusTargets.find(ue=>ue.objectId===N):null;return{scale:_??1.6,rotationDeg:G,translateX:$?-$.center.x:0,translateY:$?-$.center.z:0,selectedObjectId:C.selectedObjectId??C.objectId??null}}let O=C.objectId&&u.objects.find(N=>N.objectId===C.objectId&&!N.hidden);if(O)return ke({x:O.x,y:O.y},_??Math.max(1.8,fn.scale),G,C.selectedObjectId??O.objectId);let V=Bi(u,{...fn,rotationDeg:G},i);return _===null?{...V,rotationDeg:G,selectedObjectId:C.selectedObjectId??null}:ke({x:u.contentBounds.centerX,y:u.contentBounds.centerY},_,G,C.selectedObjectId??null)}function ke(C,G,_,O){let V={x:u.width/2,y:u.height/2},N=Vn(C,V,_);return{scale:G,rotationDeg:_,translateX:V.x-(V.x+(N.x-V.x)*G),translateY:V.y-(V.y+(N.y-V.y)*G),selectedObjectId:O}}function fe(C,G,_){s={...s,filter:Zt(C)},_&&(W=null),H(!1)}function Re(){e.onFilterChange?.(s.filter??null,ie())}function We(){e.onViewpointChange?.(me(W))}function Pe(){e.onAtlasStateChange?.(_e.getAtlasState())}function Me(){!r.minimap||!p||(p.innerHTML=om(u,f,ie()))}function De(){if(r.tooltipMode==="disabled"||!v){be(null);return}let C=qe();if(!C){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let G=Ae(C.objectId);if(!G){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let _=wy(G);I=C.objectId,v.hidden=!1,v.dataset.mode=C.mode,v.classList.toggle("is-pinned",C.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",ht(v,_,C.mode),Ge(v,G.renderObject),v.style.visibility="visible",be(_)}function qe(){return U&&he(U)?{objectId:U,mode:"pinned"}:T&&he(T)?{objectId:T,mode:"hover"}:null}function ht(C,G,_){let O=e.tooltipRenderer?.(G,_);C.innerHTML="",typeof O=="string"?C.innerHTML=O:O instanceof HTMLElement?C.append(O):C.innerHTML=My(G,_);let V=document.createElement("div");if(V.className="wo-tooltip-actions",_==="pinned"){let N=document.createElement("button");N.type="button",N.className="wo-tooltip-action",N.dataset.tooltipAction="unpin",N.textContent="Unpin",V.append(N)}else{let N=document.createElement("button");N.type="button",N.className="wo-tooltip-action",N.dataset.tooltipAction="pin",N.dataset.objectId=G.objectId,N.textContent="Pin",V.append(N)}V.childElementCount>0&&C.append(V)}function Ge(C,G){let _=Se()?g?.projectObjectToContainer(G.objectId)??null:oe(G);if(!_)return;let O=Math.max(n.clientWidth-C.offsetWidth-12,12),V=Math.max(n.clientHeight-C.offsetHeight-12,12),N=_.y>n.clientHeight*.48,$=br(_.x+18,12,O),ue=br(N?_.y-C.offsetHeight-18:_.y+18,12,V);C.style.left=`${$}px`,C.style.top=`${ue}px`}function z(C){if(Se())return C;let G={x:u.width/2,y:u.height/2},_=Vn(C,G,f.rotationDeg);return{x:G.x+(_.x-G.x)*f.scale+f.translateX,y:G.y+(_.y-G.y)*f.scale+f.translateY}}function oe(C){let G={x:C.anchorX??C.x,y:C.anchorY??C.y-Math.max(C.visualRadius,C.radius)};return Q(G)}function Q(C){if(!m)return null;let G=z(C),_=m.getBoundingClientRect(),O=n.getBoundingClientRect();return{x:_.left-O.left+G.x/Math.max(u.width,1)*_.width,y:_.top-O.top+G.y/Math.max(u.height,1)*_.height}}function xe(C){let G=C.target?.closest("[data-tooltip-action]");if(G){switch(C.preventDefault(),C.stopPropagation(),G.dataset.tooltipAction){case"pin":U=G.dataset.objectId??I;break;case"unpin":U=null;break}De()}}function be(C){let G=B?.objectId!==C?.objectId||B?.description!==C?.description||B?.imageHref!==C?.imageHref;B=C,I=C?.objectId??null,G&&e.onTooltipChange?.(C)}function Se(){return s.viewMode==="3d"}function Ke(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},ft())}function lt(){F!==null||!k.playing||D||(F=window.requestAnimationFrame(et))}function ft(){F!==null&&(window.cancelAnimationFrame(F),F=null),X=null}function et(C){if(F=null,!k.playing||D){X=null;return}let _=Math.max((C-(X??C))/1e3,0);X=C,k={...k,timeSeconds:k.timeSeconds+_*k.speed},Mt(),lt()}function Xt(){ce(),Se()&&k.playing?lt():(!k.playing||!Se())&&ft()}function Mt(){!Se()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:ae(),selectedObjectId:f.selectedObjectId,hoveredObjectId:T,state:f,timeSeconds:k.timeSeconds}),As(),Me(),De())}function lo(){if(!Se()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let C of n.querySelectorAll(".wo-event-label"))C.setAttribute("display","none")}}function As(){if(!x)return;let C=co();x.replaceChildren(...C.map(G=>Mr(G))),x.hidden=C.length===0}function co(){let C=[],G=ae();if(Es("labels"))for(let _ of u.labels){if(_.hidden||!G.has(_.objectId)||Se()&&!uo(_.objectId,G))continue;let O=Se()?g?.projectObjectToContainer(_.objectId)??null:Q({x:_.x,y:_.y});O&&C.push({key:`object:${_.renderId}`,kind:"object",point:Se()?{x:O.x,y:O.y-18}:O,textAnchor:_.textAnchor,objectId:_.objectId,primaryText:_.label,secondaryText:_.secondaryLabel,secondaryOffset:Math.max(_.secondaryY-_.y,12)})}if(!Se()&&Es("events"))for(let _ of u.events){if(_.hidden||!wr(_,G))continue;let O=Q({x:_.x,y:_.y-10});O&&C.push({key:`event:${_.renderId}`,kind:"event",point:O,textAnchor:"middle",primaryText:_.event.label||_.event.id})}return C}function wr(C,G){return C.objectIds.some(_=>G.has(_))}function uo(C,G){if(!Se()||C===f.selectedObjectId||C===T)return!0;let _=he(C);if(!_||_.hidden||!G.has(C))return!1;if(_.object.type==="star")return!0;let O=f.selectedObjectId?Ae(f.selectedObjectId):null,V=T?Ae(T):null,N=O?new Set([O.objectId,...O.renderObject.ancestorIds,...O.renderObject.childIds]):null,$=V?new Set([V.objectId,...V.renderObject.ancestorIds,...V.renderObject.childIds]):null;return N?.has(C)||$?.has(C)||_.semanticGroupIds.length>0&&_.visualRadius>=12?!0:_.childIds.length>0&&_.visualRadius>=10}function Mr(C){let G=document.createElement("div");if(G.className=`wo-viewer-label wo-viewer-label-${C.kind}`,G.dataset.worldorbitScreenLabel="true",G.dataset.labelKey=C.key,G.dataset.anchor=C.textAnchor,G.style.left=`${C.point.x}px`,G.style.top=`${C.point.y}px`,C.objectId){G.dataset.objectId=C.objectId;for(let O of ho(C.objectId))G.classList.add(O)}let _=document.createElement("span");if(_.className="wo-viewer-label-primary",C.kind==="object"&&(_.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),_.textContent=C.primaryText,G.append(_),C.secondaryText){let O=document.createElement("span");O.className="wo-viewer-label-secondary",O.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,O.style.marginTop=`${Math.max(C.secondaryOffset??12,10)-10}px`,O.textContent=C.secondaryText,G.append(O)}return G}function Es(C){return s.layers?.[C]!==!1}function ho(C){let G=[],_=Ae(f.selectedObjectId),O=Ae(T);if(f.selectedObjectId===C&&G.push("wo-object-selected"),_){let V=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]),N=new Set(_.ancestors.map($=>$.objectId));V.has(C)&&G.push("wo-chain-selected"),N.has(C)&&G.push("wo-ancestor-selected")}if(O){let V=new Set([O.objectId,...O.renderObject.childIds,...O.renderObject.ancestorIds]),N=new Set(O.ancestors.map($=>$.objectId));V.has(C)&&G.push("wo-chain-hover"),N.has(C)&&G.push("wo-ancestor-hover")}return G}function gu(C){let G=h?.focusTargets.find(_=>_.objectId===C);return G?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-G.center.x,translateY:-G.center.z,selectedObjectId:C}:{...fn,selectedObjectId:C}}}function XT(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function so(n,e){switch(n.kind){case"scene":return n.value;case"document":return dn(n.value,e);case"source":{let t=Gn(n.value);return dn(t.document,Iy(t,e))}}}function _r(n,e,t){if(t)return t;switch(n.kind){case"scene":return qT(n.value);case"document":return Fo(n.value,e);case"source":{let i=Gn(n.value);return Fo(i.document,Iy(i,e))}}}function YT(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d",quality:n.quality??"balanced",style3d:n.style3d??"symbolic"}}function Wf(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?Zt(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d",quality:e.quality??n.quality??"balanced",style3d:e.style3d??n.style3d??"symbolic"}}function Ay(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.activeEventId!==void 0}function Iy(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function qT(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Ey(n,e,t){let{center:i,distance:r}=Cy(t);return{startState:{...e},startCenter:Rr(n,e,i),startViewportCenter:i,startDistance:r}}function Cy(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function fu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function ZT(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function br(n,e,t){return Math.min(Math.max(n,e),t)}function Ty(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function ao(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function JT(){if(typeof document>"u"||document.getElementById(Sy))return;let n=document.createElement("style");n.id=Sy,n.textContent=`
3942
+ </article>`}function GT(n){let e=new Map;for(let i of HT){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:YT(i),value:wy(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${wy(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function $T(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function WT(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function wy(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):jT(n)}function jT(n){return`${n.value}${n.unit??""}`}function XT(n){return n.charAt(0).toUpperCase()+n.slice(1)}function YT(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Bn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function qT(n){return Bn(n)}var ws={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Ay="worldorbit-viewer-tooltip-style";function Di(n,e){if(QT(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??ws.minScale,maxScale:e.maxScale??ws.maxScale,fitPadding:e.fitPadding??ws.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??ws.panStep,zoomStep:e.zoomStep??ws.zoomStep,rotationStep:e.rotationStep??ws.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,viewMode:e.viewMode??"2d",quality:e.quality??"balanced",style3d:e.style3d??"symbolic",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:Zt(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,l=n.style.position,c=ZT(e),u=oa(c,s),d=e.spatialScene??null,h=s.viewMode==="3d"?_r(c,s,d):null,f={...fn},p=null,y=null,g=null,m=null,x=null,v=null,b=!1,L=null,A=null,E=0,D=!1,M=new Map,w=null,T=null,U=null,I=null,B=null,W=null,F=null,X=null,k={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),eI(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),Ke();let re=C=>{if(!r.pointer||D)return;if(C.preventDefault(),n.focus(),Se()){let O=br(Math.exp(-C.deltaY*.002),.6,1.6);_e.zoomBy(O);return}let G=ee(C.clientX,C.clientY),_=br(Math.exp(-C.deltaY*.002),.6,1.6);Ue(Cr(u,f,_,G,i))},se=C=>{if(D)return;let G=C.pointerType==="touch";if(G&&!r.touch||!G&&!r.pointer||!G&&C.button!==0&&!Se())return;n.focus(),n.setPointerCapture?.(C.pointerId);let _=j(C.clientX,C.clientY);if(G){M.set(C.pointerId,_),M.size===2?w=Ty(u,f,M):M.size===1&&(E=0,b=!1);return}L=C.pointerId,A=_,E=0,b=!1},ve=C=>{if(D)return;if(C.pointerType==="touch"){if(Se()||!r.touch||!M.has(C.pointerId))return;let N=M.get(C.pointerId),$=j(C.clientX,C.clientY);if(M.set(C.pointerId,$),M.size===2){w||(w=Ty(u,f,M));let ue=Ry(M),Ee=ue.distance/Math.max(w.startDistance,1),Ie=Cr(u,w.startState,Ee,w.startCenter,i),Oe=ue.center.x-w.startViewportCenter.x,Be=ue.center.y-w.startViewportCenter.y;Ue(ki(Ie,Oe,Be))}else if(M.size===1){let ue=$.x-N.x,Ee=$.y-N.y;E+=Math.abs(ue)+Math.abs(Ee),E>2&&(b=!0),Ue(ki(f,ue,Ee))}return}if(Se()&&r.pointer&&L===null){de(g?.hitTest(C.clientX,C.clientY)??null);return}if(Se()&&r.pointer&&L===C.pointerId&&A){let N=j(C.clientX,C.clientY),$=N.x-A.x,ue=N.y-A.y;E+=Math.abs($)+Math.abs(ue),A=N,E>2&&(b=!0),C.shiftKey||C.buttons===2?_e.panBy($,ue):(_e.rotateBy($*.35),_e.panBy(0,ue*.35)),de(g?.hitTest(C.clientX,C.clientY)??null);return}if(!r.pointer||L!==C.pointerId||!A)return;let _=j(C.clientX,C.clientY),O=_.x-A.x,V=_.y-A.y;E+=Math.abs(O)+Math.abs(V),A=_,E>2&&(b=!0),Ue(ki(f,O,V))},Le=C=>{if(C.pointerType==="touch"){M.delete(C.pointerId),M.size<2&&(w=null);return}L===C.pointerId&&(L=null,A=null)},Je=C=>{if(!r.selection||D)return;if(b){b=!1;return}let G=Se()?g?.hitTest(C.clientX,C.clientY)??null:fu(C.target);K(G),r.tooltipMode==="pinned"&&(U=G,De())},Z=C=>{if(Se())return;let G=fu(C.target);de(G)},q=()=>{de(null)},pe=C=>{if(Se())return;let G=fu(C.target);G&&de(G)},ne=()=>{de(null)},Fe=C=>{if(!r.keyboard||D)return;let G=Se()?f.selectedObjectId:fu(C.target);if((C.key==="Enter"||C.key===" ")&&G){C.preventDefault(),K(G),r.tooltipMode==="pinned"&&(U=G,De());return}switch(C.key){case"Escape":r.tooltipMode==="pinned"&&U&&(C.preventDefault(),U=null,De());return;case"+":case"=":C.preventDefault(),_e.zoomBy(r.zoomStep);return;case"-":C.preventDefault(),_e.zoomBy(1/r.zoomStep);return;case"ArrowLeft":C.preventDefault(),_e.panBy(-r.panStep,0);return;case"ArrowRight":C.preventDefault(),_e.panBy(r.panStep,0);return;case"ArrowUp":C.preventDefault(),_e.panBy(0,-r.panStep);return;case"ArrowDown":C.preventDefault(),_e.panBy(0,r.panStep);return;case"[":C.preventDefault(),_e.rotateBy(-r.rotationStep);return;case"]":C.preventDefault(),_e.rotateBy(r.rotationStep);return;case"f":case"F":C.preventDefault(),_e.fitToSystem();return;case"0":C.preventDefault(),_e.resetView();return}};n.addEventListener("wheel",re,{passive:!1}),n.addEventListener("pointerdown",se),n.addEventListener("pointermove",ve),n.addEventListener("pointerup",Le),n.addEventListener("pointercancel",Le),n.addEventListener("click",Je),n.addEventListener("mouseover",Z),n.addEventListener("mouseleave",q),n.addEventListener("focusin",pe),n.addEventListener("focusout",ne),n.addEventListener("keydown",Fe);let _e={setSource(C){c={kind:"source",value:C},u=oa(c,s),d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},setDocument(C){c={kind:"document",value:C},u=oa(c,s),d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},setScene(C){c={kind:"scene",value:C},u=C,d=null,h=s.viewMode==="3d"?_r(c,s,null):null,Ke(),W=null,H(!0)},getScene(){return u},getRenderOptions(){return JT(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(C){let G=s,_=h,O=Wf(s,{viewMode:C}),V=C==="3d"?_r(c,O,d):null;s=O,h=V,Ke();try{H(!1)}catch(N){throw s=G,h=_,Ke(),H(!1),N}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return me(W)},goToViewpoint(C){let G=me(C);if(!G)return!1;let _={},O=va(G);if(G.preset!==null&&(_.preset=G.preset),c.kind!=="scene"&&G.projection!==u.projection&&(_.projection=G.projection),G.camera?_.camera={...G.camera}:s.camera&&(_.camera=null),O&&(_.layers=O),W=G.id,Object.keys(_).length>0){let N=Ey(_);s=Wf(s,_),c.kind!=="scene"&&N&&(u=oa(c,s)),H(N)}fe(xa(G),!1,!1);let V=ge(G);return Ue(V),K(G.selectedObjectId??G.objectId??null,!1),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),We(),Pe(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(C){_e.setRenderOptions({activeEventId:C})},playAnimation(){if(!Se()){k={...k,playing:!1},ft();return}if(k.frozenByEvent){k={...k,playing:!1};return}k={...k,playing:!0},lt()},pauseAnimation(){k={...k,playing:!1},ft()},resetAnimation(){k={...k,playing:!1,timeSeconds:0},ft(),Xt()},setAnimationSpeed(C){k={...k,speed:br(C,.1,64)}},getAnimationState(){return{...k}},search(C,G=12){return ma(u,C,G)},getFilter(){return s.filter?{...s.filter}:null},setFilter(C){fe(C,!0,!0)},getVisibleObjects(){return ie()},getFocusPath(C){return Ce(C)},getObjectDetails(C){return Ae(C)},getSelectionDetails(){return Ae(f.selectedObjectId)},getTooltipDetails(){return B},getAtlasState(){return ep(f,s,s.filter??null,W)},setAtlasState(C){let G=typeof C=="string"?ya(C):C;G.viewpointId&&_e.goToViewpoint(G.viewpointId),_e.setRenderOptions(G.renderOptions),fe(G.filter??null,!1,!1),Ue(J({...f,...G.viewerState})),K(G.viewerState.selectedObjectId??null,!1),We(),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),Pe()},serializeAtlasState(){return ga(_e.getAtlasState())},captureBookmark(C,G){return tp(C,G,_e.getAtlasState())},applyBookmark(C){return typeof C=="string"?(_e.setAtlasState(C),!0):(_e.setAtlasState(C.atlasState),!0)},setRenderOptions(C){let G=Ey(C),_=s,O=u,V=h,N=Wf(s,C),$=u;c.kind!=="scene"&&G&&($=oa(c,N));let ue=N.viewMode==="3d"?_r(c,N,d):null;s=N,u=$,h=ue,Ke();try{H(G)}catch(Ee){throw s=_,u=O,h=V,Ke(),H(G),Ee}},getState(){return{...f}},setState(C){Ue(J({...f,...C}))},zoomBy(C,G){Ue(Cr(u,f,C,G??{x:u.width/2,y:u.height/2},i))},panBy(C,G){Ue(ki(f,C,G))},rotateBy(C){Ue($a(f,C))},fitToSystem(){Ue(Se()?{...fn,selectedObjectId:f.selectedObjectId}:Bi(u,f,i))},focusObject(C){W=null,Ue(Se()?gu(C):Wa(u,f,C,i)),K(C),r.tooltipMode==="pinned"&&(U=he(C)?.objectId??null,De())},pinTooltip(C){U=he(C)?.objectId??null,De()},resetView(){let C=Se()?{...fn}:Bi(u,{...fn},i);W=null,Ue(C),K(null),U=null,De()},exportSvg(){return _n(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){D||(D=!0,n.removeEventListener("wheel",re),n.removeEventListener("pointerdown",se),n.removeEventListener("pointermove",ve),n.removeEventListener("pointerup",Le),n.removeEventListener("pointercancel",Le),n.removeEventListener("click",Je),n.removeEventListener("mouseover",Z),n.removeEventListener("mouseleave",q),n.removeEventListener("focusin",pe),n.removeEventListener("focusout",ne),n.removeEventListener("keydown",Fe),ft(),g?.destroy(),g=null,x?.remove(),x=null,v?.remove(),v=null,m?.remove(),m=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=a,n.style.position=l,o===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",o))}};return H(!0),e.initialViewpointId?_e.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?_e.focusObject(e.initialSelectionObjectId):Pe(),_e;function H(C){if(g?.destroy(),g=null,n.innerHTML="",p=null,y=null,m=null,x=null,v=null,Se()?(h=h??_r(c,s,d),g=_y(n)):(n.innerHTML=_n(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),p=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(m=document.createElement("div"),m.dataset.worldorbitMinimapRoot="true",n.append(m)),x=document.createElement("div"),x.className="wo-viewer-label-root",x.dataset.worldorbitLabelRoot="true",n.append(x),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",xe),n.append(v)),!Se()&&(!p||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");ca(),f=C?Se()?{...fn}:Bi(u,{...fn},i):J(f),K(f.selectedObjectId&&he(f.selectedObjectId)?f.selectedObjectId:null,!1),de(T&&he(T)?T:null,!1),U=U&&he(U)?U:null,Xt(),Re(),We(),e.onViewChange?.({...f}),Pe()}function Ue(C){f=J(C),Xt(),e.onViewChange?.({...f}),Pe()}function J(C){return{scale:br(C.scale,i.minScale,i.maxScale),rotationDeg:Iy(C.rotationDeg),translateX:Number.isFinite(C.translateX)?C.translateX:f.translateX,translateY:Number.isFinite(C.translateY)?C.translateY:f.translateY,selectedObjectId:C.selectedObjectId&&he(C.selectedObjectId)?C.selectedObjectId:null}}function ce(){if(Se()){Mt();return}y&&(y.setAttribute("transform",ja(u,f)),As(),Me(),De())}function K(C,G=!0){if(!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${aa(f.selectedObjectId)}"]`))_.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:C&&he(C)?C:null},!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${aa(f.selectedObjectId)}"]`))_.classList.add("wo-object-selected");P(),De(),G&&(e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),e.onViewChange?.({...f}),Pe())}function de(C,G=!0){T===C&&G||(T=C&&he(C)?C:null,P(),De(),G&&(e.onHoverChange?.(he(T)),e.onHoverDetailsChange?.(Ae(T))))}function le(){return he(f.selectedObjectId)}function he(C){if(!C)return null;let G=oe();return u.objects.find(_=>_.objectId===C&&!_.hidden&&G.has(_.objectId))??null}function Ae(C){let G=he(C);return G?{objectId:G.objectId,object:G.object,renderObject:G,label:u.labels.find(_=>_.objectId===G.objectId&&!_.hidden)??null,group:u.groups.find(_=>_.renderId===G.groupId)??null,semanticGroups:u.semanticGroups.filter(_=>G.semanticGroupIds.includes(_.id)),orbit:u.orbitVisuals.find(_=>_.objectId===G.objectId&&!_.hidden)??null,relatedOrbits:u.orbitVisuals.filter(_=>!_.hidden&&(_.objectId===G.objectId||G.ancestorIds.includes(_.objectId)||G.childIds.includes(_.objectId))),relations:u.relations.filter(_=>!_.hidden&&(_.fromObjectId===G.objectId||_.toObjectId===G.objectId)),relatedEvents:u.events.filter(_=>!_.hidden&&(_.targetObjectId===G.objectId||_.objectIds.includes(G.objectId))),parent:he(G.parentId),children:G.childIds.map(_=>he(_)).filter(Boolean),ancestors:G.ancestorIds.map(_=>he(_)).filter(Boolean),focusPath:Ce(G.objectId)}:null}function P(){if(Se()){Mt();return}for(let C of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))C.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");S(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),S(T,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function S(C,G){let _=Ae(C);if(!_)return;let O=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]);for(let V of O)for(let N of n.querySelectorAll(`[data-object-id="${aa(V)}"]`))N.classList.add(G.objectClass);for(let V of _.ancestors)for(let N of n.querySelectorAll(`[data-object-id="${aa(V.objectId)}"]`))N.classList.add(G.ancestorClass);for(let V of _.relatedOrbits)for(let N of n.querySelectorAll(`[data-orbit-object-id="${aa(V.objectId)}"]`))N.classList.add(G.orbitClass)}function j(C,G){if(Se()){let O=n.getBoundingClientRect();return!O.width||!O.height?{x:u.width/2,y:u.height/2}:{x:C-O.left,y:G-O.top}}if(!p)return{x:u.width/2,y:u.height/2};let _=p.getBoundingClientRect();return!_.width||!_.height?{x:u.width/2,y:u.height/2}:{x:(C-_.left)/_.width*u.width,y:(G-_.top)/_.height*u.height}}function ee(C,G){return Rr(u,f,j(C,G))}function oe(){return pa(u,s.filter??null)}function ie(){let C=oe();return u.objects.filter(G=>!G.hidden&&C.has(G.objectId))}function Ce(C){let G=u.objects.find(_=>_.objectId===C&&!_.hidden);return G?[...G.ancestorIds,G.objectId].map(_=>he(_)).filter(Boolean):[]}function me(C){return u.viewpoints.find(G=>G.id===C)??null}function ge(C){let G=Iy(C.rotationDeg),_=C.scale!==null&&C.scale!==void 0?br(C.scale,i.minScale,i.maxScale):null;if(Se()){let N=C.objectId??C.selectedObjectId??null,$=N?h?.focusTargets.find(ue=>ue.objectId===N):null;return{scale:_??1.6,rotationDeg:G,translateX:$?-$.center.x:0,translateY:$?-$.center.z:0,selectedObjectId:C.selectedObjectId??C.objectId??null}}let O=C.objectId&&u.objects.find(N=>N.objectId===C.objectId&&!N.hidden);if(O)return ke({x:O.x,y:O.y},_??Math.max(1.8,fn.scale),G,C.selectedObjectId??O.objectId);let V=Bi(u,{...fn,rotationDeg:G},i);return _===null?{...V,rotationDeg:G,selectedObjectId:C.selectedObjectId??null}:ke({x:u.contentBounds.centerX,y:u.contentBounds.centerY},_,G,C.selectedObjectId??null)}function ke(C,G,_,O){let V={x:u.width/2,y:u.height/2},N=Vn(C,V,_);return{scale:G,rotationDeg:_,translateX:V.x-(V.x+(N.x-V.x)*G),translateY:V.y-(V.y+(N.y-V.y)*G),selectedObjectId:O}}function fe(C,G,_){s={...s,filter:Zt(C)},_&&(W=null),H(!1)}function Re(){e.onFilterChange?.(s.filter??null,ie())}function We(){e.onViewpointChange?.(me(W))}function Pe(){e.onAtlasStateChange?.(_e.getAtlasState())}function Me(){!r.minimap||!m||(m.innerHTML=lm(u,f,ie()))}function De(){if(r.tooltipMode==="disabled"||!v){be(null);return}let C=qe();if(!C){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let G=Ae(C.objectId);if(!G){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let _=My(G);I=C.objectId,v.hidden=!1,v.dataset.mode=C.mode,v.classList.toggle("is-pinned",C.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",ht(v,_,C.mode),Ge(v,G.renderObject),v.style.visibility="visible",be(_)}function qe(){return U&&he(U)?{objectId:U,mode:"pinned"}:T&&he(T)?{objectId:T,mode:"hover"}:null}function ht(C,G,_){let O=e.tooltipRenderer?.(G,_);C.innerHTML="",typeof O=="string"?C.innerHTML=O:O instanceof HTMLElement?C.append(O):C.innerHTML=Sy(G,_);let V=document.createElement("div");if(V.className="wo-tooltip-actions",_==="pinned"){let N=document.createElement("button");N.type="button",N.className="wo-tooltip-action",N.dataset.tooltipAction="unpin",N.textContent="Unpin",V.append(N)}else{let N=document.createElement("button");N.type="button",N.className="wo-tooltip-action",N.dataset.tooltipAction="pin",N.dataset.objectId=G.objectId,N.textContent="Pin",V.append(N)}V.childElementCount>0&&C.append(V)}function Ge(C,G){let _=Se()?g?.projectObjectToContainer(G.objectId)??null:ae(G);if(!_)return;let O=Math.max(n.clientWidth-C.offsetWidth-12,12),V=Math.max(n.clientHeight-C.offsetHeight-12,12),N=_.y>n.clientHeight*.48,$=br(_.x+18,12,O),ue=br(N?_.y-C.offsetHeight-18:_.y+18,12,V);C.style.left=`${$}px`,C.style.top=`${ue}px`}function z(C){if(Se())return C;let G={x:u.width/2,y:u.height/2},_=Vn(C,G,f.rotationDeg);return{x:G.x+(_.x-G.x)*f.scale+f.translateX,y:G.y+(_.y-G.y)*f.scale+f.translateY}}function ae(C){let G={x:C.anchorX??C.x,y:C.anchorY??C.y-Math.max(C.visualRadius,C.radius)};return Q(G)}function Q(C){if(!p)return null;let G=z(C),_=p.getBoundingClientRect(),O=n.getBoundingClientRect();return{x:_.left-O.left+G.x/Math.max(u.width,1)*_.width,y:_.top-O.top+G.y/Math.max(u.height,1)*_.height}}function xe(C){let G=C.target?.closest("[data-tooltip-action]");if(G){switch(C.preventDefault(),C.stopPropagation(),G.dataset.tooltipAction){case"pin":U=G.dataset.objectId??I;break;case"unpin":U=null;break}De()}}function be(C){let G=B?.objectId!==C?.objectId||B?.description!==C?.description||B?.imageHref!==C?.imageHref;B=C,I=C?.objectId??null,G&&e.onTooltipChange?.(C)}function Se(){return s.viewMode==="3d"}function Ke(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},ft())}function lt(){F!==null||!k.playing||D||(F=window.requestAnimationFrame(et))}function ft(){F!==null&&(window.cancelAnimationFrame(F),F=null),X=null}function et(C){if(F=null,!k.playing||D){X=null;return}let _=Math.max((C-(X??C))/1e3,0);X=C,k={...k,timeSeconds:k.timeSeconds+_*k.speed},Mt(),lt()}function Xt(){ce(),Se()&&k.playing?lt():(!k.playing||!Se())&&ft()}function Mt(){!Se()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:oe(),selectedObjectId:f.selectedObjectId,hoveredObjectId:T,state:f,timeSeconds:k.timeSeconds}),As(),Me(),De())}function ca(){if(!Se()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let C of n.querySelectorAll(".wo-event-label"))C.setAttribute("display","none")}}function As(){if(!x)return;let C=ua();x.replaceChildren(...C.map(G=>Mr(G))),x.hidden=C.length===0}function ua(){let C=[],G=oe();if(Es("labels"))for(let _ of u.labels){if(_.hidden||!G.has(_.objectId)||Se()&&!da(_.objectId,G))continue;let O=Se()?g?.projectObjectToContainer(_.objectId)??null:Q({x:_.x,y:_.y});O&&C.push({key:`object:${_.renderId}`,kind:"object",point:Se()?{x:O.x,y:O.y-18}:O,textAnchor:_.textAnchor,objectId:_.objectId,primaryText:_.label,secondaryText:_.secondaryLabel,secondaryOffset:Math.max(_.secondaryY-_.y,12)})}if(!Se()&&Es("events"))for(let _ of u.events){if(_.hidden||!wr(_,G))continue;let O=Q({x:_.x,y:_.y-10});O&&C.push({key:`event:${_.renderId}`,kind:"event",point:O,textAnchor:"middle",primaryText:_.event.label||_.event.id})}return C}function wr(C,G){return C.objectIds.some(_=>G.has(_))}function da(C,G){if(!Se()||C===f.selectedObjectId||C===T)return!0;let _=he(C);if(!_||_.hidden||!G.has(C))return!1;if(_.object.type==="star")return!0;let O=f.selectedObjectId?Ae(f.selectedObjectId):null,V=T?Ae(T):null,N=O?new Set([O.objectId,...O.renderObject.ancestorIds,...O.renderObject.childIds]):null,$=V?new Set([V.objectId,...V.renderObject.ancestorIds,...V.renderObject.childIds]):null;return N?.has(C)||$?.has(C)||_.semanticGroupIds.length>0&&_.visualRadius>=12?!0:_.childIds.length>0&&_.visualRadius>=10}function Mr(C){let G=document.createElement("div");if(G.className=`wo-viewer-label wo-viewer-label-${C.kind}`,G.dataset.worldorbitScreenLabel="true",G.dataset.labelKey=C.key,G.dataset.anchor=C.textAnchor,G.style.left=`${C.point.x}px`,G.style.top=`${C.point.y}px`,C.objectId){G.dataset.objectId=C.objectId;for(let O of ha(C.objectId))G.classList.add(O)}let _=document.createElement("span");if(_.className="wo-viewer-label-primary",C.kind==="object"&&(_.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),_.textContent=C.primaryText,G.append(_),C.secondaryText){let O=document.createElement("span");O.className="wo-viewer-label-secondary",O.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,O.style.marginTop=`${Math.max(C.secondaryOffset??12,10)-10}px`,O.textContent=C.secondaryText,G.append(O)}return G}function Es(C){return s.layers?.[C]!==!1}function ha(C){let G=[],_=Ae(f.selectedObjectId),O=Ae(T);if(f.selectedObjectId===C&&G.push("wo-object-selected"),_){let V=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]),N=new Set(_.ancestors.map($=>$.objectId));V.has(C)&&G.push("wo-chain-selected"),N.has(C)&&G.push("wo-ancestor-selected")}if(O){let V=new Set([O.objectId,...O.renderObject.childIds,...O.renderObject.ancestorIds]),N=new Set(O.ancestors.map($=>$.objectId));V.has(C)&&G.push("wo-chain-hover"),N.has(C)&&G.push("wo-ancestor-hover")}return G}function gu(C){let G=h?.focusTargets.find(_=>_.objectId===C);return G?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-G.center.x,translateY:-G.center.z,selectedObjectId:C}:{...fn,selectedObjectId:C}}}function ZT(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function oa(n,e){switch(n.kind){case"scene":return n.value;case"document":return dn(n.value,e);case"source":{let t=Gn(n.value);return dn(t.document,Cy(t,e))}}}function _r(n,e,t){if(t)return t;switch(n.kind){case"scene":return KT(n.value);case"document":return Fa(n.value,e);case"source":{let i=Gn(n.value);return Fa(i.document,Cy(i,e))}}}function JT(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d",quality:n.quality??"balanced",style3d:n.style3d??"symbolic"}}function Wf(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?Zt(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d",quality:e.quality??n.quality??"balanced",style3d:e.style3d??n.style3d??"symbolic"}}function Ey(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.activeEventId!==void 0}function Cy(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function KT(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Ty(n,e,t){let{center:i,distance:r}=Ry(t);return{startState:{...e},startCenter:Rr(n,e,i),startViewportCenter:i,startDistance:r}}function Ry(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function fu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function QT(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function br(n,e,t){return Math.min(Math.max(n,e),t)}function Iy(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function aa(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function eI(){if(typeof document>"u"||document.getElementById(Ay))return;let n=document.createElement("style");n.id=Ay,n.textContent=`
3943
3943
  .wo-viewer-3d-root {
3944
3944
  position: relative;
3945
3945
  min-height: 320px;
@@ -4087,7 +4087,7 @@ void main() {
4087
4087
  padding: 6px 12px;
4088
4088
  font: 600 12px/1.3 "Segoe UI Variable", "Segoe UI", sans-serif;
4089
4089
  }
4090
- `,document.head.append(n)}var KT="[data-worldorbit-embed]";function jf(n){return encodeURIComponent(JSON.stringify(n))}function Xf(n){let e=JSON.parse(decodeURIComponent(n));return{version:"2.0",mode:Ss(e.mode),scene:e.scene,spatialScene:e.spatialScene??void 0,options:e.options?{...e.options,viewMode:e.options.viewMode??pu(Ss(e.mode)),initialFilter:e.options.initialFilter??null,atlasState:e.options.atlasState??null}:void 0}}function Py(n,e,t={}){return{version:"2.0",mode:Ss(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??pu(Ss(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function Ly(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??pu(Ss(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=_n(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${oo(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${oo(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${oo(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${oo(jf(t))}">${i}</div>`}function Dy(n=document,e={}){let t=new Map,i=[],r=[...n.querySelectorAll(KT)];for(let s of r){let a=eI(s),o=Ss(e.mode??a.mode),l=e.theme??a.options?.theme,c=e.layers??a.options?.layers,u=e.subtitle??a.options?.subtitle,d=e.preset??a.options?.preset??a.scene.renderPreset??void 0,h=e.viewer?.initialFilter??a.options?.initialFilter??null,f=e.viewer?.initialViewpointId??a.options?.initialViewpointId,m=e.viewer?.initialSelectionObjectId??a.options?.initialSelectionObjectId,y=e.viewer?.minimap??a.options?.minimap,g=e.viewer?.viewMode??a.options?.viewMode??pu(o),p=()=>QT(s,a.scene,e);if(o==="interactive-2d"||o==="interactive-3d")try{let x=p(),v=Di(s,{...e.viewer,scene:a.scene,spatialScene:a.spatialScene,width:x.width,height:x.height,padding:e.padding??a.scene.padding,preset:d,theme:l,layers:c,subtitle:u,viewMode:g,initialFilter:h,initialViewpointId:f,initialSelectionObjectId:m,minimap:y});a.options?.atlasState&&v.setAtlasState(a.options.atlasState),t.set(s,v),i.push(Ry(s,()=>{let b=p();v.setRenderOptions({width:b.width,height:b.height})})),e.onMount?.(v,s)}catch(x){if(x instanceof cn&&o==="interactive-3d")s.innerHTML=Yf(x.message),e.onMount?.(null,s);else throw x}else{let x=()=>{let v=p();s.innerHTML=_n(a.scene,{width:v.width,height:v.height,padding:e.padding??a.scene.padding,preset:d,theme:l,layers:c,filter:h,selectedObjectId:m??null,subtitle:u})};x(),i.push(Ry(s,x)),e.onMount?.(null,s)}s.dataset.worldorbitMounted="true"}return{viewers:[...t.values()],destroy(){for(let s of i)s();for(let[s,a]of t.entries())a.destroy(),s.removeAttribute("data-worldorbit-mounted");for(let s of r)s.removeAttribute("data-worldorbit-mounted");t.clear()}}}function QT(n,e,t){let i=n.getBoundingClientRect(),r=Ms(t.width)??Ms(n.clientWidth)??Ms(i.width)??e.width,s=Ms(t.height)??Ms(n.clientHeight)??Ms(i.height),a=Math.max(Math.round(r*(e.height/Math.max(e.width,1))),Math.min(e.height,240));return{width:r,height:s??a}}function Ms(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?Math.round(n):null}function Ry(n,e){let t=-1,i=-1,r=()=>{let a=n.getBoundingClientRect(),o=Math.round(Math.max(n.clientWidth||a.width,0)),l=Math.round(Math.max(n.clientHeight||a.height,0));o===t&&l===i||(t=o,i=l,e())};if(r(),typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>{r()});return a.observe(n),()=>{a.disconnect()}}let s=()=>{r()};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}}function eI(n){let e=n.dataset.worldorbitPayload;if(!e)throw new Error("WorldOrbit embed is missing data-worldorbit-payload.");return Xf(e)}function oo(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function Ss(n){return!n||n==="interactive"?"interactive-2d":n}function pu(n){return n==="interactive-3d"?"3d":"2d"}function Yf(n){return`<div class="worldorbit-embed-unavailable" data-worldorbit-3d-unavailable="true"><strong>3D unavailable</strong><span>${oo(n)}</span></div>`}var Oy="worldorbit-atlas-viewer-style";function mu(n,e){if(typeof document>"u")throw new Error("Atlas viewer requires a browser environment.");nI();let t={search:e.controls?.search??!0,typeFilter:e.controls?.typeFilter??!0,groupFilter:e.controls?.groupFilter??!0,viewpointSelect:e.controls?.viewpointSelect??!0,inspector:e.controls?.inspector??!0,bookmarks:e.controls?.bookmarks??!0};n.classList.add("wo-atlas-viewer"),n.innerHTML=tI(t);let i=n.querySelector("[data-atlas-toolbar]"),r=n.querySelector("[data-atlas-search]"),s=n.querySelector("[data-atlas-type-filter]"),a=n.querySelector("[data-atlas-group-filter]"),o=n.querySelector("[data-atlas-viewpoint]"),l=n.querySelector("[data-atlas-bookmark]"),c=n.querySelector("[data-atlas-bookmarks]"),u=n.querySelector("[data-atlas-results]"),d=n.querySelector("[data-atlas-inspector]"),h=n.querySelector("[data-atlas-stage]");if(!h)throw new Error("Atlas viewer failed to initialize its stage container.");let f=Zt(e.initialFilter??null),m=e.initialQuery?.trim()??f?.query??"",y=e.initialObjectType??(f?.objectTypes?.length===1?f.objectTypes[0]:null),g=f?.groupIds?.[0]??null,p=[],x;x=Di(h,{...e,initialFilter:null,onSelectionChange(F){x&&I(),e.onSelectionChange?.(F)},onSelectionDetailsChange(F){x&&I(),e.onSelectionDetailsChange?.(F)},onFilterChange(F,X){x&&(D(F),U(),I()),e.onFilterChange?.(F,X)},onViewpointChange(F){x&&(T(),I()),e.onViewpointChange?.(F)},onAtlasStateChange(F){x&&I(),e.onAtlasStateChange?.(F)},onViewChange(F){x&&I(),e.onViewChange?.(F)}}),A(),M(),w(),D(x.getFilter()),W(),U(),I(),r?.addEventListener("input",()=>{m=r.value.trim(),A()}),s?.addEventListener("change",()=>{y=s.value||null,A()}),a?.addEventListener("change",()=>{g=a.value||null,A()}),o?.addEventListener("change",()=>{let F=v();if(!o.value){F.resetView(),A();return}F.goToViewpoint(o.value),I()}),l?.addEventListener("click",()=>{let F=v(),X=F.getActiveViewpoint()?.label??F.getSelectionDetails()?.objectId??`Bookmark ${p.length+1}`;p=[...p,F.captureBookmark(X,X)],W(),I()}),c?.addEventListener("click",F=>{let X=F.target?.closest("[data-bookmark-id]");if(!X)return;let k=p.find(se=>se.id===X.dataset.bookmarkId);if(!k)return;let re=v();re.applyBookmark(k),D(re.getFilter()),U(),I()}),u?.addEventListener("click",F=>{let X=F.target?.closest("[data-object-id]");X&&(v().focusObject(X.dataset.objectId??""),I())});function v(){if(!x)throw new Error("Atlas viewer is not initialized.");return x}return{element:n,get viewer(){return v()},getViewer(){return v()},setSource(F){v().setSource(F),L()},setDocument(F){v().setDocument(F),L()},setScene(F){v().setScene(F),L()},getAtlasState(){return v().getAtlasState()},setAtlasState(F){let X=v();X.setAtlasState(F),D(X.getFilter()),U(),I()},getInspectorSnapshot(){return B()},getSearchQuery(){return m},setSearchQuery(F){m=F.trim(),r&&(r.value=m),A()},getObjectTypeFilter(){return y},setObjectTypeFilter(F){y=F,s&&(s.value=F??""),A()},listSearchResults(F=6){return v().search(m,F)},listBookmarks(){return p.map(Uy)},captureBookmark(F,X){let k=v().captureBookmark(F,X);return p=[...p,k],W(),I(),Uy(k)},applyBookmark(F){let X=v(),k=X.applyBookmark(F);return k&&(D(X.getFilter()),U(),I()),k},goToViewpoint(F){let X=v().goToViewpoint(F);return X&&I(),X},exportSvg(){return v().exportSvg()},destroy(){v().destroy(),n.innerHTML="",n.classList.remove("wo-atlas-viewer")}};function L(){M(),w(),A(),W(),U(),I()}function A(){v().setFilter(E()),M(),U(),I()}function E(){return Zt({query:m||void 0,objectTypes:y?[y]:void 0,tags:f?.tags,groupIds:g?[g]:f?.groupIds,includeAncestors:f?.includeAncestors??!0})}function D(F){m=F?.query?.trim()??"",y=F?.objectTypes?.length===1?F.objectTypes[0]:null,g=F?.groupIds?.length===1?F.groupIds[0]:null,r&&document.activeElement!==r&&(r.value=m),s&&(s.value=y??""),a&&(a.value=g??"")}function M(){if(!o)return;let F=v(),X=F.getActiveViewpoint()?.id??"";o.innerHTML=['<option value="">Scene default</option>',...F.listViewpoints().map(k=>`<option value="${ui(k.id)}">${ui(k.label)}</option>`)].join(""),o.value=X}function w(){if(!a)return;let F=v();a.innerHTML=['<option value="">All groups</option>',...F.getScene().semanticGroups.map(X=>`<option value="${ui(X.id)}">${ui(X.label)}</option>`)].join(""),a.value=g??""}function T(){o&&(o.value=v().getActiveViewpoint()?.id??"")}function U(){if(!u)return;let F=v().search(m,6);u.innerHTML=F.map(X=>`<button type="button" class="wo-atlas-pill" data-object-id="${ui(X.objectId)}">${ui(X.objectId)} - ${ui(X.type)}</button>`).join("")}function I(){let F=B();d&&(d.textContent=JSON.stringify(F,null,2)),e.onInspectorChange?.(F)}function B(){let F=v(),X=F.getScene(),k=X.camera;return{selection:F.getSelectionDetails(),activeViewpoint:F.getActiveViewpoint(),filter:F.getFilter(),atlasState:F.getAtlasState(),visibleObjectIds:F.getVisibleObjects().map(re=>re.objectId),scene:{title:X.title,projection:X.projection,renderProjection:X.renderProjection,camera:k?{azimuth:k.azimuth,elevation:k.elevation,roll:k.roll,distance:k.distance}:null,renderPreset:X.renderPreset,groupCount:X.groups.length,semanticGroupCount:X.semanticGroups.length,relationCount:X.relations.length,eventCount:X.events.length,viewpointCount:X.viewpoints.length}}}function W(){c&&(c.innerHTML=p.map(F=>`<button type="button" class="wo-atlas-pill" data-bookmark-id="${ui(F.id)}">${ui(F.label)}</button>`).join(""))}}function tI(n){let e=[n.search?`<label class="wo-atlas-field">
4090
+ `,document.head.append(n)}var tI="[data-worldorbit-embed]";function jf(n){return encodeURIComponent(JSON.stringify(n))}function Xf(n){let e=JSON.parse(decodeURIComponent(n));return{version:"2.0",mode:Ss(e.mode),scene:e.scene,spatialScene:e.spatialScene??void 0,options:e.options?{...e.options,viewMode:e.options.viewMode??pu(Ss(e.mode)),initialFilter:e.options.initialFilter??null,atlasState:e.options.atlasState??null}:void 0}}function Ly(n,e,t={}){return{version:"2.0",mode:Ss(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??pu(Ss(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function Dy(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??pu(Ss(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=_n(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${la(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${la(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${la(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${la(jf(t))}">${i}</div>`}function Oy(n=document,e={}){let t=new Map,i=[],r=[...n.querySelectorAll(tI)];for(let s of r){let o=iI(s),a=Ss(e.mode??o.mode),l=e.theme??o.options?.theme,c=e.layers??o.options?.layers,u=e.subtitle??o.options?.subtitle,d=e.preset??o.options?.preset??o.scene.renderPreset??void 0,h=e.viewer?.initialFilter??o.options?.initialFilter??null,f=e.viewer?.initialViewpointId??o.options?.initialViewpointId,p=e.viewer?.initialSelectionObjectId??o.options?.initialSelectionObjectId,y=e.viewer?.minimap??o.options?.minimap,g=e.viewer?.viewMode??o.options?.viewMode??pu(a),m=()=>nI(s,o.scene,e);if(a==="interactive-2d"||a==="interactive-3d")try{let x=m(),v=Di(s,{...e.viewer,scene:o.scene,spatialScene:o.spatialScene,width:x.width,height:x.height,padding:e.padding??o.scene.padding,preset:d,theme:l,layers:c,subtitle:u,viewMode:g,initialFilter:h,initialViewpointId:f,initialSelectionObjectId:p,minimap:y});o.options?.atlasState&&v.setAtlasState(o.options.atlasState),t.set(s,v),i.push(Py(s,()=>{let b=m();v.setRenderOptions({width:b.width,height:b.height})})),e.onMount?.(v,s)}catch(x){if(x instanceof cn&&a==="interactive-3d")s.innerHTML=Yf(x.message),e.onMount?.(null,s);else throw x}else{let x=()=>{let v=m();s.innerHTML=_n(o.scene,{width:v.width,height:v.height,padding:e.padding??o.scene.padding,preset:d,theme:l,layers:c,filter:h,selectedObjectId:p??null,subtitle:u})};x(),i.push(Py(s,x)),e.onMount?.(null,s)}s.dataset.worldorbitMounted="true"}return{viewers:[...t.values()],destroy(){for(let s of i)s();for(let[s,o]of t.entries())o.destroy(),s.removeAttribute("data-worldorbit-mounted");for(let s of r)s.removeAttribute("data-worldorbit-mounted");t.clear()}}}function nI(n,e,t){let i=n.getBoundingClientRect(),r=Ms(t.width)??Ms(n.clientWidth)??Ms(i.width)??e.width,s=Ms(t.height)??Ms(n.clientHeight)??Ms(i.height),o=Math.max(Math.round(r*(e.height/Math.max(e.width,1))),Math.min(e.height,240));return{width:r,height:s??o}}function Ms(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?Math.round(n):null}function Py(n,e){let t=-1,i=-1,r=()=>{let o=n.getBoundingClientRect(),a=Math.round(Math.max(n.clientWidth||o.width,0)),l=Math.round(Math.max(n.clientHeight||o.height,0));a===t&&l===i||(t=a,i=l,e())};if(r(),typeof ResizeObserver<"u"){let o=new ResizeObserver(()=>{r()});return o.observe(n),()=>{o.disconnect()}}let s=()=>{r()};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}}function iI(n){let e=n.dataset.worldorbitPayload;if(!e)throw new Error("WorldOrbit embed is missing data-worldorbit-payload.");return Xf(e)}function la(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function Ss(n){return!n||n==="interactive"?"interactive-2d":n}function pu(n){return n==="interactive-3d"?"3d":"2d"}function Yf(n){return`<div class="worldorbit-embed-unavailable" data-worldorbit-3d-unavailable="true"><strong>3D unavailable</strong><span>${la(n)}</span></div>`}var Uy="worldorbit-atlas-viewer-style";function mu(n,e){if(typeof document>"u")throw new Error("Atlas viewer requires a browser environment.");sI();let t={search:e.controls?.search??!0,typeFilter:e.controls?.typeFilter??!0,groupFilter:e.controls?.groupFilter??!0,viewpointSelect:e.controls?.viewpointSelect??!0,inspector:e.controls?.inspector??!0,bookmarks:e.controls?.bookmarks??!0};n.classList.add("wo-atlas-viewer"),n.innerHTML=rI(t);let i=n.querySelector("[data-atlas-toolbar]"),r=n.querySelector("[data-atlas-search]"),s=n.querySelector("[data-atlas-type-filter]"),o=n.querySelector("[data-atlas-group-filter]"),a=n.querySelector("[data-atlas-viewpoint]"),l=n.querySelector("[data-atlas-bookmark]"),c=n.querySelector("[data-atlas-bookmarks]"),u=n.querySelector("[data-atlas-results]"),d=n.querySelector("[data-atlas-inspector]"),h=n.querySelector("[data-atlas-stage]");if(!h)throw new Error("Atlas viewer failed to initialize its stage container.");let f=Zt(e.initialFilter??null),p=e.initialQuery?.trim()??f?.query??"",y=e.initialObjectType??(f?.objectTypes?.length===1?f.objectTypes[0]:null),g=f?.groupIds?.[0]??null,m=[],x;x=Di(h,{...e,initialFilter:null,onSelectionChange(F){x&&I(),e.onSelectionChange?.(F)},onSelectionDetailsChange(F){x&&I(),e.onSelectionDetailsChange?.(F)},onFilterChange(F,X){x&&(D(F),U(),I()),e.onFilterChange?.(F,X)},onViewpointChange(F){x&&(T(),I()),e.onViewpointChange?.(F)},onAtlasStateChange(F){x&&I(),e.onAtlasStateChange?.(F)},onViewChange(F){x&&I(),e.onViewChange?.(F)}}),A(),M(),w(),D(x.getFilter()),W(),U(),I(),r?.addEventListener("input",()=>{p=r.value.trim(),A()}),s?.addEventListener("change",()=>{y=s.value||null,A()}),o?.addEventListener("change",()=>{g=o.value||null,A()}),a?.addEventListener("change",()=>{let F=v();if(!a.value){F.resetView(),A();return}F.goToViewpoint(a.value),I()}),l?.addEventListener("click",()=>{let F=v(),X=F.getActiveViewpoint()?.label??F.getSelectionDetails()?.objectId??`Bookmark ${m.length+1}`;m=[...m,F.captureBookmark(X,X)],W(),I()}),c?.addEventListener("click",F=>{let X=F.target?.closest("[data-bookmark-id]");if(!X)return;let k=m.find(se=>se.id===X.dataset.bookmarkId);if(!k)return;let re=v();re.applyBookmark(k),D(re.getFilter()),U(),I()}),u?.addEventListener("click",F=>{let X=F.target?.closest("[data-object-id]");X&&(v().focusObject(X.dataset.objectId??""),I())});function v(){if(!x)throw new Error("Atlas viewer is not initialized.");return x}return{element:n,get viewer(){return v()},getViewer(){return v()},setSource(F){v().setSource(F),L()},setDocument(F){v().setDocument(F),L()},setScene(F){v().setScene(F),L()},getAtlasState(){return v().getAtlasState()},setAtlasState(F){let X=v();X.setAtlasState(F),D(X.getFilter()),U(),I()},getInspectorSnapshot(){return B()},getSearchQuery(){return p},setSearchQuery(F){p=F.trim(),r&&(r.value=p),A()},getObjectTypeFilter(){return y},setObjectTypeFilter(F){y=F,s&&(s.value=F??""),A()},listSearchResults(F=6){return v().search(p,F)},listBookmarks(){return m.map(Ny)},captureBookmark(F,X){let k=v().captureBookmark(F,X);return m=[...m,k],W(),I(),Ny(k)},applyBookmark(F){let X=v(),k=X.applyBookmark(F);return k&&(D(X.getFilter()),U(),I()),k},goToViewpoint(F){let X=v().goToViewpoint(F);return X&&I(),X},exportSvg(){return v().exportSvg()},destroy(){v().destroy(),n.innerHTML="",n.classList.remove("wo-atlas-viewer")}};function L(){M(),w(),A(),W(),U(),I()}function A(){v().setFilter(E()),M(),U(),I()}function E(){return Zt({query:p||void 0,objectTypes:y?[y]:void 0,tags:f?.tags,groupIds:g?[g]:f?.groupIds,includeAncestors:f?.includeAncestors??!0})}function D(F){p=F?.query?.trim()??"",y=F?.objectTypes?.length===1?F.objectTypes[0]:null,g=F?.groupIds?.length===1?F.groupIds[0]:null,r&&document.activeElement!==r&&(r.value=p),s&&(s.value=y??""),o&&(o.value=g??"")}function M(){if(!a)return;let F=v(),X=F.getActiveViewpoint()?.id??"";a.innerHTML=['<option value="">Scene default</option>',...F.listViewpoints().map(k=>`<option value="${ui(k.id)}">${ui(k.label)}</option>`)].join(""),a.value=X}function w(){if(!o)return;let F=v();o.innerHTML=['<option value="">All groups</option>',...F.getScene().semanticGroups.map(X=>`<option value="${ui(X.id)}">${ui(X.label)}</option>`)].join(""),o.value=g??""}function T(){a&&(a.value=v().getActiveViewpoint()?.id??"")}function U(){if(!u)return;let F=v().search(p,6);u.innerHTML=F.map(X=>`<button type="button" class="wo-atlas-pill" data-object-id="${ui(X.objectId)}">${ui(X.objectId)} - ${ui(X.type)}</button>`).join("")}function I(){let F=B();d&&(d.textContent=JSON.stringify(F,null,2)),e.onInspectorChange?.(F)}function B(){let F=v(),X=F.getScene(),k=X.camera;return{selection:F.getSelectionDetails(),activeViewpoint:F.getActiveViewpoint(),filter:F.getFilter(),atlasState:F.getAtlasState(),visibleObjectIds:F.getVisibleObjects().map(re=>re.objectId),scene:{title:X.title,projection:X.projection,renderProjection:X.renderProjection,camera:k?{azimuth:k.azimuth,elevation:k.elevation,roll:k.roll,distance:k.distance}:null,renderPreset:X.renderPreset,groupCount:X.groups.length,semanticGroupCount:X.semanticGroups.length,relationCount:X.relations.length,eventCount:X.events.length,viewpointCount:X.viewpoints.length}}}function W(){c&&(c.innerHTML=m.map(F=>`<button type="button" class="wo-atlas-pill" data-bookmark-id="${ui(F.id)}">${ui(F.label)}</button>`).join(""))}}function rI(n){let e=[n.search?`<label class="wo-atlas-field">
4091
4091
  <span>Search</span>
4092
4092
  <input data-atlas-search type="text" placeholder="Search objects, tags, or types" />
4093
4093
  </label>`:"",n.typeFilter?`<label class="wo-atlas-field">
@@ -4124,7 +4124,7 @@ void main() {
4124
4124
  <div class="wo-atlas-results" data-atlas-results></div>
4125
4125
  ${n.bookmarks?'<div class="wo-atlas-bookmarks" data-atlas-bookmarks></div>':""}
4126
4126
  </div>
4127
- </section>`}function nI(){if(document.getElementById(Oy))return;let n=document.createElement("style");n.id=Oy,n.textContent=`
4127
+ </section>`}function sI(){if(document.getElementById(Uy))return;let n=document.createElement("style");n.id=Uy,n.textContent=`
4128
4128
  .wo-atlas-shell { display: grid; gap: 16px; min-width: 0; }
4129
4129
  .wo-atlas-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
4130
4130
  .wo-atlas-workspace { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
@@ -4158,7 +4158,7 @@ void main() {
4158
4158
  .wo-atlas-workspace { grid-template-columns: 1fr; }
4159
4159
  .wo-atlas-inspector { min-height: 220px; }
4160
4160
  }
4161
- `,document.head.append(n)}function Uy(n){return{...n,atlasState:{...n.atlasState,viewerState:{...n.atlasState.viewerState},renderOptions:{...n.atlasState.renderOptions,layers:n.atlasState.renderOptions.layers?{...n.atlasState.renderOptions.layers}:void 0,scaleModel:n.atlasState.renderOptions.scaleModel?{...n.atlasState.renderOptions.scaleModel}:void 0,viewMode:n.atlasState.renderOptions.viewMode??"2d"},filter:n.atlasState.filter?{...n.atlasState.filter}:null}}}function ui(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function Ny(n="worldorbit-viewer"){if(typeof window>"u"||typeof customElements>"u"||customElements.get(n))return;class e extends HTMLElement{static get observedAttributes(){return["source","mode","theme"]}viewer=null;connectedCallback(){this.renderCurrent()}disconnectedCallback(){this.viewer?.destroy(),this.viewer=null}attributeChangedCallback(){this.isConnected&&this.renderCurrent()}renderCurrent(){this.viewer?.destroy(),this.viewer=null;let i=this.getAttribute("source")??this.textContent??"",r=this.getAttribute("mode")??"interactive";if(!i.trim()){this.innerHTML="";return}let s=iI(i),a=dn(s),o=this.getAttribute("theme")??void 0;if(r==="static"){this.innerHTML=_n(a,{theme:o});return}if(r==="atlas"){this.viewer=mu(this,{scene:a,theme:o});return}try{this.viewer=Di(this,{source:i,theme:o,viewMode:r==="interactive-3d"?"3d":"2d"})}catch(l){if(l instanceof cn&&r==="interactive-3d"){this.innerHTML=Yf(l.message);return}throw l}}}customElements.define(n,e)}function iI(n){return Gn(n).document}return Gy(rI);})();
4161
+ `,document.head.append(n)}function Ny(n){return{...n,atlasState:{...n.atlasState,viewerState:{...n.atlasState.viewerState},renderOptions:{...n.atlasState.renderOptions,layers:n.atlasState.renderOptions.layers?{...n.atlasState.renderOptions.layers}:void 0,scaleModel:n.atlasState.renderOptions.scaleModel?{...n.atlasState.renderOptions.scaleModel}:void 0,viewMode:n.atlasState.renderOptions.viewMode??"2d"},filter:n.atlasState.filter?{...n.atlasState.filter}:null}}}function ui(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function Fy(n="worldorbit-viewer"){if(typeof window>"u"||typeof customElements>"u"||customElements.get(n))return;class e extends HTMLElement{static get observedAttributes(){return["source","mode","theme"]}viewer=null;connectedCallback(){this.renderCurrent()}disconnectedCallback(){this.viewer?.destroy(),this.viewer=null}attributeChangedCallback(){this.isConnected&&this.renderCurrent()}renderCurrent(){this.viewer?.destroy(),this.viewer=null;let i=this.getAttribute("source")??this.textContent??"",r=this.getAttribute("mode")??"interactive";if(!i.trim()){this.innerHTML="";return}let s=oI(i),o=dn(s),a=this.getAttribute("theme")??void 0;if(r==="static"){this.innerHTML=_n(o,{theme:a});return}if(r==="atlas"){this.viewer=mu(this,{scene:o,theme:a});return}try{this.viewer=Di(this,{source:i,theme:a,viewMode:r==="interactive-3d"?"3d":"2d"})}catch(l){if(l instanceof cn&&r==="interactive-3d"){this.innerHTML=Yf(l.message);return}throw l}}}customElements.define(n,e)}function oI(n){return Gn(n).document}return $y(aI);})();
4162
4162
  /**
4163
4163
  * @license
4164
4164
  * Copyright 2010-2024 Three.js Authors