worldorbit 3.0.6 → 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 (53) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/core/dist/atlas-edit.js +5 -1
  3. package/dist/browser/core/dist/atlas-validate.js +1 -1
  4. package/dist/browser/core/dist/draft-parse.js +14 -9
  5. package/dist/browser/core/dist/draft.d.ts +1 -0
  6. package/dist/browser/core/dist/draft.js +4 -2
  7. package/dist/browser/core/dist/format.js +5 -3
  8. package/dist/browser/core/dist/load.js +3 -2
  9. package/dist/browser/core/dist/normalize.js +36 -0
  10. package/dist/browser/core/dist/parse.js +54 -0
  11. package/dist/browser/core/dist/scene.js +1 -0
  12. package/dist/browser/core/dist/types.d.ts +21 -1
  13. package/dist/browser/viewer/dist/runtime-3d.js +396 -117
  14. package/dist/browser/viewer/dist/theme.js +27 -0
  15. package/dist/browser/viewer/dist/types.d.ts +17 -0
  16. package/dist/browser/viewer/dist/viewer.js +51 -0
  17. package/dist/unpkg/core/dist/atlas-edit.js +5 -1
  18. package/dist/unpkg/core/dist/atlas-validate.js +1 -1
  19. package/dist/unpkg/core/dist/draft-parse.js +14 -9
  20. package/dist/unpkg/core/dist/draft.d.ts +1 -0
  21. package/dist/unpkg/core/dist/draft.js +4 -2
  22. package/dist/unpkg/core/dist/format.js +5 -3
  23. package/dist/unpkg/core/dist/load.js +3 -2
  24. package/dist/unpkg/core/dist/normalize.js +36 -0
  25. package/dist/unpkg/core/dist/parse.js +54 -0
  26. package/dist/unpkg/core/dist/scene.js +1 -0
  27. package/dist/unpkg/core/dist/types.d.ts +21 -1
  28. package/dist/unpkg/viewer/dist/runtime-3d.js +396 -117
  29. package/dist/unpkg/viewer/dist/theme.js +27 -0
  30. package/dist/unpkg/viewer/dist/types.d.ts +17 -0
  31. package/dist/unpkg/viewer/dist/viewer.js +51 -0
  32. package/dist/unpkg/worldorbit-core.min.js +9 -9
  33. package/dist/unpkg/worldorbit-editor.min.js +360 -356
  34. package/dist/unpkg/worldorbit-markdown.min.js +20 -20
  35. package/dist/unpkg/worldorbit-viewer.min.js +210 -206
  36. package/dist/unpkg/worldorbit.js +557 -120
  37. package/dist/unpkg/worldorbit.min.js +216 -212
  38. package/package.json +1 -1
  39. package/packages/core/dist/atlas-edit.js +5 -1
  40. package/packages/core/dist/atlas-validate.js +1 -1
  41. package/packages/core/dist/draft-parse.js +14 -9
  42. package/packages/core/dist/draft.d.ts +1 -0
  43. package/packages/core/dist/draft.js +4 -2
  44. package/packages/core/dist/format.js +5 -3
  45. package/packages/core/dist/load.js +3 -2
  46. package/packages/core/dist/normalize.js +36 -0
  47. package/packages/core/dist/parse.js +54 -0
  48. package/packages/core/dist/scene.js +1 -0
  49. package/packages/core/dist/types.d.ts +21 -1
  50. package/packages/viewer/dist/runtime-3d.js +396 -117
  51. package/packages/viewer/dist/theme.js +27 -0
  52. package/packages/viewer/dist/types.d.ts +17 -0
  53. package/packages/viewer/dist/viewer.js +51 -0
@@ -1,4 +1,4 @@
1
- "use strict";var WorldOrbitViewer=(()=>{var xu=Object.defineProperty;var Ny=Object.getOwnPropertyDescriptor;var Fy=Object.getOwnPropertyNames;var ky=Object.prototype.hasOwnProperty;var By=(n,e)=>()=>(n&&(e=n(n=0)),e);var Jf=(n,e)=>{for(var t in e)xu(n,t,{get:e[t],enumerable:!0})},zy=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Fy(e))!ky.call(n,r)&&r!==t&&xu(n,r,{get:()=>e[r],enumerable:!(i=Ny(e,r))||i.enumerable});return n};var Vy=n=>zy(xu({},"__esModule",{value:!0}),n);var fy={};Jf(fy,{ACESFilmicToneMapping:()=>_0,AddEquation:()=>Ei,AddOperation:()=>m0,AdditiveAnimationBlendMode:()=>Nf,AdditiveBlending:()=>Rd,AgXToneMapping:()=>b0,AlphaFormat:()=>T0,AlwaysCompare:()=>W0,AlwaysDepth:()=>l0,AlwaysStencilFunc:()=>oh,AmbientLight:()=>Jc,AnimationAction:()=>au,AnimationClip:()=>_r,AnimationLoader:()=>Nh,AnimationMixer:()=>Qh,AnimationObjectGroup:()=>Kh,AnimationUtils:()=>rT,ArcCurve:()=>mc,ArrayCamera:()=>tc,ArrowHelper:()=>wf,AttachedBindMode:()=>Dd,Audio:()=>su,AudioAnalyser:()=>Zh,AudioContext:()=>ta,AudioListener:()=>Yh,AudioLoader:()=>jh,AxesHelper:()=>Mf,BackSide:()=>Xt,BasicDepthPacking:()=>N0,BasicShadowMap:()=>Nb,BatchedMesh:()=>uc,Bone:()=>No,BooleanKeyframeTrack:()=>li,Box2:()=>cf,Box3:()=>Ot,Box3Helper:()=>xf,BoxGeometry:()=>ur,BoxHelper:()=>_f,BufferAttribute:()=>nt,BufferGeometry:()=>Ye,BufferGeometryLoader:()=>iu,ByteType:()=>S0,Cache:()=>ti,Camera:()=>fs,CameraHelper:()=>vf,CanvasTexture:()=>Ph,CapsuleGeometry:()=>bc,CatmullRomCurve3:()=>gc,CineonToneMapping:()=>v0,CircleGeometry:()=>wc,ClampToEdgeWrapping:()=>yn,Clock:()=>ru,Color:()=>we,ColorKeyframeTrack:()=>Jo,ColorManagement:()=>at,CompressedArrayTexture:()=>Ch,CompressedCubeTexture:()=>Rh,CompressedTexture:()=>ys,CompressedTextureLoader:()=>Fh,ConeGeometry:()=>Mc,ConstantAlphaFactor:()=>s0,ConstantColorFactor:()=>i0,CubeCamera:()=>Ql,CubeReflectionMapping:()=>oi,CubeRefractionMapping:()=>Ii,CubeTexture:()=>dr,CubeTextureLoader:()=>kh,CubeUVReflectionMapping:()=>xs,CubicBezierCurve:()=>ko,CubicBezierCurve3:()=>yc,CubicInterpolant:()=>$c,CullFaceBack:()=>Cd,CullFaceFront:()=>Vg,CullFaceFrontBack:()=>Ub,CullFaceNone:()=>zg,Curve:()=>an,CurvePath:()=>xc,CustomBlending:()=>Gg,CustomToneMapping:()=>x0,CylinderGeometry:()=>_s,Cylindrical:()=>lf,Data3DTexture:()=>Io,DataArrayTexture:()=>us,DataTexture:()=>Un,DataTextureLoader:()=>Bh,DataUtils:()=>Gw,DecrementStencilOp:()=>Xb,DecrementWrapStencilOp:()=>qb,DefaultLoadingManager:()=>dy,DepthFormat:()=>ar,DepthStencilFormat:()=>ls,DepthTexture:()=>Lo,DetachedBindMode:()=>M0,DirectionalLight:()=>Zc,DirectionalLightHelper:()=>yf,DiscreteInterpolant:()=>Wc,DisplayP3ColorSpace:()=>uu,DodecahedronGeometry:()=>Sc,DoubleSide:()=>Ln,DstAlphaFactor:()=>Kg,DstColorFactor:()=>e0,DynamicCopyUsage:()=>uw,DynamicDrawUsage:()=>rw,DynamicReadUsage:()=>aw,EdgesGeometry:()=>Ac,EllipseCurve:()=>vs,EqualCompare:()=>V0,EqualDepth:()=>u0,EqualStencilFunc:()=>Qb,EquirectangularReflectionMapping:()=>mo,EquirectangularRefractionMapping:()=>go,Euler:()=>sn,EventDispatcher:()=>Tn,ExtrudeGeometry:()=>Ec,FileLoader:()=>In,Float16BufferAttribute:()=>mh,Float32BufferAttribute:()=>Te,FloatType:()=>vn,Fog:()=>ic,FogExp2:()=>nc,FramebufferTexture:()=>Ih,FrontSide:()=>si,Frustum:()=>hr,GLBufferAttribute:()=>rf,GLSL1:()=>hw,GLSL3:()=>ah,GreaterCompare:()=>H0,GreaterDepth:()=>h0,GreaterEqualCompare:()=>$0,GreaterEqualDepth:()=>d0,GreaterEqualStencilFunc:()=>iw,GreaterStencilFunc:()=>tw,GridHelper:()=>mf,Group:()=>Ti,HalfFloatType:()=>ia,HemisphereLight:()=>Xc,HemisphereLightHelper:()=>pf,IcosahedronGeometry:()=>Tc,ImageBitmapLoader:()=>Wh,ImageLoader:()=>xr,ImageUtils:()=>Jl,IncrementStencilOp:()=>jb,IncrementWrapStencilOp:()=>Yb,InstancedBufferAttribute:()=>Ri,InstancedBufferGeometry:()=>nu,InstancedInterleavedBuffer:()=>nf,InstancedMesh:()=>cc,Int16BufferAttribute:()=>fh,Int32BufferAttribute:()=>ph,Int8BufferAttribute:()=>uh,IntType:()=>Cf,InterleavedBuffer:()=>gs,InterleavedBufferAttribute:()=>fr,Interpolant:()=>gr,InterpolateDiscrete:()=>_o,InterpolateLinear:()=>xo,InterpolateSmooth:()=>Yl,InvertStencilOp:()=>Zb,KeepStencilOp:()=>er,KeyframeTrack:()=>ln,LOD:()=>oc,LatheGeometry:()=>Go,Layers:()=>ds,LessCompare:()=>z0,LessDepth:()=>c0,LessEqualCompare:()=>Ff,LessEqualDepth:()=>po,LessEqualStencilFunc:()=>ew,LessStencilFunc:()=>Kb,Light:()=>Bn,LightProbe:()=>eu,Line:()=>kn,Line3:()=>uf,LineBasicMaterial:()=>Ut,LineCurve:()=>Bo,LineCurve3:()=>vc,LineDashedMaterial:()=>Gc,LineLoop:()=>fc,LineSegments:()=>_n,LinearDisplayP3ColorSpace:()=>ra,LinearFilter:()=>wt,LinearInterpolant:()=>Zo,LinearMipMapLinearFilter:()=>zb,LinearMipMapNearestFilter:()=>Bb,LinearMipmapLinearFilter:()=>Dn,LinearMipmapNearestFilter:()=>lo,LinearSRGBColorSpace:()=>ui,LinearToneMapping:()=>g0,LinearTransfer:()=>wo,Loader:()=>Gt,LoaderUtils:()=>ea,LoadingManager:()=>Ko,LoopOnce:()=>D0,LoopPingPong:()=>U0,LoopRepeat:()=>O0,LuminanceAlphaFormat:()=>R0,LuminanceFormat:()=>C0,MOUSE:()=>Db,Material:()=>Dt,MaterialLoader:()=>tu,MathUtils:()=>Cw,Matrix3:()=>He,Matrix4:()=>Ne,MaxEquation:()=>Xg,Mesh:()=>vt,MeshBasicMaterial:()=>Fn,MeshDepthMaterial:()=>Do,MeshDistanceMaterial:()=>Oo,MeshLambertMaterial:()=>Vc,MeshMatcapMaterial:()=>Hc,MeshNormalMaterial:()=>zc,MeshPhongMaterial:()=>kc,MeshPhysicalMaterial:()=>Fc,MeshStandardMaterial:()=>qo,MeshToonMaterial:()=>Bc,MinEquation:()=>jg,MirroredRepeatWrapping:()=>vo,MixOperation:()=>p0,MultiplyBlending:()=>Ld,MultiplyOperation:()=>na,NearestFilter:()=>Pt,NearestMipMapLinearFilter:()=>kb,NearestMipMapNearestFilter:()=>Fb,NearestMipmapLinearFilter:()=>ns,NearestMipmapNearestFilter:()=>Tf,NeutralToneMapping:()=>w0,NeverCompare:()=>B0,NeverDepth:()=>a0,NeverStencilFunc:()=>Jb,NoBlending:()=>ni,NoColorSpace:()=>Jn,NoToneMapping:()=>ii,NormalAnimationBlendMode:()=>cu,NormalBlending:()=>or,NotEqualCompare:()=>G0,NotEqualDepth:()=>f0,NotEqualStencilFunc:()=>nw,NumberKeyframeTrack:()=>yr,Object3D:()=>rt,ObjectLoader:()=>$h,ObjectSpaceNormalMap:()=>k0,OctahedronGeometry:()=>Xo,OneFactor:()=>qg,OneMinusConstantAlphaFactor:()=>o0,OneMinusConstantColorFactor:()=>r0,OneMinusDstAlphaFactor:()=>Qg,OneMinusDstColorFactor:()=>t0,OneMinusSrcAlphaFactor:()=>Zl,OneMinusSrcColorFactor:()=>Jg,OrthographicCamera:()=>ms,P3Primaries:()=>So,PCFShadowMap:()=>Ef,PCFSoftShadowMap:()=>Hg,PMREMGenerator:()=>Po,Path:()=>pr,PerspectiveCamera:()=>Et,Plane:()=>Pn,PlaneGeometry:()=>ps,PlaneHelper:()=>bf,PointLight:()=>qc,PointLightHelper:()=>ff,Points:()=>pc,PointsMaterial:()=>Fo,PolarGridHelper:()=>gf,PolyhedronGeometry:()=>Pi,PositionalAudio:()=>qh,PropertyBinding:()=>ot,PropertyMixer:()=>ou,QuadraticBezierCurve:()=>zo,QuadraticBezierCurve3:()=>Vo,Quaternion:()=>Ht,QuaternionKeyframeTrack:()=>Li,QuaternionLinearInterpolant:()=>jc,RED_GREEN_RGTC2_Format:()=>rh,RED_RGTC1_Format:()=>L0,REVISION:()=>Lb,RGBADepthPacking:()=>F0,RGBAFormat:()=>tn,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:()=>Xl,RGBA_ETC2_EAC_Format:()=>zd,RGBA_PVRTC_2BPPV1_Format:()=>Fd,RGBA_PVRTC_4BPPV1_Format:()=>Nd,RGBA_S3TC_DXT1_Format:()=>$l,RGBA_S3TC_DXT3_Format:()=>Wl,RGBA_S3TC_DXT5_Format:()=>jl,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:()=>Gl,RGFormat:()=>P0,RGIntegerFormat:()=>Of,RawShaderMaterial:()=>Nc,Ray:()=>Ci,Raycaster:()=>sf,Rec709Primaries:()=>Mo,RectAreaLight:()=>Kc,RedFormat:()=>Lf,RedIntegerFormat:()=>Df,ReinhardToneMapping:()=>y0,RenderTarget:()=>Kl,RepeatWrapping:()=>yo,ReplaceStencilOp:()=>Wb,ReverseSubtractEquation:()=>Wg,RingGeometry:()=>Ic,SIGNED_RED_GREEN_RGTC2_Format:()=>sh,SIGNED_RED_RGTC1_Format:()=>ih,SRGBColorSpace:()=>gn,SRGBTransfer:()=>dt,Scene:()=>rc,ShaderChunk:()=>We,ShaderLib:()=>En,ShaderMaterial:()=>on,ShadowMaterial:()=>Uc,Shape:()=>ri,ShapeGeometry:()=>Cc,ShapePath:()=>Sf,ShapeUtils:()=>Nn,ShortType:()=>A0,Skeleton:()=>lc,SkeletonHelper:()=>hf,SkinnedMesh:()=>ac,Source:()=>Qn,Sphere:()=>Lt,SphereGeometry:()=>Yo,Spherical:()=>af,SphericalHarmonics3:()=>Qc,SplineCurve:()=>Ho,SpotLight:()=>Yc,SpotLightHelper:()=>df,Sprite:()=>sc,SpriteMaterial:()=>Uo,SrcAlphaFactor:()=>ql,SrcAlphaSaturateFactor:()=>n0,SrcColorFactor:()=>Zg,StaticCopyUsage:()=>cw,StaticDrawUsage:()=>Ao,StaticReadUsage:()=>ow,StereoCamera:()=>Xh,StreamCopyUsage:()=>dw,StreamDrawUsage:()=>sw,StreamReadUsage:()=>lw,StringKeyframeTrack:()=>ci,SubtractEquation:()=>$g,SubtractiveBlending:()=>Pd,TOUCH:()=>Ob,TangentSpaceNormalMap:()=>Di,TetrahedronGeometry:()=>Rc,Texture:()=>Mt,TextureLoader:()=>zh,TorusGeometry:()=>Pc,TorusKnotGeometry:()=>Lc,Triangle:()=>ei,TriangleFanDrawMode:()=>Gb,TriangleStripDrawMode:()=>Hb,TrianglesDrawMode:()=>Vb,TubeGeometry:()=>Dc,UVMapping:()=>lu,Uint16BufferAttribute:()=>Co,Uint32BufferAttribute:()=>Ro,Uint8BufferAttribute:()=>dh,Uint8ClampedBufferAttribute:()=>hh,Uniform:()=>ef,UniformsGroup:()=>tf,UniformsLib:()=>ve,UniformsUtils:()=>J0,UnsignedByteType:()=>ai,UnsignedInt248Type:()=>bs,UnsignedInt5999Type:()=>E0,UnsignedIntType:()=>cr,UnsignedShort4444Type:()=>Rf,UnsignedShort5551Type:()=>Pf,UnsignedShortType:()=>If,VSMShadowMap:()=>Rn,Vector2:()=>ne,Vector3:()=>T,Vector4:()=>lt,VectorKeyframeTrack:()=>vr,VideoTexture:()=>Th,WebGL3DRenderTarget:()=>ch,WebGLArrayRenderTarget:()=>lh,WebGLCoordinateSystem:()=>On,WebGLCubeRenderTarget:()=>ec,WebGLMultipleRenderTargets:()=>Af,WebGLRenderTarget:()=>rn,WebGLRenderer:()=>Sh,WebGLUtils:()=>ry,WebGPUCoordinateSystem:()=>Eo,WireframeGeometry:()=>Oc,WrapAroundEnding:()=>bo,ZeroCurvatureEnding:()=>ir,ZeroFactor:()=>Yg,ZeroSlopeEnding:()=>rr,ZeroStencilOp:()=>$b,createCanvasElement:()=>X0});function nn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Bt[n&255]+Bt[n>>8&255]+Bt[n>>16&255]+Bt[n>>24&255]+"-"+Bt[e&255]+Bt[e>>8&255]+"-"+Bt[e>>16&15|64]+Bt[e>>24&255]+"-"+Bt[t&63|128]+Bt[t>>8&255]+"-"+Bt[t>>16&255]+Bt[t>>24&255]+Bt[i&255]+Bt[i>>8&255]+Bt[i>>16&255]+Bt[i>>24&255]).toLowerCase()}function yt(n,e,t){return Math.max(e,Math.min(t,n))}function kf(n,e){return(n%e+e)%e}function fw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function pw(n,e,t){return n!==e?(t-n)/(e-n):0}function co(n,e,t){return(1-t)*n+t*e}function mw(n,e,t,i){return co(n,e,1-Math.exp(-t*i))}function gw(n,e=1){return e-Math.abs(kf(n,e*2)-e)}function yw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function vw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function _w(n,e){return n+Math.floor(Math.random()*(e-n+1))}function xw(n,e){return n+Math.random()*(e-n)}function bw(n){return n*(.5-Math.random())}function ww(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 Mw(n){return n*lr}function Sw(n){return n*cs}function Aw(n){return(n&n-1)===0&&n!==0}function Ew(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Tw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Iw(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),m=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*m,l*f,a*c);break;case"YXY":n.set(l*f,a*u,l*m,a*c);break;case"ZYZ":n.set(l*m,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function jt(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 Ge(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 is(n,e){return new Rw[n](e)}function To(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function X0(){let n=To("canvas");return n.style.display="block",n}function Y0(n){n in cm||(cm[n]=!0,console.warn(n))}function os(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?Jl.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){Gi.fromArray(n,s);let a=r.x*Math.abs(Gi.x)+r.y*Math.abs(Gi.y)+r.z*Math.abs(Gi.z),l=e.dot(Gi),c=t.dot(Gi),u=i.dot(Gi);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 Hw(){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 qt(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=yt(n,-65504,65504),Kn.floatView[0]=n;let e=Kn.uint32View[0],t=e>>23&511;return Kn.baseTable[t]+((e&8388607)>>Kn.shiftTable[t])}function oo(n){let e=n>>10;return Kn.uint32View[0]=Kn.mantissaTable[Kn.offsetTable[e]+(n&1023)]+Kn.exponentTable[e],Kn.floatView[0]}function Ww(n,e,t,i,r,s,o,a){let l;if(e.side===Xt?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===si,a),l===null)return null;fl.copy(a),fl.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(fl);return c<t.near||c>t.far?null:{distance:c,point:fl.clone(),object:n}}function pl(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,$r),n.getVertexPosition(l,Wr),n.getVertexPosition(c,jr);let u=Ww(n,e,t,i,$r,Wr,jr,hl);if(u){r&&(cl.fromBufferAttribute(r,a),ul.fromBufferAttribute(r,l),dl.fromBufferAttribute(r,c),u.uv=ei.getInterpolation(hl,$r,Wr,jr,cl,ul,dl,new ne)),s&&(cl.fromBufferAttribute(s,a),ul.fromBufferAttribute(s,l),dl.fromBufferAttribute(s,c),u.uv1=ei.getInterpolation(hl,$r,Wr,jr,cl,ul,dl,new ne)),o&&(Mm.fromBufferAttribute(o,a),Sm.fromBufferAttribute(o,l),Am.fromBufferAttribute(o,c),u.normal=ei.getInterpolation(hl,$r,Wr,jr,Mm,Sm,Am,new T),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new T,materialIndex:0};ei.getNormal($r,Wr,jr,d.normal),u.face=d}return u}function hs(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 Wt(n){let e={};for(let t=0;t<n.length;t++){let i=hs(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 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,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 Jw(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,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(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 L1(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 m(_){let v=_.isScene===!0?_.background:null;return v&&v.isTexture&&(v=(_.backgroundBlurriness>0?t:e).get(v)),v}function y(_){let v=!1,w=m(_);w===null?p(a,l):w&&w.isColor&&(p(w,1),v=!0);let P=n.xr.getEnvironmentBlendMode();P==="additive"?i.buffers.color.setClear(0,0,0,1,o):P==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(_,v){let w=m(v);w&&(w.isCubeTexture||w.mapping===xs)?(u===void 0&&(u=new vt(new ur(1,1,1),new on({name:"BackgroundCubeMaterial",uniforms:hs(En.backgroundCube.uniforms),vertexShader:En.backgroundCube.vertexShader,fragmentShader:En.backgroundCube.fragmentShader,side:Xt,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,A,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),ji.copy(v.backgroundRotation),ji.x*=-1,ji.y*=-1,ji.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(ji.y*=-1,ji.z*=-1),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(P1.makeRotationFromEuler(ji)),u.material.toneMapped=at.getTransfer(w.colorSpace)!==dt,(d!==w||h!==w.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),u.layers.enableAll(),_.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new vt(new ps(2,2),new on({name:"BackgroundMaterial",uniforms:hs(En.background.uniforms),vertexShader:En.background.vertexShader,fragmentShader:En.background.fragmentShader,side:si,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=w,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=at.getTransfer(w.colorSpace)!==dt,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||h!==w.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function p(_,v){_.getRGB(gl,Z0(n)),i.buffers.color.setClear(gl.r,gl.g,gl.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(_,v=1){a.set(_),l=v,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(_){l=_,p(a,l)},render:y,addToRenderList:g}}function D1(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(x,R,U,D,$){let j=!1,N=d(D,U,R);s!==N&&(s=N,c(s.object)),j=f(x,D,U,$),j&&m(x,D,U,$),$!==null&&e.update($,n.ELEMENT_ARRAY_BUFFER),(j||o)&&(o=!1,w(x,R,U,D),$!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function l(){return n.createVertexArray()}function c(x){return n.bindVertexArray(x)}function u(x){return n.deleteVertexArray(x)}function d(x,R,U){let D=U.wireframe===!0,$=i[x.id];$===void 0&&($={},i[x.id]=$);let j=$[R.id];j===void 0&&(j={},$[R.id]=j);let N=j[D];return N===void 0&&(N=h(l()),j[D]=N),N}function h(x){let R=[],U=[],D=[];for(let $=0;$<t;$++)R[$]=0,U[$]=0,D[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:U,attributeDivisors:D,object:x,attributes:{},index:null}}function f(x,R,U,D){let $=s.attributes,j=R.attributes,N=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let ce=$[k],Me=j[k];if(Me===void 0&&(k==="instanceMatrix"&&x.instanceMatrix&&(Me=x.instanceMatrix),k==="instanceColor"&&x.instanceColor&&(Me=x.instanceColor)),ce===void 0||ce.attribute!==Me||Me&&ce.data!==Me.data)return!0;N++}return s.attributesNum!==N||s.index!==D}function m(x,R,U,D){let $={},j=R.attributes,N=0,X=U.getAttributes();for(let k in X)if(X[k].location>=0){let ce=j[k];ce===void 0&&(k==="instanceMatrix"&&x.instanceMatrix&&(ce=x.instanceMatrix),k==="instanceColor"&&x.instanceColor&&(ce=x.instanceColor));let Me={};Me.attribute=ce,ce&&ce.data&&(Me.data=ce.data),$[k]=Me,N++}s.attributes=$,s.attributesNum=N,s.index=D}function y(){let x=s.newAttributes;for(let R=0,U=x.length;R<U;R++)x[R]=0}function g(x){p(x,0)}function p(x,R){let U=s.newAttributes,D=s.enabledAttributes,$=s.attributeDivisors;U[x]=1,D[x]===0&&(n.enableVertexAttribArray(x),D[x]=1),$[x]!==R&&(n.vertexAttribDivisor(x,R),$[x]=R)}function _(){let x=s.newAttributes,R=s.enabledAttributes;for(let U=0,D=R.length;U<D;U++)R[U]!==x[U]&&(n.disableVertexAttribArray(U),R[U]=0)}function v(x,R,U,D,$,j,N){N===!0?n.vertexAttribIPointer(x,R,U,$,j):n.vertexAttribPointer(x,R,U,D,$,j)}function w(x,R,U,D){y();let $=D.attributes,j=U.getAttributes(),N=R.defaultAttributeValues;for(let X in j){let k=j[X];if(k.location>=0){let le=$[X];if(le===void 0&&(X==="instanceMatrix"&&x.instanceMatrix&&(le=x.instanceMatrix),X==="instanceColor"&&x.instanceColor&&(le=x.instanceColor)),le!==void 0){let ce=le.normalized,Me=le.itemSize,Fe=e.get(le);if(Fe===void 0)continue;let Ke=Fe.buffer,J=Fe.type,Z=Fe.bytesPerElement,me=J===n.INT||J===n.UNSIGNED_INT||le.gpuType===Cf;if(le.isInterleavedBufferAttribute){let ie=le.data,ke=ie.stride,xe=le.offset;if(ie.isInstancedInterleavedBuffer){for(let z=0;z<k.locationSize;z++)p(k.location+z,ie.meshPerAttribute);x.isInstancedMesh!==!0&&D._maxInstanceCount===void 0&&(D._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let z=0;z<k.locationSize;z++)g(k.location+z);n.bindBuffer(n.ARRAY_BUFFER,Ke);for(let z=0;z<k.locationSize;z++)v(k.location+z,Me/k.locationSize,J,ce,ke*Z,(xe+Me/k.locationSize*z)*Z,me)}else{if(le.isInstancedBufferAttribute){for(let ie=0;ie<k.locationSize;ie++)p(k.location+ie,le.meshPerAttribute);x.isInstancedMesh!==!0&&D._maxInstanceCount===void 0&&(D._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ie=0;ie<k.locationSize;ie++)g(k.location+ie);n.bindBuffer(n.ARRAY_BUFFER,Ke);for(let ie=0;ie<k.locationSize;ie++)v(k.location+ie,Me/k.locationSize,J,ce,Me*Z,Me/k.locationSize*ie*Z,me)}}else if(N!==void 0){let ce=N[X];if(ce!==void 0)switch(ce.length){case 2:n.vertexAttrib2fv(k.location,ce);break;case 3:n.vertexAttrib3fv(k.location,ce);break;case 4:n.vertexAttrib4fv(k.location,ce);break;default:n.vertexAttrib1fv(k.location,ce)}}}}_()}function P(){L();for(let x in i){let R=i[x];for(let U in R){let D=R[U];for(let $ in D)u(D[$].object),delete D[$];delete R[U]}delete i[x]}}function A(x){if(i[x.id]===void 0)return;let R=i[x.id];for(let U in R){let D=R[U];for(let $ in D)u(D[$].object),delete D[$];delete R[U]}delete i[x.id]}function E(x){for(let R in i){let U=i[R];if(U[x.id]===void 0)continue;let D=U[x.id];for(let $ in D)u(D[$].object),delete D[$];delete U[x.id]}}function L(){b(),o=!0,s!==r&&(s=r,c(s.object))}function b(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:L,resetDefaultState:b,dispose:P,releaseStatesOfGeometry:A,releaseStatesOfProgram:E,initAttributes:y,enableAttribute:g,disableUnusedAttributes:_}}function O1(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 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++)o(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=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function U1(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!==tn&&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!==ai&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==vn&&!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),_=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),w=f>0,P=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:m,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:p,maxVaryings:_,maxFragmentUniforms:v,vertexTextures:w,maxSamples:P}}function N1(n){let e=this,t=null,i=0,r=!1,s=!1,o=new Pn,a=new He,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 _=s?0:i,v=_*4,w=p.clippingState||null;l.value=w,w=u(m,h,v,f);for(let P=0;P!==v;++P)w[P]=t[P];p.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=_}};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,_=h.matrixWorldInverse;a.getNormalMatrix(_),(g===null||g.length<p)&&(g=new Float32Array(p));for(let v=0,w=f;v!==y;++v,w+=4)o.copy(d[v]).applyMatrix4(_,a),o.normal.toArray(g,w),g[w+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function F1(n){let e=new WeakMap;function t(o,a){return a===mo?o.mapping=oi:a===go&&(o.mapping=Ii),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 ec(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 k1(n){let e=[],t=[],i=[],r=n,s=n-rs+1+Im.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let l=1/a;o>n-rs?l=Im[o-n+rs-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,m=6,y=3,g=2,p=1,_=new Float32Array(y*m*f),v=new Float32Array(g*m*f),w=new Float32Array(p*m*f);for(let A=0;A<f;A++){let E=A%3*2/3-1,L=A>2?0:-1,b=[E,L,0,E+2/3,L,0,E+2/3,L+1,0,E,L,0,E+2/3,L+1,0,E,L+1,0];_.set(b,y*m*A),v.set(h,g*m*A);let x=[A,A,A,A,A,A];w.set(x,p*m*A)}let P=new Ye;P.setAttribute("position",new nt(_,y)),P.setAttribute("uv",new nt(v,g)),P.setAttribute("faceIndex",new nt(w,p)),e.push(P),r>rs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Pm(n,e,t){let i=new rn(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function yl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function B1(n,e,t){let i=new Float32Array(nr),r=new T(0,1,0);return new on({name:"SphericalGaussianBlur",defines:{n:nr,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:ni,depthTest:!1,depthWrite:!1})}function Lm(){return new on({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:ni,depthTest:!1,depthWrite:!1})}function Dm(){return new on({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;
@@ -93,7 +93,7 @@
93
93
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
94
94
 
95
95
  }
96
- `,blending:ni,depthTest:!1,depthWrite:!1})}function Bf(){return`
96
+ `,blending:ti,depthTest:!1,depthWrite:!1})}function Bf(){return`
97
97
 
98
98
  precision mediump float;
99
99
  precision mediump int;
@@ -148,15 +148,15 @@
148
148
  gl_Position = vec4( position, 1.0 );
149
149
 
150
150
  }
151
- `}function z1(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===oi||l===Ii;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 V1(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 H1(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 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",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 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 _=f.array;y=f.version;for(let v=0,w=_.length;v<w;v+=3){let P=_[v+0],A=_[v+1],E=_[v+2];h.push(P,A,A,E,E,P)}}else if(m!==void 0){let _=m.array;y=m.version;for(let v=0,w=_.length/3-1;v<w;v+=3){let P=v+0,A=v+1,E=v+2;h.push(P,A,A,E,E,P)}}else return;let g=new(j0(h)?Ro:Co)(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:a,update:l,getWireframeAttribute:u}}function G1(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,m){m!==0&&(n.drawElementsInstanced(i,f,s,h*o,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]/o,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]/o,f[p],y[p]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,m);let p=0;for(let _=0;_<m;_++)p+=f[_];for(let _=0;_<y.length;_++)t.update(p,i,y[_])}}this.setMode=r,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function $1(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 W1(n,e,t){let i=new WeakMap,r=new lt;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 x=function(){L.dispose(),i.delete(a),a.removeEventListener("dispose",x)};var f=x;h!==void 0&&h.texture.dispose();let m=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],_=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],w=0;m===!0&&(w=1),y===!0&&(w=2),g===!0&&(w=3);let P=a.attributes.position.count*w,A=1;P>e.maxTextureSize&&(A=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);let E=new Float32Array(P*A*4*d),L=new us(E,P,A,d);L.type=vn,L.needsUpdate=!0;let b=w*4;for(let R=0;R<d;R++){let U=p[R],D=_[R],$=v[R],j=P*A*4*R;for(let N=0;N<U.count;N++){let X=N*b;m===!0&&(r.fromBufferAttribute(U,N),E[j+X+0]=r.x,E[j+X+1]=r.y,E[j+X+2]=r.z,E[j+X+3]=0),y===!0&&(r.fromBufferAttribute(D,N),E[j+X+4]=r.x,E[j+X+5]=r.y,E[j+X+6]=r.z,E[j+X+7]=0),g===!0&&(r.fromBufferAttribute($,N),E[j+X+8]=r.x,E[j+X+9]=r.y,E[j+X+10]=r.z,E[j+X+11]=$.itemSize===4?r.w:1)}}h={count:d,texture:L,size:new ne(P,A)},i.set(a,h),a.addEventListener("dispose",x)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let m=0;for(let g=0;g<c.length;g++)m+=c[g];let y=a.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 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 ws(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 o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Tt(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 It(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function du(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 X1(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Y1(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(Tt(t,e))return;n.uniform2fv(this.addr,e),It(t,e)}}function q1(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(Tt(t,e))return;n.uniform3fv(this.addr,e),It(t,e)}}function Z1(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(Tt(t,e))return;n.uniform4fv(this.addr,e),It(t,e)}}function J1(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Tt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),It(t,e)}else{if(Tt(t,i))return;km.set(i),n.uniformMatrix2fv(this.addr,!1,km),It(t,i)}}function K1(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Tt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),It(t,e)}else{if(Tt(t,i))return;Fm.set(i),n.uniformMatrix3fv(this.addr,!1,Fm),It(t,i)}}function Q1(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Tt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),It(t,e)}else{if(Tt(t,i))return;Nm.set(i),n.uniformMatrix4fv(this.addr,!1,Nm),It(t,i)}}function eA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function tA(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(Tt(t,e))return;n.uniform2iv(this.addr,e),It(t,e)}}function nA(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(Tt(t,e))return;n.uniform3iv(this.addr,e),It(t,e)}}function iA(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(Tt(t,e))return;n.uniform4iv(this.addr,e),It(t,e)}}function rA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function sA(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(Tt(t,e))return;n.uniform2uiv(this.addr,e),It(t,e)}}function oA(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(Tt(t,e))return;n.uniform3uiv(this.addr,e),It(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||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(Tt(t,e))return;n.uniform4uiv(this.addr,e),It(t,e)}}function lA(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 cA(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 uA(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 dA(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 hA(n){switch(n){case 5126:return X1;case 35664:return Y1;case 35665:return q1;case 35666:return Z1;case 35674:return J1;case 35675:return K1;case 35676:return Q1;case 5124:case 35670:return eA;case 35667:case 35671:return tA;case 35668:case 35672:return nA;case 35669:case 35673:return iA;case 5125:return rA;case 36294:return sA;case 36295:return oA;case 36296:return aA;case 35678:case 36198:case 36298:case 36306:case 35682:return lA;case 35679:case 36299:case 36307:return cA;case 35680:case 36300:case 36308:case 36293:return uA;case 36289:case 36303:case 36311:case 36292:return dA}}function fA(n,e){n.uniform1fv(this.addr,e)}function pA(n,e){let t=ws(e,this.size,2);n.uniform2fv(this.addr,t)}function mA(n,e){let t=ws(e,this.size,3);n.uniform3fv(this.addr,t)}function gA(n,e){let t=ws(e,this.size,4);n.uniform4fv(this.addr,t)}function yA(n,e){let t=ws(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function vA(n,e){let t=ws(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function _A(n,e){let t=ws(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function xA(n,e){n.uniform1iv(this.addr,e)}function bA(n,e){n.uniform2iv(this.addr,e)}function wA(n,e){n.uniform3iv(this.addr,e)}function MA(n,e){n.uniform4iv(this.addr,e)}function SA(n,e){n.uniform1uiv(this.addr,e)}function AA(n,e){n.uniform2uiv(this.addr,e)}function EA(n,e){n.uniform3uiv(this.addr,e)}function TA(n,e){n.uniform4uiv(this.addr,e)}function IA(n,e,t){let i=this.cache,r=e.length,s=du(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||Q0,s[o])}function CA(n,e,t){let i=this.cache,r=e.length,s=du(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||ny,s[o])}function RA(n,e,t){let i=this.cache,r=e.length,s=du(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||iy,s[o])}function PA(n,e,t){let i=this.cache,r=e.length,s=du(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||ty,s[o])}function LA(n){switch(n){case 5126:return fA;case 35664:return pA;case 35665:return mA;case 35666:return gA;case 35674:return yA;case 35675:return vA;case 35676:return _A;case 5124:case 35670:return xA;case 35667:case 35671:return bA;case 35668:case 35672:return wA;case 35669:case 35673:return MA;case 5125:return SA;case 36294:return AA;case 36295:return EA;case 36296:return TA;case 35678:case 36198:case 36298:case 36306:case 35682:return IA;case 35679:case 36299:case 36307:return CA;case 35680:case 36300:case 36308:case 36293:return RA;case 36289:case 36303:case 36311:case 36292:return PA}}function Bm(n,e){n.seq.push(e),n.map[e.id]=e}function DA(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){Bm(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),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 NA(n,e){let t=n.split(`
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
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 FA(n){let e=at.getPrimaries(at.workingColorSpace),t=at.getPrimaries(n),i;switch(e===t?i="":e===So&&t===Mo?i="LinearDisplayP3ToLinearSRGB":e===Mo&&t===So&&(i="LinearSRGBToLinearDisplayP3"),n){case ui:case ra:return[i,"LinearTransferOETF"];case gn:case uu: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 o=parseInt(s[1]);return t.toUpperCase()+`
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
- `+NA(n.getShaderSource(e),o)}else return r}function kA(n,e){let t=FA(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function BA(n,e){let t;switch(e){case g0:t="Linear";break;case y0:t="Reinhard";break;case v0:t="OptimizedCineon";break;case _0:t="ACESFilmic";break;case b0:t="AgX";break;case w0:t="Neutral";break;case x0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function zA(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ao).join(`
158
- `)}function VA(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
159
- `)}function HA(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 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 _h(n){return n.replace(GA,WA)}function WA(n,e){let t=We[e];if(t===void 0){let i=$A.get(e);if(i!==void 0)t=We[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 _h(t)}function $m(n){return n.replace(jA,XA)}function XA(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 YA(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Ef?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Hg?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Rn&&(e="SHADOWMAP_TYPE_VSM"),e}function qA(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case oi:case Ii:e="ENVMAP_TYPE_CUBE";break;case xs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ZA(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Ii&&(e="ENVMAP_MODE_REFRACTION"),e}function JA(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case na:e="ENVMAP_BLENDING_MULTIPLY";break;case p0:e="ENVMAP_BLENDING_MIX";break;case m0:e="ENVMAP_BLENDING_ADD";break}return e}function KA(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 QA(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=YA(t),c=qA(t),u=ZA(t),d=JA(t),h=KA(t),f=zA(t),m=VA(s),y=r.createProgram(),g,p,_=t.glslVersion?"#version "+t.glslVersion+`
180
- `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(ao).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(ao).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",`
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
185
  `].filter(ao).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!==ii?"#define TONE_MAPPING":"",t.toneMapping!==ii?We.tonemapping_pars_fragment:"",t.toneMapping!==ii?BA("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,kA("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
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
187
  `].filter(ao).join(`
188
- `)),o=_h(o),o=Hm(o,t),o=Gm(o,t),a=_h(a),a=Hm(a,t),a=Gm(a,t),o=$m(o),a=$m(a),t.isRawShaderMaterial!==!0&&(_=`#version 300 es
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===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(`
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=_+g+o,w=_+p+a,P=zm(r,r.VERTEX_SHADER,v),A=zm(r,r.FRAGMENT_SHADER,w);r.attachShader(y,P),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(R){if(n.debug.checkShaderErrors){let U=r.getProgramInfoLog(y).trim(),D=r.getShaderInfoLog(P).trim(),$=r.getShaderInfoLog(A).trim(),j=!0,N=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(j=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,P,A);else{let X=Vm(r,P,"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
- Material Name: `+R.name+`
196
- Material Type: `+R.type+`
195
+ Material Name: `+T.name+`
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):(D===""||$==="")&&(N=!1);N&&(R.diagnostics={runnable:j,programLog:U,vertexShader:{log:D,prefix:g},fragmentShader:{log:$,prefix:p}})}r.deleteShader(P),r.deleteShader(A),L=new as(r,y),b=HA(r,y)}let L;this.getUniforms=function(){return L===void 0&&E(this),L};let b;this.getAttributes=function(){return b===void 0&&E(this),b};let x=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return x===!1&&(x=r.getProgramParameter(y,OA)),x},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=UA++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=P,this.fragmentShader=A,this}function tE(n,e,t,i,r,s,o){let a=new ds,l=new xh,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(b){return c.add(b),b===0?"uv":`uv${b}`}function g(b,x,R,U,D){let $=U.fog,j=D.geometry,N=b.isMeshStandardMaterial?U.environment:null,X=(b.isMeshStandardMaterial?t:e).get(b.envMap||N),k=X&&X.mapping===xs?X.image.height:null,le=m[b.type];b.precision!==null&&(f=r.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let ce=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Me=ce!==void 0?ce.length:0,Fe=0;j.morphAttributes.position!==void 0&&(Fe=1),j.morphAttributes.normal!==void 0&&(Fe=2),j.morphAttributes.color!==void 0&&(Fe=3);let Ke,J,Z,me;if(le){let tt=En[le];Ke=tt.vertexShader,J=tt.fragmentShader}else Ke=b.vertexShader,J=b.fragmentShader,l.update(b),Z=l.getVertexShaderID(b),me=l.getFragmentShaderID(b);let ie=n.getRenderTarget(),ke=D.isInstancedMesh===!0,xe=D.isBatchedMesh===!0,z=!!b.map,Ue=!!b.matcap,K=!!X,ue=!!b.aoMap,Q=!!b.lightMap,de=!!b.bumpMap,ae=!!b.normalMap,fe=!!b.displacementMap,Ee=!!b.emissiveMap,C=!!b.metalnessMap,S=!!b.roughnessMap,W=b.anisotropy>0,te=b.clearcoat>0,se=b.dispersion>0,re=b.iridescence>0,Re=b.sheen>0,ge=b.transmission>0,ye=W&&!!b.anisotropyMap,Be=te&&!!b.clearcoatMap,he=te&&!!b.clearcoatNormalMap,Pe=te&&!!b.clearcoatRoughnessMap,je=re&&!!b.iridescenceMap,Le=re&&!!b.iridescenceThicknessMap,Se=Re&&!!b.sheenColorMap,De=Re&&!!b.sheenRoughnessMap,Ze=!!b.specularMap,ft=!!b.specularColorMap,$e=!!b.specularIntensityMap,B=ge&&!!b.transmissionMap,oe=ge&&!!b.thicknessMap,ee=!!b.gradientMap,_e=!!b.alphaMap,be=b.alphaTest>0,Ae=!!b.alphaHash,Qe=!!b.extensions,ct=ii;b.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(ct=n.toneMapping);let pt={shaderID:le,shaderType:b.type,shaderName:b.name,vertexShader:Ke,fragmentShader:J,defines:b.defines,customVertexShaderID:Z,customFragmentShaderID:me,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:xe,instancing:ke,instancingColor:ke&&D.instanceColor!==null,instancingMorph:ke&&D.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ie===null?n.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:ui,alphaToCoverage:!!b.alphaToCoverage,map:z,matcap:Ue,envMap:K,envMapMode:K&&X.mapping,envMapCubeUVHeight:k,aoMap:ue,lightMap:Q,bumpMap:de,normalMap:ae,displacementMap:h&&fe,emissiveMap:Ee,normalMapObjectSpace:ae&&b.normalMapType===k0,normalMapTangentSpace:ae&&b.normalMapType===Di,metalnessMap:C,roughnessMap:S,anisotropy:W,anisotropyMap:ye,clearcoat:te,clearcoatMap:Be,clearcoatNormalMap:he,clearcoatRoughnessMap:Pe,dispersion:se,iridescence:re,iridescenceMap:je,iridescenceThicknessMap:Le,sheen:Re,sheenColorMap:Se,sheenRoughnessMap:De,specularMap:Ze,specularColorMap:ft,specularIntensityMap:$e,transmission:ge,transmissionMap:B,thicknessMap:oe,gradientMap:ee,opaque:b.transparent===!1&&b.blending===or&&b.alphaToCoverage===!1,alphaMap:_e,alphaTest:be,alphaHash:Ae,combine:b.combine,mapUv:z&&y(b.map.channel),aoMapUv:ue&&y(b.aoMap.channel),lightMapUv:Q&&y(b.lightMap.channel),bumpMapUv:de&&y(b.bumpMap.channel),normalMapUv:ae&&y(b.normalMap.channel),displacementMapUv:fe&&y(b.displacementMap.channel),emissiveMapUv:Ee&&y(b.emissiveMap.channel),metalnessMapUv:C&&y(b.metalnessMap.channel),roughnessMapUv:S&&y(b.roughnessMap.channel),anisotropyMapUv:ye&&y(b.anisotropyMap.channel),clearcoatMapUv:Be&&y(b.clearcoatMap.channel),clearcoatNormalMapUv:he&&y(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Pe&&y(b.clearcoatRoughnessMap.channel),iridescenceMapUv:je&&y(b.iridescenceMap.channel),iridescenceThicknessMapUv:Le&&y(b.iridescenceThicknessMap.channel),sheenColorMapUv:Se&&y(b.sheenColorMap.channel),sheenRoughnessMapUv:De&&y(b.sheenRoughnessMap.channel),specularMapUv:Ze&&y(b.specularMap.channel),specularColorMapUv:ft&&y(b.specularColorMap.channel),specularIntensityMapUv:$e&&y(b.specularIntensityMap.channel),transmissionMapUv:B&&y(b.transmissionMap.channel),thicknessMapUv:oe&&y(b.thicknessMap.channel),alphaMapUv:_e&&y(b.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(ae||W),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!j.attributes.uv&&(z||_e),fog:!!$,useFog:b.fog===!0,fogExp2:!!$&&$.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:D.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Fe,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&R.length>0,shadowMapType:n.shadowMap.type,toneMapping:ct,useLegacyLights:n._useLegacyLights,decodeVideoTexture:z&&b.map.isVideoTexture===!0&&at.getTransfer(b.map.colorSpace)===dt,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Ln,flipSided:b.side===Xt,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Qe&&b.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Qe&&b.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return pt.vertexUv1s=c.has(1),pt.vertexUv2s=c.has(2),pt.vertexUv3s=c.has(3),c.clear(),pt}function p(b){let x=[];if(b.shaderID?x.push(b.shaderID):(x.push(b.customVertexShaderID),x.push(b.customFragmentShaderID)),b.defines!==void 0)for(let R in b.defines)x.push(R),x.push(b.defines[R]);return b.isRawShaderMaterial===!1&&(_(x,b),v(x,b),x.push(n.outputColorSpace)),x.push(b.customProgramCacheKey),x.join()}function _(b,x){b.push(x.precision),b.push(x.outputColorSpace),b.push(x.envMapMode),b.push(x.envMapCubeUVHeight),b.push(x.mapUv),b.push(x.alphaMapUv),b.push(x.lightMapUv),b.push(x.aoMapUv),b.push(x.bumpMapUv),b.push(x.normalMapUv),b.push(x.displacementMapUv),b.push(x.emissiveMapUv),b.push(x.metalnessMapUv),b.push(x.roughnessMapUv),b.push(x.anisotropyMapUv),b.push(x.clearcoatMapUv),b.push(x.clearcoatNormalMapUv),b.push(x.clearcoatRoughnessMapUv),b.push(x.iridescenceMapUv),b.push(x.iridescenceThicknessMapUv),b.push(x.sheenColorMapUv),b.push(x.sheenRoughnessMapUv),b.push(x.specularMapUv),b.push(x.specularColorMapUv),b.push(x.specularIntensityMapUv),b.push(x.transmissionMapUv),b.push(x.thicknessMapUv),b.push(x.combine),b.push(x.fogExp2),b.push(x.sizeAttenuation),b.push(x.morphTargetsCount),b.push(x.morphAttributeCount),b.push(x.numDirLights),b.push(x.numPointLights),b.push(x.numSpotLights),b.push(x.numSpotLightMaps),b.push(x.numHemiLights),b.push(x.numRectAreaLights),b.push(x.numDirLightShadows),b.push(x.numPointLightShadows),b.push(x.numSpotLightShadows),b.push(x.numSpotLightShadowsWithMaps),b.push(x.numLightProbes),b.push(x.shadowMapType),b.push(x.toneMapping),b.push(x.numClippingPlanes),b.push(x.numClipIntersection),b.push(x.depthPacking)}function v(b,x){a.disableAll(),x.supportsVertexTextures&&a.enable(0),x.instancing&&a.enable(1),x.instancingColor&&a.enable(2),x.instancingMorph&&a.enable(3),x.matcap&&a.enable(4),x.envMap&&a.enable(5),x.normalMapObjectSpace&&a.enable(6),x.normalMapTangentSpace&&a.enable(7),x.clearcoat&&a.enable(8),x.iridescence&&a.enable(9),x.alphaTest&&a.enable(10),x.vertexColors&&a.enable(11),x.vertexAlphas&&a.enable(12),x.vertexUv1s&&a.enable(13),x.vertexUv2s&&a.enable(14),x.vertexUv3s&&a.enable(15),x.vertexTangents&&a.enable(16),x.anisotropy&&a.enable(17),x.alphaHash&&a.enable(18),x.batching&&a.enable(19),x.dispersion&&a.enable(20),b.push(a.mask),a.disableAll(),x.fog&&a.enable(0),x.useFog&&a.enable(1),x.flatShading&&a.enable(2),x.logarithmicDepthBuffer&&a.enable(3),x.skinning&&a.enable(4),x.morphTargets&&a.enable(5),x.morphNormals&&a.enable(6),x.morphColors&&a.enable(7),x.premultipliedAlpha&&a.enable(8),x.shadowMapEnabled&&a.enable(9),x.useLegacyLights&&a.enable(10),x.doubleSided&&a.enable(11),x.flipSided&&a.enable(12),x.useDepthPacking&&a.enable(13),x.dithering&&a.enable(14),x.transmission&&a.enable(15),x.sheen&&a.enable(16),x.opaque&&a.enable(17),x.pointsUvs&&a.enable(18),x.decodeVideoTexture&&a.enable(19),x.alphaToCoverage&&a.enable(20),b.push(a.mask)}function w(b){let x=m[b.type],R;if(x){let U=En[x];R=J0.clone(U.uniforms)}else R=b.uniforms;return R}function P(b,x){let R;for(let U=0,D=u.length;U<D;U++){let $=u[U];if($.cacheKey===x){R=$,++R.usedTimes;break}}return R===void 0&&(R=new QA(n,x,b,s),u.push(R)),R}function A(b){if(--b.usedTimes===0){let x=u.indexOf(b);u[x]=u[u.length-1],u.pop(),b.destroy()}}function E(b){l.remove(b)}function L(){l.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:w,acquireProgram:P,releaseProgram:A,releaseShaderCache:E,programs:u,dispose:L}}function nE(){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 iE(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 o(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 a(d,h,f,m,y,g){let p=o(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=o(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||iE),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:a,unshift:l,finish:u,sort:c}}function rE(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new Xm,n.set(i,[o])):r>=s.length?(o=new Xm,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function sE(){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 T,color:new we};break;case"SpotLight":t={position:new T,direction:new T,color:new we,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new T,color:new we,distance:0,decay:0};break;case"HemisphereLight":t={direction:new T,skyColor:new we,groundColor:new we};break;case"RectAreaLight":t={color:new we,position:new T,halfWidth:new T,halfHeight:new T};break}return n[e.id]=t,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={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function lE(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function cE(n){let e=new sE,t=oE(),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 T);let r=new T,s=new Ne,o=new Ne;function a(c,u){let d=0,h=0,f=0;for(let R=0;R<9;R++)i.probe[R].set(0,0,0);let m=0,y=0,g=0,p=0,_=0,v=0,w=0,P=0,A=0,E=0,L=0;c.sort(lE);let b=u===!0?Math.PI:1;for(let R=0,U=c.length;R<U;R++){let D=c[R],$=D.color,j=D.intensity,N=D.distance,X=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)d+=$.r*j*b,h+=$.g*j*b,f+=$.b*j*b;else if(D.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(D.sh.coefficients[k],j);L++}else if(D.isDirectionalLight){let k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity*b),D.castShadow){let le=D.shadow,ce=t.get(D);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,i.directionalShadow[m]=ce,i.directionalShadowMap[m]=X,i.directionalShadowMatrix[m]=D.shadow.matrix,v++}i.directional[m]=k,m++}else if(D.isSpotLight){let k=e.get(D);k.position.setFromMatrixPosition(D.matrixWorld),k.color.copy($).multiplyScalar(j*b),k.distance=N,k.coneCos=Math.cos(D.angle),k.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),k.decay=D.decay,i.spot[g]=k;let le=D.shadow;if(D.map&&(i.spotLightMap[A]=D.map,A++,le.updateMatrices(D),D.castShadow&&E++),i.spotLightMatrix[g]=le.matrix,D.castShadow){let ce=t.get(D);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,i.spotShadow[g]=ce,i.spotShadowMap[g]=X,P++}g++}else if(D.isRectAreaLight){let k=e.get(D);k.color.copy($).multiplyScalar(j),k.halfWidth.set(D.width*.5,0,0),k.halfHeight.set(0,D.height*.5,0),i.rectArea[p]=k,p++}else if(D.isPointLight){let k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity*b),k.distance=D.distance,k.decay=D.decay,D.castShadow){let le=D.shadow,ce=t.get(D);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,ce.shadowCameraNear=le.camera.near,ce.shadowCameraFar=le.camera.far,i.pointShadow[y]=ce,i.pointShadowMap[y]=X,i.pointShadowMatrix[y]=D.shadow.matrix,w++}i.point[y]=k,y++}else if(D.isHemisphereLight){let k=e.get(D);k.skyColor.copy(D.color).multiplyScalar(j*b),k.groundColor.copy(D.groundColor).multiplyScalar(j*b),i.hemi[_]=k,_++}}p>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ve.LTC_FLOAT_1,i.rectAreaLTC2=ve.LTC_FLOAT_2):(i.rectAreaLTC1=ve.LTC_HALF_1,i.rectAreaLTC2=ve.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let x=i.hash;(x.directionalLength!==m||x.pointLength!==y||x.spotLength!==g||x.rectAreaLength!==p||x.hemiLength!==_||x.numDirectionalShadows!==v||x.numPointShadows!==w||x.numSpotShadows!==P||x.numSpotMaps!==A||x.numLightProbes!==L)&&(i.directional.length=m,i.spot.length=g,i.rectArea.length=p,i.point.length=y,i.hemi.length=_,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=P,i.spotShadowMap.length=P,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=P+A-E,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=E,i.numLightProbes=L,x.directionalLength=m,x.pointLength=y,x.spotLength=g,x.rectAreaLength=p,x.hemiLength=_,x.numDirectionalShadows=v,x.numPointShadows=w,x.numSpotShadows=P,x.numSpotMaps=A,x.numLightProbes=L,i.version=aE++)}function l(c,u){let d=0,h=0,f=0,m=0,y=0,g=u.matrixWorldInverse;for(let p=0,_=c.length;p<_;p++){let v=c[p];if(v.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(v.isSpotLight){let w=i.spot[f];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let w=i.rectArea[m];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(v.width*.5,0,0),w.halfHeight.set(0,v.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),m++}else if(v.isPointLight){let w=i.point[h];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let w=i.hemi[y];w.direction.setFromMatrixPosition(v.matrixWorld),w.direction.transformDirection(g),y++}}}return{setup:a,setupView:l,state:i}}function Ym(n){let e=new cE(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 uE(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new Ym(n),e.set(r,[a])):s>=o.length?(a=new Ym(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function fE(n,e,t){let i=new hr,r=new ne,s=new ne,o=new lt,a=new Do({depthPacking:F0}),l=new Oo,c={},u=t.maxTextureSize,d={[si]:Xt,[Xt]:si,[Ln]:Ln},h=new on({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ne},radius:{value:4}},vertexShader:dE,fragmentShader:hE}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Ye;m.setAttribute("position",new nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new vt(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,L){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||A.length===0)return;let b=n.getRenderTarget(),x=n.getActiveCubeFace(),R=n.getActiveMipmapLevel(),U=n.state;U.setBlending(ni),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let D=p!==Rn&&this.type===Rn,$=p===Rn&&this.type!==Rn;for(let j=0,N=A.length;j<N;j++){let X=A[j],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 le=k.getFrameExtents();if(r.multiply(le),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,k.mapSize.y=s.y)),k.map===null||D===!0||$===!0){let Me=this.type!==Rn?{minFilter:Pt,magFilter:Pt}:{};k.map!==null&&k.map.dispose(),k.map=new rn(r.x,r.y,Me),k.map.texture.name=X.name+".shadowMap",k.camera.updateProjectionMatrix()}n.setRenderTarget(k.map),n.clear();let ce=k.getViewportCount();for(let Me=0;Me<ce;Me++){let Fe=k.getViewport(Me);o.set(s.x*Fe.x,s.y*Fe.y,s.x*Fe.z,s.y*Fe.w),U.viewport(o),k.updateMatrices(X,Me),i=k.getFrustum(),w(E,L,k.camera,X,this.type)}k.isPointLightShadow!==!0&&this.type===Rn&&_(k,L),k.needsUpdate=!1}p=this.type,g.needsUpdate=!1,n.setRenderTarget(b,x,R)};function _(A,E){let L=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 rn(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,L,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,L,f,y,null)}function v(A,E,L,b){let x=null,R=L.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)x=R;else if(x=L.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=x.uuid,D=E.uuid,$=c[U];$===void 0&&($={},c[U]=$);let j=$[D];j===void 0&&(j=x.clone(),$[D]=j,E.addEventListener("dispose",P)),x=j}if(x.visible=E.visible,x.wireframe=E.wireframe,b===Rn?x.side=E.shadowSide!==null?E.shadowSide:E.side:x.side=E.shadowSide!==null?E.shadowSide:d[E.side],x.alphaMap=E.alphaMap,x.alphaTest=E.alphaTest,x.map=E.map,x.clipShadows=E.clipShadows,x.clippingPlanes=E.clippingPlanes,x.clipIntersection=E.clipIntersection,x.displacementMap=E.displacementMap,x.displacementScale=E.displacementScale,x.displacementBias=E.displacementBias,x.wireframeLinewidth=E.wireframeLinewidth,x.linewidth=E.linewidth,L.isPointLight===!0&&x.isMeshDistanceMaterial===!0){let U=n.properties.get(x);U.light=L}return x}function w(A,E,L,b,x){if(A.visible===!1)return;if(A.layers.test(E.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&x===Rn)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,A.matrixWorld);let D=e.update(A),$=A.material;if(Array.isArray($)){let j=D.groups;for(let N=0,X=j.length;N<X;N++){let k=j[N],le=$[k.materialIndex];if(le&&le.visible){let ce=v(A,le,b,x);A.onBeforeShadow(n,A,E,L,D,ce,k),n.renderBufferDirect(L,null,D,ce,A,k),A.onAfterShadow(n,A,E,L,D,ce,k)}}}else if($.visible){let j=v(A,$,b,x);A.onBeforeShadow(n,A,E,L,D,j,null),n.renderBufferDirect(L,null,D,j,A,null),A.onAfterShadow(n,A,E,L,D,j,null)}}let U=A.children;for(let D=0,$=U.length;D<$;D++)w(U[D],E,L,b,x)}function P(A){A.target.removeEventListener("dispose",P);for(let L in c){let b=c[L],x=A.target.uuid;x in b&&(b[x].dispose(),delete b[x])}}}function pE(n){function e(){let B=!1,oe=new lt,ee=null,_e=new lt(0,0,0,0);return{setMask:function(be){ee!==be&&!B&&(n.colorMask(be,be,be,be),ee=be)},setLocked:function(be){B=be},setClear:function(be,Ae,Qe,ct,pt){pt===!0&&(be*=ct,Ae*=ct,Qe*=ct),oe.set(be,Ae,Qe,ct),_e.equals(oe)===!1&&(n.clearColor(be,Ae,Qe,ct),_e.copy(oe))},reset:function(){B=!1,ee=null,_e.set(-1,0,0,0)}}}function t(){let B=!1,oe=null,ee=null,_e=null;return{setTest:function(be){be?me(n.DEPTH_TEST):ie(n.DEPTH_TEST)},setMask:function(be){oe!==be&&!B&&(n.depthMask(be),oe=be)},setFunc:function(be){if(ee!==be){switch(be){case a0:n.depthFunc(n.NEVER);break;case l0:n.depthFunc(n.ALWAYS);break;case c0:n.depthFunc(n.LESS);break;case po: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)}ee=be}},setLocked:function(be){B=be},setClear:function(be){_e!==be&&(n.clearDepth(be),_e=be)},reset:function(){B=!1,oe=null,ee=null,_e=null}}}function i(){let B=!1,oe=null,ee=null,_e=null,be=null,Ae=null,Qe=null,ct=null,pt=null;return{setTest:function(tt){B||(tt?me(n.STENCIL_TEST):ie(n.STENCIL_TEST))},setMask:function(tt){oe!==tt&&!B&&(n.stencilMask(tt),oe=tt)},setFunc:function(tt,Yt,St){(ee!==tt||_e!==Yt||be!==St)&&(n.stencilFunc(tt,Yt,St),ee=tt,_e=Yt,be=St)},setOp:function(tt,Yt,St){(Ae!==tt||Qe!==Yt||ct!==St)&&(n.stencilOp(tt,Yt,St),Ae=tt,Qe=Yt,ct=St)},setLocked:function(tt){B=tt},setClear:function(tt){pt!==tt&&(n.clearStencil(tt),pt=tt)},reset:function(){B=!1,oe=null,ee=null,_e=null,be=null,Ae=null,Qe=null,ct=null,pt=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,m=!1,y=null,g=null,p=null,_=null,v=null,w=null,P=null,A=new we(0,0,0),E=0,L=!1,b=null,x=null,R=null,U=null,D=null,$=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),j=!1,N=0,X=n.getParameter(n.VERSION);X.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(X)[1]),j=N>=1):X.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),j=N>=2);let k=null,le={},ce=n.getParameter(n.SCISSOR_BOX),Me=n.getParameter(n.VIEWPORT),Fe=new lt().fromArray(ce),Ke=new lt().fromArray(Me);function J(B,oe,ee,_e){let be=new Uint8Array(4),Ae=n.createTexture();n.bindTexture(B,Ae),n.texParameteri(B,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(B,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Qe=0;Qe<ee;Qe++)B===n.TEXTURE_3D||B===n.TEXTURE_2D_ARRAY?n.texImage3D(oe,0,n.RGBA,1,1,_e,0,n.RGBA,n.UNSIGNED_BYTE,be):n.texImage2D(oe+Qe,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,be);return Ae}let Z={};Z[n.TEXTURE_2D]=J(n.TEXTURE_2D,n.TEXTURE_2D,1),Z[n.TEXTURE_CUBE_MAP]=J(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Z[n.TEXTURE_2D_ARRAY]=J(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Z[n.TEXTURE_3D]=J(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),me(n.DEPTH_TEST),s.setFunc(po),de(!1),ae(Cd),me(n.CULL_FACE),ue(ni);function me(B){c[B]!==!0&&(n.enable(B),c[B]=!0)}function ie(B){c[B]!==!1&&(n.disable(B),c[B]=!1)}function ke(B,oe){return u[B]!==oe?(n.bindFramebuffer(B,oe),u[B]=oe,B===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=oe),B===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=oe),!0):!1}function xe(B,oe){let ee=h,_e=!1;if(B){ee=d.get(oe),ee===void 0&&(ee=[],d.set(oe,ee));let be=B.textures;if(ee.length!==be.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let Ae=0,Qe=be.length;Ae<Qe;Ae++)ee[Ae]=n.COLOR_ATTACHMENT0+Ae;ee.length=be.length,_e=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,_e=!0);_e&&n.drawBuffers(ee)}function z(B){return f!==B?(n.useProgram(B),f=B,!0):!1}let Ue={[Ei]:n.FUNC_ADD,[$g]:n.FUNC_SUBTRACT,[Wg]:n.FUNC_REVERSE_SUBTRACT};Ue[jg]=n.MIN,Ue[Xg]=n.MAX;let K={[Yg]:n.ZERO,[qg]:n.ONE,[Zg]:n.SRC_COLOR,[ql]:n.SRC_ALPHA,[n0]:n.SRC_ALPHA_SATURATE,[e0]:n.DST_COLOR,[Kg]:n.DST_ALPHA,[Jg]:n.ONE_MINUS_SRC_COLOR,[Zl]: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,[o0]:n.ONE_MINUS_CONSTANT_ALPHA};function ue(B,oe,ee,_e,be,Ae,Qe,ct,pt,tt){if(B===ni){m===!0&&(ie(n.BLEND),m=!1);return}if(m===!1&&(me(n.BLEND),m=!0),B!==Gg){if(B!==y||tt!==L){if((g!==Ei||v!==Ei)&&(n.blendEquation(n.FUNC_ADD),g=Ei,v=Ei),tt)switch(B){case or: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: ",B);break}else switch(B){case or: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: ",B);break}p=null,_=null,w=null,P=null,A.set(0,0,0),E=0,y=B,L=tt}return}be=be||oe,Ae=Ae||ee,Qe=Qe||_e,(oe!==g||be!==v)&&(n.blendEquationSeparate(Ue[oe],Ue[be]),g=oe,v=be),(ee!==p||_e!==_||Ae!==w||Qe!==P)&&(n.blendFuncSeparate(K[ee],K[_e],K[Ae],K[Qe]),p=ee,_=_e,w=Ae,P=Qe),(ct.equals(A)===!1||pt!==E)&&(n.blendColor(ct.r,ct.g,ct.b,pt),A.copy(ct),E=pt),y=B,L=!1}function Q(B,oe){B.side===Ln?ie(n.CULL_FACE):me(n.CULL_FACE);let ee=B.side===Xt;oe&&(ee=!ee),de(ee),B.blending===or&&B.transparent===!1?ue(ni):ue(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),s.setFunc(B.depthFunc),s.setTest(B.depthTest),s.setMask(B.depthWrite),r.setMask(B.colorWrite);let _e=B.stencilWrite;o.setTest(_e),_e&&(o.setMask(B.stencilWriteMask),o.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),o.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),Ee(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?me(n.SAMPLE_ALPHA_TO_COVERAGE):ie(n.SAMPLE_ALPHA_TO_COVERAGE)}function de(B){b!==B&&(B?n.frontFace(n.CW):n.frontFace(n.CCW),b=B)}function ae(B){B!==zg?(me(n.CULL_FACE),B!==x&&(B===Cd?n.cullFace(n.BACK):B===Vg?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ie(n.CULL_FACE),x=B}function fe(B){B!==R&&(j&&n.lineWidth(B),R=B)}function Ee(B,oe,ee){B?(me(n.POLYGON_OFFSET_FILL),(U!==oe||D!==ee)&&(n.polygonOffset(oe,ee),U=oe,D=ee)):ie(n.POLYGON_OFFSET_FILL)}function C(B){B?me(n.SCISSOR_TEST):ie(n.SCISSOR_TEST)}function S(B){B===void 0&&(B=n.TEXTURE0+$-1),k!==B&&(n.activeTexture(B),k=B)}function W(B,oe,ee){ee===void 0&&(k===null?ee=n.TEXTURE0+$-1:ee=k);let _e=le[ee];_e===void 0&&(_e={type:void 0,texture:void 0},le[ee]=_e),(_e.type!==B||_e.texture!==oe)&&(k!==ee&&(n.activeTexture(ee),k=ee),n.bindTexture(B,oe||Z[B]),_e.type=B,_e.texture=oe)}function te(){let B=le[k];B!==void 0&&B.type!==void 0&&(n.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function se(){try{n.compressedTexImage2D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function re(){try{n.compressedTexImage3D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Re(){try{n.texSubImage2D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ge(){try{n.texSubImage3D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ye(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Be(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function he(){try{n.texStorage2D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Pe(){try{n.texStorage3D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function je(){try{n.texImage2D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Le(){try{n.texImage3D.apply(n,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Se(B){Fe.equals(B)===!1&&(n.scissor(B.x,B.y,B.z,B.w),Fe.copy(B))}function De(B){Ke.equals(B)===!1&&(n.viewport(B.x,B.y,B.z,B.w),Ke.copy(B))}function Ze(B,oe){let ee=l.get(oe);ee===void 0&&(ee=new WeakMap,l.set(oe,ee));let _e=ee.get(B);_e===void 0&&(_e=n.getUniformBlockIndex(oe,B.name),ee.set(B,_e))}function ft(B,oe){let _e=l.get(oe).get(B);a.get(oe)!==_e&&(n.uniformBlockBinding(oe,_e,B.__bindingPointIndex),a.set(oe,_e))}function $e(){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,le={},u={},d=new WeakMap,h=[],f=null,m=!1,y=null,g=null,p=null,_=null,v=null,w=null,P=null,A=new we(0,0,0),E=0,L=!1,b=null,x=null,R=null,U=null,D=null,Fe.set(0,0,n.canvas.width,n.canvas.height),Ke.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:me,disable:ie,bindFramebuffer:ke,drawBuffers:xe,useProgram:z,setBlending:ue,setMaterial:Q,setFlipSided:de,setCullFace:ae,setLineWidth:fe,setPolygonOffset:Ee,setScissorTest:C,activeTexture:S,bindTexture:W,unbindTexture:te,compressedTexImage2D:se,compressedTexImage3D:re,texImage2D:je,texImage3D:Le,updateUBOMapping:Ze,uniformBlockBinding:ft,texStorage2D:he,texStorage3D:Pe,texSubImage2D:Re,texSubImage3D:ge,compressedTexSubImage2D:ye,compressedTexSubImage3D:Be,scissor:Se,viewport:De,reset:$e}}function mE(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 ne,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(C,S){return f?new OffscreenCanvas(C,S):To("canvas")}function y(C,S,W){let te=1,se=Ee(C);if((se.width>W||se.height>W)&&(te=W/Math.max(se.width,se.height)),te<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){let re=Math.floor(te*se.width),Re=Math.floor(te*se.height);d===void 0&&(d=m(re,Re));let ge=S?m(re,Re):d;return ge.width=re,ge.height=Re,ge.getContext("2d").drawImage(C,0,0,re,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+se.width+"x"+se.height+") to ("+re+"x"+Re+")."),ge}else return"data"in C&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+se.width+"x"+se.height+")."),C;return C}function g(C){return C.generateMipmaps&&C.minFilter!==Pt&&C.minFilter!==wt}function p(C){n.generateMipmap(C)}function _(C,S,W,te,se=!1){if(C!==null){if(n[C]!==void 0)return n[C];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let re=S;if(S===n.RED&&(W===n.FLOAT&&(re=n.R32F),W===n.HALF_FLOAT&&(re=n.R16F),W===n.UNSIGNED_BYTE&&(re=n.R8)),S===n.RED_INTEGER&&(W===n.UNSIGNED_BYTE&&(re=n.R8UI),W===n.UNSIGNED_SHORT&&(re=n.R16UI),W===n.UNSIGNED_INT&&(re=n.R32UI),W===n.BYTE&&(re=n.R8I),W===n.SHORT&&(re=n.R16I),W===n.INT&&(re=n.R32I)),S===n.RG&&(W===n.FLOAT&&(re=n.RG32F),W===n.HALF_FLOAT&&(re=n.RG16F),W===n.UNSIGNED_BYTE&&(re=n.RG8)),S===n.RG_INTEGER&&(W===n.UNSIGNED_BYTE&&(re=n.RG8UI),W===n.UNSIGNED_SHORT&&(re=n.RG16UI),W===n.UNSIGNED_INT&&(re=n.RG32UI),W===n.BYTE&&(re=n.RG8I),W===n.SHORT&&(re=n.RG16I),W===n.INT&&(re=n.RG32I)),S===n.RGB&&W===n.UNSIGNED_INT_5_9_9_9_REV&&(re=n.RGB9_E5),S===n.RGBA){let Re=se?wo:at.getTransfer(te);W===n.FLOAT&&(re=n.RGBA32F),W===n.HALF_FLOAT&&(re=n.RGBA16F),W===n.UNSIGNED_BYTE&&(re=Re===dt?n.SRGB8_ALPHA8:n.RGBA8),W===n.UNSIGNED_SHORT_4_4_4_4&&(re=n.RGBA4),W===n.UNSIGNED_SHORT_5_5_5_1&&(re=n.RGB5_A1)}return(re===n.R16F||re===n.R32F||re===n.RG16F||re===n.RG32F||re===n.RGBA16F||re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),re}function v(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Pt&&C.minFilter!==wt?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function w(C){let S=C.target;S.removeEventListener("dispose",w),A(S),S.isVideoTexture&&u.delete(S)}function P(C){let S=C.target;S.removeEventListener("dispose",P),L(S)}function A(C){let S=i.get(C);if(S.__webglInit===void 0)return;let W=C.source,te=h.get(W);if(te){let se=te[S.__cacheKey];se.usedTimes--,se.usedTimes===0&&E(C),Object.keys(te).length===0&&h.delete(W)}i.remove(C)}function E(C){let S=i.get(C);n.deleteTexture(S.__webglTexture);let W=C.source,te=h.get(W);delete te[S.__cacheKey],o.memory.textures--}function L(C){let S=i.get(C);if(C.depthTexture&&C.depthTexture.dispose(),C.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(S.__webglFramebuffer[te]))for(let se=0;se<S.__webglFramebuffer[te].length;se++)n.deleteFramebuffer(S.__webglFramebuffer[te][se]);else n.deleteFramebuffer(S.__webglFramebuffer[te]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[te])}else{if(Array.isArray(S.__webglFramebuffer))for(let te=0;te<S.__webglFramebuffer.length;te++)n.deleteFramebuffer(S.__webglFramebuffer[te]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let te=0;te<S.__webglColorRenderbuffer.length;te++)S.__webglColorRenderbuffer[te]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[te]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}let W=C.textures;for(let te=0,se=W.length;te<se;te++){let re=i.get(W[te]);re.__webglTexture&&(n.deleteTexture(re.__webglTexture),o.memory.textures--),i.remove(W[te])}i.remove(C)}let b=0;function x(){b=0}function R(){let C=b;return C>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+r.maxTextures),b+=1,C}function U(C){let S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function D(C,S){let W=i.get(C);if(C.isVideoTexture&&ae(C),C.isRenderTargetTexture===!1&&C.version>0&&W.__version!==C.version){let te=C.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Fe(W,C,S);return}}t.bindTexture(n.TEXTURE_2D,W.__webglTexture,n.TEXTURE0+S)}function $(C,S){let W=i.get(C);if(C.version>0&&W.__version!==C.version){Fe(W,C,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,W.__webglTexture,n.TEXTURE0+S)}function j(C,S){let W=i.get(C);if(C.version>0&&W.__version!==C.version){Fe(W,C,S);return}t.bindTexture(n.TEXTURE_3D,W.__webglTexture,n.TEXTURE0+S)}function N(C,S){let W=i.get(C);if(C.version>0&&W.__version!==C.version){Ke(W,C,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+S)}let X={[yo]:n.REPEAT,[yn]:n.CLAMP_TO_EDGE,[vo]:n.MIRRORED_REPEAT},k={[Pt]:n.NEAREST,[Tf]:n.NEAREST_MIPMAP_NEAREST,[ns]:n.NEAREST_MIPMAP_LINEAR,[wt]:n.LINEAR,[lo]:n.LINEAR_MIPMAP_NEAREST,[Dn]:n.LINEAR_MIPMAP_LINEAR},le={[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 ce(C,S){if(S.type===vn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===wt||S.magFilter===lo||S.magFilter===ns||S.magFilter===Dn||S.minFilter===wt||S.minFilter===lo||S.minFilter===ns||S.minFilter===Dn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(C,n.TEXTURE_WRAP_S,X[S.wrapS]),n.texParameteri(C,n.TEXTURE_WRAP_T,X[S.wrapT]),(C===n.TEXTURE_3D||C===n.TEXTURE_2D_ARRAY)&&n.texParameteri(C,n.TEXTURE_WRAP_R,X[S.wrapR]),n.texParameteri(C,n.TEXTURE_MAG_FILTER,k[S.magFilter]),n.texParameteri(C,n.TEXTURE_MIN_FILTER,k[S.minFilter]),S.compareFunction&&(n.texParameteri(C,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(C,n.TEXTURE_COMPARE_FUNC,le[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Pt||S.minFilter!==ns&&S.minFilter!==Dn||S.type===vn&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){let W=e.get("EXT_texture_filter_anisotropic");n.texParameterf(C,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function Me(C,S){let W=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",w));let te=S.source,se=h.get(te);se===void 0&&(se={},h.set(te,se));let re=U(S);if(re!==C.__cacheKey){se[re]===void 0&&(se[re]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,W=!0),se[re].usedTimes++;let Re=se[C.__cacheKey];Re!==void 0&&(se[C.__cacheKey].usedTimes--,Re.usedTimes===0&&E(S)),C.__cacheKey=re,C.__webglTexture=se[re].texture}return W}function Fe(C,S,W){let te=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(te=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(te=n.TEXTURE_3D);let se=Me(C,S),re=S.source;t.bindTexture(te,C.__webglTexture,n.TEXTURE0+W);let Re=i.get(re);if(re.version!==Re.__version||se===!0){t.activeTexture(n.TEXTURE0+W);let ge=at.getPrimaries(at.workingColorSpace),ye=S.colorSpace===Jn?null:at.getPrimaries(S.colorSpace),Be=S.colorSpace===Jn||ge===ye?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,Be);let he=y(S.image,!1,r.maxTextureSize);he=fe(S,he);let Pe=s.convert(S.format,S.colorSpace),je=s.convert(S.type),Le=_(S.internalFormat,Pe,je,S.colorSpace,S.isVideoTexture);ce(te,S);let Se,De=S.mipmaps,Ze=S.isVideoTexture!==!0,ft=Re.__version===void 0||se===!0,$e=re.dataReady,B=v(S,he);if(S.isDepthTexture)Le=n.DEPTH_COMPONENT16,S.type===vn?Le=n.DEPTH_COMPONENT32F:S.type===cr?Le=n.DEPTH_COMPONENT24:S.type===bs&&(Le=n.DEPTH24_STENCIL8),ft&&(Ze?t.texStorage2D(n.TEXTURE_2D,1,Le,he.width,he.height):t.texImage2D(n.TEXTURE_2D,0,Le,he.width,he.height,0,Pe,je,null));else if(S.isDataTexture)if(De.length>0){Ze&&ft&&t.texStorage2D(n.TEXTURE_2D,B,Le,De[0].width,De[0].height);for(let oe=0,ee=De.length;oe<ee;oe++)Se=De[oe],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Se.width,Se.height,Pe,je,Se.data):t.texImage2D(n.TEXTURE_2D,oe,Le,Se.width,Se.height,0,Pe,je,Se.data);S.generateMipmaps=!1}else Ze?(ft&&t.texStorage2D(n.TEXTURE_2D,B,Le,he.width,he.height),$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,he.width,he.height,Pe,je,he.data)):t.texImage2D(n.TEXTURE_2D,0,Le,he.width,he.height,0,Pe,je,he.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){Ze&&ft&&t.texStorage3D(n.TEXTURE_2D_ARRAY,B,Le,De[0].width,De[0].height,he.depth);for(let oe=0,ee=De.length;oe<ee;oe++)Se=De[oe],S.format!==tn?Pe!==null?Ze?$e&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,oe,0,0,0,Se.width,Se.height,he.depth,Pe,Se.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,oe,Le,Se.width,Se.height,he.depth,0,Se.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ze?$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,oe,0,0,0,Se.width,Se.height,he.depth,Pe,je,Se.data):t.texImage3D(n.TEXTURE_2D_ARRAY,oe,Le,Se.width,Se.height,he.depth,0,Pe,je,Se.data)}else{Ze&&ft&&t.texStorage2D(n.TEXTURE_2D,B,Le,De[0].width,De[0].height);for(let oe=0,ee=De.length;oe<ee;oe++)Se=De[oe],S.format!==tn?Pe!==null?Ze?$e&&t.compressedTexSubImage2D(n.TEXTURE_2D,oe,0,0,Se.width,Se.height,Pe,Se.data):t.compressedTexImage2D(n.TEXTURE_2D,oe,Le,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Se.width,Se.height,Pe,je,Se.data):t.texImage2D(n.TEXTURE_2D,oe,Le,Se.width,Se.height,0,Pe,je,Se.data)}else if(S.isDataArrayTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_2D_ARRAY,B,Le,he.width,he.height,he.depth),$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,he.width,he.height,he.depth,Pe,je,he.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Le,he.width,he.height,he.depth,0,Pe,je,he.data);else if(S.isData3DTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_3D,B,Le,he.width,he.height,he.depth),$e&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,he.width,he.height,he.depth,Pe,je,he.data)):t.texImage3D(n.TEXTURE_3D,0,Le,he.width,he.height,he.depth,0,Pe,je,he.data);else if(S.isFramebufferTexture){if(ft)if(Ze)t.texStorage2D(n.TEXTURE_2D,B,Le,he.width,he.height);else{let oe=he.width,ee=he.height;for(let _e=0;_e<B;_e++)t.texImage2D(n.TEXTURE_2D,_e,Le,oe,ee,0,Pe,je,null),oe>>=1,ee>>=1}}else if(De.length>0){if(Ze&&ft){let oe=Ee(De[0]);t.texStorage2D(n.TEXTURE_2D,B,Le,oe.width,oe.height)}for(let oe=0,ee=De.length;oe<ee;oe++)Se=De[oe],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,oe,0,0,Pe,je,Se):t.texImage2D(n.TEXTURE_2D,oe,Le,Pe,je,Se);S.generateMipmaps=!1}else if(Ze){if(ft){let oe=Ee(he);t.texStorage2D(n.TEXTURE_2D,B,Le,oe.width,oe.height)}$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Pe,je,he)}else t.texImage2D(n.TEXTURE_2D,0,Le,Pe,je,he);g(S)&&p(te),Re.__version=re.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function Ke(C,S,W){if(S.image.length!==6)return;let te=Me(C,S),se=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,C.__webglTexture,n.TEXTURE0+W);let re=i.get(se);if(se.version!==re.__version||te===!0){t.activeTexture(n.TEXTURE0+W);let Re=at.getPrimaries(at.workingColorSpace),ge=S.colorSpace===Jn?null:at.getPrimaries(S.colorSpace),ye=S.colorSpace===Jn||Re===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,ye);let Be=S.isCompressedTexture||S.image[0].isCompressedTexture,he=S.image[0]&&S.image[0].isDataTexture,Pe=[];for(let ee=0;ee<6;ee++)!Be&&!he?Pe[ee]=y(S.image[ee],!0,r.maxCubemapSize):Pe[ee]=he?S.image[ee].image:S.image[ee],Pe[ee]=fe(S,Pe[ee]);let je=Pe[0],Le=s.convert(S.format,S.colorSpace),Se=s.convert(S.type),De=_(S.internalFormat,Le,Se,S.colorSpace),Ze=S.isVideoTexture!==!0,ft=re.__version===void 0||te===!0,$e=se.dataReady,B=v(S,je);ce(n.TEXTURE_CUBE_MAP,S);let oe;if(Be){Ze&&ft&&t.texStorage2D(n.TEXTURE_CUBE_MAP,B,De,je.width,je.height);for(let ee=0;ee<6;ee++){oe=Pe[ee].mipmaps;for(let _e=0;_e<oe.length;_e++){let be=oe[_e];S.format!==tn?Le!==null?Ze?$e&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e,0,0,be.width,be.height,Le,be.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e,De,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ze?$e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e,0,0,be.width,be.height,Le,Se,be.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e,De,be.width,be.height,0,Le,Se,be.data)}}}else{if(oe=S.mipmaps,Ze&&ft){oe.length>0&&B++;let ee=Ee(Pe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,B,De,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(he){Ze?$e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Pe[ee].width,Pe[ee].height,Le,Se,Pe[ee].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,De,Pe[ee].width,Pe[ee].height,0,Le,Se,Pe[ee].data);for(let _e=0;_e<oe.length;_e++){let Ae=oe[_e].image[ee].image;Ze?$e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e+1,0,0,Ae.width,Ae.height,Le,Se,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e+1,De,Ae.width,Ae.height,0,Le,Se,Ae.data)}}else{Ze?$e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Le,Se,Pe[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,De,Le,Se,Pe[ee]);for(let _e=0;_e<oe.length;_e++){let be=oe[_e];Ze?$e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e+1,0,0,Le,Se,be.image[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,_e+1,De,Le,Se,be.image[ee])}}}g(S)&&p(n.TEXTURE_CUBE_MAP),re.__version=se.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function J(C,S,W,te,se,re){let Re=s.convert(W.format,W.colorSpace),ge=s.convert(W.type),ye=_(W.internalFormat,Re,ge,W.colorSpace);if(!i.get(S).__hasExternalTextures){let he=Math.max(1,S.width>>re),Pe=Math.max(1,S.height>>re);se===n.TEXTURE_3D||se===n.TEXTURE_2D_ARRAY?t.texImage3D(se,re,ye,he,Pe,S.depth,0,Re,ge,null):t.texImage2D(se,re,ye,he,Pe,0,Re,ge,null)}t.bindFramebuffer(n.FRAMEBUFFER,C),de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,te,se,i.get(W).__webglTexture,0,Q(S)):(se===n.TEXTURE_2D||se>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&se<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,te,se,i.get(W).__webglTexture,re),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Z(C,S,W){if(n.bindRenderbuffer(n.RENDERBUFFER,C),S.depthBuffer&&!S.stencilBuffer){let te=n.DEPTH_COMPONENT24;if(W||de(S)){let se=S.depthTexture;se&&se.isDepthTexture&&(se.type===vn?te=n.DEPTH_COMPONENT32F:se.type===cr&&(te=n.DEPTH_COMPONENT24));let re=Q(S);de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,te,S.width,S.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,re,te,S.width,S.height)}else n.renderbufferStorage(n.RENDERBUFFER,te,S.width,S.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,C)}else if(S.depthBuffer&&S.stencilBuffer){let te=Q(S);W&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,te,n.DEPTH24_STENCIL8,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,te,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,C)}else{let te=S.textures;for(let se=0;se<te.length;se++){let re=te[se],Re=s.convert(re.format,re.colorSpace),ge=s.convert(re.type),ye=_(re.internalFormat,Re,ge,re.colorSpace),Be=Q(S);W&&de(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Be,ye,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Be,ye,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,ye,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function me(C,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,C),!(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),D(S.depthTexture,0);let te=i.get(S.depthTexture).__webglTexture,se=Q(S);if(S.depthTexture.format===ar)de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0,se):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0);else if(S.depthTexture.format===ls)de(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0,se):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0);else throw new Error("Unknown depthTexture format")}function ie(C){let S=i.get(C),W=C.isWebGLCubeRenderTarget===!0;if(C.depthTexture&&!S.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");me(S.__webglFramebuffer,C)}else if(W){S.__webglDepthbuffer=[];for(let te=0;te<6;te++)t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[te]),S.__webglDepthbuffer[te]=n.createRenderbuffer(),Z(S.__webglDepthbuffer[te],C,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=n.createRenderbuffer(),Z(S.__webglDepthbuffer,C,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function ke(C,S,W){let te=i.get(C);S!==void 0&&J(te.__webglFramebuffer,C,C.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),W!==void 0&&ie(C)}function xe(C){let S=C.texture,W=i.get(C),te=i.get(S);C.addEventListener("dispose",P);let se=C.textures,re=C.isWebGLCubeRenderTarget===!0,Re=se.length>1;if(Re||(te.__webglTexture===void 0&&(te.__webglTexture=n.createTexture()),te.__version=S.version,o.memory.textures++),re){W.__webglFramebuffer=[];for(let ge=0;ge<6;ge++)if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer[ge]=[];for(let ye=0;ye<S.mipmaps.length;ye++)W.__webglFramebuffer[ge][ye]=n.createFramebuffer()}else W.__webglFramebuffer[ge]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer=[];for(let ge=0;ge<S.mipmaps.length;ge++)W.__webglFramebuffer[ge]=n.createFramebuffer()}else W.__webglFramebuffer=n.createFramebuffer();if(Re)for(let ge=0,ye=se.length;ge<ye;ge++){let Be=i.get(se[ge]);Be.__webglTexture===void 0&&(Be.__webglTexture=n.createTexture(),o.memory.textures++)}if(C.samples>0&&de(C)===!1){W.__webglMultisampledFramebuffer=n.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let ge=0;ge<se.length;ge++){let ye=se[ge];W.__webglColorRenderbuffer[ge]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,W.__webglColorRenderbuffer[ge]);let Be=s.convert(ye.format,ye.colorSpace),he=s.convert(ye.type),Pe=_(ye.internalFormat,Be,he,ye.colorSpace,C.isXRRenderTarget===!0),je=Q(C);n.renderbufferStorageMultisample(n.RENDERBUFFER,je,Pe,C.width,C.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ge,n.RENDERBUFFER,W.__webglColorRenderbuffer[ge])}n.bindRenderbuffer(n.RENDERBUFFER,null),C.depthBuffer&&(W.__webglDepthRenderbuffer=n.createRenderbuffer(),Z(W.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(re){t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),ce(n.TEXTURE_CUBE_MAP,S);for(let ge=0;ge<6;ge++)if(S.mipmaps&&S.mipmaps.length>0)for(let ye=0;ye<S.mipmaps.length;ye++)J(W.__webglFramebuffer[ge][ye],C,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ge,ye);else J(W.__webglFramebuffer[ge],C,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0);g(S)&&p(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Re){for(let ge=0,ye=se.length;ge<ye;ge++){let Be=se[ge],he=i.get(Be);t.bindTexture(n.TEXTURE_2D,he.__webglTexture),ce(n.TEXTURE_2D,Be),J(W.__webglFramebuffer,C,Be,n.COLOR_ATTACHMENT0+ge,n.TEXTURE_2D,0),g(Be)&&p(n.TEXTURE_2D)}t.unbindTexture()}else{let ge=n.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(ge=C.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ge,te.__webglTexture),ce(ge,S),S.mipmaps&&S.mipmaps.length>0)for(let ye=0;ye<S.mipmaps.length;ye++)J(W.__webglFramebuffer[ye],C,S,n.COLOR_ATTACHMENT0,ge,ye);else J(W.__webglFramebuffer,C,S,n.COLOR_ATTACHMENT0,ge,0);g(S)&&p(ge),t.unbindTexture()}C.depthBuffer&&ie(C)}function z(C){let S=C.textures;for(let W=0,te=S.length;W<te;W++){let se=S[W];if(g(se)){let re=C.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Re=i.get(se).__webglTexture;t.bindTexture(re,Re),p(re),t.unbindTexture()}}}let Ue=[],K=[];function ue(C){if(C.samples>0){if(de(C)===!1){let S=C.textures,W=C.width,te=C.height,se=n.COLOR_BUFFER_BIT,re=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Re=i.get(C),ge=S.length>1;if(ge)for(let ye=0;ye<S.length;ye++)t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ye,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ye,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let ye=0;ye<S.length;ye++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(se|=n.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(se|=n.STENCIL_BUFFER_BIT)),ge){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Re.__webglColorRenderbuffer[ye]);let Be=i.get(S[ye]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Be,0)}n.blitFramebuffer(0,0,W,te,0,0,W,te,se,n.NEAREST),l===!0&&(Ue.length=0,K.length=0,Ue.push(n.COLOR_ATTACHMENT0+ye),C.depthBuffer&&C.resolveDepthBuffer===!1&&(Ue.push(re),K.push(re),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,K)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ge)for(let ye=0;ye<S.length;ye++){t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ye,n.RENDERBUFFER,Re.__webglColorRenderbuffer[ye]);let Be=i.get(S[ye]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ye,n.TEXTURE_2D,Be,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){let S=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function Q(C){return Math.min(r.maxSamples,C.samples)}function de(C){let S=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function ae(C){let S=o.render.frame;u.get(C)!==S&&(u.set(C,S),C.update())}function fe(C,S){let W=C.colorSpace,te=C.format,se=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||W!==ui&&W!==Jn&&(at.getTransfer(W)===dt?(te!==tn||se!==ai)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),S}function Ee(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=R,this.resetTextureUnits=x,this.setTexture2D=D,this.setTexture2DArray=$,this.setTexture3D=j,this.setTextureCube=N,this.rebindTextures=ke,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=ue,this.setupDepthRenderbuffer=ie,this.setupFrameBufferTexture=J,this.useMultisampledRTT=de}function ry(n,e){function t(i,r=Jn){let s,o=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===cr)return n.UNSIGNED_INT;if(i===vn)return n.FLOAT;if(i===ia)return n.HALF_FLOAT;if(i===T0)return n.ALPHA;if(i===I0)return n.RGB;if(i===tn)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===ls)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===Gl||i===$l||i===Wl||i===jl)if(o===dt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Gl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Wl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===jl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Gl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===$l)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Wl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===jl)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===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===zd)return o===dt?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===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$d)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Yd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===qd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Xl||i===th||i===nh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Xl)return o===dt?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===Xl)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===bs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function xE(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,_,v,w){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,w)):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?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?l(g,p,_,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===Xt&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===Xt&&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 _=e.get(p),v=_.envMap,w=_.envMapRotation;if(v&&(g.envMap.value=v,Xi.copy(w),Xi.x*=-1,Xi.y*=-1,Xi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Xi.y*=-1,Xi.z*=-1),g.envMapRotation.value.setFromMatrix4(_E.makeRotationFromEuler(Xi)),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 P=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=p.lightMapIntensity*P,t(p.lightMap,g.lightMapTransform)}p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,g.aoMapTransform))}function o(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 a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,_,v){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*_,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,_){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===Xt&&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=_.texture,g.transmissionSamplerSize.value.set(_.width,_.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 _=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(_.matrixWorld),g.nearDistance.value=_.shadow.camera.near,g.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function bE(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(_,v){let w=v.program;i.uniformBlockBinding(_,w)}function c(_,v){let w=r[_.id];w===void 0&&(m(_),w=u(_),r[_.id]=w,_.addEventListener("dispose",g));let P=v.program;i.updateUBOMapping(_,P);let A=e.render.frame;s[_.id]!==A&&(h(_),s[_.id]=A)}function u(_){let v=d();_.__bindingPointIndex=v;let w=n.createBuffer(),P=_.__size,A=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,w),n.bufferData(n.UNIFORM_BUFFER,P,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,w),w}function d(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(_){let v=r[_.id],w=_.uniforms,P=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let A=0,E=w.length;A<E;A++){let L=Array.isArray(w[A])?w[A]:[w[A]];for(let b=0,x=L.length;b<x;b++){let R=L[b];if(f(R,A,b,P)===!0){let U=R.__offset,D=Array.isArray(R.value)?R.value:[R.value],$=0;for(let j=0;j<D.length;j++){let N=D[j],X=y(N);typeof N=="number"||typeof N=="boolean"?(R.__data[0]=N,n.bufferSubData(n.UNIFORM_BUFFER,U+$,R.__data)):N.isMatrix3?(R.__data[0]=N.elements[0],R.__data[1]=N.elements[1],R.__data[2]=N.elements[2],R.__data[3]=0,R.__data[4]=N.elements[3],R.__data[5]=N.elements[4],R.__data[6]=N.elements[5],R.__data[7]=0,R.__data[8]=N.elements[6],R.__data[9]=N.elements[7],R.__data[10]=N.elements[8],R.__data[11]=0):(N.toArray(R.__data,$),$+=X.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,U,R.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(_,v,w,P){let A=_.value,E=v+"_"+w;if(P[E]===void 0)return typeof A=="number"||typeof A=="boolean"?P[E]=A:P[E]=A.clone(),!0;{let L=P[E];if(typeof A=="number"||typeof A=="boolean"){if(L!==A)return P[E]=A,!0}else if(L.equals(A)===!1)return L.copy(A),!0}return!1}function m(_){let v=_.uniforms,w=0,P=16;for(let E=0,L=v.length;E<L;E++){let b=Array.isArray(v[E])?v[E]:[v[E]];for(let x=0,R=b.length;x<R;x++){let U=b[x],D=Array.isArray(U.value)?U.value:[U.value];for(let $=0,j=D.length;$<j;$++){let N=D[$],X=y(N),k=w%P;k!==0&&P-k<X.boundary&&(w+=P-k),U.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=w,w+=X.storage}}}let A=w%P;return A>0&&(w+=P-A),_.__size=w,_.__cache={},this}function y(_){let v={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(v.boundary=4,v.storage=4):_.isVector2?(v.boundary=8,v.storage=8):_.isVector3||_.isColor?(v.boundary=16,v.storage=12):_.isVector4?(v.boundary=16,v.storage=16):_.isMatrix3?(v.boundary=48,v.storage=48):_.isMatrix4?(v.boundary=64,v.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),v}function g(_){let v=_.target;v.removeEventListener("dispose",g);let w=o.indexOf(v.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function p(){for(let _ in r)n.deleteBuffer(r[_]);o=[],r={},s={}}return{bind:l,update:c,dispose:p}}function xl(n,e,t,i,r,s){Qr.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Qs.x=s*Qr.x-r*Qr.y,Qs.y=r*Qr.x+s*Qr.y):Qs.copy(Qr),n.copy(e),n.x+=Qs.x,n.y+=Qs.y,n.applyMatrix4(sy)}function AE(n,e){return n.z-e.z}function EE(n,e){return e.z-n.z}function IE(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 Tl(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(dc.fromBufferAttribute(o,r),hc.fromBufferAttribute(o,s),t.distanceSqToSegment(dc,hc,xd,cg)>i)return;xd.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(xd);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,o){let a=Eh.distanceSqToPoint(n);if(a<t){let l=new T;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 pg(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 CE(n,e){let t=1-n;return t*t*e}function RE(n,e){return 2*(1-n)*n*e}function PE(n,e){return n*n*e}function ho(n,e,t,i){return CE(n,e)+RE(n,t)+PE(n,i)}function LE(n,e){let t=1-n;return t*t*t*e}function DE(n,e){let t=1-n;return 3*t*t*n*e}function OE(n,e){return 3*(1-n)*n*n*e}function UE(n,e){return n*n*n*e}function fo(n,e,t,i,r){return LE(n,e)+DE(n,t)+OE(n,i)+UE(n,r)}function oy(n,e,t,i,r){let s,o;if(r===KE(n,e,t,i)>0)for(s=e;s<t;s+=i)o=mg(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=mg(s,n[s],n[s+1],o);return o&&hu(o,o.next)&&(jo(o),o=o.next),o}function mr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(hu(t,t.next)||mt(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?kE(n,i,r,s):FE(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=BE(mr(n),e,t),$o(n,e,t,i,r,s,2)):o===2&&zE(n,e,t,i,r,s):$o(mr(n),e,t,i,r,s,1);break}}}function FE(n){let e=n.prev,t=n,i=n.next;if(mt(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,m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=h&&m.y>=d&&m.y<=f&&ss(r,a,s,l,o,c,m.x,m.y)&&mt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function kE(n,e,t,i){let r=n.prev,s=n,o=n.next;if(mt(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,m=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,p=Lh(f,m,e,t,i),_=Lh(y,g,e,t,i),v=n.prevZ,w=n.nextZ;for(;v&&v.z>=p&&w&&w.z<=_;){if(v.x>=f&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==o&&ss(a,u,l,d,c,h,v.x,v.y)&&mt(v.prev,v,v.next)>=0||(v=v.prevZ,w.x>=f&&w.x<=y&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&ss(a,u,l,d,c,h,w.x,w.y)&&mt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;v&&v.z>=p;){if(v.x>=f&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==o&&ss(a,u,l,d,c,h,v.x,v.y)&&mt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=_;){if(w.x>=f&&w.x<=y&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&ss(a,u,l,d,c,h,w.x,w.y)&&mt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function BE(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!hu(r,s)&&ay(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 mr(i)}function zE(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&qE(o,a)){let l=ly(o,a);o=mr(o,o.next),l=mr(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 VE(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=oy(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(YE(c));for(r.sort(HE),s=0;s<r.length;s++)t=GE(r[s],t);return t}function HE(n,e){return n.x-e.x}function GE(n,e){let t=$E(n,e);if(!t)return e;let i=ly(t,n);return mr(i,i.next),mr(t,t.next)}function $E(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&&ss(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&&WE(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function WE(n,e){return mt(n.prev,n,e.prev)<0&&mt(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,XE(r)}function XE(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 YE(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 ss(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 qE(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!ZE(n,e)&&(Wo(n,e)&&Wo(e,n)&&JE(n,e)&&(mt(n.prev,n,e.prev)||mt(n,e.prev,e))||hu(n,e)&&mt(n.prev,n,n.next)>0&&mt(e.prev,e,e.next)>0)}function mt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function hu(n,e){return n.x===e.x&&n.y===e.y}function ay(n,e,t,i){let r=Ul(mt(n,e,t)),s=Ul(mt(n,e,i)),o=Ul(mt(t,i,n)),a=Ul(mt(t,i,e));return!!(r!==s&&o!==a||r===0&&Ol(n,t,e)||s===0&&Ol(n,i,e)||o===0&&Ol(t,n,i)||a===0&&Ol(t,e,i))}function Ol(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 Ul(n){return n>0?1:n<0?-1:0}function ZE(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&&ay(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Wo(n,e){return mt(n.prev,n,n.next)<0?mt(n,e,n.next)>=0&&mt(n,n.prev,e)>=0:mt(n,e,n.prev)<0||mt(n,n.next,e)<0}function JE(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 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 KE(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 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 eT(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 tT(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 sr(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,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 nT(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 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=sr(d,c.times.constructor),c.values=sr(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 iT(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(p){return p.name===a.name&&p.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 m=a.times.length-1,y;if(s<=a.times[0]){let p=u,_=d-u;y=a.values.slice(p,_)}else if(s>=a.times[m]){let p=m*d+u,_=p+d-u;y=a.values.slice(p,_)}else{let p=a.createInterpolant(),_=u,v=d-u;p.evaluate(s),y=p.resultBuffer.slice(_,v)}l==="quaternion"&&new Ht().fromArray(y).normalize().conjugate().toArray(y);let g=c.times.length;for(let p=0;p<g;++p){let _=p*f+h;if(l==="quaternion")Ht.multiplyQuaternionsFlat(c.values,_,y,0,c.values,_);else{let v=f-h*2;for(let w=0;w<v;++w)c.values[_+w]-=y[w]}}}return n.blendMode=Nf,n}function sT(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yr;case"vector":case"vector2":case"vector3":case"vector4":return vr;case"color":return Jo;case"quaternion":return Li;case"bool":case"boolean":return li;case"string":return ci}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function oT(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=sT(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 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 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 _t(n,e,t,i,r,s,o){zl.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],zl.x,zl.y,zl.z)}}var Lb,Db,Ob,zg,Cd,Vg,Ub,Nb,Ef,Hg,Rn,si,Xt,Ln,ni,or,Rd,Pd,Ld,Gg,Ei,$g,Wg,jg,Xg,Yg,qg,Zg,Jg,ql,Zl,Kg,Qg,e0,t0,n0,i0,r0,s0,o0,a0,l0,c0,po,u0,d0,h0,f0,na,p0,m0,ii,g0,y0,v0,_0,x0,b0,w0,Dd,M0,lu,oi,Ii,mo,go,xs,yo,yn,vo,Pt,Tf,Fb,ns,kb,wt,lo,Bb,Dn,zb,ai,S0,A0,If,Cf,cr,vn,ia,Rf,Pf,bs,E0,T0,I0,tn,C0,R0,ar,ls,Lf,Df,P0,Of,Uf,Gl,$l,Wl,jl,Od,Ud,Nd,Fd,kd,Bd,zd,Vd,Hd,Gd,$d,Wd,jd,Xd,Yd,qd,Zd,Jd,Kd,Qd,eh,Xl,th,nh,L0,ih,rh,sh,D0,O0,U0,_o,xo,Yl,ir,rr,bo,cu,Nf,Vb,Hb,Gb,N0,F0,Di,k0,Jn,gn,ui,uu,ra,wo,dt,Mo,So,$b,er,Wb,jb,Xb,Yb,qb,Zb,Jb,Kb,Qb,ew,tw,nw,iw,oh,B0,z0,V0,Ff,H0,G0,$0,W0,Ao,rw,sw,ow,aw,lw,cw,uw,dw,hw,ah,On,Eo,Tn,Bt,lm,lr,cs,Cw,ne,He,Wu,Rw,cm,um,dm,Ja,Pw,at,Or,Jl,Lw,Qn,Dw,Mt,lt,Kl,rn,us,lh,Io,ch,Ht,T,Yu,hm,Ot,Wn,Mn,Ka,Ur,Nr,Fr,vi,_i,Hi,Ys,Qa,el,Gi,Ow,qs,Zu,Lt,jn,Ju,tl,xi,Ku,nl,Qu,Ci,Ne,kr,Sn,Uw,Nw,bi,il,Qt,fm,pm,sn,ds,Fw,mm,Br,Xn,rl,Zs,kw,Bw,gm,ym,vm,_m,zw,zr,ed,rt,An,Yn,td,qn,Vr,Hr,xm,nd,id,rd,ei,q0,wi,sl,we,zt,Vw,Dt,Fn,Kn,Gw,bt,ol,nt,uh,dh,hh,fh,Co,ph,Ro,mh,Te,$w,mn,od,Gr,en,Js,Rt,Ye,bm,$i,al,wm,$r,Wr,jr,ad,ll,cl,ul,dl,Mm,Sm,Am,hl,fl,vt,ur,J0,Xw,Yw,on,fs,Mi,Em,Tm,Et,Xr,Yr,Ql,dr,ec,ld,qw,Zw,Pn,Wi,ml,hr,ps,Kw,Qw,eM,tM,nM,iM,rM,sM,oM,aM,lM,cM,uM,dM,hM,fM,pM,mM,gM,yM,vM,_M,xM,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,_S,xS,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,_1,x1,b1,w1,M1,S1,A1,E1,T1,I1,C1,R1,We,ve,En,gl,ji,P1,ms,rs,Im,nr,cd,Cm,ud,dd,hd,fd,tr,qr,Rm,Po,Lo,Q0,ey,ty,ny,iy,Om,Um,Nm,Fm,km,gh,yh,vh,pd,as,OA,UA,GA,$A,jA,eE,xh,bh,aE,Do,Oo,dE,hE,tc,Ti,gE,uo,yE,vE,wh,Mh,Xi,_E,Sh,nc,ic,rc,gs,$t,fr,Uo,Zr,Ks,Jr,Kr,Qr,Qs,sy,vl,eo,_l,qm,md,Zm,sc,bl,Jm,oc,Km,Qm,eg,wE,tg,wl,gd,ng,yd,ac,No,Un,ig,ME,lc,Ri,es,rg,Ml,sg,SE,to,no,cc,Ah,ts,Si,og,TE,ag,vd,Sl,Yi,io,_d,Vt,Al,uc,Ut,dc,hc,lg,ro,El,xd,cg,kn,ug,dg,_n,fc,Fo,hg,Eh,Il,Cl,pc,Th,Ih,ys,Ch,Rh,Ph,an,vs,mc,Rl,bd,wd,Md,gc,ko,yc,Bo,vc,zo,Vo,Ho,_c,xc,pr,Go,bc,wc,_s,Mc,Pi,Sc,Pl,Ll,Sd,Dl,Ac,ri,NE,Nn,Ec,QE,Tc,Xo,Ic,Cc,Yo,Rc,Pc,Lc,Dc,Oc,_g,Uc,Nc,qo,Fc,kc,Bc,zc,Vc,Hc,Gc,rT,gr,$c,Zo,Wc,ln,li,Jo,yr,jc,Li,ci,vr,_r,ti,Ko,dy,Gt,Zn,Uh,In,Nh,Fh,xr,kh,Bh,zh,Bn,Xc,Ad,xg,bg,Qo,Vh,Yc,wg,so,Ed,Hh,qc,Gh,Zc,Jc,Kc,Qc,eu,tu,ea,nu,iu,$h,aT,Mg,Sg,Wh,Nl,ta,jh,Ag,Eg,qi,Xh,ru,Zi,Ig,lT,Ji,Yh,su,Ki,Cg,cT,Qi,qh,Zh,ou,Hf,uT,Gf,dT,hT,fT,pT,mT,gT,yT,Jh,ot,Kh,au,vT,Qh,ef,_T,tf,nf,rf,Rg,sf,af,lf,Lg,cf,Dg,Fl,uf,Og,df,Ai,kl,Td,hf,ff,xT,Ug,Ng,pf,mf,gf,Fg,Bl,kg,yf,zl,gt,vf,Vl,_f,xf,bf,Bg,Hl,Id,wf,Mf,Sf,Af,py=By(()=>{"use strict";Lb="164",Db={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ob={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zg=0,Cd=1,Vg=2,Ub=3,Nb=0,Ef=1,Hg=2,Rn=3,si=0,Xt=1,Ln=2,ni=0,or=1,Rd=2,Pd=3,Ld=4,Gg=5,Ei=100,$g=101,Wg=102,jg=103,Xg=104,Yg=200,qg=201,Zg=202,Jg=203,ql=204,Zl=205,Kg=206,Qg=207,e0=208,t0=209,n0=210,i0=211,r0=212,s0=213,o0=214,a0=0,l0=1,c0=2,po=3,u0=4,d0=5,h0=6,f0=7,na=0,p0=1,m0=2,ii=0,g0=1,y0=2,v0=3,_0=4,x0=5,b0=6,w0=7,Dd="attached",M0="detached",lu=300,oi=301,Ii=302,mo=303,go=304,xs=306,yo=1e3,yn=1001,vo=1002,Pt=1003,Tf=1004,Fb=1004,ns=1005,kb=1005,wt=1006,lo=1007,Bb=1007,Dn=1008,zb=1008,ai=1009,S0=1010,A0=1011,If=1012,Cf=1013,cr=1014,vn=1015,ia=1016,Rf=1017,Pf=1018,bs=1020,E0=35902,T0=1021,I0=1022,tn=1023,C0=1024,R0=1025,ar=1026,ls=1027,Lf=1028,Df=1029,P0=1030,Of=1031,Uf=1033,Gl=33776,$l=33777,Wl=33778,jl=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,Xl=36492,th=36494,nh=36495,L0=36283,ih=36284,rh=36285,sh=36286,D0=2200,O0=2201,U0=2202,_o=2300,xo=2301,Yl=2302,ir=2400,rr=2401,bo=2402,cu=2500,Nf=2501,Vb=0,Hb=1,Gb=2,N0=3200,F0=3201,Di=0,k0=1,Jn="",gn="srgb",ui="srgb-linear",uu="display-p3",ra="display-p3-linear",wo="linear",dt="srgb",Mo="rec709",So="p3",$b=0,er=7680,Wb=7681,jb=7682,Xb=7683,Yb=34055,qb=34056,Zb=5386,Jb=512,Kb=513,Qb=514,ew=515,tw=516,nw=517,iw=518,oh=519,B0=512,z0=513,V0=514,Ff=515,H0=516,G0=517,$0=518,W0=519,Ao=35044,rw=35048,sw=35040,ow=35045,aw=35049,lw=35041,cw=35046,uw=35050,dw=35042,hw="100",ah="300 es",On=2e3,Eo=2001,Tn=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}}},Bt=["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,lr=Math.PI/180,cs=180/Math.PI;Cw={DEG2RAD:lr,RAD2DEG:cs,generateUUID:nn,clamp:yt,euclideanModulo:kf,mapLinear:fw,inverseLerp:pw,lerp:co,damp:mw,pingpong:gw,smoothstep:yw,smootherstep:vw,randInt:_w,randFloat:xw,randFloatSpread:bw,seededRandom:ww,degToRad:Mw,radToDeg:Sw,isPowerOfTwo:Aw,ceilPowerOfTwo:Ew,floorPowerOfTwo:Tw,setQuaternionFromProperEuler:Iw,normalize:Ge,denormalize:jt},ne=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(yt(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}},He=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],m=i[8],y=r[0],g=r[3],p=r[6],_=r[1],v=r[4],w=r[7],P=r[2],A=r[5],E=r[8];return s[0]=o*y+a*_+l*P,s[3]=o*g+a*v+l*A,s[6]=o*p+a*w+l*E,s[1]=c*y+u*_+d*P,s[4]=c*g+u*v+d*A,s[7]=c*p+u*w+d*E,s[2]=h*y+f*_+m*P,s[5]=h*g+f*v+m*A,s[8]=h*p+f*w+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],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,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]=(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 He;Rw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};cm={};um=new He().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),dm=new He().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ja={[ui]:{transfer:wo,primaries:Mo,toReference:n=>n,fromReference:n=>n},[gn]:{transfer:dt,primaries:Mo,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[ra]:{transfer:wo,primaries:So,toReference:n=>n.applyMatrix3(dm),fromReference:n=>n.applyMatrix3(um)},[uu]:{transfer:dt,primaries:So,toReference:n=>n.convertSRGBToLinear().applyMatrix3(dm),fromReference:n=>n.applyMatrix3(um).convertLinearToSRGB()}},Pw=new Set([ui,ra]),at={enabled:!0,_workingColorSpace:ui,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Pw.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=Ja[e].toReference,r=Ja[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 Ja[n].primaries},getTransfer:function(n){return n===Jn?wo:Ja[n].transfer}};Jl=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{Or===void 0&&(Or=To("canvas")),Or.width=e.width,Or.height=e.height;let i=Or.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Or}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]=os(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(os(t[i]/255)*255):t[i]=os(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}},Lw=0,Qn=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Lw++}),this.uuid=nn(),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}};Dw=0,Mt=class n extends Tn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=yn,r=yn,s=wt,o=Dn,a=tn,l=ai,c=n.DEFAULT_ANISOTROPY,u=Jn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dw++}),this.uuid=nn(),this.name="",this.source=new Qn(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 ne(0,0),this.repeat=new ne(1,1),this.center=new ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,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!==lu)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 yn: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 yn: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++}};Mt.DEFAULT_IMAGE=null;Mt.DEFAULT_MAPPING=lu;Mt.DEFAULT_ANISOTROPY=1;lt=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],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,w=(f+1)/2,P=(p+1)/2,A=(u+h)/4,E=(d+y)/4,L=(m+g)/4;return v>w&&v>P?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=A/i,s=E/i):w>P?w<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),i=A/r,s=L/r):P<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(P),i=E/s,r=L/s),this.set(i,r,s,t),this}let _=Math.sqrt((g-m)*(g-m)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(_)<.001&&(_=1),this.x=(g-m)/_,this.y=(d-y)/_,this.z=(h-u)/_,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}},Kl=class extends Tn{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new lt(0,0,e,t),this.scissorTest=!1,this.viewport=new lt(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new Mt(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 Qn(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"})}},rn=class extends Kl{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},us=class extends Mt{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=Pt,this.minFilter=Pt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},lh=class extends rn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new us(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Io=class extends Mt{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=Pt,this.minFilter=Pt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ch=class extends rn{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}},Ht=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],m=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]=m,e[t+3]=y;return}if(d!==y||l!==h||c!==f||u!==m){let g=1-a,p=l*h+c*f+u*m+d*y,_=p>=0?1:-1,v=1-p*p;if(v>Number.EPSILON){let P=Math.sqrt(v),A=Math.atan2(P,p*_);g=Math.sin(g*A)/P,a=Math.sin(a*A)/P}let w=a*_;if(l=l*g+h*w,c=c*g+f*w,u=u*g+m*w,d=d*g+y*w,g===1-a){let P=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=P,c*=P,u*=P,d*=P}}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],m=s[o+3];return e[t]=a*m+u*d+l*f-c*h,e[t+1]=l*m+u*h+c*d-a*f,e[t+2]=c*m+u*f+a*h-l*d,e[t+3]=u*m-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),m=l(s/2);switch(o){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: "+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(yt(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}},T=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,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(yt(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 T,hm=new Ht,Ot=class{constructor(e=new T(1/0,1/0,1/0),t=new T(-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(Mn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Mn.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=Mn.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,Mn):Mn.fromBufferAttribute(s,o),Mn.applyMatrix4(e.matrixWorld),this.expandByPoint(Mn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ka.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ka.copy(i.boundingBox)),Ka.applyMatrix4(e.matrixWorld),this.union(Ka)}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,Mn),Mn.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),Qa.subVectors(this.max,Ys),Ur.subVectors(e.a,Ys),Nr.subVectors(e.b,Ys),Fr.subVectors(e.c,Ys),vi.subVectors(Nr,Ur),_i.subVectors(Fr,Nr),Hi.subVectors(Ur,Fr);let t=[0,-vi.z,vi.y,0,-_i.z,_i.y,0,-Hi.z,Hi.y,vi.z,0,-vi.x,_i.z,0,-_i.x,Hi.z,0,-Hi.x,-vi.y,vi.x,0,-_i.y,_i.x,0,-Hi.y,Hi.x,0];return!qu(t,Ur,Nr,Fr,Qa)||(t=[1,0,0,0,1,0,0,0,1],!qu(t,Ur,Nr,Fr,Qa))?!1:(el.crossVectors(vi,_i),t=[el.x,el.y,el.z],qu(t,Ur,Nr,Fr,Qa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Mn).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:(Wn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wn),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)}},Wn=[new T,new T,new T,new T,new T,new T,new T,new T],Mn=new T,Ka=new Ot,Ur=new T,Nr=new T,Fr=new T,vi=new T,_i=new T,Hi=new T,Ys=new T,Qa=new T,el=new T,Gi=new T;Ow=new Ot,qs=new T,Zu=new T,Lt=class{constructor(e=new T,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):Ow.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)}},jn=new T,Ju=new T,tl=new T,xi=new T,Ku=new T,nl=new T,Qu=new T,Ci=class{constructor(e=new T,t=new T(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,jn)),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=jn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(jn.copy(this.origin).addScaledVector(this.direction,t),jn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ju.copy(e).add(t).multiplyScalar(.5),tl.copy(t).sub(e).normalize(),xi.copy(this.origin).sub(Ju);let s=e.distanceTo(t)*.5,o=-this.direction.dot(tl),a=xi.dot(this.direction),l=-xi.dot(tl),c=xi.lengthSq(),u=Math.abs(1-o*o),d,h,f,m;if(u>0)if(d=o*l-a,h=o*a-l,m=s*u,d>=0)if(h>=-m)if(h<=m){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<=-m?(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<=m?(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(tl,h),f}intersectSphere(e,t){jn.subVectors(e.center,this.origin);let i=jn.dot(this.direction),r=jn.dot(jn)-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,jn)!==null}intersectTriangle(e,t,i,r,s){Ku.subVectors(t,e),nl.subVectors(i,e),Qu.crossVectors(Ku,nl);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(nl.crossVectors(xi,nl));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,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,o,a,l,c,u,d,h,f,m,y,g)}set(e,t,i,r,s,o,a,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]=o,p[9]=a,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/kr.setFromMatrixColumn(e,0).length(),s=1/kr.setFromMatrixColumn(e,1).length(),o=1/kr.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,m=a*u,y=a*d;t[0]=l*u,t[4]=-l*d,t[8]=c,t[1]=f+m*c,t[5]=h-y*c,t[9]=-a*l,t[2]=y-h*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){let h=l*u,f=l*d,m=c*u,y=c*d;t[0]=h+y*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-m,t[6]=y+h*a,t[10]=o*l}else if(e.order==="ZXY"){let h=l*u,f=l*d,m=c*u,y=c*d;t[0]=h-y*a,t[4]=-o*d,t[8]=m+f*a,t[1]=f+m*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,m=a*u,y=a*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]=a*l,t[10]=o*l}else if(e.order==="YZX"){let h=o*l,f=o*c,m=a*l,y=a*c;t[0]=l*u,t[4]=y-h*d,t[8]=m*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*d+m,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*l,f=o*c,m=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-m,t[2]=m*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(Uw,e,Nw)}lookAt(e,t,i){let r=this.elements;return Qt.subVectors(e,t),Qt.lengthSq()===0&&(Qt.z=1),Qt.normalize(),bi.crossVectors(i,Qt),bi.lengthSq()===0&&(Math.abs(i.z)===1?Qt.x+=1e-4:Qt.z+=1e-4,Qt.normalize(),bi.crossVectors(i,Qt)),bi.normalize(),il.crossVectors(Qt,bi),r[0]=bi.x,r[4]=il.x,r[8]=Qt.x,r[1]=bi.y,r[5]=il.y,r[9]=Qt.y,r[2]=bi.z,r[6]=il.z,r[10]=Qt.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],m=i[2],y=i[6],g=i[10],p=i[14],_=i[3],v=i[7],w=i[11],P=i[15],A=r[0],E=r[4],L=r[8],b=r[12],x=r[1],R=r[5],U=r[9],D=r[13],$=r[2],j=r[6],N=r[10],X=r[14],k=r[3],le=r[7],ce=r[11],Me=r[15];return s[0]=o*A+a*x+l*$+c*k,s[4]=o*E+a*R+l*j+c*le,s[8]=o*L+a*U+l*N+c*ce,s[12]=o*b+a*D+l*X+c*Me,s[1]=u*A+d*x+h*$+f*k,s[5]=u*E+d*R+h*j+f*le,s[9]=u*L+d*U+h*N+f*ce,s[13]=u*b+d*D+h*X+f*Me,s[2]=m*A+y*x+g*$+p*k,s[6]=m*E+y*R+g*j+p*le,s[10]=m*L+y*U+g*N+p*ce,s[14]=m*b+y*D+g*X+p*Me,s[3]=_*A+v*x+w*$+P*k,s[7]=_*E+v*R+w*j+P*le,s[11]=_*L+v*U+w*N+P*ce,s[15]=_*b+v*D+w*X+P*Me,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],m=e[3],y=e[7],g=e[11],p=e[15];return m*(+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)+p*(-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],m=e[12],y=e[13],g=e[14],p=e[15],_=d*g*c-y*h*c+y*l*f-a*g*f-d*l*p+a*h*p,v=m*h*c-u*g*c-m*l*f+o*g*f+u*l*p-o*h*p,w=u*y*c-m*d*c+m*a*f-o*y*f-u*a*p+o*d*p,P=m*d*l-u*y*l-m*a*h+o*y*h+u*a*g-o*d*g,A=t*_+i*v+r*w+s*P;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]=_*E,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*p-i*h*p)*E,e[2]=(a*g*s-y*l*s+y*r*c-i*g*c-a*r*p+i*l*p)*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-m*h*s+m*r*f-t*g*f-u*r*p+t*h*p)*E,e[6]=(m*l*s-o*g*s-m*r*c+t*g*c+o*r*p-t*l*p)*E,e[7]=(o*h*s-u*l*s+u*r*c-t*h*c-o*r*f+t*l*f)*E,e[8]=w*E,e[9]=(m*d*s-u*y*s-m*i*f+t*y*f+u*i*p-t*d*p)*E,e[10]=(o*y*s-m*a*s+m*i*c-t*y*c-o*i*p+t*a*p)*E,e[11]=(u*a*s-o*d*s-u*i*c+t*d*c+o*i*f-t*a*f)*E,e[12]=P*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*a*r-o*y*r-m*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,m=s*d,y=o*u,g=o*d,p=a*d,_=l*c,v=l*u,w=l*d,P=i.x,A=i.y,E=i.z;return r[0]=(1-(y+p))*P,r[1]=(f+w)*P,r[2]=(m-v)*P,r[3]=0,r[4]=(f-w)*A,r[5]=(1-(h+p))*A,r[6]=(g+_)*A,r[7]=0,r[8]=(m+v)*E,r[9]=(g-_)*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=kr.set(r[0],r[1],r[2]).length(),o=kr.set(r[4],r[5],r[6]).length(),a=kr.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],Sn.copy(this);let c=1/s,u=1/o,d=1/a;return Sn.elements[0]*=c,Sn.elements[1]*=c,Sn.elements[2]*=c,Sn.elements[4]*=u,Sn.elements[5]*=u,Sn.elements[6]*=u,Sn.elements[8]*=d,Sn.elements[9]*=d,Sn.elements[10]*=d,t.setFromRotationMatrix(Sn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=On){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(a===On)f=-(o+s)/(o-s),m=-2*o*s/(o-s);else if(a===Eo)f=-o/(o-s),m=-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]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=On){let l=this.elements,c=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*c,f=(i+r)*u,m,y;if(a===On)m=(o+s)*d,y=-2*d;else if(a===Eo)m=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]=-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}},kr=new T,Sn=new Ne,Uw=new T(0,0,0),Nw=new T(1,1,1),bi=new T,il=new T,Qt=new T,fm=new Ne,pm=new Ht,sn=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(yt(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(-yt(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(yt(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(-yt(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(yt(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(-yt(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 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}};sn.DEFAULT_ORDER="XYZ";ds=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}},Fw=0,mm=new T,Br=new Ht,Xn=new Ne,rl=new T,Zs=new T,kw=new T,Bw=new Ht,gm=new T(1,0,0),ym=new T(0,1,0),vm=new T(0,0,1),_m={type:"added"},zw={type:"removed"},zr={type:"childadded",child:null},ed={type:"childremoved",child:null},rt=class n extends Tn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fw++}),this.uuid=nn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new T,t=new sn,i=new Ht,r=new T(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 He}}),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 ds,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 Br.setFromAxisAngle(e,t),this.quaternion.multiply(Br),this}rotateOnWorldAxis(e,t){return Br.setFromAxisAngle(e,t),this.quaternion.premultiply(Br),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(Xn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?rl.copy(e):rl.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Zs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xn.lookAt(Zs,rl,this.up):Xn.lookAt(rl,Zs,this.up),this.quaternion.setFromRotationMatrix(Xn),r&&(Xn.extractRotation(r.matrixWorld),Br.setFromRotationMatrix(Xn),this.quaternion.premultiply(Br.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),zr.child=e,this.dispatchEvent(zr),zr.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(zw),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),Xn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(_m),zr.child=e,this.dispatchEvent(zr),zr.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,kw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,Bw,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),m=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),m.length>0&&(i.nodes=m)}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}};rt.DEFAULT_UP=new T(0,1,0);rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;An=new T,Yn=new T,td=new T,qn=new T,Vr=new T,Hr=new T,xm=new T,nd=new T,id=new T,rd=new T,ei=class n{constructor(e=new T,t=new T,i=new T){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),An.subVectors(e,t),r.cross(An);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){An.subVectors(r,t),Yn.subVectors(i,t),td.subVectors(e,t);let o=An.dot(An),a=An.dot(Yn),l=An.dot(td),c=Yn.dot(Yn),u=Yn.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,m=(o*u-a*l)*h;return s.set(1-f-m,m,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,qn)===null?!1:qn.x>=0&&qn.y>=0&&qn.x+qn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,qn)===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,qn.x),l.addScaledVector(o,qn.y),l.addScaledVector(a,qn.z),l)}static isFrontFacing(e,t,i,r){return An.subVectors(i,t),Yn.subVectors(e,t),An.cross(Yn).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 An.subVectors(this.c,this.b),Yn.subVectors(this.a,this.b),An.cross(Yn).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;Vr.subVectors(r,i),Hr.subVectors(s,i),nd.subVectors(e,i);let l=Vr.dot(nd),c=Hr.dot(nd);if(l<=0&&c<=0)return t.copy(i);id.subVectors(e,r);let u=Vr.dot(id),d=Hr.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(Vr,o);rd.subVectors(e,s);let f=Vr.dot(rd),m=Hr.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 a=c/(c-m),t.copy(i).addScaledVector(Hr,a);let g=u*m-f*d;if(g<=0&&d-u>=0&&f-m>=0)return xm.subVectors(s,r),a=(d-u)/(d-u+(f-m)),t.copy(r).addScaledVector(xm,a);let p=1/(g+y+h);return o=y*p,a=h*p,t.copy(i).addScaledVector(Vr,o).addScaledVector(Hr,a)}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},wi={h:0,s:0,l:0},sl={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=gn){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=yt(t,0,1),i=yt(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 at.toWorkingColorSpace(this,r),this}setStyle(e,t=gn){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=gn){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=os(e.r),this.g=os(e.g),this.b=os(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=gn){return at.fromWorkingColorSpace(zt.copy(this),e),Math.round(yt(zt.r*255,0,255))*65536+Math.round(yt(zt.g*255,0,255))*256+Math.round(yt(zt.b*255,0,255))}getHexString(e=gn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=at.workingColorSpace){at.fromWorkingColorSpace(zt.copy(this),t);let i=zt.r,r=zt.g,s=zt.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=at.workingColorSpace){return at.fromWorkingColorSpace(zt.copy(this),t),e.r=zt.r,e.g=zt.g,e.b=zt.b,e}getStyle(e=gn){at.fromWorkingColorSpace(zt.copy(this),e);let t=zt.r,i=zt.g,r=zt.b;return e!==gn?`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(wi),this.setHSL(wi.h+e,wi.s+t,wi.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(wi),e.getHSL(sl);let i=co(wi.h,sl.h,t),r=co(wi.s,sl.s,t),s=co(wi.l,sl.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}},zt=new we;we.NAMES=q0;Vw=0,Dt=class extends Tn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vw++}),this.uuid=nn(),this.name="",this.type="Material",this.blending=or,this.side=si,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ql,this.blendDst=Zl,this.blendEquation=Ei,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=er,this.stencilZFail=er,this.stencilZPass=er,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!==or&&(i.blending=this.blending),this.side!==si&&(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!==ql&&(i.blendSrc=this.blendSrc),this.blendDst!==Zl&&(i.blendDst=this.blendDst),this.blendEquation!==Ei&&(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!==er&&(i.stencilFail=this.stencilFail),this.stencilZFail!==er&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==er&&(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++}},Fn=class extends Dt{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 sn,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}},Kn=Hw();Gw={toHalfFloat:qt,fromHalfFloat:oo},bt=new T,ol=new ne,nt=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=vn,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++)ol.fromBufferAttribute(this,t),ol.applyMatrix3(e),this.setXY(t,ol.x,ol.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)bt.fromBufferAttribute(this,t),bt.applyMatrix3(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)bt.fromBufferAttribute(this,t),bt.applyMatrix4(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)bt.fromBufferAttribute(this,t),bt.applyNormalMatrix(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)bt.fromBufferAttribute(this,t),bt.transformDirection(e),this.setXYZ(t,bt.x,bt.y,bt.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=jt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ge(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=jt(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=jt(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ge(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=jt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ge(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=jt(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ge(t,this.array),i=Ge(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=Ge(t,this.array),i=Ge(i,this.array),r=Ge(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=Ge(t,this.array),i=Ge(i,this.array),r=Ge(r,this.array),s=Ge(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 nt{constructor(e,t,i){super(new Int8Array(e),t,i)}},dh=class extends nt{constructor(e,t,i){super(new Uint8Array(e),t,i)}},hh=class extends nt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},fh=class extends nt{constructor(e,t,i){super(new Int16Array(e),t,i)}},Co=class extends nt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},ph=class extends nt{constructor(e,t,i){super(new Int32Array(e),t,i)}},Ro=class extends nt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},mh=class extends nt{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=jt(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize]=qt(t),this}getY(e){let t=oo(this.array[e*this.itemSize+1]);return this.normalized&&(t=jt(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+1]=qt(t),this}getZ(e){let t=oo(this.array[e*this.itemSize+2]);return this.normalized&&(t=jt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+2]=qt(t),this}getW(e){let t=oo(this.array[e*this.itemSize+3]);return this.normalized&&(t=jt(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+3]=qt(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ge(t,this.array),i=Ge(i,this.array)),this.array[e+0]=qt(t),this.array[e+1]=qt(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ge(t,this.array),i=Ge(i,this.array),r=Ge(r,this.array)),this.array[e+0]=qt(t),this.array[e+1]=qt(i),this.array[e+2]=qt(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ge(t,this.array),i=Ge(i,this.array),r=Ge(r,this.array),s=Ge(s,this.array)),this.array[e+0]=qt(t),this.array[e+1]=qt(i),this.array[e+2]=qt(r),this.array[e+3]=qt(s),this}},Te=class extends nt{constructor(e,t,i){super(new Float32Array(e),t,i)}},$w=0,mn=new Ne,od=new rt,Gr=new T,en=new Ot,Js=new Ot,Rt=new T,Ye=class n extends Tn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$w++}),this.uuid=nn(),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)?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 He().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 mn.makeRotationFromQuaternion(e),this.applyMatrix4(mn),this}rotateX(e){return mn.makeRotationX(e),this.applyMatrix4(mn),this}rotateY(e){return mn.makeRotationY(e),this.applyMatrix4(mn),this}rotateZ(e){return mn.makeRotationZ(e),this.applyMatrix4(mn),this}translate(e,t,i){return mn.makeTranslation(e,t,i),this.applyMatrix4(mn),this}scale(e,t,i){return mn.makeScale(e,t,i),this.applyMatrix4(mn),this}lookAt(e){return od.lookAt(e),od.updateMatrix(),this.applyMatrix4(od.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gr).negate(),this.translate(Gr.x,Gr.y,Gr.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 Ot);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 T(-1/0,-1/0,-1/0),new T(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];en.setFromBufferAttribute(s),this.morphTargetsRelative?(Rt.addVectors(this.boundingBox.min,en.min),this.boundingBox.expandByPoint(Rt),Rt.addVectors(this.boundingBox.max,en.max),this.boundingBox.expandByPoint(Rt)):(this.boundingBox.expandByPoint(en.min),this.boundingBox.expandByPoint(en.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 Lt);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 T,1/0);return}if(e){let i=this.boundingSphere.center;if(en.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Js.setFromBufferAttribute(a),this.morphTargetsRelative?(Rt.addVectors(en.min,Js.min),en.expandByPoint(Rt),Rt.addVectors(en.max,Js.max),en.expandByPoint(Rt)):(en.expandByPoint(Js.min),en.expandByPoint(Js.max))}en.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Rt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Rt));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++)Rt.fromBufferAttribute(a,c),l&&(Gr.fromBufferAttribute(e,c),Rt.add(Gr)),r=Math.max(r,i.distanceToSquared(Rt))}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 nt(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let L=0;L<i.count;L++)a[L]=new T,l[L]=new T;let c=new T,u=new T,d=new T,h=new ne,f=new ne,m=new ne,y=new T,g=new T;function p(L,b,x){c.fromBufferAttribute(i,L),u.fromBufferAttribute(i,b),d.fromBufferAttribute(i,x),h.fromBufferAttribute(s,L),f.fromBufferAttribute(s,b),m.fromBufferAttribute(s,x),u.sub(c),d.sub(c),f.sub(h),m.sub(h);let R=1/(f.x*m.y-m.x*f.y);isFinite(R)&&(y.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(R),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(R),a[L].add(y),a[b].add(y),a[x].add(y),l[L].add(g),l[b].add(g),l[x].add(g))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let L=0,b=_.length;L<b;++L){let x=_[L],R=x.start,U=x.count;for(let D=R,$=R+U;D<$;D+=3)p(e.getX(D+0),e.getX(D+1),e.getX(D+2))}let v=new T,w=new T,P=new T,A=new T;function E(L){P.fromBufferAttribute(r,L),A.copy(P);let b=a[L];v.copy(b),v.sub(P.multiplyScalar(P.dot(b))).normalize(),w.crossVectors(A,b);let R=w.dot(l[L])<0?-1:1;o.setXYZW(L,v.x,v.y,v.z,R)}for(let L=0,b=_.length;L<b;++L){let x=_[L],R=x.start,U=x.count;for(let D=R,$=R+U;D<$;D+=3)E(e.getX(D+0)),E(e.getX(D+1)),E(e.getX(D+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 nt(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 T,s=new T,o=new T,a=new T,l=new T,c=new T,u=new T,d=new T;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),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,g),a.add(u),l.add(u),c.add(u),i.setXYZ(m,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++)Rt.fromBufferAttribute(e,t),Rt.normalize(),e.setXYZ(t,Rt.x,Rt.y,Rt.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,m=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 p=0;p<u;p++)h[m++]=c[f++]}return new nt(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"})}},bm=new Ne,$i=new Ci,al=new Lt,wm=new T,$r=new T,Wr=new T,jr=new T,ad=new T,ll=new T,cl=new ne,ul=new ne,dl=new ne,Mm=new T,Sm=new T,Am=new T,hl=new T,fl=new T,vt=class extends rt{constructor(e=new Ye,t=new Fn){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){ll.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?ll.addScaledVector(ad,u):ll.addScaledVector(ad.sub(t),u))}t.add(ll)}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),$i.copy(e.ray).recast(e.near),!(al.containsPoint($i.origin)===!1&&($i.intersectSphere(al,wm)===null||$i.origin.distanceToSquared(wm)>(e.far-e.near)**2))&&(bm.copy(s).invert(),$i.copy(e.ray).applyMatrix4(bm),!(i.boundingBox!==null&&$i.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,$i)))}_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 m=0,y=h.length;m<y;m++){let g=h[m],p=o[g.materialIndex],_=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let w=_,P=v;w<P;w+=3){let A=a.getX(w),E=a.getX(w+1),L=a.getX(w+2);r=pl(this,p,e,i,c,u,d,A,E,L),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let m=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=m,p=y;g<p;g+=3){let _=a.getX(g),v=a.getX(g+1),w=a.getX(g+2);r=pl(this,o,e,i,c,u,d,_,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,y=h.length;m<y;m++){let g=h[m],p=o[g.materialIndex],_=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let w=_,P=v;w<P;w+=3){let A=w,E=w+1,L=w+2;r=pl(this,p,e,i,c,u,d,A,E,L),r&&(r.faceIndex=Math.floor(w/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 _=g,v=g+1,w=g+2;r=pl(this,o,e,i,c,u,d,_,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};ur=class n extends Ye{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;m("z","y","x",-1,-1,i,t,e,o,s,0),m("z","y","x",1,-1,i,t,-e,o,s,1),m("x","z","y",1,1,e,i,t,r,o,2),m("x","z","y",1,-1,e,i,-t,r,o,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,_,v,w,P,A,E,L,b){let x=w/E,R=P/L,U=w/2,D=P/2,$=A/2,j=E+1,N=L+1,X=0,k=0,le=new T;for(let ce=0;ce<N;ce++){let Me=ce*R-D;for(let Fe=0;Fe<j;Fe++){let Ke=Fe*x-U;le[y]=Ke*_,le[g]=Me*v,le[p]=$,c.push(le.x,le.y,le.z),le[y]=0,le[g]=0,le[p]=A>0?1:-1,u.push(le.x,le.y,le.z),d.push(Fe/E),d.push(1-ce/L),X+=1}}for(let ce=0;ce<L;ce++)for(let Me=0;Me<E;Me++){let Fe=h+Me+j*ce,Ke=h+Me+j*(ce+1),J=h+(Me+1)+j*(ce+1),Z=h+(Me+1)+j*ce;l.push(Fe,Ke,Z),l.push(Ke,J,Z),k+=6}a.addGroup(f,k,b),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:hs,merge:Wt},Xw=`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
- }`,Yw=`void main() {
202
+ }`,Qw=`void main() {
203
203
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
204
- }`,on=class extends Dt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Xw,this.fragmentShader=Yw,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=hs(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}},fs=class extends rt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ne,this.projectionMatrix=new Ne,this.projectionMatrixInverse=new Ne,this.coordinateSystem=On}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)}},Mi=new T,Em=new ne,Tm=new ne,Et=class extends fs{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=cs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(lr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cs*2*Math.atan(Math.tan(lr*.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){Mi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mi.x,Mi.y).multiplyScalar(-e/Mi.z),Mi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Mi.x,Mi.y).multiplyScalar(-e/Mi.z)}getViewSize(e,t){return this.getViewBounds(e,Em,Tm),t.subVectors(Tm,Em)}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(lr*.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}},Xr=-90,Yr=1,Ql=class extends rt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Et(Xr,Yr,e,t);r.layers=this.layers,this.add(r);let s=new Et(Xr,Yr,e,t);s.layers=this.layers,this.add(s);let o=new Et(Xr,Yr,e,t);o.layers=this.layers,this.add(o);let a=new Et(Xr,Yr,e,t);a.layers=this.layers,this.add(a);let l=new Et(Xr,Yr,e,t);l.layers=this.layers,this.add(l);let c=new Et(Xr,Yr,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===On)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(),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,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=m,i.texture.needsPMREMUpdate=!0}},dr=class extends Mt{constructor(e,t,i,r,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:oi,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}},ec=class extends rn{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 dr(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:wt}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 ur(5,5,5),s=new on({name:"CubemapFromEquirect",uniforms:hs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Xt,blending:ni});s.uniforms.tEquirect.value=t;let o=new vt(r,s),a=t.minFilter;return t.minFilter===Dn&&(t.minFilter=wt),new Ql(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 T,qw=new T,Zw=new He,Pn=class{constructor(e=new T(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(qw.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||Zw.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)}},Wi=new Lt,ml=new T,hr=class{constructor(e=new Pn,t=new Pn,i=new Pn,r=new Pn,s=new Pn,o=new Pn){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=On){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],m=r[9],y=r[10],g=r[11],p=r[12],_=r[13],v=r[14],w=r[15];if(i[0].setComponents(l-s,h-c,g-f,w-p).normalize(),i[1].setComponents(l+s,h+c,g+f,w+p).normalize(),i[2].setComponents(l+o,h+u,g+m,w+_).normalize(),i[3].setComponents(l-o,h-u,g-m,w-_).normalize(),i[4].setComponents(l-a,h-d,g-y,w-v).normalize(),t===On)i[5].setComponents(l+a,h+d,g+y,w+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(),Wi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wi)}intersectsSprite(e){return Wi.center.set(0,0,0),Wi.radius=.7071067811865476,Wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)}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(ml.x=r.normal.x>0?e.max.x:e.min.x,ml.y=r.normal.y>0?e.max.y:e.min.y,ml.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ml)<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)}};ps=class n extends Ye{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=[],m=[],y=[],g=[];for(let p=0;p<u;p++){let _=p*h-o;for(let v=0;v<c;v++){let w=v*d-s;m.push(w,-_,0),y.push(0,0,1),g.push(v/a),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let _=0;_<a;_++){let v=_+c*p,w=_+c*(p+1),P=_+1+c*(p+1),A=_+1+c*p;f.push(v,w,A),f.push(w,P,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)}},Kw=`#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`,Qw=`#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`,eM=`#ifdef USE_ALPHAMAP
276
+ #endif`,sM=`#ifdef USE_ALPHAMAP
277
277
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
278
- #endif`,tM=`#ifdef USE_ALPHAMAP
278
+ #endif`,oM=`#ifdef USE_ALPHAMAP
279
279
  uniform sampler2D alphaMap;
280
- #endif`,nM=`#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`,iM=`#ifdef USE_ALPHATEST
287
+ #endif`,lM=`#ifdef USE_ALPHATEST
288
288
  uniform float alphaTest;
289
- #endif`,rM=`#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`,sM=`#ifdef USE_AOMAP
302
+ #endif`,uM=`#ifdef USE_AOMAP
303
303
  uniform sampler2D aoMap;
304
304
  uniform float aoMapIntensity;
305
- #endif`,oM=`#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`,aM=`#ifdef USE_BATCHING
319
+ #endif`,hM=`#ifdef USE_BATCHING
320
320
  mat4 batchingMatrix = getBatchingMatrix( batchId );
321
- #endif`,lM=`vec3 transformed = vec3( position );
321
+ #endif`,fM=`vec3 transformed = vec3( position );
322
322
  #ifdef USE_ALPHAHASH
323
323
  vPosition = vec3( position );
324
- #endif`,cM=`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`,uM=`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`,dM=`#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`,hM=`#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`,fM=`#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`,pM=`#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`,mM=`#if NUM_CLIPPING_PLANES > 0
474
+ #endif`,_M=`#if NUM_CLIPPING_PLANES > 0
475
475
  varying vec3 vClipPosition;
476
- #endif`,gM=`#if NUM_CLIPPING_PLANES > 0
476
+ #endif`,bM=`#if NUM_CLIPPING_PLANES > 0
477
477
  vClipPosition = - mvPosition.xyz;
478
- #endif`,yM=`#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`,vM=`#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`,_M=`#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`,xM=`#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`,bM=`#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`,wM=`#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`,MM=`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`,SM=`#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`,AM=`#ifdef USE_DISPLACEMENTMAP
704
+ #endif`,RM=`#ifdef USE_DISPLACEMENTMAP
705
705
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
706
- #endif`,EM=`#ifdef USE_EMISSIVEMAP
706
+ #endif`,PM=`#ifdef USE_EMISSIVEMAP
707
707
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
708
708
  totalEmissiveRadiance *= emissiveColor.rgb;
709
- #endif`,TM=`#ifdef USE_EMISSIVEMAP
709
+ #endif`,LM=`#ifdef USE_EMISSIVEMAP
710
710
  uniform sampler2D emissiveMap;
711
- #endif`,IM="gl_FragColor = linearToOutputTexel( gl_FragColor );",CM=`
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
- }`,RM=`#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`,PM=`#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`,LM=`#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`,DM=`#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`,OM=`#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`,UM=`#ifdef USE_FOG
817
+ #endif`,zM=`#ifdef USE_FOG
818
818
  vFogDepth = - mvPosition.z;
819
- #endif`,NM=`#ifdef USE_FOG
819
+ #endif`,VM=`#ifdef USE_FOG
820
820
  varying float vFogDepth;
821
- #endif`,FM=`#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`,kM=`#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`,BM=`#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
- }`,zM=`#ifdef USE_LIGHTMAP
849
+ }`,WM=`#ifdef USE_LIGHTMAP
850
850
  uniform sampler2D lightMap;
851
851
  uniform float lightMapIntensity;
852
- #endif`,VM=`LambertMaterial material;
852
+ #endif`,jM=`LambertMaterial material;
853
853
  material.diffuseColor = diffuseColor.rgb;
854
- material.specularStrength = specularStrength;`,HM=`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`,GM=`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`,$M=`#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`,WM=`ToonMaterial material;
1025
- material.diffuseColor = diffuseColor.rgb;`,jM=`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`,XM=`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;`,YM=`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`,qM=`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`,ZM=`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
- }`,JM=`
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`,KM=`#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`,QM=`#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`,eS=`#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`,tS=`#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`,nS=`#ifdef USE_LOGDEPTHBUF
1590
+ #endif`,aS=`#ifdef USE_LOGDEPTHBUF
1591
1591
  varying float vFragDepth;
1592
1592
  varying float vIsPerspective;
1593
- #endif`,iS=`#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`,rS=`#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`,sS=`#ifdef USE_MAP
1603
+ #endif`,uS=`#ifdef USE_MAP
1604
1604
  uniform sampler2D map;
1605
- #endif`,oS=`#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`,aS=`#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`,lS=`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`,cS=`#ifdef USE_METALNESSMAP
1633
+ #endif`,pS=`#ifdef USE_METALNESSMAP
1634
1634
  uniform sampler2D metalnessMap;
1635
- #endif`,uS=`#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`,dS=`#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`,hS=`#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`,fS=`#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`,pS=`#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`,mS=`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;`,gS=`#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;`,gS=`#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`,yS=`#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`,vS=`#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`,_S=`#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`,xS=`#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;`,gS=`#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`,bS=`#ifdef USE_CLEARCOAT
1800
+ #endif`,ES=`#ifdef USE_CLEARCOAT
1801
1801
  vec3 clearcoatNormal = nonPerturbedNormal;
1802
- #endif`,wS=`#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`,MS=`#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;`,gS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1812
1812
  #endif
1813
1813
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1814
1814
  uniform sampler2D clearcoatRoughnessMap;
1815
- #endif`,SS=`#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`,AS=`#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 );`,ES=`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
- }`,TS=`#ifdef PREMULTIPLIED_ALPHA
1867
+ }`,LS=`#ifdef PREMULTIPLIED_ALPHA
1868
1868
  gl_FragColor.rgb *= gl_FragColor.a;
1869
- #endif`,IS=`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;`,CS=`#ifdef DITHERING
1877
+ gl_Position = projectionMatrix * mvPosition;`,OS=`#ifdef DITHERING
1878
1878
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1879
- #endif`,RS=`#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`,PS=`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`,LS=`#ifdef USE_ROUGHNESSMAP
1890
+ #endif`,FS=`#ifdef USE_ROUGHNESSMAP
1891
1891
  uniform sampler2D roughnessMap;
1892
- #endif`,DS=`#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;`,CS=`#ifdef DITHERING
2072
2072
  }
2073
2073
  return shadow;
2074
2074
  }
2075
- #endif`,OS=`#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;`,CS=`#ifdef DITHERING
2110
2110
  };
2111
2111
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2112
2112
  #endif
2113
- #endif`,US=`#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;`,CS=`#ifdef DITHERING
2142
2142
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2143
2143
  }
2144
2144
  #pragma unroll_loop_end
2145
- #endif`,NS=`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;`,CS=`#ifdef DITHERING
2174
2174
  #endif
2175
2175
  #endif
2176
2176
  return shadow;
2177
- }`,FS=`#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`,kS=`#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;`,CS=`#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`,BS=`#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;`,CS=`#ifdef DITHERING
2202
2202
  skinned += boneMatZ * skinVertex * skinWeight.z;
2203
2203
  skinned += boneMatW * skinVertex * skinWeight.w;
2204
2204
  transformed = ( bindMatrixInverse * skinned ).xyz;
2205
- #endif`,zS=`#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;`,CS=`#ifdef DITHERING
2213
2213
  #ifdef USE_TANGENT
2214
2214
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2215
2215
  #endif
2216
- #endif`,VS=`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`,HS=`#ifdef USE_SPECULARMAP
2222
+ #endif`,XS=`#ifdef USE_SPECULARMAP
2223
2223
  uniform sampler2D specularMap;
2224
- #endif`,GS=`#if defined( TONE_MAPPING )
2224
+ #endif`,YS=`#if defined( TONE_MAPPING )
2225
2225
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2226
- #endif`,$S=`#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; }`,WS=`#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; }`,WS=`#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`,jS=`#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; }`,WS=`#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`,XS=`#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; }`,WS=`#ifdef USE_TRANSMISS
2542
2542
  #ifdef USE_THICKNESSMAP
2543
2543
  uniform mat3 thicknessMapTransform;
2544
2544
  varying vec2 vThicknessMapUv;
2545
- #endif`,YS=`#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; }`,WS=`#ifdef USE_TRANSMISS
2636
2636
  #ifdef USE_THICKNESSMAP
2637
2637
  uniform mat3 thicknessMapTransform;
2638
2638
  varying vec2 vThicknessMapUv;
2639
- #endif`,qS=`#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; }`,WS=`#ifdef USE_TRANSMISS
2707
2707
  #endif
2708
2708
  #ifdef USE_THICKNESSMAP
2709
2709
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2710
- #endif`,ZS=`#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; }`,WS=`#ifdef USE_TRANSMISS
2716
2716
  worldPosition = instanceMatrix * worldPosition;
2717
2717
  #endif
2718
2718
  worldPosition = modelMatrix * worldPosition;
2719
- #endif`,JS=`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
- }`,KS=`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
- }`,QS=`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
- }`,e1=`#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
- }`,t1=`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
- }`,n1=`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
- }`,i1=`#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
- }`,r1=`#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
- }`,s1=`#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
- }`,o1=`#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
- }`,a1=`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
- }`,l1=`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
- }`,c1=`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
- }`,u1=`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
- }`,d1=`#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
- }`,h1=`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
- }`,f1=`#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
- }`,p1=`#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
- }`,m1=`#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
- }`,g1=`#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
- }`,y1=`#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
- }`,v1=`#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
- }`,_1=`#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
- }`,x1=`#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
- }`,b1=`#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
- }`,w1=`#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
- }`,M1=`#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
- }`,S1=`#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
- }`,A1=`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
- }`,E1=`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
- }`,T1=`#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
- }`,I1=`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
- }`,C1=`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
- }`,R1=`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
- }`,We={alphahash_fragment:Kw,alphahash_pars_fragment:Qw,alphamap_fragment:eM,alphamap_pars_fragment:tM,alphatest_fragment:nM,alphatest_pars_fragment:iM,aomap_fragment:rM,aomap_pars_fragment:sM,batching_pars_vertex:oM,batching_vertex:aM,begin_vertex:lM,beginnormal_vertex:cM,bsdfs:uM,iridescence_fragment:dM,bumpmap_pars_fragment:hM,clipping_planes_fragment:fM,clipping_planes_pars_fragment:pM,clipping_planes_pars_vertex:mM,clipping_planes_vertex:gM,color_fragment:yM,color_pars_fragment:vM,color_pars_vertex:_M,color_vertex:xM,common:bM,cube_uv_reflection_fragment:wM,defaultnormal_vertex:MM,displacementmap_pars_vertex:SM,displacementmap_vertex:AM,emissivemap_fragment:EM,emissivemap_pars_fragment:TM,colorspace_fragment:IM,colorspace_pars_fragment:CM,envmap_fragment:RM,envmap_common_pars_fragment:PM,envmap_pars_fragment:LM,envmap_pars_vertex:DM,envmap_physical_pars_fragment:$M,envmap_vertex:OM,fog_vertex:UM,fog_pars_vertex:NM,fog_fragment:FM,fog_pars_fragment:kM,gradientmap_pars_fragment:BM,lightmap_pars_fragment:zM,lights_lambert_fragment:VM,lights_lambert_pars_fragment:HM,lights_pars_begin:GM,lights_toon_fragment:WM,lights_toon_pars_fragment:jM,lights_phong_fragment:XM,lights_phong_pars_fragment:YM,lights_physical_fragment:qM,lights_physical_pars_fragment:ZM,lights_fragment_begin:JM,lights_fragment_maps:KM,lights_fragment_end:QM,logdepthbuf_fragment:eS,logdepthbuf_pars_fragment:tS,logdepthbuf_pars_vertex:nS,logdepthbuf_vertex:iS,map_fragment:rS,map_pars_fragment:sS,map_particle_fragment:oS,map_particle_pars_fragment:aS,metalnessmap_fragment:lS,metalnessmap_pars_fragment:cS,morphinstance_vertex:uS,morphcolor_vertex:dS,morphnormal_vertex:hS,morphtarget_pars_vertex:fS,morphtarget_vertex:pS,normal_fragment_begin:mS,normal_fragment_maps:gS,normal_pars_fragment:yS,normal_pars_vertex:vS,normal_vertex:_S,normalmap_pars_fragment:xS,clearcoat_normal_fragment_begin:bS,clearcoat_normal_fragment_maps:wS,clearcoat_pars_fragment:MS,iridescence_pars_fragment:SS,opaque_fragment:AS,packing:ES,premultiplied_alpha_fragment:TS,project_vertex:IS,dithering_fragment:CS,dithering_pars_fragment:RS,roughnessmap_fragment:PS,roughnessmap_pars_fragment:LS,shadowmap_pars_fragment:DS,shadowmap_pars_vertex:OS,shadowmap_vertex:US,shadowmask_pars_fragment:NS,skinbase_vertex:FS,skinning_pars_vertex:kS,skinning_vertex:BS,skinnormal_vertex:zS,specularmap_fragment:VS,specularmap_pars_fragment:HS,tonemapping_fragment:GS,tonemapping_pars_fragment:$S,transmission_fragment:WS,transmission_pars_fragment:jS,uv_pars_fragment:XS,uv_pars_vertex:YS,uv_vertex:qS,worldpos_vertex:ZS,background_vert:JS,background_frag:KS,backgroundCube_vert:QS,backgroundCube_frag:e1,cube_vert:t1,cube_frag:n1,depth_vert:i1,depth_frag:r1,distanceRGBA_vert:s1,distanceRGBA_frag:o1,equirect_vert:a1,equirect_frag:l1,linedashed_vert:c1,linedashed_frag:u1,meshbasic_vert:d1,meshbasic_frag:h1,meshlambert_vert:f1,meshlambert_frag:p1,meshmatcap_vert:m1,meshmatcap_frag:g1,meshnormal_vert:y1,meshnormal_frag:v1,meshphong_vert:_1,meshphong_frag:x1,meshphysical_vert:b1,meshphysical_frag:w1,meshtoon_vert:M1,meshtoon_frag:S1,points_vert:A1,points_frag:E1,shadow_vert:T1,shadow_frag:I1,sprite_vert:C1,sprite_frag:R1},ve={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},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 He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new we(16777215)},opacity:{value:1},center:{value:new ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},En={basic:{uniforms:Wt([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Wt([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,ve.lights,{emissive:{value:new we(0)}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Wt([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,ve.lights,{emissive:{value:new we(0)},specular:{value:new we(1118481)},shininess:{value:30}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Wt([ve.common,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.roughnessmap,ve.metalnessmap,ve.fog,ve.lights,{emissive:{value:new we(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Wt([ve.common,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.gradientmap,ve.fog,ve.lights,{emissive:{value:new we(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Wt([ve.common,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Wt([ve.points,ve.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Wt([ve.common,ve.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Wt([ve.common,ve.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Wt([ve.common,ve.bumpmap,ve.normalmap,ve.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Wt([ve.sprite,ve.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distanceRGBA:{uniforms:Wt([ve.common,ve.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distanceRGBA_vert,fragmentShader:We.distanceRGBA_frag},shadow:{uniforms:Wt([ve.lights,ve.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};En.physical={uniforms:Wt([En.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new we(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new we(0)},specularColor:{value:new we(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};gl={r:0,b:0,g:0},ji=new sn,P1=new Ne;ms=class extends fs{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}},rs=4,Im=[.125,.215,.35,.446,.526,.582],nr=20,cd=new ms,Cm=new we,ud=null,dd=0,hd=0,fd=!1,tr=(1+Math.sqrt(5))/2,qr=1/tr,Rm=[new T(-tr,qr,0),new T(tr,qr,0),new T(-qr,0,tr),new T(qr,0,tr),new T(0,tr,-qr),new T(0,tr,qr),new T(-1,1,-1),new T(1,1,-1),new T(-1,1,1),new T(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=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,yl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===oi||e.mapping===Ii?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:wt,minFilter:wt,generateMipmaps:!1,type:ia,format:tn,colorSpace:ui,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}=k1(s)),this._blurMaterial=B1(s,e,t)}return r}_compileMaterial(e){let t=new vt(this._lodPlanes[0],e);this._renderer.compile(t,cd)}_sceneToCubeUV(e,t,i,r){let a=new Et(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=ii,u.autoClear=!1;let f=new Fn({name:"PMREM.Background",side:Xt,depthWrite:!1,depthTest:!1}),m=new vt(new ur,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 _=p%3;_===0?(a.up.set(0,l[p],0),a.lookAt(c[p],0,0)):_===1?(a.up.set(0,0,l[p]),a.lookAt(0,c[p],0)):(a.up.set(0,l[p],0),a.lookAt(0,0,c[p]));let v=this._cubeSize;yl(r,_*v,p>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(m,a),u.render(e,a)}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===oi||e.mapping===Ii;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,o=new vt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;yl(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=Rm[(r-s-1)%Rm.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 vt(this._lodPlanes[r],c),h=c.uniforms,f=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*nr-1),y=s/m,g=isFinite(s)?1+Math.floor(u*y):nr;g>nr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${nr}`);let p=[],_=0;for(let E=0;E<nr;++E){let L=E/y,b=Math.exp(-L*L/2);p.push(b),E===0?_+=b:E<g&&(_+=2*b)}for(let E=0;E<p.length;E++)p[E]=p[E]/_;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=p,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:v}=this;h.dTheta.value=m,h.mipInt.value=v-i;let w=this._sizeLods[r],P=3*w*(r>v-rs?r-v+rs:0),A=4*(this._cubeSize-w);yl(t,P,A,3*w,2*w),l.setRenderTarget(t),l.render(d,cd)}};Lo=class extends Mt{constructor(e,t,i,r,s,o,a,l,c,u){if(u=u!==void 0?u:ar,u!==ar&&u!==ls)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===ar&&(i=cr),i===void 0&&u===ls&&(i=bs),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:Pt,this.minFilter=l!==void 0?l:Pt,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 Mt,ey=new Lo(1,1);ey.compareFunction=Ff;ty=new us,ny=new Io,iy=new dr,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=hA(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=LA(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;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),o=e.getUniformLocation(t,s.name);DA(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}};OA=37297,UA=0;GA=/^[ \t]*#include +<([\w\d./]+)>/gm;$A=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;eE=0,xh=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=eE++,this.code=e,this.usedTimes=0}};aE=0;Do=class extends Dt{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}},Oo=class extends Dt{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}},dE=`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
- }`,hE=`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
- }`;tc=class extends Et{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ti=class extends rt{constructor(){super(),this.isGroup=!0,this.type="Group"}},gE={type:"move"},uo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ti,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 Ti,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new T,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new T),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ti,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new T,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new T),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),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));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(gE)))}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 Ti;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},yE=`
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
- }`,vE=`
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 Mt,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 on({vertexShader:yE,fragmentShader:vE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new vt(new ps(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},Mh=class extends Tn{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,m=null,y=new wh,g=t.getContextAttributes(),p=null,_=null,v=[],w=[],P=new ne,A=null,E=new Et;E.layers.enable(1),E.viewport=new lt;let L=new Et;L.layers.enable(2),L.viewport=new lt;let b=[E,L],x=new tc;x.layers.enable(1),x.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let Z=v[J];return Z===void 0&&(Z=new uo,v[J]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(J){let Z=v[J];return Z===void 0&&(Z=new uo,v[J]=Z),Z.getGripSpace()},this.getHand=function(J){let Z=v[J];return Z===void 0&&(Z=new uo,v[J]=Z),Z.getHandSpace()};function D(J){let Z=w.indexOf(J.inputSource);if(Z===-1)return;let me=v[Z];me!==void 0&&(me.update(J.inputSource,J.frame,c||o),me.dispatchEvent({type:J.type,data:J.inputSource}))}function $(){r.removeEventListener("select",D),r.removeEventListener("selectstart",D),r.removeEventListener("selectend",D),r.removeEventListener("squeeze",D),r.removeEventListener("squeezestart",D),r.removeEventListener("squeezeend",D),r.removeEventListener("end",$),r.removeEventListener("inputsourceschange",j);for(let J=0;J<v.length;J++){let Z=w[J];Z!==null&&(w[J]=null,v[J].disconnect(Z))}R=null,U=null,y.reset(),e.setRenderTarget(p),f=null,h=null,d=null,r=null,_=null,Ke.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(P.width,P.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){a=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(J){c=J},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(J){if(r=J,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",D),r.addEventListener("selectstart",D),r.addEventListener("selectend",D),r.addEventListener("squeeze",D),r.addEventListener("squeezestart",D),r.addEventListener("squeezeend",D),r.addEventListener("end",$),r.addEventListener("inputsourceschange",j),g.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(P),r.renderState.layers===void 0){let Z={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,Z),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new rn(f.framebufferWidth,f.framebufferHeight,{format:tn,type:ai,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let Z=null,me=null,ie=null;g.depth&&(ie=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=g.stencil?ls:ar,me=g.stencil?bs:cr);let ke={colorFormat:t.RGBA8,depthFormat:ie,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(ke),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new rn(h.textureWidth,h.textureHeight,{format:tn,type:ai,depthTexture:new Lo(h.textureWidth,h.textureHeight,me,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),Ke.setContext(r),Ke.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function j(J){for(let Z=0;Z<J.removed.length;Z++){let me=J.removed[Z],ie=w.indexOf(me);ie>=0&&(w[ie]=null,v[ie].disconnect(me))}for(let Z=0;Z<J.added.length;Z++){let me=J.added[Z],ie=w.indexOf(me);if(ie===-1){for(let xe=0;xe<v.length;xe++)if(xe>=w.length){w.push(me),ie=xe;break}else if(w[xe]===null){w[xe]=me,ie=xe;break}if(ie===-1)break}let ke=v[ie];ke&&ke.connect(me)}}let N=new T,X=new T;function k(J,Z,me){N.setFromMatrixPosition(Z.matrixWorld),X.setFromMatrixPosition(me.matrixWorld);let ie=N.distanceTo(X),ke=Z.projectionMatrix.elements,xe=me.projectionMatrix.elements,z=ke[14]/(ke[10]-1),Ue=ke[14]/(ke[10]+1),K=(ke[9]+1)/ke[5],ue=(ke[9]-1)/ke[5],Q=(ke[8]-1)/ke[0],de=(xe[8]+1)/xe[0],ae=z*Q,fe=z*de,Ee=ie/(-Q+de),C=Ee*-Q;Z.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(C),J.translateZ(Ee),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();let S=z+Ee,W=Ue+Ee,te=ae-C,se=fe+(ie-C),re=K*Ue/W*S,Re=ue*Ue/W*S;J.projectionMatrix.makePerspective(te,se,re,Re,S,W),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function le(J,Z){Z===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(Z.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;y.texture!==null&&(J.near=y.depthNear,J.far=y.depthFar),x.near=L.near=E.near=J.near,x.far=L.far=E.far=J.far,(R!==x.near||U!==x.far)&&(r.updateRenderState({depthNear:x.near,depthFar:x.far}),R=x.near,U=x.far,E.near=R,E.far=U,L.near=R,L.far=U,E.updateProjectionMatrix(),L.updateProjectionMatrix(),J.updateProjectionMatrix());let Z=J.parent,me=x.cameras;le(x,Z);for(let ie=0;ie<me.length;ie++)le(me[ie],Z);me.length===2?k(x,E,L):x.projectionMatrix.copy(E.projectionMatrix),ce(J,x,Z)};function ce(J,Z,me){me===null?J.matrix.copy(Z.matrixWorld):(J.matrix.copy(me.matrixWorld),J.matrix.invert(),J.matrix.multiply(Z.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(Z.projectionMatrix),J.projectionMatrixInverse.copy(Z.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=cs*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return x},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(J){l=J,h!==null&&(h.fixedFoveation=J),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=J)},this.hasDepthSensing=function(){return y.texture!==null};let Me=null;function Fe(J,Z){if(u=Z.getViewerPose(c||o),m=Z,u!==null){let me=u.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let ie=!1;me.length!==x.cameras.length&&(x.cameras.length=0,ie=!0);for(let xe=0;xe<me.length;xe++){let z=me[xe],Ue=null;if(f!==null)Ue=f.getViewport(z);else{let ue=d.getViewSubImage(h,z);Ue=ue.viewport,xe===0&&(e.setRenderTargetTextures(_,ue.colorTexture,h.ignoreDepthValues?void 0:ue.depthStencilTexture),e.setRenderTarget(_))}let K=b[xe];K===void 0&&(K=new Et,K.layers.enable(xe),K.viewport=new lt,b[xe]=K),K.matrix.fromArray(z.transform.matrix),K.matrix.decompose(K.position,K.quaternion,K.scale),K.projectionMatrix.fromArray(z.projectionMatrix),K.projectionMatrixInverse.copy(K.projectionMatrix).invert(),K.viewport.set(Ue.x,Ue.y,Ue.width,Ue.height),xe===0&&(x.matrix.copy(K.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale)),ie===!0&&x.cameras.push(K)}let ke=r.enabledFeatures;if(ke&&ke.includes("depth-sensing")){let xe=d.getDepthInformation(me[0]);xe&&xe.isValid&&xe.texture&&y.init(e,xe,r.renderState)}}for(let me=0;me<v.length;me++){let ie=w[me],ke=v[me];ie!==null&&ke!==void 0&&ke.update(ie,Z,c||o)}y.render(e,x),Me&&Me(J,Z),Z.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Z}),m=null}let Ke=new K0;Ke.setAnimationLoop(Fe),this.setAnimationLoop=function(J){Me=J},this.dispose=function(){}}},Xi=new sn,_E=new Ne;Sh=class{constructor(e={}){let{canvas:t=X0(),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),m=new Int32Array(4),y=null,g=null,p=[],_=[];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=gn,this._useLegacyLights=!1,this.toneMapping=ii,this.toneMappingExposure=1;let v=this,w=!1,P=0,A=0,E=null,L=-1,b=null,x=new lt,R=new lt,U=null,D=new we(0),$=0,j=t.width,N=t.height,X=1,k=null,le=null,ce=new lt(0,0,j,N),Me=new lt(0,0,j,N),Fe=!1,Ke=new hr,J=!1,Z=!1,me=new Ne,ie=new T,ke={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function xe(){return E===null?X:1}let z=i;function Ue(M,O){return t.getContext(M,O)}try{let M={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",B,!1),t.addEventListener("webglcontextrestored",oe,!1),t.addEventListener("webglcontextcreationerror",ee,!1),z===null){let O="webgl2";if(z=Ue(O,M),z===null)throw Ue(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let K,ue,Q,de,ae,fe,Ee,C,S,W,te,se,re,Re,ge,ye,Be,he,Pe,je,Le,Se,De,Ze;function ft(){K=new V1(z),K.init(),Se=new ry(z,K),ue=new U1(z,K,e,Se),Q=new pE(z),de=new $1(z),ae=new nE,fe=new mE(z,K,Q,ae,ue,Se,de),Ee=new F1(v),C=new z1(v),S=new Jw(z),De=new D1(z,S),W=new H1(z,S,de,De),te=new j1(z,W,S,de),Pe=new W1(z,ue,fe),ye=new N1(ae),se=new tE(v,Ee,C,K,ue,De,ye),re=new xE(v,ae),Re=new rE,ge=new uE(K),he=new L1(v,Ee,C,Q,te,h,l),Be=new fE(v,te,ue),Ze=new bE(z,de,ue,Q),je=new O1(z,K,de),Le=new G1(z,K,de),de.programs=se.programs,v.capabilities=ue,v.extensions=K,v.properties=ae,v.renderLists=Re,v.shadowMap=Be,v.state=Q,v.info=de}ft();let $e=new Mh(v,z);this.xr=$e,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let M=K.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){let M=K.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(M){M!==void 0&&(X=M,this.setSize(j,N,!1))},this.getSize=function(M){return M.set(j,N)},this.setSize=function(M,O,F=!0){if($e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}j=M,N=O,t.width=Math.floor(M*X),t.height=Math.floor(O*X),F===!0&&(t.style.width=M+"px",t.style.height=O+"px"),this.setViewport(0,0,M,O)},this.getDrawingBufferSize=function(M){return M.set(j*X,N*X).floor()},this.setDrawingBufferSize=function(M,O,F){j=M,N=O,X=F,t.width=Math.floor(M*F),t.height=Math.floor(O*F),this.setViewport(0,0,M,O)},this.getCurrentViewport=function(M){return M.copy(x)},this.getViewport=function(M){return M.copy(ce)},this.setViewport=function(M,O,F,H){M.isVector4?ce.set(M.x,M.y,M.z,M.w):ce.set(M,O,F,H),Q.viewport(x.copy(ce).multiplyScalar(X).round())},this.getScissor=function(M){return M.copy(Me)},this.setScissor=function(M,O,F,H){M.isVector4?Me.set(M.x,M.y,M.z,M.w):Me.set(M,O,F,H),Q.scissor(R.copy(Me).multiplyScalar(X).round())},this.getScissorTest=function(){return Fe},this.setScissorTest=function(M){Q.setScissorTest(Fe=M)},this.setOpaqueSort=function(M){k=M},this.setTransparentSort=function(M){le=M},this.getClearColor=function(M){return M.copy(he.getClearColor())},this.setClearColor=function(){he.setClearColor.apply(he,arguments)},this.getClearAlpha=function(){return he.getClearAlpha()},this.setClearAlpha=function(){he.setClearAlpha.apply(he,arguments)},this.clear=function(M=!0,O=!0,F=!0){let H=0;if(M){let G=!1;if(E!==null){let pe=E.texture.format;G=pe===Uf||pe===Of||pe===Df}if(G){let pe=E.texture.type,Ie=pe===ai||pe===cr||pe===If||pe===bs||pe===Rf||pe===Pf,Ce=he.getClearColor(),Oe=he.getClearAlpha(),ze=Ce.r,Xe=Ce.g,qe=Ce.b;Ie?(f[0]=ze,f[1]=Xe,f[2]=qe,f[3]=Oe,z.clearBufferuiv(z.COLOR,0,f)):(m[0]=ze,m[1]=Xe,m[2]=qe,m[3]=Oe,z.clearBufferiv(z.COLOR,0,m))}else H|=z.COLOR_BUFFER_BIT}O&&(H|=z.DEPTH_BUFFER_BIT),F&&(H|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(H)},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",B,!1),t.removeEventListener("webglcontextrestored",oe,!1),t.removeEventListener("webglcontextcreationerror",ee,!1),Re.dispose(),ge.dispose(),ae.dispose(),Ee.dispose(),C.dispose(),te.dispose(),De.dispose(),Ze.dispose(),se.dispose(),$e.dispose(),$e.removeEventListener("sessionstart",tt),$e.removeEventListener("sessionend",Yt),St.stop()};function B(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function oe(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;let M=de.autoReset,O=Be.enabled,F=Be.autoUpdate,H=Be.needsUpdate,G=Be.type;ft(),de.autoReset=M,Be.enabled=O,Be.autoUpdate=F,Be.needsUpdate=H,Be.type=G}function ee(M){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function _e(M){let O=M.target;O.removeEventListener("dispose",_e),be(O)}function be(M){Ae(M),ae.remove(M)}function Ae(M){let O=ae.get(M).programs;O!==void 0&&(O.forEach(function(F){se.releaseProgram(F)}),M.isShaderMaterial&&se.releaseShaderCache(M))}this.renderBufferDirect=function(M,O,F,H,G,pe){O===null&&(O=ke);let Ie=G.isMesh&&G.matrixWorld.determinant()<0,Ce=I(M,O,F,H,G);Q.setMaterial(H,Ie);let Oe=F.index,ze=1;if(H.wireframe===!0){if(Oe=W.getWireframeAttribute(F),Oe===void 0)return;ze=2}let Xe=F.drawRange,qe=F.attributes.position,xt=Xe.start*ze,Nt=(Xe.start+Xe.count)*ze;pe!==null&&(xt=Math.max(xt,pe.start*ze),Nt=Math.min(Nt,(pe.start+pe.count)*ze)),Oe!==null?(xt=Math.max(xt,0),Nt=Math.min(Nt,Oe.count)):qe!=null&&(xt=Math.max(xt,0),Nt=Math.min(Nt,qe.count));let Zt=Nt-xt;if(Zt<0||Zt===1/0)return;De.setup(G,H,Ce,F,Oe);let Vn,it=je;if(Oe!==null&&(Vn=S.get(Oe),it=Le,it.setIndex(Vn)),G.isMesh)H.wireframe===!0?(Q.setLineWidth(H.wireframeLinewidth*xe()),it.setMode(z.LINES)):it.setMode(z.TRIANGLES);else if(G.isLine){let Ve=H.linewidth;Ve===void 0&&(Ve=1),Q.setLineWidth(Ve*xe()),G.isLineSegments?it.setMode(z.LINES):G.isLineLoop?it.setMode(z.LINE_LOOP):it.setMode(z.LINE_STRIP)}else G.isPoints?it.setMode(z.POINTS):G.isSprite&&it.setMode(z.TRIANGLES);if(G.isBatchedMesh)G._multiDrawInstances!==null?it.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances):it.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)it.renderInstances(xt,Zt,G.count);else if(F.isInstancedBufferGeometry){let Ve=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,Ts=Math.min(F.instanceCount,Ve);it.renderInstances(xt,Zt,Ts)}else it.render(xt,Zt)};function Qe(M,O,F){M.transparent===!0&&M.side===Ln&&M.forceSinglePass===!1?(M.side=Xt,M.needsUpdate=!0,Ui(M,O,F),M.side=si,M.needsUpdate=!0,Ui(M,O,F),M.side=Ln):Ui(M,O,F)}this.compile=function(M,O,F=null){F===null&&(F=M),g=ge.get(F),g.init(O),_.push(g),F.traverseVisible(function(G){G.isLight&&G.layers.test(O.layers)&&(g.pushLight(G),G.castShadow&&g.pushShadow(G))}),M!==F&&M.traverseVisible(function(G){G.isLight&&G.layers.test(O.layers)&&(g.pushLight(G),G.castShadow&&g.pushShadow(G))}),g.setupLights(v._useLegacyLights);let H=new Set;return M.traverse(function(G){let pe=G.material;if(pe)if(Array.isArray(pe))for(let Ie=0;Ie<pe.length;Ie++){let Ce=pe[Ie];Qe(Ce,F,G),H.add(Ce)}else Qe(pe,F,G),H.add(pe)}),_.pop(),g=null,H},this.compileAsync=function(M,O,F=null){let H=this.compile(M,O,F);return new Promise(G=>{function pe(){if(H.forEach(function(Ie){ae.get(Ie).currentProgram.isReady()&&H.delete(Ie)}),H.size===0){G(M);return}setTimeout(pe,10)}K.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let ct=null;function pt(M){ct&&ct(M)}function tt(){St.stop()}function Yt(){St.start()}let St=new K0;St.setAnimationLoop(pt),typeof self<"u"&&St.setContext(self),this.setAnimationLoop=function(M){ct=M,$e.setAnimationLoop(M),M===null?St.stop():St.start()},$e.addEventListener("sessionstart",tt),$e.addEventListener("sessionend",Yt),this.render=function(M,O){if(O!==void 0&&O.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),$e.enabled===!0&&$e.isPresenting===!0&&($e.cameraAutoUpdate===!0&&$e.updateCamera(O),O=$e.getCamera()),M.isScene===!0&&M.onBeforeRender(v,M,O,E),g=ge.get(M,_.length),g.init(O),_.push(g),me.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ke.setFromProjectionMatrix(me),Z=this.localClippingEnabled,J=ye.init(this.clippingPlanes,Z),y=Re.get(M,p.length),y.init(),p.push(y),ca(M,O,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,le);let F=$e.enabled===!1||$e.isPresenting===!1||$e.hasDepthSensing()===!1;F&&he.addToRenderList(y,M),this.info.render.frame++,J===!0&&ye.beginShadows();let H=g.state.shadowsArray;Be.render(H,M,O),J===!0&&ye.endShadows(),this.info.autoReset===!0&&this.info.reset();let G=y.opaque,pe=y.transmissive;if(g.setupLights(v._useLegacyLights),O.isArrayCamera){let Ie=O.cameras;if(pe.length>0)for(let Ce=0,Oe=Ie.length;Ce<Oe;Ce++){let ze=Ie[Ce];ua(G,pe,M,ze)}F&&he.render(M);for(let Ce=0,Oe=Ie.length;Ce<Oe;Ce++){let ze=Ie[Ce];Es(y,M,ze,ze.viewport)}}else pe.length>0&&ua(G,pe,M,O),F&&he.render(M),Es(y,M,O);E!==null&&(fe.updateMultisampleRenderTarget(E),fe.updateRenderTargetMipmap(E)),M.isScene===!0&&M.onAfterRender(v,M,O),De.resetDefaultState(),L=-1,b=null,_.pop(),_.length>0?(g=_[_.length-1],J===!0&&ye.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,p.pop(),p.length>0?y=p[p.length-1]:y=null};function ca(M,O,F,H){if(M.visible===!1)return;if(M.layers.test(O.layers)){if(M.isGroup)F=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(O);else if(M.isLight)g.pushLight(M),M.castShadow&&g.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||Ke.intersectsSprite(M)){H&&ie.setFromMatrixPosition(M.matrixWorld).applyMatrix4(me);let Ie=te.update(M),Ce=M.material;Ce.visible&&y.push(M,Ie,Ce,F,ie.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||Ke.intersectsObject(M))){let Ie=te.update(M),Ce=M.material;if(H&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),ie.copy(M.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),ie.copy(Ie.boundingSphere.center)),ie.applyMatrix4(M.matrixWorld).applyMatrix4(me)),Array.isArray(Ce)){let Oe=Ie.groups;for(let ze=0,Xe=Oe.length;ze<Xe;ze++){let qe=Oe[ze],xt=Ce[qe.materialIndex];xt&&xt.visible&&y.push(M,Ie,xt,F,ie.z,qe)}}else Ce.visible&&y.push(M,Ie,Ce,F,ie.z,null)}}let pe=M.children;for(let Ie=0,Ce=pe.length;Ie<Ce;Ie++)ca(pe[Ie],O,F,H)}function Es(M,O,F,H){let G=M.opaque,pe=M.transmissive,Ie=M.transparent;g.setupLightsView(F),J===!0&&ye.setGlobalState(v.clippingPlanes,F),H&&Q.viewport(x.copy(H)),G.length>0&&Mr(G,O,F),pe.length>0&&Mr(pe,O,F),Ie.length>0&&Mr(Ie,O,F),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function ua(M,O,F,H){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[H.id]===void 0&&(g.state.transmissionRenderTarget[H.id]=new rn(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")||K.has("EXT_color_buffer_float")?ia:ai,minFilter:Dn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let pe=g.state.transmissionRenderTarget[H.id],Ie=H.viewport||x;pe.setSize(Ie.z,Ie.w);let Ce=v.getRenderTarget();v.setRenderTarget(pe),v.getClearColor(D),$=v.getClearAlpha(),$<1&&v.setClearColor(16777215,.5),v.clear();let Oe=v.toneMapping;v.toneMapping=ii;let ze=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),g.setupLightsView(H),J===!0&&ye.setGlobalState(v.clippingPlanes,H),Mr(M,F,H),fe.updateMultisampleRenderTarget(pe),fe.updateRenderTargetMipmap(pe),K.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let qe=0,xt=O.length;qe<xt;qe++){let Nt=O[qe],Zt=Nt.object,Vn=Nt.geometry,it=Nt.material,Ve=Nt.group;if(it.side===Ln&&Zt.layers.test(H.layers)){let Ts=it.side;it.side=Xt,it.needsUpdate=!0,da(Zt,F,H,Vn,it,Ve),it.side=Ts,it.needsUpdate=!0,Xe=!0}}Xe===!0&&(fe.updateMultisampleRenderTarget(pe),fe.updateRenderTargetMipmap(pe))}v.setRenderTarget(Ce),v.setClearColor(D,$),ze!==void 0&&(H.viewport=ze),v.toneMapping=Oe}function Mr(M,O,F){let H=O.isScene===!0?O.overrideMaterial:null;for(let G=0,pe=M.length;G<pe;G++){let Ie=M[G],Ce=Ie.object,Oe=Ie.geometry,ze=H===null?Ie.material:H,Xe=Ie.group;Ce.layers.test(F.layers)&&da(Ce,O,F,Oe,ze,Xe)}}function da(M,O,F,H,G,pe){M.onBeforeRender(v,O,F,H,G,pe),M.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),G.onBeforeRender(v,O,F,H,M,pe),G.transparent===!0&&G.side===Ln&&G.forceSinglePass===!1?(G.side=Xt,G.needsUpdate=!0,v.renderBufferDirect(F,O,H,G,M,pe),G.side=si,G.needsUpdate=!0,v.renderBufferDirect(F,O,H,G,M,pe),G.side=Ln):v.renderBufferDirect(F,O,H,G,M,pe),M.onAfterRender(v,O,F,H,G,pe)}function Ui(M,O,F){O.isScene!==!0&&(O=ke);let H=ae.get(M),G=g.state.lights,pe=g.state.shadowsArray,Ie=G.state.version,Ce=se.getParameters(M,G.state,pe,O,F),Oe=se.getProgramCacheKey(Ce),ze=H.programs;H.environment=M.isMeshStandardMaterial?O.environment:null,H.fog=O.fog,H.envMap=(M.isMeshStandardMaterial?C:Ee).get(M.envMap||H.environment),H.envMapRotation=H.environment!==null&&M.envMap===null?O.environmentRotation:M.envMapRotation,ze===void 0&&(M.addEventListener("dispose",_e),ze=new Map,H.programs=ze);let Xe=ze.get(Oe);if(Xe!==void 0){if(H.currentProgram===Xe&&H.lightsStateVersion===Ie)return fa(M,Ce),Xe}else Ce.uniforms=se.getUniforms(M),M.onBuild(F,Ce,v),M.onBeforeCompile(Ce,v),Xe=se.acquireProgram(Ce,Oe),ze.set(Oe,Xe),H.uniforms=Ce.uniforms;let qe=H.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(qe.clippingPlanes=ye.uniform),fa(M,Ce),H.needsLights=Y(M),H.lightsStateVersion=Ie,H.needsLights&&(qe.ambientLightColor.value=G.state.ambient,qe.lightProbe.value=G.state.probe,qe.directionalLights.value=G.state.directional,qe.directionalLightShadows.value=G.state.directionalShadow,qe.spotLights.value=G.state.spot,qe.spotLightShadows.value=G.state.spotShadow,qe.rectAreaLights.value=G.state.rectArea,qe.ltc_1.value=G.state.rectAreaLTC1,qe.ltc_2.value=G.state.rectAreaLTC2,qe.pointLights.value=G.state.point,qe.pointLightShadows.value=G.state.pointShadow,qe.hemisphereLights.value=G.state.hemi,qe.directionalShadowMap.value=G.state.directionalShadowMap,qe.directionalShadowMatrix.value=G.state.directionalShadowMatrix,qe.spotShadowMap.value=G.state.spotShadowMap,qe.spotLightMatrix.value=G.state.spotLightMatrix,qe.spotLightMap.value=G.state.spotLightMap,qe.pointShadowMap.value=G.state.pointShadowMap,qe.pointShadowMatrix.value=G.state.pointShadowMatrix),H.currentProgram=Xe,H.uniformsList=null,Xe}function ha(M){if(M.uniformsList===null){let O=M.currentProgram.getUniforms();M.uniformsList=as.seqWithValue(O.seq,M.uniforms)}return M.uniformsList}function fa(M,O){let F=ae.get(M);F.outputColorSpace=O.outputColorSpace,F.batching=O.batching,F.instancing=O.instancing,F.instancingColor=O.instancingColor,F.instancingMorph=O.instancingMorph,F.skinning=O.skinning,F.morphTargets=O.morphTargets,F.morphNormals=O.morphNormals,F.morphColors=O.morphColors,F.morphTargetsCount=O.morphTargetsCount,F.numClippingPlanes=O.numClippingPlanes,F.numIntersection=O.numClipIntersection,F.vertexAlphas=O.vertexAlphas,F.vertexTangents=O.vertexTangents,F.toneMapping=O.toneMapping}function I(M,O,F,H,G){O.isScene!==!0&&(O=ke),fe.resetTextureUnits();let pe=O.fog,Ie=H.isMeshStandardMaterial?O.environment:null,Ce=E===null?v.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:ui,Oe=(H.isMeshStandardMaterial?C:Ee).get(H.envMap||Ie),ze=H.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Xe=!!F.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),qe=!!F.morphAttributes.position,xt=!!F.morphAttributes.normal,Nt=!!F.morphAttributes.color,Zt=ii;H.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Zt=v.toneMapping);let Vn=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,it=Vn!==void 0?Vn.length:0,Ve=ae.get(H),Ts=g.state.lights;if(J===!0&&(Z===!0||M!==b)){let cn=M===b&&H.id===L;ye.setState(H,M,cn)}let ht=!1;H.version===Ve.__version?(Ve.needsLights&&Ve.lightsStateVersion!==Ts.state.version||Ve.outputColorSpace!==Ce||G.isBatchedMesh&&Ve.batching===!1||!G.isBatchedMesh&&Ve.batching===!0||G.isInstancedMesh&&Ve.instancing===!1||!G.isInstancedMesh&&Ve.instancing===!0||G.isSkinnedMesh&&Ve.skinning===!1||!G.isSkinnedMesh&&Ve.skinning===!0||G.isInstancedMesh&&Ve.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Ve.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Ve.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Ve.instancingMorph===!1&&G.morphTexture!==null||Ve.envMap!==Oe||H.fog===!0&&Ve.fog!==pe||Ve.numClippingPlanes!==void 0&&(Ve.numClippingPlanes!==ye.numPlanes||Ve.numIntersection!==ye.numIntersection)||Ve.vertexAlphas!==ze||Ve.vertexTangents!==Xe||Ve.morphTargets!==qe||Ve.morphNormals!==xt||Ve.morphColors!==Nt||Ve.toneMapping!==Zt||Ve.morphTargetsCount!==it)&&(ht=!0):(ht=!0,Ve.__version=H.version);let Ni=Ve.currentProgram;ht===!0&&(Ni=Ui(H,O,G));let qf=!1,Is=!1,yu=!1,Ft=Ni.getUniforms(),hi=Ve.uniforms;if(Q.useProgram(Ni.program)&&(qf=!0,Is=!0,yu=!0),H.id!==L&&(L=H.id,Is=!0),qf||b!==M){Ft.setValue(z,"projectionMatrix",M.projectionMatrix),Ft.setValue(z,"viewMatrix",M.matrixWorldInverse);let cn=Ft.map.cameraPosition;cn!==void 0&&cn.setValue(z,ie.setFromMatrixPosition(M.matrixWorld)),ue.logarithmicDepthBuffer&&Ft.setValue(z,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ft.setValue(z,"isOrthographic",M.isOrthographicCamera===!0),b!==M&&(b=M,Is=!0,yu=!0)}if(G.isSkinnedMesh){Ft.setOptional(z,G,"bindMatrix"),Ft.setOptional(z,G,"bindMatrixInverse");let cn=G.skeleton;cn&&(cn.boneTexture===null&&cn.computeBoneTexture(),Ft.setValue(z,"boneTexture",cn.boneTexture,fe))}G.isBatchedMesh&&(Ft.setOptional(z,G,"batchingTexture"),Ft.setValue(z,"batchingTexture",G._matricesTexture,fe));let vu=F.morphAttributes;if((vu.position!==void 0||vu.normal!==void 0||vu.color!==void 0)&&Pe.update(G,F,Ni),(Is||Ve.receiveShadow!==G.receiveShadow)&&(Ve.receiveShadow=G.receiveShadow,Ft.setValue(z,"receiveShadow",G.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(hi.envMap.value=Oe,hi.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&O.environment!==null&&(hi.envMapIntensity.value=O.environmentIntensity),Is&&(Ft.setValue(z,"toneMappingExposure",v.toneMappingExposure),Ve.needsLights&&V(hi,yu),pe&&H.fog===!0&&re.refreshFogUniforms(hi,pe),re.refreshMaterialUniforms(hi,H,X,N,g.state.transmissionRenderTarget[M.id]),as.upload(z,ha(Ve),hi,fe)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(as.upload(z,ha(Ve),hi,fe),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ft.setValue(z,"center",G.center),Ft.setValue(z,"modelViewMatrix",G.modelViewMatrix),Ft.setValue(z,"normalMatrix",G.normalMatrix),Ft.setValue(z,"modelMatrix",G.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){let cn=H.uniformsGroups;for(let _u=0,Uy=cn.length;_u<Uy;_u++){let Zf=cn[_u];Ze.update(Zf,Ni),Ze.bind(Zf,Ni)}}return Ni}function V(M,O){M.ambientLightColor.needsUpdate=O,M.lightProbe.needsUpdate=O,M.directionalLights.needsUpdate=O,M.directionalLightShadows.needsUpdate=O,M.pointLights.needsUpdate=O,M.pointLightShadows.needsUpdate=O,M.spotLights.needsUpdate=O,M.spotLightShadows.needsUpdate=O,M.rectAreaLights.needsUpdate=O,M.hemisphereLights.needsUpdate=O}function Y(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(M,O,F){ae.get(M.texture).__webglTexture=O,ae.get(M.depthTexture).__webglTexture=F;let H=ae.get(M);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=F===void 0,H.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(M,O){let F=ae.get(M);F.__webglFramebuffer=O,F.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(M,O=0,F=0){E=M,P=O,A=F;let H=!0,G=null,pe=!1,Ie=!1;if(M){let Oe=ae.get(M);Oe.__useDefaultFramebuffer!==void 0?(Q.bindFramebuffer(z.FRAMEBUFFER,null),H=!1):Oe.__webglFramebuffer===void 0?fe.setupRenderTarget(M):Oe.__hasExternalTextures&&fe.rebindTextures(M,ae.get(M.texture).__webglTexture,ae.get(M.depthTexture).__webglTexture);let ze=M.texture;(ze.isData3DTexture||ze.isDataArrayTexture||ze.isCompressedArrayTexture)&&(Ie=!0);let Xe=ae.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Xe[O])?G=Xe[O][F]:G=Xe[O],pe=!0):M.samples>0&&fe.useMultisampledRTT(M)===!1?G=ae.get(M).__webglMultisampledFramebuffer:Array.isArray(Xe)?G=Xe[F]:G=Xe,x.copy(M.viewport),R.copy(M.scissor),U=M.scissorTest}else x.copy(ce).multiplyScalar(X).floor(),R.copy(Me).multiplyScalar(X).floor(),U=Fe;if(Q.bindFramebuffer(z.FRAMEBUFFER,G)&&H&&Q.drawBuffers(M,G),Q.viewport(x),Q.scissor(R),Q.setScissorTest(U),pe){let Oe=ae.get(M.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+O,Oe.__webglTexture,F)}else if(Ie){let Oe=ae.get(M.texture),ze=O||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,Oe.__webglTexture,F||0,ze)}L=-1},this.readRenderTargetPixels=function(M,O,F,H,G,pe,Ie){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ce=ae.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Ie!==void 0&&(Ce=Ce[Ie]),Ce){Q.bindFramebuffer(z.FRAMEBUFFER,Ce);try{let Oe=M.texture,ze=Oe.format,Xe=Oe.type;if(!ue.textureFormatReadable(ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ue.textureTypeReadable(Xe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=M.width-H&&F>=0&&F<=M.height-G&&z.readPixels(O,F,H,G,Se.convert(ze),Se.convert(Xe),pe)}finally{let Oe=E!==null?ae.get(E).__webglFramebuffer:null;Q.bindFramebuffer(z.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(M,O,F=0){let H=Math.pow(2,-F),G=Math.floor(O.image.width*H),pe=Math.floor(O.image.height*H);fe.setTexture2D(O,0),z.copyTexSubImage2D(z.TEXTURE_2D,F,0,0,M.x,M.y,G,pe),Q.unbindTexture()},this.copyTextureToTexture=function(M,O,F,H=0){let G=O.image.width,pe=O.image.height,Ie=Se.convert(F.format),Ce=Se.convert(F.type);fe.setTexture2D(F,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,F.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,F.unpackAlignment),O.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,H,M.x,M.y,G,pe,Ie,Ce,O.image.data):O.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,H,M.x,M.y,O.mipmaps[0].width,O.mipmaps[0].height,Ie,O.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,H,M.x,M.y,Ie,Ce,O.image),H===0&&F.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(M,O,F,H,G=0){let pe=M.max.x-M.min.x,Ie=M.max.y-M.min.y,Ce=M.max.z-M.min.z,Oe=Se.convert(H.format),ze=Se.convert(H.type),Xe;if(H.isData3DTexture)fe.setTexture3D(H,0),Xe=z.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)fe.setTexture2DArray(H,0),Xe=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);let qe=z.getParameter(z.UNPACK_ROW_LENGTH),xt=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Nt=z.getParameter(z.UNPACK_SKIP_PIXELS),Zt=z.getParameter(z.UNPACK_SKIP_ROWS),Vn=z.getParameter(z.UNPACK_SKIP_IMAGES),it=F.isCompressedTexture?F.mipmaps[G]:F.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,it.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,it.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,M.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,M.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,M.min.z),F.isDataTexture||F.isData3DTexture?z.texSubImage3D(Xe,G,O.x,O.y,O.z,pe,Ie,Ce,Oe,ze,it.data):H.isCompressedArrayTexture?z.compressedTexSubImage3D(Xe,G,O.x,O.y,O.z,pe,Ie,Ce,Oe,it.data):z.texSubImage3D(Xe,G,O.x,O.y,O.z,pe,Ie,Ce,Oe,ze,it),z.pixelStorei(z.UNPACK_ROW_LENGTH,qe),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,xt),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Nt),z.pixelStorei(z.UNPACK_SKIP_ROWS,Zt),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Vn),G===0&&H.generateMipmaps&&z.generateMipmap(Xe),Q.unbindTexture()},this.initTexture=function(M){M.isCubeTexture?fe.setTextureCube(M,0):M.isData3DTexture?fe.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?fe.setTexture2DArray(M,0):fe.setTexture2D(M,0),Q.unbindTexture()},this.resetState=function(){P=0,A=0,E=null,Q.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return On}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===uu?"display-p3":"srgb",t.unpackColorSpace=at.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}},nc=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}}},ic=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}}},rc=class extends rt{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 sn,this.environmentIntensity=1,this.environmentRotation=new sn,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}},gs=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=nn()}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=nn()),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=nn()),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}}},$t=new T,fr=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++)$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}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=jt(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ge(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Ge(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ge(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ge(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ge(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=jt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=jt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=jt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=jt(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ge(t,this.array),i=Ge(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=Ge(t,this.array),i=Ge(i,this.array),r=Ge(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=Ge(t,this.array),i=Ge(i,this.array),r=Ge(r,this.array),s=Ge(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 nt(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 Dt{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 T,Jr=new T,Kr=new T,Qr=new ne,Qs=new ne,sy=new Ne,vl=new T,eo=new T,_l=new T,qm=new ne,md=new ne,Zm=new ne,sc=class extends rt{constructor(e=new Uo){if(super(),this.isSprite=!0,this.type="Sprite",Zr===void 0){Zr=new Ye;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 gs(t,5);Zr.setIndex([0,1,2,0,2,3]),Zr.setAttribute("position",new fr(i,3,0,!1)),Zr.setAttribute("uv",new fr(i,2,3,!1))}this.geometry=Zr,this.material=e,this.center=new ne(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Jr.setFromMatrixScale(this.matrixWorld),sy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Kr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Jr.multiplyScalar(-Kr.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;xl(vl.set(-.5,-.5,0),Kr,o,Jr,r,s),xl(eo.set(.5,-.5,0),Kr,o,Jr,r,s),xl(_l.set(.5,.5,0),Kr,o,Jr,r,s),qm.set(0,0),md.set(1,0),Zm.set(1,1);let a=e.ray.intersectTriangle(vl,eo,_l,!1,Ks);if(a===null&&(xl(eo.set(-.5,.5,0),Kr,o,Jr,r,s),md.set(0,1),a=e.ray.intersectTriangle(vl,_l,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:ei.getInterpolation(Ks,vl,eo,_l,qm,md,Zm,new ne),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}};bl=new T,Jm=new T,oc=class extends rt{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){bl.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(bl);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){bl.setFromMatrixPosition(e.matrixWorld),Jm.setFromMatrixPosition(this.matrixWorld);let i=bl.distanceTo(Jm)/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}},Km=new T,Qm=new lt,eg=new lt,wE=new T,tg=new Ne,wl=new T,gd=new Lt,ng=new Ne,yd=new Ci,ac=class extends vt{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 Ot),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,wl),this.boundingBox.expandByPoint(wl)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Lt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,wl),this.boundingSphere.expandByPoint(wl)}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 lt,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 o=eg.getComponent(s);if(o!==0){let a=Qm.getComponent(s);tg.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(wE.copy(Km).applyMatrix4(tg),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},No=class extends rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Un=class extends Mt{constructor(e=null,t=1,i=1,r,s,o,a,l,c=Pt,u=Pt,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}},ig=new Ne,ME=new Ne,lc=class n{constructor(e=[],t=[]){this.uuid=nn(),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:ME;ig.multiplyMatrices(a,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 Un(t,e,e,tn,vn);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}},Ri=class extends nt{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}},es=new Ne,rg=new Ne,Ml=[],sg=new Ot,SE=new Ne,to=new vt,no=new Lt,cc=class extends vt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ri(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,SE)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ot),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,es),sg.copy(e.boundingBox).applyMatrix4(es),this.boundingBox.union(sg)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Lt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,es),no.copy(e.boundingSphere).applyMatrix4(es),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,es),rg.multiplyMatrices(i,es),to.matrixWorld=rg,to.raycast(e,Ml);for(let o=0,a=Ml.length;o<a;o++){let l=Ml[o];l.instanceId=s,l.object=this,t.push(l)}Ml.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ri(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 Un(new Float32Array(r*this.count),r,this.count,Lf,vn));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}},ts="batchId",Si=new Ne,og=new Ne,TE=new Ne,ag=new Ne,vd=new hr,Sl=new Ot,Yi=new Lt,io=new T,_d=new Ah,Vt=new vt,Al=[];uc=class extends vt{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new Ye,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 Un(t,e,e,tn,vn);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 nt(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new nt(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(ts,new nt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(ts))throw new Error(`BatchedMesh: Geometry cannot use attribute "${ts}"`);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===ts)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 Ot);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,Si),this.getBoundingBoxAt(r,Sl).applyMatrix4(Si),t.union(Sl))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Lt);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,Si),this.getBoundingSphereAt(r,Yi).applyMatrix4(Si),t.union(Yi))}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,m=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,TE.toArray(m,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ot,sphereInitialized:!1,sphere:new Lt});let g=this.geometry.getAttribute(ts);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(),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===ts)continue;let m=t.getAttribute(f),y=i.getAttribute(f);IE(m,y,l);let g=m.itemSize;for(let p=m.count,_=c;p<_;p++){let v=l+p;for(let w=0;w<g;w++)y.setComponent(v,w,0)}y.needsUpdate=!0,y.addUpdateRange(l*g,c*g)}if(r){let f=a.indexStart;for(let m=0;m<o.count;m++)s.setX(f+m,l+o.getX(m));for(let m=o.count,y=a.indexCount;m<y;m++)s.setX(f+m,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,Sl),Sl.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;Vt.material=this.material,Vt.geometry.index=l.index,Vt.geometry.attributes=l.attributes,Vt.geometry.boundingBox===null&&(Vt.geometry.boundingBox=new Ot),Vt.geometry.boundingSphere===null&&(Vt.geometry.boundingSphere=new Lt);for(let c=0;c<o;c++){if(!i[c]||!r[c])continue;let u=s[c];Vt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Vt.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,Vt.geometry.boundingBox),this.getBoundingSphereAt(c,Vt.geometry.boundingSphere),Vt.raycast(e,Al);for(let d=0,h=Al.length;d<h;d++){let f=Al[d];f.object=this,f.batchId=c,t.push(f)}Al.length=0}Vt.material=null,Vt.geometry.index=null,Vt.geometry.attributes={},Vt.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&&(ag.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vd.setFromProjectionMatrix(ag,e.coordinateSystem));let m=0;if(this.sortObjects){og.copy(this.matrixWorld).invert(),io.setFromMatrixPosition(i.matrixWorld).applyMatrix4(og);for(let p=0,_=c.length;p<_;p++)if(c[p]&&l[p]){this.getMatrixAt(p,Si),this.getBoundingSphereAt(p,Yi).applyMatrix4(Si);let v=!1;if(f&&(v=!vd.intersectsSphere(Yi)),!v){let w=io.distanceTo(Yi.center);_d.push(h[p],w)}}let y=_d.list,g=this.customSort;g===null?y.sort(s.transparent?EE:AE):g.call(this,y,i);for(let p=0,_=y.length;p<_;p++){let v=y[p];u[m]=v.start*a,d[m]=v.count,m++}_d.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,Si),this.getBoundingSphereAt(y,Yi).applyMatrix4(Si),p=!vd.intersectsSphere(Yi)),!p){let _=h[y];u[m]=_.start*a,d[m]=_.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Ut=class extends Dt{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}},dc=new T,hc=new T,lg=new Ne,ro=new Ci,El=new Lt,xd=new T,cg=new T,kn=class extends rt{constructor(e=new Ye,t=new Ut){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++)dc.fromBufferAttribute(t,r-1),hc.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=dc.distanceTo(hc);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(),El.copy(i.boundingSphere),El.applyMatrix4(r),El.radius+=s,e.ray.intersectsSphere(El)===!1)return;lg.copy(r).invert(),ro.copy(e.ray).applyMatrix4(lg);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),m=Math.min(u.count,o.start+o.count);for(let y=f,g=m-1;y<g;y+=c){let p=u.getX(y),_=u.getX(y+1),v=Tl(this,e,ro,l,p,_);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(m-1),g=u.getX(f),p=Tl(this,e,ro,l,y,g);p&&t.push(p)}}else{let f=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let y=f,g=m-1;y<g;y+=c){let p=Tl(this,e,ro,l,y,y+1);p&&t.push(p)}if(this.isLineLoop){let y=Tl(this,e,ro,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,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};ug=new T,dg=new T,_n=class extends kn{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}},fc=class extends kn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Fo=class extends Dt{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 Ci,Il=new Lt,Cl=new T,pc=class extends rt{constructor(e=new Ye,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(),Il.copy(i.boundingSphere),Il.applyMatrix4(r),Il.radius+=s,e.ray.intersectsSphere(Il)===!1)return;hg.copy(r).invert(),Eh.copy(e.ray).applyMatrix4(hg);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 m=h,y=f;m<y;m++){let g=c.getX(m);Cl.fromBufferAttribute(d,g),fg(Cl,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 m=h,y=f;m<y;m++)Cl.fromBufferAttribute(d,m),fg(Cl,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,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};Th=class extends Mt{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:wt,this.magFilter=s!==void 0?s:wt,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 Mt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Pt,this.minFilter=Pt,this.generateMipmaps=!1,this.needsUpdate=!0}},ys=class extends Mt{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 ys{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=yn}},Rh=class extends ys{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,oi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Ph=class extends Mt{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}},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 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 ne:new T);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 T,r=[],s=[],o=[],a=new T,l=new Ne;for(let f=0;f<=e;f++){let m=f/e;r[f]=this.getTangentAt(m,new T)}s[0]=new T,o[0]=new T;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 m=Math.acos(yt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(yt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],f*m)),o[m].crossVectors(r[m],s[m])}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}},vs=class extends an{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 ne){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}},mc=class extends vs{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};Rl=new T,bd=new zf,wd=new zf,Md=new zf,gc=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 T){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]:(Rl.subVectors(r[0],r[1]).add(r[0]),c=Rl);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Rl.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Rl),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 T().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ko=class extends an{constructor(e=new ne,t=new ne,i=new ne,r=new ne){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ne){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}},yc=class extends an{constructor(e=new T,t=new T,i=new T,r=new T){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new T){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 an{constructor(e=new ne,t=new ne){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ne){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 ne){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}},vc=class extends an{constructor(e=new T,t=new T){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new T){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 T){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 an{constructor(e=new ne,t=new ne,i=new ne){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ne){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 an{constructor(e=new T,t=new T,i=new T){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new T){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 an{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ne){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(pg(a,l.x,c.x,u.x,d.x),pg(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 ne().fromArray(r))}return this}},_c=Object.freeze({__proto__:null,ArcCurve:mc,CatmullRomCurve3:gc,CubicBezierCurve:ko,CubicBezierCurve3:yc,EllipseCurve:vs,LineCurve:Bo,LineCurve3:vc,QuadraticBezierCurve:zo,QuadraticBezierCurve3:Vo,SplineCurve:Ho}),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 _c[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 _c[r.type]().fromJSON(r))}return this}},pr=class extends xc{constructor(e){super(),this.type="Path",this.currentPoint=new ne,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 ne(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 ne(e,t),new ne(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 ne(e,t),new ne(i,r),new ne(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 vs(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 Ye{constructor(e=[new ne(0,-.5),new ne(.5,0),new ne(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=yt(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/t,d=new T,h=new ne,f=new T,m=new T,y=new T,g=0,p=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].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[_+1].x-e[_].x,p=e[_+1].y-e[_].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 _=0;_<=t;_++){let v=i+_*u*r,w=Math.sin(v),P=Math.cos(v);for(let A=0;A<=e.length-1;A++){d.x=e[A].x*w,d.y=e[A].y,d.z=e[A].x*P,o.push(d.x,d.y,d.z),h.x=_/t,h.y=A/(e.length-1),a.push(h.x,h.y);let E=l[3*A+0]*w,L=l[3*A+1],b=l[3*A+0]*P;c.push(E,L,b)}}for(let _=0;_<t;_++)for(let v=0;v<e.length-1;v++){let w=v+_*e.length,P=w,A=w+e.length,E=w+e.length+1,L=w+1;s.push(P,A,L),s.push(E,L,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)}},bc=class n extends Go{constructor(e=1,t=1,i=4,r=8){let s=new pr;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)}},wc=class n extends Ye{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 T,u=new ne;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)}},_s=class n extends Ye{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=[],m=0,y=[],g=i/2,p=0;_(),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 _(){let w=new T,P=new T,A=0,E=(t-e)/i;for(let L=0;L<=s;L++){let b=[],x=L/s,R=x*(t-e)+e;for(let U=0;U<=r;U++){let D=U/r,$=D*l+a,j=Math.sin($),N=Math.cos($);P.x=R*j,P.y=-x*i+g,P.z=R*N,d.push(P.x,P.y,P.z),w.set(j,E,N).normalize(),h.push(w.x,w.y,w.z),f.push(D,1-x),b.push(m++)}y.push(b)}for(let L=0;L<r;L++)for(let b=0;b<s;b++){let x=y[b][L],R=y[b+1][L],U=y[b+1][L+1],D=y[b][L+1];u.push(x,R,D),u.push(R,U,D),A+=6}c.addGroup(p,A,0),p+=A}function v(w){let P=m,A=new ne,E=new T,L=0,b=w===!0?e:t,x=w===!0?1:-1;for(let U=1;U<=r;U++)d.push(0,g*x,0),h.push(0,x,0),f.push(.5,.5),m++;let R=m;for(let U=0;U<=r;U++){let $=U/r*l+a,j=Math.cos($),N=Math.sin($);E.x=b*N,E.y=g*x,E.z=b*j,d.push(E.x,E.y,E.z),h.push(0,x,0),A.x=j*.5+.5,A.y=N*.5*x+.5,f.push(A.x,A.y),m++}for(let U=0;U<r;U++){let D=P+U,$=R+U;w===!0?u.push($,$+1,D):u.push($+1,$,D),L+=3}c.addGroup(p,L,w===!0?1:2),p+=L}}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)}},Mc=class n extends _s{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)}},Pi=class n extends Ye{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(_){let v=new T,w=new T,P=new T;for(let A=0;A<t.length;A+=3)f(t[A+0],v),f(t[A+1],w),f(t[A+2],P),l(v,w,P,_)}function l(_,v,w,P){let A=P+1,E=[];for(let L=0;L<=A;L++){E[L]=[];let b=_.clone().lerp(w,L/A),x=v.clone().lerp(w,L/A),R=A-L;for(let U=0;U<=R;U++)U===0&&L===A?E[L][U]=b:E[L][U]=b.clone().lerp(x,U/R)}for(let L=0;L<A;L++)for(let b=0;b<2*(A-L)-1;b++){let x=Math.floor(b/2);b%2===0?(h(E[L][x+1]),h(E[L+1][x]),h(E[L][x])):(h(E[L][x+1]),h(E[L+1][x+1]),h(E[L+1][x]))}}function c(_){let v=new T;for(let w=0;w<s.length;w+=3)v.x=s[w+0],v.y=s[w+1],v.z=s[w+2],v.normalize().multiplyScalar(_),s[w+0]=v.x,s[w+1]=v.y,s[w+2]=v.z}function u(){let _=new T;for(let v=0;v<s.length;v+=3){_.x=s[v+0],_.y=s[v+1],_.z=s[v+2];let w=g(_)/2/Math.PI+.5,P=p(_)/Math.PI+.5;o.push(w,1-P)}m(),d()}function d(){for(let _=0;_<o.length;_+=6){let v=o[_+0],w=o[_+2],P=o[_+4],A=Math.max(v,w,P),E=Math.min(v,w,P);A>.9&&E<.1&&(v<.2&&(o[_+0]+=1),w<.2&&(o[_+2]+=1),P<.2&&(o[_+4]+=1))}}function h(_){s.push(_.x,_.y,_.z)}function f(_,v){let w=_*3;v.x=e[w+0],v.y=e[w+1],v.z=e[w+2]}function m(){let _=new T,v=new T,w=new T,P=new T,A=new ne,E=new ne,L=new ne;for(let b=0,x=0;b<s.length;b+=9,x+=6){_.set(s[b+0],s[b+1],s[b+2]),v.set(s[b+3],s[b+4],s[b+5]),w.set(s[b+6],s[b+7],s[b+8]),A.set(o[x+0],o[x+1]),E.set(o[x+2],o[x+3]),L.set(o[x+4],o[x+5]),P.copy(_).add(v).add(w).divideScalar(3);let R=g(P);y(A,x+0,_,R),y(E,x+2,v,R),y(L,x+4,w,R)}}function y(_,v,w,P){P<0&&_.x===1&&(o[v]=_.x-1),w.x===0&&w.z===0&&(o[v]=P/2/Math.PI+.5)}function g(_){return Math.atan2(_.z,-_.x)}function p(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.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)}},Sc=class n extends Pi{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)}},Pl=new T,Ll=new T,Sd=new T,Dl=new ei,Ac=class extends Ye{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(lr*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 m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);let{a:y,b:g,c:p}=Dl;if(y.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),p.fromBufferAttribute(a,c[2]),Dl.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 _=0;_<3;_++){let v=(_+1)%3,w=d[_],P=d[v],A=Dl[u[_]],E=Dl[u[v]],L=`${w}_${P}`,b=`${P}_${w}`;b in h&&h[b]?(Sd.dot(h[b].normal)<=s&&(f.push(A.x,A.y,A.z),f.push(E.x,E.y,E.z)),h[b]=null):L in h||(h[L]={index0:c[_],index1:c[v],normal:Sd.clone()})}}for(let m in h)if(h[m]){let{index0:y,index1:g}=h[m];Pl.fromBufferAttribute(a,y),Ll.fromBufferAttribute(a,g),f.push(Pl.x,Pl.y,Pl.z),f.push(Ll.x,Ll.y,Ll.z)}this.setAttribute("position",new Te(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ri=class extends pr{constructor(e){super(e),this.uuid=nn(),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 pr().fromJSON(r))}return this}},NE={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=oy(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=VE(n,e,s,t)),n.length>80*t){a=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)d=n[m],h=n[m+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}};Nn=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 o=e.length;t.forEach(gg);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,yg(i,t[l]);let a=NE.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};Ec=class n extends Ye{constructor(e=new ri([new ne(.5,.5),new ne(-.5,.5),new ne(-.5,-.5),new ne(.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,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,_=t.UVGenerator!==void 0?t.UVGenerator:QE,v,w=!1,P,A,E,L;p&&(v=p.getSpacedPoints(u),w=!0,h=!1,P=p.computeFrenetFrames(u,!1),A=new T,E=new T,L=new T),h||(g=0,f=0,m=0,y=0);let b=a.extractPoints(c),x=b.shape,R=b.holes;if(!Nn.isClockWise(x)){x=x.reverse();for(let K=0,ue=R.length;K<ue;K++){let Q=R[K];Nn.isClockWise(Q)&&(R[K]=Q.reverse())}}let D=Nn.triangulateShape(x,R),$=x;for(let K=0,ue=R.length;K<ue;K++){let Q=R[K];x=x.concat(Q)}function j(K,ue,Q){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),K.clone().addScaledVector(ue,Q)}let N=x.length,X=D.length;function k(K,ue,Q){let de,ae,fe,Ee=K.x-ue.x,C=K.y-ue.y,S=Q.x-K.x,W=Q.y-K.y,te=Ee*Ee+C*C,se=Ee*W-C*S;if(Math.abs(se)>Number.EPSILON){let re=Math.sqrt(te),Re=Math.sqrt(S*S+W*W),ge=ue.x-C/re,ye=ue.y+Ee/re,Be=Q.x-W/Re,he=Q.y+S/Re,Pe=((Be-ge)*W-(he-ye)*S)/(Ee*W-C*S);de=ge+Ee*Pe-K.x,ae=ye+C*Pe-K.y;let je=de*de+ae*ae;if(je<=2)return new ne(de,ae);fe=Math.sqrt(je/2)}else{let re=!1;Ee>Number.EPSILON?S>Number.EPSILON&&(re=!0):Ee<-Number.EPSILON?S<-Number.EPSILON&&(re=!0):Math.sign(C)===Math.sign(W)&&(re=!0),re?(de=-C,ae=Ee,fe=Math.sqrt(te)):(de=Ee,ae=C,fe=Math.sqrt(te/2))}return new ne(de/fe,ae/fe)}let le=[];for(let K=0,ue=$.length,Q=ue-1,de=K+1;K<ue;K++,Q++,de++)Q===ue&&(Q=0),de===ue&&(de=0),le[K]=k($[K],$[Q],$[de]);let ce=[],Me,Fe=le.concat();for(let K=0,ue=R.length;K<ue;K++){let Q=R[K];Me=[];for(let de=0,ae=Q.length,fe=ae-1,Ee=de+1;de<ae;de++,fe++,Ee++)fe===ae&&(fe=0),Ee===ae&&(Ee=0),Me[de]=k(Q[de],Q[fe],Q[Ee]);ce.push(Me),Fe=Fe.concat(Me)}for(let K=0;K<g;K++){let ue=K/g,Q=f*Math.cos(ue*Math.PI/2),de=m*Math.sin(ue*Math.PI/2)+y;for(let ae=0,fe=$.length;ae<fe;ae++){let Ee=j($[ae],le[ae],de);ie(Ee.x,Ee.y,-Q)}for(let ae=0,fe=R.length;ae<fe;ae++){let Ee=R[ae];Me=ce[ae];for(let C=0,S=Ee.length;C<S;C++){let W=j(Ee[C],Me[C],de);ie(W.x,W.y,-Q)}}}let Ke=m+y;for(let K=0;K<N;K++){let ue=h?j(x[K],Fe[K],Ke):x[K];w?(E.copy(P.normals[0]).multiplyScalar(ue.x),A.copy(P.binormals[0]).multiplyScalar(ue.y),L.copy(v[0]).add(E).add(A),ie(L.x,L.y,L.z)):ie(ue.x,ue.y,0)}for(let K=1;K<=u;K++)for(let ue=0;ue<N;ue++){let Q=h?j(x[ue],Fe[ue],Ke):x[ue];w?(E.copy(P.normals[K]).multiplyScalar(Q.x),A.copy(P.binormals[K]).multiplyScalar(Q.y),L.copy(v[K]).add(E).add(A),ie(L.x,L.y,L.z)):ie(Q.x,Q.y,d/u*K)}for(let K=g-1;K>=0;K--){let ue=K/g,Q=f*Math.cos(ue*Math.PI/2),de=m*Math.sin(ue*Math.PI/2)+y;for(let ae=0,fe=$.length;ae<fe;ae++){let Ee=j($[ae],le[ae],de);ie(Ee.x,Ee.y,d+Q)}for(let ae=0,fe=R.length;ae<fe;ae++){let Ee=R[ae];Me=ce[ae];for(let C=0,S=Ee.length;C<S;C++){let W=j(Ee[C],Me[C],de);w?ie(W.x,W.y+v[u-1].y,v[u-1].x+Q):ie(W.x,W.y,d+Q)}}}J(),Z();function J(){let K=r.length/3;if(h){let ue=0,Q=N*ue;for(let de=0;de<X;de++){let ae=D[de];ke(ae[2]+Q,ae[1]+Q,ae[0]+Q)}ue=u+g*2,Q=N*ue;for(let de=0;de<X;de++){let ae=D[de];ke(ae[0]+Q,ae[1]+Q,ae[2]+Q)}}else{for(let ue=0;ue<X;ue++){let Q=D[ue];ke(Q[2],Q[1],Q[0])}for(let ue=0;ue<X;ue++){let Q=D[ue];ke(Q[0]+N*u,Q[1]+N*u,Q[2]+N*u)}}i.addGroup(K,r.length/3-K,0)}function Z(){let K=r.length/3,ue=0;me($,ue),ue+=$.length;for(let Q=0,de=R.length;Q<de;Q++){let ae=R[Q];me(ae,ue),ue+=ae.length}i.addGroup(K,r.length/3-K,1)}function me(K,ue){let Q=K.length;for(;--Q>=0;){let de=Q,ae=Q-1;ae<0&&(ae=K.length-1);for(let fe=0,Ee=u+g*2;fe<Ee;fe++){let C=N*fe,S=N*(fe+1),W=ue+de+C,te=ue+ae+C,se=ue+ae+S,re=ue+de+S;xe(W,te,se,re)}}}function ie(K,ue,Q){l.push(K),l.push(ue),l.push(Q)}function ke(K,ue,Q){z(K),z(ue),z(Q);let de=r.length/3,ae=_.generateTopUV(i,r,de-3,de-2,de-1);Ue(ae[0]),Ue(ae[1]),Ue(ae[2])}function xe(K,ue,Q,de){z(K),z(ue),z(de),z(ue),z(Q),z(de);let ae=r.length/3,fe=_.generateSideWallUV(i,r,ae-6,ae-3,ae-2,ae-1);Ue(fe[0]),Ue(fe[1]),Ue(fe[3]),Ue(fe[1]),Ue(fe[2]),Ue(fe[3])}function z(K){r.push(l[K*3+0]),r.push(l[K*3+1]),r.push(l[K*3+2])}function Ue(K){s.push(K.x),s.push(K.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 eT(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 _c[r.type]().fromJSON(r)),new n(i,e.options)}},QE={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 ne(s,o),new ne(a,l),new ne(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],m=e[r*3+2],y=e[s*3],g=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new ne(o,1-l),new ne(c,1-d),new ne(h,1-m),new ne(y,1-p)]:[new ne(a,1-l),new ne(u,1-d),new ne(f,1-m),new ne(g,1-p)]}};Tc=class n extends Pi{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 Pi{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)}},Ic=class n extends Ye{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 T,m=new ne;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let p=s+g/i*o;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 _=p+g,v=_,w=_+i+1,P=_+i+2,A=_+1;a.push(v,w,A),a.push(w,P,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)}},Cc=class n extends Ye{constructor(e=new ri([new ne(0,.5),new ne(-.5,-.5),new ne(.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,m=h.holes;Nn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,p=m.length;g<p;g++){let _=m[g];Nn.isClockWise(_)===!0&&(m[g]=_.reverse())}let y=Nn.triangulateShape(f,m);for(let g=0,p=m.length;g<p;g++){let _=m[g];f=f.concat(_)}for(let g=0,p=f.length;g<p;g++){let _=f[g];r.push(_.x,_.y,0),s.push(0,0,1),o.push(_.x,_.y)}for(let g=0,p=y.length;g<p;g++){let _=y[g],v=_[0]+d,w=_[1]+d,P=_[2]+d;i.push(v,w,P),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 tT(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 Ye{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 T,h=new T,f=[],m=[],y=[],g=[];for(let p=0;p<=i;p++){let _=[],v=p/i,w=0;p===0&&o===0?w=.5/t:p===i&&l===Math.PI&&(w=-.5/t);for(let P=0;P<=t;P++){let A=P/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),m.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(A+w,1-v),_.push(c++)}u.push(_)}for(let p=0;p<i;p++)for(let _=0;_<t;_++){let v=u[p][_+1],w=u[p][_],P=u[p+1][_],A=u[p+1][_+1];(p!==0||o>0)&&f.push(v,w,A),(p!==i-1||l<Math.PI)&&f.push(w,P,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)}},Rc=class n extends Pi{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)}},Pc=class n extends Ye{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 T,d=new T,h=new T;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),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(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,_=(r+1)*f+m;o.push(y,g,_),o.push(g,p,_)}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)}},Lc=class n extends Ye{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 T,h=new T,f=new T,m=new T,y=new T,g=new T,p=new T;for(let v=0;v<=i;++v){let w=v/i*s*Math.PI*2;_(w,s,o,e,f),_(w+.01,s,o,e,m),g.subVectors(m,f),p.addVectors(m,f),y.crossVectors(g,p),p.crossVectors(y,g),y.normalize(),p.normalize();for(let P=0;P<=r;++P){let A=P/r*Math.PI*2,E=-t*Math.cos(A),L=t*Math.sin(A);d.x=f.x+(E*p.x+L*y.x),d.y=f.y+(E*p.y+L*y.y),d.z=f.z+(E*p.z+L*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(P/r)}}for(let v=1;v<=i;v++)for(let w=1;w<=r;w++){let P=(r+1)*(v-1)+(w-1),A=(r+1)*v+(w-1),E=(r+1)*v+w,L=(r+1)*(v-1)+w;a.push(P,A,L),a.push(A,E,L)}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 _(v,w,P,A,E){let L=Math.cos(v),b=Math.sin(v),x=P/w*v,R=Math.cos(x);E.x=A*(2+R)*.5*L,E.y=A*(2+R)*b*.5,E.z=A*Math.sin(x)*.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)}},Dc=class n extends Ye{constructor(e=new Vo(new T(-1,-1,0),new T(-1,1,0),new T(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 T,l=new T,c=new ne,u=new T,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),_(),p()}function g(v){u=e.getPointAt(v/t,u);let w=o.normals[v],P=o.binormals[v];for(let A=0;A<=r;A++){let E=A/r*Math.PI*2,L=Math.sin(E),b=-Math.cos(E);l.x=b*w.x+L*P.x,l.y=b*w.y+L*P.y,l.z=b*w.z+L*P.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 p(){for(let v=1;v<=t;v++)for(let w=1;w<=r;w++){let P=(r+1)*(v-1)+(w-1),A=(r+1)*v+(w-1),E=(r+1)*v+w,L=(r+1)*(v-1)+w;m.push(P,A,L),m.push(A,E,L)}}function _(){for(let v=0;v<=t;v++)for(let w=0;w<=r;w++)c.x=v/t,c.y=w/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 _c[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},Oc=class extends Ye{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new T,s=new T;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 m=h,y=h+f;m<y;m+=3)for(let g=0;g<3;g++){let p=a.getX(m+g),_=a.getX(m+(g+1)%3);r.fromBufferAttribute(o,p),s.fromBufferAttribute(o,_),vg(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),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}};_g=Object.freeze({__proto__:null,BoxGeometry:ur,CapsuleGeometry:bc,CircleGeometry:wc,ConeGeometry:Mc,CylinderGeometry:_s,DodecahedronGeometry:Sc,EdgesGeometry:Ac,ExtrudeGeometry:Ec,IcosahedronGeometry:Tc,LatheGeometry:Go,OctahedronGeometry:Xo,PlaneGeometry:ps,PolyhedronGeometry:Pi,RingGeometry:Ic,ShapeGeometry:Cc,SphereGeometry:Yo,TetrahedronGeometry:Rc,TorusGeometry:Pc,TorusKnotGeometry:Lc,TubeGeometry:Dc,WireframeGeometry:Oc}),Uc=class extends Dt{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}},Nc=class extends on{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},qo=class extends Dt{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=Di,this.normalScale=new ne(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 sn,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}},Fc=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 ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(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}},kc=class extends Dt{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=Di,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new sn,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}},Bc=class extends Dt{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=Di,this.normalScale=new ne(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}},zc=class extends Dt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Di,this.normalScale=new ne(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}},Vc=class extends Dt{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=Di,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new sn,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}},Hc=class extends Dt{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=Di,this.normalScale=new ne(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}},Gc=class extends Ut{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}};rT={convertArray:sr,isTypedArray:cy,getKeyframeOrder:uy,sortedArray:Oh,flattenJSON:Vf,subclip:nT,makeClipAdditive:iT},gr=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_(){}},$c=class extends gr{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:ir,endingEnd:ir}}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 rr: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 rr: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,m=(i-t)/(r-t),y=m*m,g=y*m,p=-h*g+2*h*y-h*m,_=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*m+1,v=(-1-f)*g+(1.5+f)*y+.5*m,w=f*g-f*y;for(let P=0;P!==a;++P)s[P]=p*o[u+P]+_*o[c+P]+v*o[l+P]+w*o[d+P];return s}},Zo=class extends gr{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}},Wc=class extends gr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},ln=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=sr(t,this.TimeBufferType),this.values=sr(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:sr(e.times,Array),values:sr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Wc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Zo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $c(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case _o:t=this.InterpolantFactoryMethodDiscrete;break;case xo:t=this.InterpolantFactoryMethodLinear;break;case Yl: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 _o;case this.InterpolantFactoryMethodLinear:return xo;case this.InterpolantFactoryMethodSmooth:return Yl}}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&&cy(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()===Yl,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 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(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}};ln.prototype.TimeBufferType=Float32Array;ln.prototype.ValueBufferType=Float32Array;ln.prototype.DefaultInterpolation=xo;li=class extends ln{};li.prototype.ValueTypeName="bool";li.prototype.ValueBufferType=Array;li.prototype.DefaultInterpolation=_o;li.prototype.InterpolantFactoryMethodLinear=void 0;li.prototype.InterpolantFactoryMethodSmooth=void 0;Jo=class extends ln{};Jo.prototype.ValueTypeName="color";yr=class extends ln{};yr.prototype.ValueTypeName="number";jc=class extends gr{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)Ht.slerpFlat(s,0,o,c-a,o,c,l);return s}},Li=class extends ln{InterpolantFactoryMethodLinear(e){return new jc(this.times,this.values,this.getValueSize(),e)}};Li.prototype.ValueTypeName="quaternion";Li.prototype.DefaultInterpolation=xo;Li.prototype.InterpolantFactoryMethodSmooth=void 0;ci=class extends ln{};ci.prototype.ValueTypeName="string";ci.prototype.ValueBufferType=Array;ci.prototype.DefaultInterpolation=_o;ci.prototype.InterpolantFactoryMethodLinear=void 0;ci.prototype.InterpolantFactoryMethodSmooth=void 0;vr=class extends ln{};vr.prototype.ValueTypeName="vector";_r=class{constructor(e="",t=-1,i=[],r=cu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=nn(),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(oT(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(ln.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=uy(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 yr(".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,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",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={},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 _=0;_!==h[m].morphTargets.length;++_){let v=h[m];g.push(v.time),p.push(v.morphTarget===y?1:0)}r.push(new yr(".morphTargetInfluence["+y+"]",g,p))}l=f.length*o}else{let f=".bones["+t[d].name+"]";i(vr,f+".position",h,"pos",r),i(Li,f+".quaternion",h,"rot",r),i(vr,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)}};ti={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],m=c[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return m}return null}}},dy=new Ko,Gt=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}};Gt.DEFAULT_MATERIAL_NAME="__DEFAULT";Zn={},Uh=class extends Error{constructor(e,t){super(e),this.response=t}},In=class extends Gt{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=ti.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zn[e]!==void 0){Zn[e].push({onLoad:t,onProgress:i,onError:r});return}Zn[e]=[],Zn[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=Zn[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){_();function _(){d.read().then(({done:v,value:w})=>{if(v)p.close();else{y+=w.byteLength;let P=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:f});for(let A=0,E=u.length;A<E;A++){let L=u[A];L.onProgress&&L.onProgress(P)}p.enqueue(w),_()}})}}});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(m=>f.decode(m))}}}).then(c=>{ti.add(e,c);let u=Zn[e];delete Zn[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=Zn[e];if(u===void 0)throw this.manager.itemError(e),c;delete Zn[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 Gt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new In(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=_r.parse(e[i]);t.push(r)}return t}},Fh=class extends Gt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new ys,l=new In(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=wt),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 m=0;m<f;m++){o[m]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[m].mipmaps.push(h.mipmaps[m*h.mipmapCount+y]),o[m].format=h.format,o[m].width=h.width,o[m].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=wt),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},xr=class extends Gt{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=ti.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(),ti.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 Gt{constructor(e){super(e)}load(e,t,i,r){let s=new dr;s.colorSpace=gn;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 Gt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Un,a=new In(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:yn,o.wrapT=c.wrapT!==void 0?c.wrapT:yn,o.magFilter=c.magFilter!==void 0?c.magFilter:wt,o.minFilter=c.minFilter!==void 0?c.minFilter:wt,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=Dn),c.mipmapCount===1&&(o.minFilter=wt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}},zh=class extends Gt{constructor(e){super(e)}load(e,t,i,r){let s=new Mt,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}},Bn=class extends rt{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}},Xc=class extends Bn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(rt.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,xg=new T,bg=new T,Qo=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ne(512,512),this.map=null,this.mapPass=null,this.matrix=new Ne,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hr,this._frameExtents=new ne(1,1),this._viewportCount=1,this._viewports=[new lt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;xg.setFromMatrixPosition(e.matrixWorld),t.position.copy(xg),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 Qo{constructor(){super(new Et(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=cs*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}},Yc=class extends Bn{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(rt.DEFAULT_UP),this.updateMatrix(),this.target=new rt,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}},wg=new Ne,so=new T,Ed=new T,Hh=class extends Qo{constructor(){super(new Et(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ne(4,2),this._viewportCount=6,this._viewports=[new lt(2,1,1,1),new lt(0,1,1,1),new lt(3,1,1,1),new lt(1,1,1,1),new lt(3,0,1,1),new lt(1,0,1,1)],this._cubeDirections=[new T(1,0,0),new T(-1,0,0),new T(0,0,1),new T(0,0,-1),new T(0,1,0),new T(0,-1,0)],this._cubeUps=[new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,0,1),new T(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),wg.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wg)}},qc=class extends Bn{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 ms(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Zc=class extends Bn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(rt.DEFAULT_UP),this.updateMatrix(),this.target=new rt,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}},Jc=class extends Bn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Kc=class extends Bn{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}},Qc=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new T)}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)}},eu=class extends Bn{constructor(e=new Qc,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}},tu=class n extends Gt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new In(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 ne().fromArray(o.value);break;case"v3":r.uniforms[s].value=new T().fromArray(o.value);break;case"v4":r.uniforms[s].value=new lt().fromArray(o.value);break;case"m3":r.uniforms[s].value=new He().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 ne().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 ne().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:Uc,SpriteMaterial:Uo,RawShaderMaterial:Nc,ShaderMaterial:on,PointsMaterial:Fo,MeshPhysicalMaterial:Fc,MeshStandardMaterial:qo,MeshPhongMaterial:kc,MeshToonMaterial:Bc,MeshNormalMaterial:zc,MeshLambertMaterial:Vc,MeshDepthMaterial:Do,MeshDistanceMaterial:Oo,MeshBasicMaterial:Fn,MeshMatcapMaterial:Hc,LineDashedMaterial:Gc,LineBasicMaterial:Ut,Material:Dt};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)}},nu=class extends Ye{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}},iu=class extends Gt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new In(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,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],p=s(f,g.buffer),_=is(g.type,p),v=new gs(_,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 o=e.isInstancedBufferGeometry?new nu:new Ye,a=e.data.index;if(a!==void 0){let f=is(a.type,a.array);o.setIndex(new nt(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 fr(g,m.itemSize,m.offset,m.normalized)}else{let g=is(m.type,m.array),p=m.isInstancedBufferAttribute?Ri:nt;y=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),m.usage!==void 0&&y.setUsage(m.usage),o.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 _=m[g],v;if(_.isInterleavedBufferAttribute){let w=r(e.data,_.data);v=new fr(w,_.itemSize,_.offset,_.normalized)}else{let w=is(_.type,_.array);v=new nt(w,_.itemSize,_.normalized)}_.name!==void 0&&(v.name=_.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,m=d.length;f!==m;++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 T;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Lt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},$h=class extends Gt{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 In(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 In(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 ri().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 lc().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new iu;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 tu;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=_r.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:is(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 m=0,y=h.length;m<y;m++){let g=h[m],p=a(g);p!==null&&(p instanceof HTMLImageElement?f.push(p):f.push(new Un(p.data,p.width,p.height)))}r[d.uuid]=new Qn(f)}else{let f=a(d.url);r[d.uuid]=new Qn(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:is(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],m=await s(f);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Un(m.data,m.width,m.height)))}i[l.uuid]=new Qn(u)}else{let u=await s(l.url);i[l.uuid]=new Qn(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 dr,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Un:u=new Mt,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,aT)),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],Mg),u.wrapT=i(a.wrap[1],Mg)),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,Sg)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Sg)),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 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":o=new rc,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 ic(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new nc(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 Et(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 ms(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 Jc(e.color,e.intensity);break;case"DirectionalLight":o=new Zc(e.color,e.intensity);break;case"PointLight":o=new qc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Kc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Yc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Xc(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new eu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new ac(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 vt(u,d);break;case"InstancedMesh":u=a(e.geometry),d=l(e.material);let h=e.count,f=e.instanceMatrix,m=e.instanceColor;o=new cc(u,d,h),o.instanceMatrix=new Ri(new Float32Array(f.array),16),m!==void 0&&(o.instanceColor=new Ri(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new uc(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 Ot;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let p=new Lt;return p.radius=y.sphereRadius,p.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:p}}),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 oc;break;case"Line":o=new kn(a(e.geometry),l(e.material));break;case"LineLoop":o=new fc(a(e.geometry),l(e.material));break;case"LineSegments":o=new _n(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new pc(a(e.geometry),l(e.material));break;case"Sprite":o=new sc(l(e.material));break;case"Group":o=new Ti;break;case"Bone":o=new No;break;default:o=new rt}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 m=h[f];o.animations.push(s[m])}}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 m=h[f],y=o.getObjectByProperty("uuid",m.object);y!==void 0&&o.addLevel(y,m.distance,m.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)}})}},aT={UVMapping:lu,CubeReflectionMapping:oi,CubeRefractionMapping:Ii,EquirectangularReflectionMapping:mo,EquirectangularRefractionMapping:go,CubeUVReflectionMapping:xs},Mg={RepeatWrapping:yo,ClampToEdgeWrapping:yn,MirroredRepeatWrapping:vo},Sg={NearestFilter:Pt,NearestMipmapNearestFilter:Tf,NearestMipmapLinearFilter:ns,LinearFilter:wt,LinearMipmapNearestFilter:lo,LinearMipmapLinearFilter:Dn},Wh=class extends Gt{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=ti.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 ti.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ti.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ti.add(e,l),s.manager.itemStart(e)}},ta=class{static getContext(){return Nl===void 0&&(Nl=new(window.AudioContext||window.webkitAudioContext)),Nl}static setContext(e){Nl=e}},jh=class extends Gt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new In(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)}}},Ag=new Ne,Eg=new Ne,qi=new Ne,Xh=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Et,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Et,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,qi.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(lr*t.fov*.5)/t.zoom,a,l;Eg.elements[12]=-r,Ag.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,qi.elements[0]=2*t.near/(l-a),qi.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(qi),a=-o*t.aspect-s,l=o*t.aspect-s,qi.elements[0]=2*t.near/(l-a),qi.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(qi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Eg),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ag)}},ru=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}};Zi=new T,Ig=new Ht,lT=new T,Ji=new T,Yh=class extends rt{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 ru}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(Zi,Ig,lT),Ji.set(0,0,-1).applyQuaternion(Ig),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Zi.x,r),t.positionY.linearRampToValueAtTime(Zi.y,r),t.positionZ.linearRampToValueAtTime(Zi.z,r),t.forwardX.linearRampToValueAtTime(Ji.x,r),t.forwardY.linearRampToValueAtTime(Ji.y,r),t.forwardZ.linearRampToValueAtTime(Ji.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Zi.x,Zi.y,Zi.z),t.setOrientation(Ji.x,Ji.y,Ji.z,i.x,i.y,i.z)}},su=class extends rt{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}},Ki=new T,Cg=new Ht,cT=new T,Qi=new T,qh=class extends su{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(Ki,Cg,cT),Qi.set(0,0,1).applyQuaternion(Cg);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ki.x,i),t.positionY.linearRampToValueAtTime(Ki.y,i),t.positionZ.linearRampToValueAtTime(Ki.z,i),t.orientationX.linearRampToValueAtTime(Qi.x,i),t.orientationY.linearRampToValueAtTime(Qi.y,i),t.orientationZ.linearRampToValueAtTime(Qi.z,i)}else t.setPosition(Ki.x,Ki.y,Ki.z),t.setOrientation(Qi.x,Qi.y,Qi.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}},ou=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){Ht.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Ht.multiplyQuaternionsFlat(e,o,e,t,e,i),Ht.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="\\[\\]\\.:\\/",uT=new RegExp("["+Hf+"]","g"),Gf="[^"+Hf+"]",dT="[^"+Hf.replace("\\.","")+"]",hT=/((?:WC+[\/:])*)/.source.replace("WC",Gf),fT=/(WCOD+)?/.source.replace("WCOD",dT),pT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gf),mT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gf),gT=new RegExp("^"+hT+fT+pT+mT+"$"),yT=["material","materials","bones","map"],Jh=class{constructor(e,t,i){let r=i||ot.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()}},ot=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(uT,"")}static parseTrackName(e){let t=gT.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);yT.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}};ot.Composite=Jh;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Kh=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=nn(),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,m=t[f];if(m===void 0){m=l++,t[f]=m,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new ot(h,i[y],r[y]))}else if(m<c){a=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,_=o;p!==_;++p){let v=s[p],w=v[y],P=v[m];v[m]=w,P===void 0&&(P=new ot(h,i[p],r[p])),v[y]=P}}else e[m]!==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,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_,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],m=--o,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 _=i[g],v=_[h],w=_[m];_[d]=v,_[h]=w,_.pop()}}else{let h=--o,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 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 m=l[h];d[h]=new ot(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,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()}}},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,o=s.length,a=new Array(o),l={endingStart:ir,endingEnd:ir};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=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,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 cu: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===U0;if(e===0)return s===-1?r:o&&(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,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=rr,r.endingEnd=rr):(e?r.endingStart=this.zeroSlopeAtStart?rr:ir:r.endingStart=bo,t?r.endingEnd=this.zeroSlopeAtEnd?rr:ir: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}},vT=new Float32Array(1),Qh=class extends Tn{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,m=u[f];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[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 ou(ot.create(i,f,y),h.ValueTypeName,h.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[d]=m}a[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,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,vT),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"?_r.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=cu),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 au(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"?_r.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())}},_T=0,tf=class extends Tn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:_T++}),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 gs{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 Ci(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new ds,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 of(e,this,i,t),i.sort(Pg),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(Pg),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(yt(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 ne,cf=class{constructor(e=new ne(1/0,1/0),t=new ne(-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 T,Fl=new T,uf=class{constructor(e=new T,t=new T){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),Fl.subVectors(this.end,this.start);let i=Fl.dot(Fl),s=Fl.dot(Dg)/i;return t&&(s=yt(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 T,df=class extends rt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ye,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 Ut({fog:!1,toneMapped:!1});this.cone=new _n(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)}},Ai=new T,kl=new Ne,Td=new Ne,hf=class extends _n{constructor(e){let t=hy(e),i=new Ye,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 Ut({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&&(kl.multiplyMatrices(Td,a.matrixWorld),Ai.setFromMatrixPosition(kl),r.setXYZ(o,Ai.x,Ai.y,Ai.z),kl.multiplyMatrices(Td,a.parent.matrixWorld),Ai.setFromMatrixPosition(kl),r.setXYZ(o+1,Ai.x,Ai.y,Ai.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};ff=class extends vt{constructor(e,t,i){let r=new Yo(t,4,2),s=new Fn({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)}},xT=new T,Ug=new we,Ng=new we,pf=class extends rt{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 Fn({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 nt(o,3)),this.add(new vt(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(xT.setFromMatrixPosition(this.light.matrixWorld).negate())}},mf=class extends _n{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,m=-a;h<=t;h++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,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 Ye;u.setAttribute("position",new Te(l,3)),u.setAttribute("color",new Te(c,3));let d=new Ut({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},gf=class extends _n{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,m=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,m);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 m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*f,p=Math.cos(y)*f;a.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,a.push(g,0,p),l.push(h.r,h.g,h.b)}}let c=new Ye;c.setAttribute("position",new Te(a,3)),c.setAttribute("color",new Te(l,3));let u=new Ut({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Fg=new T,Bl=new T,kg=new T,yf=class extends rt{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 Ye;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Ut({fog:!1,toneMapped:!1});this.lightPlane=new kn(r,s),this.add(this.lightPlane),r=new Ye,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new kn(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),Bl.setFromMatrixPosition(this.light.target.matrixWorld),kg.subVectors(Bl,Fg),this.lightPlane.lookAt(Bl),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(Bl),this.targetLine.scale.z=kg.length()}},zl=new T,gt=new fs,vf=class extends _n{constructor(e){let t=new Ye,i=new Ut({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(m,y){l(m),l(y)}function l(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[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=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;gt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),_t("c",t,e,gt,0,0,-1),_t("t",t,e,gt,0,0,1),_t("n1",t,e,gt,-i,-r,-1),_t("n2",t,e,gt,i,-r,-1),_t("n3",t,e,gt,-i,r,-1),_t("n4",t,e,gt,i,r,-1),_t("f1",t,e,gt,-i,-r,1),_t("f2",t,e,gt,i,-r,1),_t("f3",t,e,gt,-i,r,1),_t("f4",t,e,gt,i,r,1),_t("u1",t,e,gt,i*.7,r*1.1,-1),_t("u2",t,e,gt,-i*.7,r*1.1,-1),_t("u3",t,e,gt,0,r*2,-1),_t("cf1",t,e,gt,-i,0,1),_t("cf2",t,e,gt,i,0,1),_t("cf3",t,e,gt,0,-r,1),_t("cf4",t,e,gt,0,r,1),_t("cn1",t,e,gt,-i,0,-1),_t("cn2",t,e,gt,i,0,-1),_t("cn3",t,e,gt,0,-r,-1),_t("cn4",t,e,gt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};Vl=new Ot,_f=class extends _n{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 Ye;s.setIndex(new nt(i,1)),s.setAttribute("position",new nt(r,3)),super(s,new Ut({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&&Vl.setFromObject(this.object),Vl.isEmpty())return;let t=Vl.min,i=Vl.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()}},xf=class extends _n{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 Ye;s.setIndex(new nt(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new Ut({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 kn{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 Ye;o.setAttribute("position",new Te(s,3)),o.computeBoundingSphere(),super(o,new Ut({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 Ye;l.setAttribute("position",new Te(a,3)),l.computeBoundingSphere(),this.add(new vt(l,new Fn({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 T,wf=class extends rt{constructor(e=new T(0,0,1),t=new T(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",Hl===void 0&&(Hl=new Ye,Hl.setAttribute("position",new Te([0,0,0,0,1,0],3)),Id=new _s(0,.5,1,5,1),Id.translate(0,-.5,0)),this.position.copy(t),this.line=new kn(Hl,new Ut({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new vt(Id,new Fn({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{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 _n{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 Ye;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new Ut({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 pr,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(p){let _=[];for(let v=0,w=p.length;v<w;v++){let P=p[v],A=new ri;A.curves=P.curves,_.push(A)}return _}function i(p,_){let v=_.length,w=!1;for(let P=v-1,A=0;A<v;P=A++){let E=_[P],L=_[A],b=L.x-E.x,x=L.y-E.y;if(Math.abs(x)>Number.EPSILON){if(x<0&&(E=_[A],b=-b,L=_[P],x=-x),p.y<E.y||p.y>L.y)continue;if(p.y===E.y){if(p.x===E.x)return!0}else{let R=x*(p.x-E.x)-b*(p.y-E.y);if(R===0)return!0;if(R<0)continue;w=!w}}else{if(p.y!==E.y)continue;if(L.x<=p.x&&p.x<=E.x||E.x<=p.x&&p.x<=L.x)return!0}}return w}let r=Nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new ri,l.curves=a.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,_=s.length;p<_;p++)a=s[p],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[m]&&m++,h[m]={s:new ri,p:y},h[m].s.curves=a.curves,u&&m++,f[m]=[]):f[m].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let p=!1,_=0;for(let v=0,w=h.length;v<w;v++)d[v]=[];for(let v=0,w=h.length;v<w;v++){let P=f[v];for(let A=0;A<P.length;A++){let E=P[A],L=!0;for(let b=0;b<h.length;b++)i(E.p,h[b].p)&&(v!==b&&_++,L?(L=!1,d[b].push(E)):p=!0);L&&d[v].push(E)}}_>0&&p===!1&&(f=d)}let g;for(let p=0,_=h.length;p<_;p++){l=h[p].s,c.push(l),g=f[p];for(let v=0,w=g.length;v<w;v++)l.holes.push(g[v].h)}return c}},Af=class extends rn{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 ZT={};Jf(ZT,{DEFAULT_VIEWER_STATE:()=>pn,WORLD_LAYER_ID:()=>Za,WorldOrbit3DUnavailableError:()=>un,WorldOrbitViewerError:()=>Cs,clampScale:()=>js,composeViewerTransform:()=>Xa,createAtlasViewer:()=>gu,createEmbedPayload:()=>Cy,createInteractiveViewer:()=>Oi,createWorldOrbitEmbedMarkup:()=>Ry,defineWorldOrbitViewerElement:()=>Oy,deserializeViewerAtlasState:()=>va,deserializeWorldOrbitEmbedPayload:()=>Xf,fitViewerState:()=>zi,focusViewerState:()=>ja,getSceneCenter:()=>Vi,getThemePreset:()=>Kf,getViewerVisibleBounds:()=>Ya,invertViewerPoint:()=>Pr,mountWorldOrbitEmbeds:()=>Py,normalizeRotation:()=>Vu,normalizeViewerFilter:()=>Jt,panViewerState:()=>Bi,renderDocumentToSvg:()=>$u,renderSceneToSvg:()=>bn,renderSourceToSvg:()=>im,resolveLayers:()=>pa,resolveTheme:()=>Sr,rotateViewerState:()=>Wa,sceneViewpointToLayerOptions:()=>_a,searchSceneObjects:()=>ga,serializeViewerAtlasState:()=>ya,serializeWorldOrbitEmbedPayload:()=>jf,viewpointToViewerFilter:()=>xa,zoomViewerStateAt:()=>Rr});var Cs=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},un=class extends Cs{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var Hy={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",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",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",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Sr(n){return n?typeof n=="string"?Rs[n]??Rs.atlas:{...Rs.atlas,...n}:Rs.atlas}function pa(n){return{...Hy,...n}}function Kf(n){return Rs[n]}function Jt(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 Gy(e)?e:null}function Gy(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function ma(n,e){let t=Jt(e),i=new Set;for(let r of n.objects)if(!r.hidden&&$y(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 ga(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Wy(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:Jt(t)}}function ya(n){return encodeURIComponent(JSON.stringify(n))}function va(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:Jt(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 _a(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?Jt({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 $y(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 Wy(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 q=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"],dn=Ps.filter(n=>n!=="system"),jy=["star","planet","moon","asteroid","comet","structure","phenomenon"],ip=["structure","phenomenon"],fi=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],Xy=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function et(n,e){return{key:n,...e}}var ba=new Set(Ps),rp=new Map([et("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:fi}),et("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"distance"}),et("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"distance"}),et("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:fi}),et("period",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"duration"}),et("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"angle"}),et("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"angle"}),et("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:fi,unitFamily:"angle"}),et("at",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),et("surface",{kind:"string",placement:!0,arity:"single",objectTypes:ip}),et("free",{kind:"string",placement:!0,arity:"single",objectTypes:Xy}),et("kind",{kind:"string",placement:!1,arity:"single",objectTypes:dn}),et("class",{kind:"string",placement:!1,arity:"single",objectTypes:dn}),et("culture",{kind:"string",placement:!1,arity:"single",objectTypes:dn}),et("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:Ps}),et("color",{kind:"string",placement:!1,arity:"single",objectTypes:Ps}),et("image",{kind:"string",placement:!1,arity:"single",objectTypes:jy}),et("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:Ps}),et("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"radius"}),et("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"mass"}),et("density",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"generic"}),et("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"generic"}),et("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"generic"}),et("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:dn}),et("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),et("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),et("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),et("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),et("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),et("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),et("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),et("on",{kind:"string",placement:!1,arity:"single",objectTypes:dn}),et("source",{kind:"string",placement:!1,arity:"single",objectTypes:dn}),et("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:dn,unitFamily:"duration"})].map(n=>[n.key,n])),Yy=new Set(rp.keys());function Kt(n){return rp.get(n)}function sp(n){return Yy.has(n)}function op(n,e){return n.objectTypes.includes(e)}function wa(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 q("Unclosed quote in line",e.line,l??i+n.length);return c(),t}function Ma(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 o=0;o<e.length;o++){let a=e[o],l=o+1;if(!a.trim())continue;let c=Ma(a),u=Ls(a.slice(c),{line:l,columnOffset:c});if(u.length!==0){if(c===0){r=!1,s=null;let d=qy(u,l);t.push(d),i=d;continue}if(!i)throw new q("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(Ky(u,l)):i.blockFields.push(Jy(u,l))}}return{type:"document",objects:t}}function qy(n,e){if(n.length<2)throw new q("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!ba.has(t.value))throw new q(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:Zy(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function Zy(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=Kt(r.value);if(!s)throw new q(`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 q(`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 Jy(n,e){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);if(!Kt(n[0].value))throw new q(`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 Ky(n,e){if(n.length<2)throw new q("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)?$/,Qy=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),ev=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Os(n){let e=null,t=[];for(let i of n.objects){let r=tv(i);if(i.objectType==="system"){if(e)throw q.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 tv(n){let e=[...n.inlineFields,...n.blockFields];nv(n.objectType,e);let t=iv(e),i=rv(n.objectType,t),r=sv(t),s=lv(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 nv(n,e){for(let t of e){let i=Kt(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(!op(i,n))throw q.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function iv(n){let e=new Map;for(let t of n){if(e.has(t.key))throw q.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function rv(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 q.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw q.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Sa(e,"orbit"),distance:Ar(e,"distance"),semiMajor:Ar(e,"semiMajor"),eccentricity:dv(e,"eccentricity"),period:Ar(e,"period"),angle:Ar(e,"angle"),inclination:Ar(e,"inclination"),phase:Ar(e,"phase")};if(i){let a=Aa(e,"at"),l=Sa(e,"at");return{mode:"at",target:l,reference:cv(l,a.location)}}if(r)return{mode:"surface",target:Sa(e,"surface")};if(s){let a=Sa(e,"free"),l=uv(a);return{mode:"free",distance:l??void 0,descriptor:l?void 0:a}}return null}function sv(n){let e={};for(let[t,i]of n.entries()){let r=Kt(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=hv(i);break;case"number":e[t]=cp(Er(i),t,i.location);break;case"unit":e[t]=lp(Er(i),i.location,t);break;case"string":e[t]=ov(t,i);break}}return e}function ov(n,e){let t=e.values.join(" ").trim();return n==="image"&&av(t,e.location),t}function av(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(ev);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function lv(n){let e={};for(let t of n){if(t.key in e)throw q.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function cv(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.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 q.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(ap);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Kt(t);if(s?.unitFamily&&!wa(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function uv(n){let e=n.match(ap);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Ar(n,e){if(!n.has(e))return;let t=Aa(n,e);return lp(Er(t),t.location,e)}function dv(n,e){if(!n.has(e))return;let t=Aa(n,e);return cp(Er(t),e,t.location)}function cp(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function hv(n){let e=Er(n).toLowerCase(),t=Qy.get(e);if(t===void 0)throw q.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Aa(n,e){let t=n.get(e);if(!t)throw new q(`Missing value for key "${e}"`);return t}function Sa(n,e){return Er(Aa(n,e))}function Er(n){if(n.values.length!==1)throw q.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var fv=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 q(`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 q(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!fv.has(r.type))throw new q(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&pv(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&mv(i,i.placement.reference,e))}}function pv(n,e,t){if(!t.has(e.primary))throw new q(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new q(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function mv(n,e,t){if(!t.has(e.objectId))throw new q(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function Fi(n,e,t=`${e}.failed`){return n instanceof q?{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,gv=6371,yv=71492,vv=695700,_v=63241.077,xv=206264.806,bv=206264806,gp=.68,wv=.2,yp=28;function hn(n,e={}){let t=Av(e),i=t.width,r=t.height,s=t.padding,o=Sv(n),a=Tv(n,e.projection),l=Tu(e.camera??null),c=Eu(a,l),u=Rv(o,e.scaleModel),d=Lv(o),h=n.system?.id??null,f=e.activeEventId??null,m=Mv(n.objects,n.events??[],f),y=new Map(m.map(Z=>[Z.id,Z])),g=m_(m,y),p=new Map,_=[],v=[],w=[],P=[],A=[],E=new Map,L=new Map;for(let Z of m){let me=Z.placement;if(!me){w.push(Z);continue}if(me.mode==="orbit"){fp(L,me.target,Z);continue}if(me.mode==="surface"){fp(E,me.target,Z);continue}if(me.mode==="at"){A.push(Z);continue}P.push(Z)}let b=P.length>0?i*.42:i/2,x=r/2,R={orbitChildren:L,surfaceChildren:E,objectMap:y,spacingFactor:d,projection:c,scaleModel:u},U=w.find(Z=>Z.type==="star")??w[0]??null;U&&Mu(U,b,x,0,p,_,v,R);let D=w.filter(Z=>Z.id!==U?.id);if(D.length>0){let Z=Math.min(i,r)*.28*d*u.orbitDistanceMultiplier;D.forEach((me,ie)=>{let ke=Vs(ie,D.length,-Math.PI/2),xe=Hs(ke,Z,c,1);Mu(me,b+xe.x,x+xe.y,0,p,_,v,R)})}P.forEach((Z,me)=>{let ie=i-s-140-b_(Z.placement?.mode==="free"?Z.placement.distance:void 0,u),ke=Math.max(76,(r-s*2-180)/Math.max(1,P.length)*d)*u.freePlacementMultiplier,xe=s+92+me*ke;p.set(Z.id,{object:Z,x:ie,y:xe,radius:Ra(Z,0,u),sortKey:La(ie,xe,0)}),v.push({object:Z,groupId:g.groupIds.get(Z.id)??null,x1:ie-60,y1:xe,x2:ie-18,y2:xe,mode:"free"}),Ia(Z,p,_,v,R,1)}),A.forEach((Z,me)=>{if(p.has(Z.id)||!Z.placement||Z.placement.mode!=="at")return;let ie=f_(Z.placement.reference,p,y,me,A.length,i,r,s,R);p.set(Z.id,{object:Z,x:ie.x,y:ie.y,radius:Ra(Z,2,u),sortKey:La(ie.x,ie.y,2),anchorX:ie.anchorX,anchorY:ie.anchorY}),ie.anchorX!==void 0&&ie.anchorY!==void 0&&v.push({object:Z,groupId:g.groupIds.get(Z.id)??null,x1:ie.anchorX,y1:ie.anchorY,x2:ie.x,y2:ie.y,mode:"at"}),Ia(Z,p,_,v,R,2)});let $=[...p.values()].map(Z=>Dv(Z,u,g)),j=_.map(Z=>Ov(Z,g.groupIds.get(Z.object.id)??null)),N=v.map(Z=>Uv(Z)),X=Nv($,i,r,u.labelMultiplier),k=$v(n,$),le=Wv(n.events??[],$,f),ce=Vv(j,k,le,N,$,X),Me=Hv($,j,N,X,g,u.labelMultiplier),Fe=Gv(n,$),Ke=jv(n,a,t.preset,g,y),J=r_(i,r,$,j,N,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:Cv(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:J,layers:ce,groups:Me,semanticGroups:Fe,viewpoints:Ke,events:le,activeEventId:f,objects:$,orbitVisuals:j,relations:k,leaders:N,labels:X}}function Hn(n,e,t){let i=Da(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 Mv(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 Sv(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 Av(n){let e=Ev(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function Ev(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 Tv(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return xp(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:Iv(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 Iv(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Cv(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 Rv(n,e){return{...Pv(n),...e}}function Pv(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 Lv(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function Dv(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:Tr(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:x_(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:M_(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function Ov(n,e){return{renderId:`${Tr(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 Uv(n){return{renderId:`${Tr(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 Nv(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(Fv);for(let l of a){let c=kv(l,o,s,e,t,i)??_p(l,vp(l,o.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 Fv(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 kv(n,e,t,i,r,s){for(let o of Bv(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=Ap(n,c,s);if(!t.some(d=>v_(d,u)))return c}}return null}function Bv(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=vp(n,r,i),o=s==="below"?"above":"below",a=zv(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 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 zv(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 Vv(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 Hv(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=g_(l,n,e,t,i,s);return[...o.values()].sort((l,c)=>l.label.localeCompare(c.label))}function Gv(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 $v(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:`${Tr(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 Wv(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:`${Tr(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=Xv(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 m=t_(h);if(!m)continue;let y=f.join(".").toLowerCase(),g=o.get(m)??{id:m};Yv(g,y,u,n,e,t,i,r),o.set(m,g)}let a=[...o.values()].map(c=>qv(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 Xv(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 Yv(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=xp(l)??r;return;case"preset":n.preset=Jv(l)??s;return;case"rotation":case"angle":n.rotationDeg=Fs(l)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??Ta(),azimuth:Fs(l)};return;case"camera.elevation":n.camera={...n.camera??Ta(),elevation:Fs(l)};return;case"camera.roll":n.camera={...n.camera??Ta(),roll:Fs(l)};return;case"camera.distance":n.camera={...n.camera??Ta(),distance:dp(l)};return;case"zoom":case"scale":n.scale=dp(l);return;case"layers":n.layers=Kv(l);return;case"query":n.filter={...n.filter??Ea(),query:l||null};return;case"types":case"objecttypes":n.filter={...n.filter??Ea(),objectTypes:Qv(l)};return;case"tags":n.filter={...n.filter??Ea(),tags:Bs(l)};return;case"groups":n.filter={...n.filter??Ea(),groupIds:e_(l,i,o,a)};return}}function qv(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=Zv(n.filter),a=n.label?.trim()||n_(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()||i_(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 Ea(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Ta(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Zv(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 xp(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Jv(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 Kv(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 Qv(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 e_(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 t_(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function n_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function i_(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 r_(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||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,o);return!Number.isFinite(a)||!Number.isFinite(l)?zs(0,0,n,e):zs(a,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 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 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,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:Ra(n,i,a.scaleModel),sortKey:La(e,t,i)}),Ia(n,r,s,o,a,i+1))}function Ia(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(s_),l=o_(a,o.radius,r.spacingFactor,r.scaleModel),c=c_(a,l);a.forEach((d,h)=>{let f=a_(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),m=28*r.spacingFactor,y=Hs(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=Hs(f,o.radius+m,r.projection,r.projection==="isometric"?.9:1),p=o.x+y.x,_=o.y+y.y,v=o.x+g.x,w=o.y+g.y;e.set(d.id,{object:d,x:v,y:w,radius:Ra(d,s+1,r.scaleModel),sortKey:La(v,w,s+1),anchorX:p,anchorY:_}),i.push({object:d,groupId:r.objectMap.has(d.id)?ks(y_(d,r.objectMap)):null,x1:p,y1:_,x2:v,y2:w,mode:"surface"}),Ia(d,e,t,i,r,s+1)})}function s_(n,e){let t=Ca(n),i=Ca(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 o_(n,e,t,i){let r=n.map(d=>Ca(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 a_(n,e,t,i,r,s,o){let a=n.placement,l=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let L=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:L,rotationDeg:0,band:l,bandThickness:l?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-L}}let c=At(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(wv,Math.cos(Da(h)))*gp:1,m=Math.max(d*f,u*.14),y=Au(a.angle)??0,g=u*c,p=Cp(-g,0,y),_=i.x+p.x,v=i.y+p.y,w=d_(a.phase,e,t),P=Ip(_,v,u,m,y,w),A=o.projection==="topdown"&&c<=1e-4&&Math.abs(y)<=1e-4,E=l?h_(n,u,r,o.scaleModel):void 0;return{kind:A?"circle":"ellipse",cx:A?i.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:o.projection==="isometric"||l?hp(_,v,u,m,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||l?hp(_,v,u,m,y,Math.PI,Math.PI*2):void 0,objectX:P.x,objectY:P.y}}function l_(n,e){return e.innerPx+e.stepPx*u_(Math.max(n,0)+1)}function c_(n,e){let t=[];return n.forEach((i,r)=>{let s=Ca(i),o=e.innerPx+r*e.stepPx,a=s===null?o:l_(s,e),l=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,l))}),t}function Ca(n){return!n.placement||n.placement.mode!=="orbit"?null:Pa(n.placement.semiMajor??n.placement.distance??null)}function u_(n){return Math.log(n)/Math.log(2)}function d_(n,e,t){let i=n?Au(n):null;return i!==null?Da(i-90):Vs(e,t,-Math.PI/2)}function h_(n,e,t,i){let r=Pa(Su(n.properties.inner)),s=Pa(Su(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.metricSpread>0)return At(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let l=Math.max(Math.max(r,s),1e-4);return At(a/l*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function f_(n,e,t,i,r,s,o,a,l){if(n.kind==="lagrange")return p_(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 p_(n,e,t,i,r){let s=n.secondary?e.get(n.primary):__(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,m=At(c*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*m,y:o.y-d*m,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*m,y:o.y+d*m,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*m,y:s.y-d*m,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*m,y:o.y+(d*.5-f*.8660254)*m,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*m,y:o.y+(d*.5+f*.8660254)*m,anchorX:o.x,anchorY:o.y}}}function m_(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,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 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 g_(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)&&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(o)||!Number.isFinite(a)?zs(0,0,0,0):zs(o,a,l,c)}function y_(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,o,a){let l=S_(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 v_(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function __(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function Ra(n,e,t){let i=w_(n.properties.radius,t);if(i!==null)return i;let r=t.bodyRadiusMultiplier;switch(n.type){case"star":return At((e===0?28:20)*r,t.minBodyRadius,t.maxBodyRadius);case"planet":return At(12*r,t.minBodyRadius,t.maxBodyRadius);case"moon":return At(7*r,t.minBodyRadius,t.maxBodyRadius);case"belt":return At(5*r,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return At(5*r,t.minBodyRadius,t.maxBodyRadius);case"comet":return At(6*r,t.minBodyRadius,t.maxBodyRadius);case"ring":return At(5*r,t.minBodyRadius,t.maxBodyRadius);case"structure":return At(6*r,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return At(8*r,t.minBodyRadius,t.maxBodyRadius)}}function x_(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 Pa(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*_v;case"pc":return n.value*xv;case"kpc":return n.value*bv;case"re":return n.value*gv/Ns;case"rj":return n.value*yv/Ns;case"sol":return n.value*vv/Ns;default:return n.value}}function b_(n,e){let t=Pa(n??null);return t===null||t<=0?0:At(t*96*e.freePlacementMultiplier,0,420)}function w_(n,e){let t=Su(n);if(!t)return null;let i;switch(t.unit){case"sol":i=At(t.value*22,14,40);break;case"re":i=At(t.value*10,6,18);break;case"km":i=At(Math.log10(Math.max(t.value,1))*2.6,4,16);break;default:i=At(t.value*4,4,20);break}return At(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,o){let a=Tp(n,e,t,i,r,s,o,yp);return a.length===0?"":a.map((l,c)=>`${c===0?"M":"L"} ${mp(l.x)} ${mp(l.y)}`).join(" ")}function Tp(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(Ip(n,e,t,i,r,u))}return l}function Ip(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),l=Cp(o,a,r);return{x:n+l.x,y:e+l.y}}function Cp(n,e,t){let i=Da(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 La(n,e,t){return e*1e3+n+t*.01}function At(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 Tr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function ks(n){return`${Tr(n)}-group`}function M_(n){return typeof n=="string"&&n.trim()?n:void 0}function S_(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 Da(n){return n*Math.PI/180}function mp(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Lp=86400,Oa=Lp*365.25,Ua=18,Rp=180;function ka(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=hn(n,t),r=I_(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=>A_(y,i,s,o,a,r,u,c)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>E_(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:R_(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:m}}function A_(n,e,t,i,r,s,o,a){let l=Na(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:Ir(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Ir(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 E_(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??Fa(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 Na(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?Na(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(a?.mode==="surface"&&n.parentId){let c=i.get(n.parentId),u=c?Na(c,e,t,i,r,s):{x:0,y:0,z:0},d=c?.visualRadius??16,h=P_(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?Na(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=Dp(a.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),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??Ir(Cu(r)*48,24,1200),o=e?.radius??e?.ry??s,a=T_(r.period),l=Cu(r),c=Ir(l/Math.max(t,1e-4),1,20),u=Ir(a?Ua*c:Ua*Math.pow(c,.75),Ua,Rp);return{phase0Deg:Fa(r.phase)??0,rotationDeg:Fa(r.angle)??e?.rotationDeg??0,inclinationDeg:Fa(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=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 T_(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*Oa;case"ky":return n.value*Oa*1e3;case"my":return n.value*Oa*1e6;case"gy":return n.value*Oa*1e9;default:return null}}function Fa(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function I_(n,e){return{...C_(n),...e}}function C_(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 R_(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 Op(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function P_(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 Ir(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:F_(n.system),info:k_(n.system)}:null,i=n.objects.map(L_);return U_(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(D_),objects:i}}function L_(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:N_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function D_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(O_)}}function O_(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 U_(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=Up(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 N_(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 F_(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 k_(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=B_(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 B_(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)?$/,H_=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),G_=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Cr(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 q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Kt(t);if(s?.unitFamily&&!wa(s.unitFamily,r.unit))throw q.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 Ba(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function pi(n,e,t){let i=H_.get(n.toLowerCase());if(i===void 0)throw q.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 q.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 q.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 $_(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(G_);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function kp(n,e,t){let i=Kt(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw q.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return pi(Gs(e,n,t),n,t);case"number":return Ba(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"&&$_(r,t),r}}}function Uu(n,e,t){let i=Kt(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw q.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function Gs(n,e,t){if(n.length!==1)throw q.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var zp=new Set(["star","planet","moon","asteroid","comet"]),W_=332946.0487,j_=1047.3486,za=1495978707e-1,X_=6371,Y_=695700,q_=63241.077,Z_=206264.806,J_=206264806;function Va(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(Je("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(Je("validate.id.duplicate",`Duplicate ${a} id "${c}" already used by ${u}.`)):o.set(c,a)}for(let a of n.relations)K_(a,i,t);for(let a of n.system?.viewpoints??[])Q_(a,r,s,e,t,i);for(let a of n.objects)ex(a,n.system,i,r,t);for(let a of n.events)tx(a,n.system,i,t);return t}function K_(n,e,t){n.from?e.has(n.from)||t.push(Je("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(Je("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(Je("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(Je("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(Je("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function Q_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"){if(o)for(let a of o.groupIds)e.has(a)||r.push(ut("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(ut("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}sx(n.projection,r,`viewpoint.${n.id}.projection`,n.id),ox(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function ex(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(ut("validate.group.unknown",`Unknown group "${l}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(ut("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(ut("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(Je("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(Je("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(ut("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(ut("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(ut("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(Je("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(Je("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(Je("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),ix(n,t,r)||r.push(Je("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(ut("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(Je("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(ut("validate.derive.unsupported",`Unsupported derive rule "${l.field} ${l.strategy}" on "${n.id}".`,n.id,"derive"));continue}let c=Bp(n,a);if(c===null){r.push(ut("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 ${ux(c)}.`,n.id,"derive"))}for(let l of n.validationRules??[]){if(l.rule!=="kepler"){r.push(ut("validate.rule.unsupported",`Unsupported validation rule "${l.rule}" on "${n.id}".`,n.id,"validate"));continue}let c=Vp(o?.period),u=Bp(n,a);if(c===null||u===null)continue;let d=cx(n,"period");Math.abs(c-u)>d&&r.push(Je("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function tx(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(Je("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(ut("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(ut("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(Je("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(Je("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(ut("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${c}".`,void 0,`${r}.participants`));continue}o.add(c),t.has(c)||i.push(Je("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(ut("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(ut("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(ut("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(Je("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(Je("validate.event.pose.object.unknown",`Unknown event pose object "${c.objectId}" on "${n.id}".`,void 0,u));continue}s.has(c.objectId)||i.push(ut("validate.event.pose.unreferenced",`Event pose "${c.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),nx(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(ut("validate.event.positions.partial",`Event "${n.id}" leaves ${l.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function nx(n,e,t,i,r,s,o,a){let l=n.placement;if(!l){s.push(Je("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(Je("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(Je("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),l.phase&&!ax(i,e,t,n)&&s.push(ut("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),l.inclination&&!lx(i,e,t,n)&&s.push(ut("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(ut("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?zp.has(c.type)||s.push(Je("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(Je("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(Je("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(Je("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(Je("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(Je("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${c.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(Je("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${c.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function ix(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(Je("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(Je("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(Je("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=rx(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 rx(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/za;case"m":return n.value/(za*1e3);case"ly":return n.value*q_;case"pc":return n.value*Z_;case"kpc":return n.value*J_;case"re":return n.value*X_/za;case"sol":return n.value*Y_/za;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/W_;case"mj":return e.value/j_;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 sx(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(Je("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function ox(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(Je("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${c}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(ut("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(ut("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(ut("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 ax(n,e,t,i){return mi(i?.epoch)??mi(t?.epoch)??mi(e.epoch)??mi(n?.epoch)??null}function lx(n,e,t,i){return mi(i?.referencePlane)??mi(t?.referencePlane)??mi(e.referencePlane)??mi(n?.referencePlane)??null}function mi(n){return typeof n=="string"&&n.trim()?n.trim():null}function cx(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 ux(n){return`${Math.round(n*100)/100}d`}function Je(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function ut(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 dx=new Set(["climate","habitability","settlement"]),Ga=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=Kt(n);e&&Ga.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}])Ga.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var hx=new Set(Ga.keys()),Gp=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function ku(n){return fx(n)}function fx(n,e){let t=Qx(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,l=null,c=[],u=[],d=[],h=[],f=new Map,m=!1,y=!1,g=new Set,p=new Set,_=new Set,v=new Set,w=new Set;for(let x=0;x<i.length;x++){let R=i[x],U=x+1;if(!R.trim())continue;let D=Ma(R),$=Ls(R.slice(D),{line:U,columnOffset:D});if($.length!==0){if(!s){o=px($,U),s=!0,t.comments.length>0&&$a(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(D===0){l=mx($,U,o,r,a,c,u,d,h,f,g,p,_,v,w,{sawDefaults:m,sawAtlas:y}),l.kind==="system"?a=l.system:l.kind==="defaults"?m=!0:l.kind==="atlas"&&(y=!0);continue}if(!l)throw new q("Indented line without parent atlas section",U,D+1);Mx(l,D,$,U)}}if(!s)throw new q('Missing required atlas schema header "schema 2.0"');let P=c.map(x=>Hx(x,o,r)),A=h.map(x=>Gx(x,f.get(x.id)??[])),E=e??(o==="2.0-draft"?"2.0":o),L={format:"worldorbit",sourceVersion:"1.0",system:a,groups:u,relations:d,events:A,objects:P,diagnostics:r};if(E==="2.0-draft"){let x={...L,version:"2.0-draft",schemaVersion:"2.0-draft"};return x.diagnostics.push(...Va(x,o)),x}let b={...L,version:E,schemaVersion:E};return o==="2.0-draft"&&b.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".'}),b.diagnostics.push(...Va(b,o)),b}function px(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 q('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 mx(n,e,t,i,r,s,o,a,l,c,u,d,h,f,m,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new q('Atlas section "system" may only appear once',e,n[0].column);return gx(n,e,t,i);case"defaults":if(!r)throw new q('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new q('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 q('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new q('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 q('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return yx(n,e,r,u,t,i);case"annotation":if(!r)throw new q('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return vx(n,e,r,d);case"group":return fn(t,i,"group",{line:e,column:n[0].column}),_x(n,e,o,h);case"relation":return fn(t,i,"relation",{line:e,column:n[0].column}),xx(n,e,a,f);case"event":return fn(t,i,"event",{line:e,column:n[0].column}),bx(n,e,l,c,m,t,i);case"object":return wx(n,e,t,i,s);default:throw new q(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function gx(n,e,t,i){if(n.length!==2)throw new q("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 yx(n,e,t,i,r,s){if(n.length!==2)throw new q("Invalid viewpoint declaration",e,n[0]?.column??1);let o=Cr(n[1].value);if(!o)throw new q("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new q(`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 vx(n,e,t,i){if(n.length!==2)throw new q("Invalid annotation declaration",e,n[0]?.column??1);let r=Cr(n[1].value);if(!r)throw new q("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`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 _x(n,e,t,i){if(n.length!==2)throw new q("Invalid group declaration",e,n[0]?.column??1);let r=Cr(n[1].value);if(!r)throw new q("Group id must not be empty",e,n[1].column);if(i.has(r))throw new q(`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 xx(n,e,t,i){if(n.length!==2)throw new q("Invalid relation declaration",e,n[0]?.column??1);let r=Cr(n[1].value);if(!r)throw new q("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`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 bx(n,e,t,i,r,s,o){if(n.length!==2)throw new q("Invalid event declaration",e,n[0]?.column??1);let a=Cr(n[1].value);if(!a)throw new q("Event id must not be empty",e,n[1].column);if(r.has(a))throw new q(`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 wx(n,e,t,i,r){if(n.length<3)throw new q("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!ba.has(a)||a==="system")throw new q(`Unknown object type "${s.value}"`,e,s.column);let l={objectType:a,id:o.value,fields:zx(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 Mx(n,e,t,i){switch(n.kind){case"system":Sx(n,t,i);return;case"defaults":Ax(n,t,i);return;case"atlas":Ex(n,e,t,i);return;case"viewpoint":Tx(n,e,t,i);return;case"annotation":Rx(n,t,i);return;case"group":Px(n,t,i);return;case"relation":Lx(n,t,i);return;case"event":Dx(n,e,t,i);return;case"object":Ux(n,e,t,i);return}}function Sx(n,e,t){let i=Gn(e,n.seenFields,t),r=st(e,t);switch(i){case"title":n.system.title=r;return;case"description":fn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":fn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":fn(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new q(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function Ax(n,e,t){let i=Gn(e,n.seenFields,t),r=st(e,t);switch(i){case"view":Wp(r)&&ki(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 q(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function Ex(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 q(`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 q(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function Tx(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){Ix(n,t,i);return}if(n.inFilter){Cx(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(ki(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new q('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 q('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=Gn(t,n.seenFields,i),s=st(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)&&ki(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=yi(s,i,t[0].column,"rotation");return;case"camera":ki(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=Bx(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=Fx(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":fn(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=Cn(t.slice(1),i,"events");return;default:throw new q(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function Ix(n,e,t){let i=Gn(e,n.seenCameraFields,t),r=st(e,t),s=n.viewpoint.camera??zu();switch(i){case"azimuth":s.azimuth=yi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=yi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=yi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=Bu(r,t,e[0].column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function Cx(n,e,t){let i=Gn(e,n.seenFilterFields,t),r=n.viewpoint.filter??kx();switch(i){case"query":r.query=st(e,t);break;case"objecttypes":r.objectTypes=Nx(e.slice(1),t);break;case"tags":r.tags=Cn(e.slice(1),t,"tags");break;case"groups":r.groupIds=Cn(e.slice(1),t,"groups");break;default:throw new q(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function Rx(n,e,t){switch(Gn(e,n.seenFields,t)){case"label":n.annotation.label=st(e,t);return;case"target":n.annotation.targetObjectId=st(e,t);return;case"body":n.annotation.body=st(e,t);return;case"tags":n.annotation.tags=Cn(e.slice(1),t,"tags");return;default:throw new q(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function Px(n,e,t){switch(Gn(e,n.seenFields,t)){case"label":n.group.label=st(e,t);return;case"summary":n.group.summary=st(e,t);return;case"color":n.group.color=st(e,t);return;case"tags":n.group.tags=Cn(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=pi(st(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function Lx(n,e,t){switch(Gn(e,n.seenFields,t)){case"from":n.relation.from=st(e,t);return;case"to":n.relation.to=st(e,t);return;case"kind":n.relation.kind=st(e,t);return;case"label":n.relation.label=st(e,t);return;case"summary":n.relation.summary=st(e,t);return;case"tags":n.relation.tags=Cn(e.slice(1),t,"tags");return;case"color":n.relation.color=st(e,t);return;case"hidden":n.relation.hidden=pi(st(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function Dx(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")&&ki(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(Ox(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new q(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new q("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 q('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(Gn(t,n.seenFields,i)){case"kind":n.event.kind=st(t,i);return;case"label":n.event.label=st(t,i);return;case"summary":n.event.summary=st(t,i);return;case"target":n.event.targetObjectId=st(t,i);return;case"participants":n.event.participantObjectIds=Cn(t.slice(1),i,"participants");return;case"timing":n.event.timing=st(t,i);return;case"visibility":n.event.visibility=st(t,i);return;case"epoch":ki(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=st(t,i);return;case"referenceplane":ki(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=st(t,i);return;case"tags":n.event.tags=Cn(t.slice(1),i,"tags");return;case"color":n.event.color=st(t,i);return;case"hidden":n.event.hidden=pi(st(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new q(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function Ox(n,e,t){if(n.length<2)throw new q("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Gp.has(i))throw new q(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new q(`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 Ux(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"||dx.has(r)){r!=="info"&&fn(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 q(`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 q(`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(Vx(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function Gn(n,e,t){if(n.length<2)throw new q("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new q(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function st(n,e){if(n.length<2)throw new q("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function Nx(n,e){return Cn(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Fx(n,e,t,i){let r={};for(let s of Cn(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&&fn(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function Cn(n,e,t){if(n.length===0)throw new q(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new q(`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 q(`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 q(`Unknown render preset "${n}"`,e,t)}function Bu(n,e,t,i){let r=yi(n,e,t,i);if(r<=0)throw new q(`Field "${i}" must be greater than zero`,e,t);return r}function yi(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new q(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function kx(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function zu(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Bx(n,e,t){if(n.length===0||n.length%2!==0)throw new q('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 q(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(l);let c=a.value;switch(l){case"azimuth":i.azimuth=yi(c,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=yi(c,e,o.column,"camera.elevation");break;case"roll":i.roll=yi(c,e,o.column,"camera.roll");break;case"distance":i.distance=Bu(c,e,o.column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function zx(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 q(`Unknown field "${a.value}"`,e,a.column);l.version==="2.1"&&fn(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&&!hx.has(n[o].value);)c.push(n[o]),o++;if(c.length===0)throw new q(`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 Jp(s,t),s}function Vx(n,e,t,i,r){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);let s=Ws(n[0].value);if(!s)throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&fn(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 Jp([o],t),o}function Xp(n,e,t){if(n.length<2)throw new q(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 Hx(n,e,t){let i=Yp(n.fields),r=qp(i),s=Wx(n.objectType,i),o=Jx(i.get("groups")?.[0]),a=Ha(i.get("epoch")?.[0]),l=Ha(i.get("referencePlane")?.[0]),c=i.has("tidalLock")?pi(xn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Yx(i.get("resonance")[0]):void 0,d=Xx(i),h=i.get("derive")?.map(v=>qx(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=>Zx(v)),g=jx(n.typedBlockEntries),p=Zp(n.infoEntries,"info"),_={type:n.objectType,id:n.id,properties:s,placement:r,info:p};return o.length>0&&(_.groups=o),a&&(_.epoch=a),l&&(_.referencePlane=l),c!==void 0&&(_.tidalLock=c),u&&(_.resonance=u),d&&(_.renderHints=d),h?.length&&(_.deriveRules=h),f?.length&&(_.validationRules=f),m?.length&&(_.lockedFields=m),y?.length&&(_.tolerances=y),g&&Object.keys(g).length>0&&(_.typedBlocks=g),$a(e,"2.1")&&(_.groups||_.epoch||_.referencePlane||_.tidalLock!==void 0||_.resonance||_.renderHints||_.deriveRules?.length||_.validationRules?.length||_.lockedFields?.length||_.tolerances?.length||_.typedBlocks)&&fn(e,t,n.id,n.location),_}function Gx(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>$x(t))}}function $x(n){let e=Yp(n.fields,"event-pose"),t=qp(e);return{objectId:n.objectId,placement:t,inner:gi(e.get("inner")?.[0],"inner"),outer:gi(e.get("outer")?.[0],"outer"),epoch:Ha(e.get("epoch")?.[0]),referencePlane:Ha(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 q.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw q.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 o=e??t??i??r;throw q.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:xn(e),distance:gi(n.get("distance")?.[0],"distance"),semiMajor:gi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:Kx(n.get("eccentricity")?.[0],"eccentricity"),period:gi(n.get("period")?.[0],"period"),angle:gi(n.get("angle")?.[0],"angle"),inclination:gi(n.get("inclination")?.[0],"inclination"),phase:gi(n.get("phase")?.[0],"phase")};if(t){let o=xn(t);return{mode:"at",target:o,reference:Fp(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 Wx(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]=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 q.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function jx(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=Zp(i,t))}return e}function Xx(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=pi(xn(t),"renderLabel",t.location)),i&&(e.renderOrbit=pi(xn(i),"renderOrbit",i.location)),r&&(e.renderPriority=Ba(xn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Yx(n){if(n.values.length!==2)throw q.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw q.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function qx(n){if(n.values.length!==2)throw q.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function Zx(n){if(n.values.length!==2)throw q.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 Jx(n){return n?[...new Set(n.values)]:[]}function Ha(n){return n&&n.values.join(" ").trim()||null}function gi(n,e){return n?Du(xn(n),n.location,e):void 0}function Kx(n,e){return n?Ba(xn(n),e,n.location):void 0}function xn(n){return Gs(n.values,n.key,n.location)}function Ws(n){return Ga.get(n)}function Jp(n,e){for(let t of n){let i=Ws(t.key);if(!i)throw q.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 q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function fn(n,e,t,i){$a(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 ki(n,e,t,i){$a(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 $a(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 Qx(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!==`
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
- `?(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==="#"&&!eb(e,l)){t.push({kind:"line",line:o,column:a}),e[l]=" ";let d=l+1;for(;d<e.length&&e[d]!==`
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
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 q.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function eb(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 tb=/^schema\s+2(?:\.0|\.1|\.5)?$/i,nb=/^schema\s+2\.1$/i,ib=/^schema\s+2\.5$/i,rb=/^schema\s+2\.0-draft$/i;function Kp(n){for(let e of sb(n).split(/\r?\n/)){let t=e.trim();if(t)return rb.test(t)?"2.0-draft":nb.test(t)?"2.1":ib.test(t)?"2.5":tb.test(t)?"2.0":"1.0"}return"1.0"}function sb(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!==`
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
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 $n(n){let e=Qp(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new q(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 ob(n,e);let t;try{t=Ds(n)}catch(r){return{ok:!1,value:null,diagnostics:[Fi(r,"parse")]}}let i;try{i=Os(t)}catch(r){return{ok:!1,value:null,diagnostics:[Fi(r,"normalize")]}}try{Us(i)}catch(r){return{ok:!1,value:null,diagnostics:[Fi(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function ob(n,e){let t;try{t=ku(n)}catch(o){return{ok:!1,value:null,diagnostics:[Fi(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:[Fi(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 pn={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 Bi(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function Wa(n,e){return{...n,rotationDeg:Vu(n.rotationDeg+e)}}function Rr(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=Vi(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 zi(n,e,t){let i=Vi(n),r=cb(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=Hn({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 ja(n,e,t,i){let r=n.objects.find(l=>l.objectId===t&&!l.hidden);if(!r)return e;let s=Vi(n),o=js(Math.max(e.scale,1.8),i),a=Hn({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 Xa(n,e){let t=Vi(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function Pr(n,e,t){let i=Vi(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=Hn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Ya(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=>Pr(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 Vi(n){return{x:n.width/2,y:n.height/2}}function cb(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=>Hn(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 Za="worldorbit-camera-root";function bn(n,e={}){let t=Sr(e.theme),i=Eb(e.preset??n.renderPreset??void 0),r=pa({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=ma(n,e.filter??null),a=n.objects.filter(_=>!_.hidden).filter(_=>o.has(_.objectId)).filter(_=>r.structures||!qa(_.object)).sort((_,v)=>_.sortKey-v.sortKey),l=n.labels.filter(_=>!_.hidden).filter(_=>o.has(_.objectId)).filter(_=>r.structures||!qa(_.object)),c=fb(a),u=r.orbits?hb(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(_=>!_.hidden).filter(_=>o.has(_.objectId)).filter(_=>r.structures||!qa(_.object)).map(_=>`<line class="wo-leader wo-leader-${_.mode}" x1="${_.x1}" y1="${_.y1}" x2="${_.x2}" y2="${_.y2}" data-render-id="${Ct(_.renderId)}" data-group-id="${kt(_.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(_=>!_.hidden).filter(_=>o.has(_.fromObjectId)&&o.has(_.toObjectId)).map(_=>`<line class="wo-relation" x1="${_.x1}" y1="${_.y1}" x2="${_.x2}" y2="${_.y2}" data-render-id="${Ct(_.renderId)}" data-relation-id="${kt(_.relationId)}" />`).join(""):"",f=r.events?n.events.filter(_=>!_.hidden).map(_=>ub(n,_,o,t)).join(""):"",m=r.objects?a.map(_=>pb(_,e.selectedObjectId??null,t)).join(""):"",y=r.labels?l.map(_=>mb(n,_,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Ct(n.title)}</text>
3829
- <text class="wo-subtitle" x="56" y="88">${Ct(s)}</text>
3830
- <text class="wo-meta" x="56" y="${n.height-42}">${Ct(Ib(n))}</text>`:"",p=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
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
+ <text class="wo-subtitle" x="56" y="88">${It(s)}</text>
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?Tb(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
- <title id="worldorbit-title">${Ct(n.title)}</title>
3834
- <desc id="worldorbit-desc">A ${Ct(n.viewMode)} WorldOrbit render with ${a.length} visible objects.</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
+ <title id="worldorbit-title">${It(n.title)}</title>
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,61 +3885,61 @@ 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="${Za}" id="${Za}">
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 ub(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="${kt(s)}" data-event-id="${kt(e.eventId)}" data-object-id="${kt(l.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${Ct(e.renderId)}" data-event-id="${kt(e.eventId)}">
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
3904
  ${a}
3905
- <circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${kt(s)}" />
3906
- <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${Ct(o)}</text>
3907
- </g>`}function $u(n,e={}){return bn(hn(n,e),e)}function im(n,e={}){let t=$n(n);return $u(t.document,db(t,e))}function db(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function hb(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!qa(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="${Ct(s.renderId)}" data-orbit-object-id="${kt(s.objectId)}" data-parent-id="${kt(s.parentId)}" data-group-id="${kt(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 fb(n){return n.filter(e=>!!e.imageHref).map(e=>vb(e)).join("")}function pb(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=xb(n,t),d=yb(n),h=d?em(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${c}${l}" data-object-id="${Ct(n.objectId)}" data-parent-id="${kt(n.parentId??"")}" data-group-id="${kt(n.groupId??"")}" data-render-id="${Ct(n.renderId)}" tabindex="0" role="button" aria-label="${Ct(`${i.type} ${n.objectId}`)}">
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(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
3908
  <circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${a+8}" />
3909
- ${gb(n,u)}
3910
- ${em(i,r,s,o,u)}
3909
+ ${bb(n,u)}
3910
+ ${tm(i,r,s,o,u)}
3911
3911
  ${d}
3912
3912
  ${h}
3913
- </g>`}function mb(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="${Ct(e.objectId)}" data-group-id="${kt(e.groupId??"")}" data-render-id="${Ct(e.renderId)}">
3914
- <text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${Ct(e.label)}</text>
3915
- <text class="wo-label-secondary" x="${e.x}" y="${e.secondaryY}" text-anchor="${e.textAnchor}" font-size="${11*r}">${Ct(e.secondaryLabel)}</text>
3916
- </g>`}function em(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" />
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
+ <text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${It(e.label)}</text>
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 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
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="${sm(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" />
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
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
3920
  <ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${o}" stroke="${r.stroke}" stroke-width="1.2" />
3921
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="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Hu(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function gb(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 yb(n){if(!n.imageHref)return"";let e=_b(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${kt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${kt(rm(n))})" />`}function vb(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="${kt(rm(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function _b(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 xb(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=bb(n.object.type,t,e),r=n.fillColor&&Rb(n.fillColor)?n.fillColor:i.fill,s=tm(n.object.properties.albedo),o=tm(n.object.properties.temperature),a=Mb(r,o,s,n.object.type),l=Xs(a,"#ffffff",.4)??i.stroke,c=Ab(n.object.properties.atmosphere),u=n.object.type==="star"?nm(Xs(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:l,glow:u,atmosphere:c,tail:n.object.type==="comet"?nm(Xs(a,"#ffffff",.5)??a,.72):void 0}}function bb(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 wb(e)}}function wb(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 Mb(n,e,t,i){let r=n;if(e!==null){let s=Sb(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 Sb(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function Ab(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 Eb(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 Tb(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 Ib(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function qa(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 Cb({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 Cb(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function Rb(n){return!!n.trim()}function Ct(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function kt(n){return Ct(n)}var Lr=180,Dr=120,om=10;function am(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((Lr-om*2)/Math.max(i.width,1),(Dr-om*2)/Math.max(i.height,1)),s=(Lr-i.width*r)/2-i.minX*r,o=(Dr-i.height*r)/2-i.minY*r,a=Ya(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??Pb(c.object.type);return`<circle cx="${wn(u)}" cy="${wn(d)}" r="${wn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${Lr}px;height:${Dr}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
- <svg width="${Lr}" height="${Dr}" viewBox="0 0 ${Lr} ${Dr}" role="presentation" aria-hidden="true">
3925
- <rect x="0.5" y="0.5" width="${Lr-1}" height="${Dr-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3926
- <rect x="${wn(i.minX*r+s)}" y="${wn(i.minY*r+o)}" width="${wn(i.width*r)}" height="${wn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
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
+ <svg width="${Pr}" height="${Lr}" viewBox="0 0 ${Pr} ${Lr}" role="presentation" aria-hidden="true">
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+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="${wn(a.minX*r+s)}" y="${wn(a.minY*r+o)}" width="${wn(a.width*r)}" height="${wn(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" />
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 Pb(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 wn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var bT="wo-viewer-3d-root",$f=null;function yy(n){TT();let e=document.createElement("div");e.className=bT,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=0,u=new Map,d=null,h=!1,f=new Map,m=new Map,y=[];return RT().then(b=>{if(h)return;let x=new b.Scene,R=new b.PerspectiveCamera(52,1,.1,2e4),U=new b.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});U.domElement.classList.add("wo-viewer-3d-canvas"),U.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(U.domElement);let D=new b.AmbientLight(16777215,1.2),$=new b.PointLight(16777215,1.35,0,2);x.add(D),x.add($);let j=new b.Group,N=new b.Group;x.add(j),x.add(N);let X=new b.Raycaster;X.params.Line={threshold:10},t={THREE:b,scene3d:x,camera:R,renderer:U,keyLight:$,orbitLayer:j,objectLayer:N,raycaster:X,pointer:new b.Vector2},d&&g(d)}).catch(b=>{h||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${CT(b instanceof Error?b.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(b){d=b,g(b)},hitTest(b,x){if(!t||!i)return null;let R=t.renderer.domElement.getBoundingClientRect();if(!R.width||!R.height)return null;t.pointer.x=(b-R.left)/R.width*2-1,t.pointer.y=-((x-R.top)/R.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let U=t.raycaster.intersectObjects(y,!0);for(let D of U){let $=IT(D.object);if($)return $}return null},projectObjectToContainer(b){if(!t)return null;let x=u.get(b);if(!x)return null;let R=new t.THREE.Vector3(x.x,x.y,x.z);if(R.project(t.camera),R.z>1)return null;let U=t.renderer.domElement.getBoundingClientRect(),D=n.getBoundingClientRect();return{x:U.left-D.left+(R.x+1)/2*U.width,y:U.top-D.top+(1-R.y)/2*U.height}},destroy(){h=!0,d=null,t?.renderer.dispose(),e.remove(),f.clear(),m.clear(),y.length=0,t=null}};function g(b){if(!t)return;let x=i!==b.spatialScene;i=b.spatialScene,r=b.renderOptions,s=b.state,o=b.visibleObjectIds,a=b.selectedObjectId,l=b.hoveredObjectId,c=b.timeSeconds,x&&p(b.spatialScene),E(b.spatialScene),u=Ru(b.spatialScene,b.timeSeconds),_(),v(),w(),P(),A(),L()}function p(b){if(!t)return;gy(t.orbitLayer),gy(t.objectLayer),f.clear(),m.clear(),y.length=0;let x=Sr(r?.theme);t.scene3d.background=new t.THREE.Color(x.backgroundStart);for(let R of b.orbits){let U=MT(t.THREE,R,x);t.orbitLayer.add(U.root),m.set(R.objectId,U),y.push(U.root)}for(let R of b.objects){let U=wT(t.THREE,R,x);t.objectLayer.add(U.root),f.set(R.objectId,U),y.push(U.root)}}function _(){for(let b of i?.objects??[]){let x=f.get(b.objectId),R=u.get(b.objectId);!x||!R||x.root.position.set(R.x,R.y,R.z)}}function v(){for(let b of i?.orbits??[]){let x=m.get(b.objectId);if(!x)continue;let R=u.get(b.parentId);x.root.position.set(R?.x??b.center.x,R?.y??b.center.y,R?.z??b.center.z)}}function w(){let b=r?.layers??{};for(let x of i?.objects??[]){let R=f.get(x.objectId);if(!R)continue;let U=b.structures===!1&&(x.object.type==="structure"||x.object.type==="phenomenon"),D=b.objects===!1;R.root.visible=!x.hidden&&o.has(x.objectId)&&!U&&!D}for(let x of i?.orbits??[]){let R=m.get(x.objectId);if(!R)continue;let U=b.structures===!1&&(x.object.type==="structure"||x.object.type==="phenomenon");R.root.visible=!x.hidden&&o.has(x.objectId)&&b.orbits!==!1&&!U}}function P(){if(t){for(let b of f.values()){my(t.THREE,b.materials,b.baseColor,a===b.objectId,l===b.objectId);let x=a===b.objectId?1.2:l===b.objectId?1.1:1;b.root.scale.set(x,x,x)}for(let b of m.values())my(t.THREE,b.materials,b.baseColor,a===b.objectId,l===b.objectId)}}function A(){if(!t||!i||!s)return;let b=r?.camera??i.camera,x=i.contentBounds,R=Math.max(x.width,x.depth,x.height,160),U=sa((b?.azimuth??34)+s.rotationDeg),D=sa(fu(b?.elevation??24,-75,75)),$=fu(2.4/Math.max(s.scale,.1),.35,8),j=fu(b?.distance??6,2,24),N=fu(R*$*(j/6),28,8e3),X=Math.max(R/900,.12),k=new t.THREE.Vector3(x.center.x-s.translateX*X,x.center.y,x.center.z-s.translateY*X);t.camera.position.set(k.x+N*Math.cos(D)*Math.sin(U),k.y+N*Math.sin(D),k.z+N*Math.cos(D)*Math.cos(U)),t.camera.lookAt(k),b?.roll&&(t.camera.rotation.z=sa(b.roll)),t.keyLight.position.copy(t.camera.position)}function E(b){if(!t)return;let x=Math.max(1,Math.round(n.clientWidth||b.width||960)),R=Math.max(1,Math.round(n.clientHeight||b.height||560));t.renderer.setSize(x,R,!1),t.camera.aspect=x/R,t.camera.updateProjectionMatrix()}function L(){t&&t.renderer.render(t.scene3d,t.camera)}}function wT(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??ET(e),s=new n.MeshPhongMaterial({color:r,emissive:e.object.type==="star"?new n.Color(t.starGlow):new n.Color(0),emissiveIntensity:e.object.type==="star"?.6:.08,transparent:!0,opacity:e.object.type==="phenomenon"?.7:1}),o=ST(n,e),a=new n.Mesh(o,s);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,body:a,materials:[s],baseColor:r}}function MT(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,s=[];if(e.band){let o=new n.MeshBasicMaterial({color:r,transparent:!0,opacity:.42,side:2}),a=AT(n,e),l=new n.Mesh(a,o);l.userData.objectId=e.objectId,i.add(l),s.push(o)}else{let o=new n.LineBasicMaterial({color:r,transparent:!0,opacity:.55}),a=vy(n,e),l=new n.BufferGeometry().setFromPoints(a),c=new n.LineLoop(l,o);c.userData.objectId=e.objectId,i.add(c),s.push(o)}return{objectId:e.objectId,root:i,materials:s,baseColor:r}}function ST(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.12,28,20);case"structure":return new n.BoxGeometry(t*1.5,t*1.5,t*1.5);case"phenomenon":return new n.OctahedronGeometry(t*1.25,0);case"belt":case"ring":return new n.OctahedronGeometry(Math.max(t*.85,3),0);default:return new n.SphereGeometry(t,20,14)}}function AT(n,e){let t=Math.max(e.bandThickness??8,3),i=vy(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,128,t*.28,10,!0)}function vy(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 ET(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 my(n,e,t,i,r){let s=new n.Color(t);i?s.offsetHSL(0,0,.16):r&&s.offsetHSL(0,0,.08);for(let o of e)o&&(o.color?.set?.(s),typeof o.opacity=="number"&&(o.opacity=i?.85:r?.72:o.transparent?.55:1),o.emissive?.set?.(i?new n.Color("#ffdda9"):r?new n.Color("#cfe9ff"):new n.Color(0)),o.emissiveIntensity=i?.28:r?.14:o.emissiveIntensity??.08)}function gy(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.geometry?.dispose?.(),Array.isArray(e.material)?e.material.forEach(t=>t?.dispose?.()):e.material?.dispose?.()}}function TT(){if(typeof document>"u")throw new un;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new un("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 un("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function IT(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function fu(n,e,t){return Math.min(Math.max(n,e),t)}function sa(n){return n*Math.PI/180}function CT(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function RT(){return $f||($f=Promise.resolve().then(()=>(py(),fy))),$f}var PT=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function xy(n){return{objectId:n.objectId,title:n.objectId,typeLabel:NT(n.object.type),imageHref:n.renderObject.imageHref??null,description:OT(n),tags:DT(n.object.properties.tags),fields:LT(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function by(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${zn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${zn(s.label)}</dt><dd>${zn(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="${zn(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="${kT(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${zn(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
- <strong>${zn(n.title)}</strong>
3935
- <span>${zn(n.typeLabel)}</span>
3934
+ <strong>${Bn(n.title)}</strong>
3935
+ <span>${Bn(n.typeLabel)}</span>
3936
3936
  </div>
3937
3937
  </div>
3938
- ${n.description?`<p class="wo-tooltip-description">${zn(n.description)}</p>`:""}
3938
+ ${n.description?`<p class="wo-tooltip-description">${Bn(n.description)}</p>`:""}
3939
3939
  ${t}
3940
3940
  ${i}
3941
- ${r.length?`<p class="wo-tooltip-relations">${zn(r.join(" - "))}</p>`:""}
3942
- </article>`}function LT(n){let e=new Map;for(let i of PT){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:FT(i),value:_y(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 ${_y(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function DT(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function OT(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 _y(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):UT(n)}function UT(n){return`${n.value}${n.unit??""}`}function NT(n){return n.charAt(0).toUpperCase()+n.slice(1)}function FT(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function zn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kT(n){return zn(n)}var Ms={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},wy="worldorbit-viewer-tooltip-style";function Oi(n,e){if(HT(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??Ms.minScale,maxScale:e.maxScale??Ms.maxScale,fitPadding:e.fitPadding??Ms.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??Ms.panStep,zoomStep:e.zoomStep??Ms.zoomStep,rotationStep:e.rotationStep??Ms.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,viewMode:e.viewMode??"2d",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:Jt(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,l=n.style.position,c=BT(e),u=oa(c,s),d=e.spatialScene??null,h=s.viewMode==="3d"?br(c,s,d):null,f={...pn},m=null,y=null,g=null,p=null,_=null,v=null,w=!1,P=null,A=null,E=0,L=!1,b=new Map,x=null,R=null,U=null,D=null,$=null,j=null,N=null,X=null,k={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),GT(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),Qe();let le=I=>{if(!r.pointer||L)return;if(I.preventDefault(),n.focus(),Ae()){let M=wr(Math.exp(-I.deltaY*.002),.6,1.6);xe.zoomBy(M);return}let V=te(I.clientX,I.clientY),Y=wr(Math.exp(-I.deltaY*.002),.6,1.6);Ue(Rr(u,f,Y,V,i))},ce=I=>{if(L)return;let V=I.pointerType==="touch";if(V&&!r.touch||!V&&!r.pointer||!V&&I.button!==0&&!Ae())return;n.focus(),n.setPointerCapture?.(I.pointerId);let Y=W(I.clientX,I.clientY);if(V){b.set(I.pointerId,Y),b.size===2?x=Sy(u,f,b):b.size===1&&(E=0,w=!1);return}P=I.pointerId,A=Y,E=0,w=!1},Me=I=>{if(L)return;if(I.pointerType==="touch"){if(Ae()||!r.touch||!b.has(I.pointerId))return;let F=b.get(I.pointerId),H=W(I.clientX,I.clientY);if(b.set(I.pointerId,H),b.size===2){x||(x=Sy(u,f,b));let G=Ty(b),pe=G.distance/Math.max(x.startDistance,1),Ie=Rr(u,x.startState,pe,x.startCenter,i),Ce=G.center.x-x.startViewportCenter.x,Oe=G.center.y-x.startViewportCenter.y;Ue(Bi(Ie,Ce,Oe))}else if(b.size===1){let G=H.x-F.x,pe=H.y-F.y;E+=Math.abs(G)+Math.abs(pe),E>2&&(w=!0),Ue(Bi(f,G,pe))}return}if(Ae()&&r.pointer&&P===null){de(g?.hitTest(I.clientX,I.clientY)??null);return}if(Ae()&&r.pointer&&P===I.pointerId&&A){let F=W(I.clientX,I.clientY),H=F.x-A.x,G=F.y-A.y;E+=Math.abs(H)+Math.abs(G),A=F,E>2&&(w=!0),I.shiftKey||I.buttons===2?xe.panBy(H,G):(xe.rotateBy(H*.35),xe.panBy(0,G*.35)),de(g?.hitTest(I.clientX,I.clientY)??null);return}if(!r.pointer||P!==I.pointerId||!A)return;let Y=W(I.clientX,I.clientY),M=Y.x-A.x,O=Y.y-A.y;E+=Math.abs(M)+Math.abs(O),A=Y,E>2&&(w=!0),Ue(Bi(f,M,O))},Fe=I=>{if(I.pointerType==="touch"){b.delete(I.pointerId),b.size<2&&(x=null);return}P===I.pointerId&&(P=null,A=null)},Ke=I=>{if(!r.selection||L)return;if(w){w=!1;return}let V=Ae()?g?.hitTest(I.clientX,I.clientY)??null:pu(I.target);Q(V),r.tooltipMode==="pinned"&&(U=V,De())},J=I=>{if(Ae())return;let V=pu(I.target);de(V)},Z=()=>{de(null)},me=I=>{if(Ae())return;let V=pu(I.target);V&&de(V)},ie=()=>{de(null)},ke=I=>{if(!r.keyboard||L)return;let V=Ae()?f.selectedObjectId:pu(I.target);if((I.key==="Enter"||I.key===" ")&&V){I.preventDefault(),Q(V),r.tooltipMode==="pinned"&&(U=V,De());return}switch(I.key){case"Escape":r.tooltipMode==="pinned"&&U&&(I.preventDefault(),U=null,De());return;case"+":case"=":I.preventDefault(),xe.zoomBy(r.zoomStep);return;case"-":I.preventDefault(),xe.zoomBy(1/r.zoomStep);return;case"ArrowLeft":I.preventDefault(),xe.panBy(-r.panStep,0);return;case"ArrowRight":I.preventDefault(),xe.panBy(r.panStep,0);return;case"ArrowUp":I.preventDefault(),xe.panBy(0,-r.panStep);return;case"ArrowDown":I.preventDefault(),xe.panBy(0,r.panStep);return;case"[":I.preventDefault(),xe.rotateBy(-r.rotationStep);return;case"]":I.preventDefault(),xe.rotateBy(r.rotationStep);return;case"f":case"F":I.preventDefault(),xe.fitToSystem();return;case"0":I.preventDefault(),xe.resetView();return}};n.addEventListener("wheel",le,{passive:!1}),n.addEventListener("pointerdown",ce),n.addEventListener("pointermove",Me),n.addEventListener("pointerup",Fe),n.addEventListener("pointercancel",Fe),n.addEventListener("click",Ke),n.addEventListener("mouseover",J),n.addEventListener("mouseleave",Z),n.addEventListener("focusin",me),n.addEventListener("focusout",ie),n.addEventListener("keydown",ke);let xe={setSource(I){c={kind:"source",value:I},u=oa(c,s),d=null,h=s.viewMode==="3d"?br(c,s,null):null,Qe(),j=null,z(!0)},setDocument(I){c={kind:"document",value:I},u=oa(c,s),d=null,h=s.viewMode==="3d"?br(c,s,null):null,Qe(),j=null,z(!0)},setScene(I){c={kind:"scene",value:I},u=I,d=null,h=s.viewMode==="3d"?br(c,s,null):null,Qe(),j=null,z(!0)},getScene(){return u},getRenderOptions(){return zT(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(I){let V=s,Y=h,M=Wf(s,{viewMode:I}),O=I==="3d"?br(c,M,d):null;s=M,h=O,Qe();try{z(!1)}catch(F){throw s=V,h=Y,Qe(),z(!1),F}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return ge(j)},goToViewpoint(I){let V=ge(I);if(!V)return!1;let Y={},M=_a(V);if(V.preset!==null&&(Y.preset=V.preset),c.kind!=="scene"&&V.projection!==u.projection&&(Y.projection=V.projection),V.camera?Y.camera={...V.camera}:s.camera&&(Y.camera=null),M&&(Y.layers=M),j=V.id,Object.keys(Y).length>0){let F=My(Y);s=Wf(s,Y),c.kind!=="scene"&&F&&(u=oa(c,s)),z(F)}he(xa(V),!1,!1);let O=ye(V);return Ue(O),Q(V.selectedObjectId??V.objectId??null,!1),e.onSelectionChange?.(ae()),e.onSelectionDetailsChange?.(Ee(f.selectedObjectId)),je(),Le(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(I){xe.setRenderOptions({activeEventId:I})},playAnimation(){if(!Ae()){k={...k,playing:!1},pt();return}if(k.frozenByEvent){k={...k,playing:!1};return}k={...k,playing:!0},ct()},pauseAnimation(){k={...k,playing:!1},pt()},resetAnimation(){k={...k,playing:!1,timeSeconds:0},pt(),Yt()},setAnimationSpeed(I){k={...k,speed:wr(I,.1,64)}},getAnimationState(){return{...k}},search(I,V=12){return ga(u,I,V)},getFilter(){return s.filter?{...s.filter}:null},setFilter(I){he(I,!0,!0)},getVisibleObjects(){return re()},getFocusPath(I){return Re(I)},getObjectDetails(I){return Ee(I)},getSelectionDetails(){return Ee(f.selectedObjectId)},getTooltipDetails(){return $},getAtlasState(){return ep(f,s,s.filter??null,j)},setAtlasState(I){let V=typeof I=="string"?va(I):I;V.viewpointId&&xe.goToViewpoint(V.viewpointId),xe.setRenderOptions(V.renderOptions),he(V.filter??null,!1,!1),Ue(K({...f,...V.viewerState})),Q(V.viewerState.selectedObjectId??null,!1),je(),e.onSelectionChange?.(ae()),e.onSelectionDetailsChange?.(Ee(f.selectedObjectId)),Le()},serializeAtlasState(){return ya(xe.getAtlasState())},captureBookmark(I,V){return tp(I,V,xe.getAtlasState())},applyBookmark(I){return typeof I=="string"?(xe.setAtlasState(I),!0):(xe.setAtlasState(I.atlasState),!0)},setRenderOptions(I){let V=My(I),Y=s,M=u,O=h,F=Wf(s,I),H=u;c.kind!=="scene"&&V&&(H=oa(c,F));let G=F.viewMode==="3d"?br(c,F,d):null;s=F,u=H,h=G,Qe();try{z(V)}catch(pe){throw s=Y,u=M,h=O,Qe(),z(V),pe}},getState(){return{...f}},setState(I){Ue(K({...f,...I}))},zoomBy(I,V){Ue(Rr(u,f,I,V??{x:u.width/2,y:u.height/2},i))},panBy(I,V){Ue(Bi(f,I,V))},rotateBy(I){Ue(Wa(f,I))},fitToSystem(){Ue(Ae()?{...pn,selectedObjectId:f.selectedObjectId}:zi(u,f,i))},focusObject(I){j=null,Ue(Ae()?fa(I):ja(u,f,I,i)),Q(I),r.tooltipMode==="pinned"&&(U=fe(I)?.objectId??null,De())},pinTooltip(I){U=fe(I)?.objectId??null,De()},resetView(){let I=Ae()?{...pn}:zi(u,{...pn},i);j=null,Ue(I),Q(null),U=null,De()},exportSvg(){return bn(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){L||(L=!0,n.removeEventListener("wheel",le),n.removeEventListener("pointerdown",ce),n.removeEventListener("pointermove",Me),n.removeEventListener("pointerup",Fe),n.removeEventListener("pointercancel",Fe),n.removeEventListener("click",Ke),n.removeEventListener("mouseover",J),n.removeEventListener("mouseleave",Z),n.removeEventListener("focusin",me),n.removeEventListener("focusout",ie),n.removeEventListener("keydown",ke),pt(),g?.destroy(),g=null,_?.remove(),_=null,v?.remove(),v=null,p?.remove(),p=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 z(!0),e.initialViewpointId?xe.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?xe.focusObject(e.initialSelectionObjectId):Le(),xe;function z(I){if(g?.destroy(),g=null,n.innerHTML="",m=null,y=null,p=null,_=null,v=null,Ae()?(h=h??br(c,s,d),g=yy(n)):(n.innerHTML=bn(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)),_=document.createElement("div"),_.className="wo-viewer-label-root",_.dataset.worldorbitLabelRoot="true",n.append(_),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",_e),n.append(v)),!Ae()&&(!m||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");ca(),f=I?Ae()?{...pn}:zi(u,{...pn},i):K(f),Q(f.selectedObjectId&&fe(f.selectedObjectId)?f.selectedObjectId:null,!1),de(R&&fe(R)?R:null,!1),U=U&&fe(U)?U:null,Yt(),Pe(),je(),e.onViewChange?.({...f}),Le()}function Ue(I){f=K(I),Yt(),e.onViewChange?.({...f}),Le()}function K(I){return{scale:wr(I.scale,i.minScale,i.maxScale),rotationDeg:Ay(I.rotationDeg),translateX:Number.isFinite(I.translateX)?I.translateX:f.translateX,translateY:Number.isFinite(I.translateY)?I.translateY:f.translateY,selectedObjectId:I.selectedObjectId&&fe(I.selectedObjectId)?I.selectedObjectId:null}}function ue(){if(Ae()){St();return}y&&(y.setAttribute("transform",Xa(u,f)),Es(),Se(),De())}function Q(I,V=!0){if(!Ae()&&f.selectedObjectId)for(let Y of n.querySelectorAll(`[data-object-id="${aa(f.selectedObjectId)}"]`))Y.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:I&&fe(I)?I:null},!Ae()&&f.selectedObjectId)for(let Y of n.querySelectorAll(`[data-object-id="${aa(f.selectedObjectId)}"]`))Y.classList.add("wo-object-selected");C(),De(),V&&(e.onSelectionChange?.(ae()),e.onSelectionDetailsChange?.(Ee(f.selectedObjectId)),e.onViewChange?.({...f}),Le())}function de(I,V=!0){R===I&&V||(R=I&&fe(I)?I:null,C(),De(),V&&(e.onHoverChange?.(fe(R)),e.onHoverDetailsChange?.(Ee(R))))}function ae(){return fe(f.selectedObjectId)}function fe(I){if(!I)return null;let V=se();return u.objects.find(Y=>Y.objectId===I&&!Y.hidden&&V.has(Y.objectId))??null}function Ee(I){let V=fe(I);return V?{objectId:V.objectId,object:V.object,renderObject:V,label:u.labels.find(Y=>Y.objectId===V.objectId&&!Y.hidden)??null,group:u.groups.find(Y=>Y.renderId===V.groupId)??null,semanticGroups:u.semanticGroups.filter(Y=>V.semanticGroupIds.includes(Y.id)),orbit:u.orbitVisuals.find(Y=>Y.objectId===V.objectId&&!Y.hidden)??null,relatedOrbits:u.orbitVisuals.filter(Y=>!Y.hidden&&(Y.objectId===V.objectId||V.ancestorIds.includes(Y.objectId)||V.childIds.includes(Y.objectId))),relations:u.relations.filter(Y=>!Y.hidden&&(Y.fromObjectId===V.objectId||Y.toObjectId===V.objectId)),relatedEvents:u.events.filter(Y=>!Y.hidden&&(Y.targetObjectId===V.objectId||Y.objectIds.includes(V.objectId))),parent:fe(V.parentId),children:V.childIds.map(Y=>fe(Y)).filter(Boolean),ancestors:V.ancestorIds.map(Y=>fe(Y)).filter(Boolean),focusPath:Re(V.objectId)}:null}function C(){if(Ae()){St();return}for(let I of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))I.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(R,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function S(I,V){let Y=Ee(I);if(!Y)return;let M=new Set([Y.objectId,...Y.renderObject.childIds,...Y.renderObject.ancestorIds]);for(let O of M)for(let F of n.querySelectorAll(`[data-object-id="${aa(O)}"]`))F.classList.add(V.objectClass);for(let O of Y.ancestors)for(let F of n.querySelectorAll(`[data-object-id="${aa(O.objectId)}"]`))F.classList.add(V.ancestorClass);for(let O of Y.relatedOrbits)for(let F of n.querySelectorAll(`[data-orbit-object-id="${aa(O.objectId)}"]`))F.classList.add(V.orbitClass)}function W(I,V){if(Ae()){let M=n.getBoundingClientRect();return!M.width||!M.height?{x:u.width/2,y:u.height/2}:{x:I-M.left,y:V-M.top}}if(!m)return{x:u.width/2,y:u.height/2};let Y=m.getBoundingClientRect();return!Y.width||!Y.height?{x:u.width/2,y:u.height/2}:{x:(I-Y.left)/Y.width*u.width,y:(V-Y.top)/Y.height*u.height}}function te(I,V){return Pr(u,f,W(I,V))}function se(){return ma(u,s.filter??null)}function re(){let I=se();return u.objects.filter(V=>!V.hidden&&I.has(V.objectId))}function Re(I){let V=u.objects.find(Y=>Y.objectId===I&&!Y.hidden);return V?[...V.ancestorIds,V.objectId].map(Y=>fe(Y)).filter(Boolean):[]}function ge(I){return u.viewpoints.find(V=>V.id===I)??null}function ye(I){let V=Ay(I.rotationDeg),Y=I.scale!==null&&I.scale!==void 0?wr(I.scale,i.minScale,i.maxScale):null;if(Ae()){let F=I.objectId??I.selectedObjectId??null,H=F?h?.focusTargets.find(G=>G.objectId===F):null;return{scale:Y??1.6,rotationDeg:V,translateX:H?-H.center.x:0,translateY:H?-H.center.z:0,selectedObjectId:I.selectedObjectId??I.objectId??null}}let M=I.objectId&&u.objects.find(F=>F.objectId===I.objectId&&!F.hidden);if(M)return Be({x:M.x,y:M.y},Y??Math.max(1.8,pn.scale),V,I.selectedObjectId??M.objectId);let O=zi(u,{...pn,rotationDeg:V},i);return Y===null?{...O,rotationDeg:V,selectedObjectId:I.selectedObjectId??null}:Be({x:u.contentBounds.centerX,y:u.contentBounds.centerY},Y,V,I.selectedObjectId??null)}function Be(I,V,Y,M){let O={x:u.width/2,y:u.height/2},F=Hn(I,O,Y);return{scale:V,rotationDeg:Y,translateX:O.x-(O.x+(F.x-O.x)*V),translateY:O.y-(O.y+(F.y-O.y)*V),selectedObjectId:M}}function he(I,V,Y){s={...s,filter:Jt(I)},Y&&(j=null),z(!1)}function Pe(){e.onFilterChange?.(s.filter??null,re())}function je(){e.onViewpointChange?.(ge(j))}function Le(){e.onAtlasStateChange?.(xe.getAtlasState())}function Se(){!r.minimap||!p||(p.innerHTML=am(u,f,re()))}function De(){if(r.tooltipMode==="disabled"||!v){be(null);return}let I=Ze();if(!I){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let V=Ee(I.objectId);if(!V){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),be(null);return}let Y=xy(V);D=I.objectId,v.hidden=!1,v.dataset.mode=I.mode,v.classList.toggle("is-pinned",I.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",ft(v,Y,I.mode),$e(v,V.renderObject),v.style.visibility="visible",be(Y)}function Ze(){return U&&fe(U)?{objectId:U,mode:"pinned"}:R&&fe(R)?{objectId:R,mode:"hover"}:null}function ft(I,V,Y){let M=e.tooltipRenderer?.(V,Y);I.innerHTML="",typeof M=="string"?I.innerHTML=M:M instanceof HTMLElement?I.append(M):I.innerHTML=by(V,Y);let O=document.createElement("div");if(O.className="wo-tooltip-actions",Y==="pinned"){let F=document.createElement("button");F.type="button",F.className="wo-tooltip-action",F.dataset.tooltipAction="unpin",F.textContent="Unpin",O.append(F)}else{let F=document.createElement("button");F.type="button",F.className="wo-tooltip-action",F.dataset.tooltipAction="pin",F.dataset.objectId=V.objectId,F.textContent="Pin",O.append(F)}O.childElementCount>0&&I.append(O)}function $e(I,V){let Y=Ae()?g?.projectObjectToContainer(V.objectId)??null:oe(V);if(!Y)return;let M=Math.max(n.clientWidth-I.offsetWidth-12,12),O=Math.max(n.clientHeight-I.offsetHeight-12,12),F=Y.y>n.clientHeight*.48,H=wr(Y.x+18,12,M),G=wr(F?Y.y-I.offsetHeight-18:Y.y+18,12,O);I.style.left=`${H}px`,I.style.top=`${G}px`}function B(I){if(Ae())return I;let V={x:u.width/2,y:u.height/2},Y=Hn(I,V,f.rotationDeg);return{x:V.x+(Y.x-V.x)*f.scale+f.translateX,y:V.y+(Y.y-V.y)*f.scale+f.translateY}}function oe(I){let V={x:I.anchorX??I.x,y:I.anchorY??I.y-Math.max(I.visualRadius,I.radius)};return ee(V)}function ee(I){if(!m)return null;let V=B(I),Y=m.getBoundingClientRect(),M=n.getBoundingClientRect();return{x:Y.left-M.left+V.x/Math.max(u.width,1)*Y.width,y:Y.top-M.top+V.y/Math.max(u.height,1)*Y.height}}function _e(I){let V=I.target?.closest("[data-tooltip-action]");if(V){switch(I.preventDefault(),I.stopPropagation(),V.dataset.tooltipAction){case"pin":U=V.dataset.objectId??D;break;case"unpin":U=null;break}De()}}function be(I){let V=$?.objectId!==I?.objectId||$?.description!==I?.description||$?.imageHref!==I?.imageHref;$=I,D=I?.objectId??null,V&&e.onTooltipChange?.(I)}function Ae(){return s.viewMode==="3d"}function Qe(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},pt())}function ct(){N!==null||!k.playing||L||(N=window.requestAnimationFrame(tt))}function pt(){N!==null&&(window.cancelAnimationFrame(N),N=null),X=null}function tt(I){if(N=null,!k.playing||L){X=null;return}let Y=Math.max((I-(X??I))/1e3,0);X=I,k={...k,timeSeconds:k.timeSeconds+Y*k.speed},St(),ct()}function Yt(){ue(),Ae()&&k.playing?ct():(!k.playing||!Ae())&&pt()}function St(){!Ae()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:se(),selectedObjectId:f.selectedObjectId,hoveredObjectId:R,state:f,timeSeconds:k.timeSeconds}),Es(),Se(),De())}function ca(){if(!Ae()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let I of n.querySelectorAll(".wo-event-label"))I.setAttribute("display","none")}}function Es(){if(!_)return;let I=ua();_.replaceChildren(...I.map(V=>da(V))),_.hidden=I.length===0}function ua(){let I=[],V=se();if(Ui("labels"))for(let Y of u.labels){if(Y.hidden||!V.has(Y.objectId))continue;let M=Ae()?g?.projectObjectToContainer(Y.objectId)??null:ee({x:Y.x,y:Y.y});M&&I.push({key:`object:${Y.renderId}`,kind:"object",point:Ae()?{x:M.x,y:M.y-18}:M,textAnchor:Y.textAnchor,objectId:Y.objectId,primaryText:Y.label,secondaryText:Y.secondaryLabel,secondaryOffset:Math.max(Y.secondaryY-Y.y,12)})}if(!Ae()&&Ui("events"))for(let Y of u.events){if(Y.hidden||!Mr(Y,V))continue;let M=ee({x:Y.x,y:Y.y-10});M&&I.push({key:`event:${Y.renderId}`,kind:"event",point:M,textAnchor:"middle",primaryText:Y.event.label||Y.event.id})}return I}function Mr(I,V){return I.objectIds.some(Y=>V.has(Y))}function da(I){let V=document.createElement("div");if(V.className=`wo-viewer-label wo-viewer-label-${I.kind}`,V.dataset.worldorbitScreenLabel="true",V.dataset.labelKey=I.key,V.dataset.anchor=I.textAnchor,V.style.left=`${I.point.x}px`,V.style.top=`${I.point.y}px`,I.objectId){V.dataset.objectId=I.objectId;for(let M of ha(I.objectId))V.classList.add(M)}let Y=document.createElement("span");if(Y.className="wo-viewer-label-primary",I.kind==="object"&&(Y.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),Y.textContent=I.primaryText,V.append(Y),I.secondaryText){let M=document.createElement("span");M.className="wo-viewer-label-secondary",M.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,M.style.marginTop=`${Math.max(I.secondaryOffset??12,10)-10}px`,M.textContent=I.secondaryText,V.append(M)}return V}function Ui(I){return s.layers?.[I]!==!1}function ha(I){let V=[],Y=Ee(f.selectedObjectId),M=Ee(R);if(f.selectedObjectId===I&&V.push("wo-object-selected"),Y){let O=new Set([Y.objectId,...Y.renderObject.childIds,...Y.renderObject.ancestorIds]),F=new Set(Y.ancestors.map(H=>H.objectId));O.has(I)&&V.push("wo-chain-selected"),F.has(I)&&V.push("wo-ancestor-selected")}if(M){let O=new Set([M.objectId,...M.renderObject.childIds,...M.renderObject.ancestorIds]),F=new Set(M.ancestors.map(H=>H.objectId));O.has(I)&&V.push("wo-chain-hover"),F.has(I)&&V.push("wo-ancestor-hover")}return V}function fa(I){let V=h?.focusTargets.find(Y=>Y.objectId===I);return V?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-V.center.x,translateY:-V.center.z,selectedObjectId:I}:{...pn,selectedObjectId:I}}}function BT(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 hn(n.value,e);case"source":{let t=$n(n.value);return hn(t.document,Ey(t,e))}}}function br(n,e,t){if(t)return t;switch(n.kind){case"scene":return VT(n.value);case"document":return ka(n.value,e);case"source":{let i=$n(n.value);return ka(i.document,Ey(i,e))}}}function zT(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"}}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?Jt(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"}}function My(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 Ey(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function VT(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 Sy(n,e,t){let{center:i,distance:r}=Ty(t);return{startState:{...e},startCenter:Pr(n,e,i),startViewportCenter:i,startDistance:r}}function Ty(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 pu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function HT(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 wr(n,e,t){return Math.min(Math.max(n,e),t)}function Ay(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 GT(){if(typeof document>"u"||document.getElementById(wy))return;let n=document.createElement("style");n.id=wy,n.textContent=`
3941
+ ${r.length?`<p class="wo-tooltip-relations">${Bn(r.join(" - "))}</p>`:""}
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;
@@ -3979,6 +3979,10 @@ void main() {
3979
3979
  position: absolute;
3980
3980
  display: grid;
3981
3981
  gap: 2px;
3982
+ padding: 4px 8px;
3983
+ border-radius: 999px;
3984
+ background: linear-gradient(180deg, rgba(5, 16, 26, 0.72), rgba(5, 16, 26, 0.38));
3985
+ border: 1px solid rgba(164, 194, 228, 0.16);
3982
3986
  color: #edf6ff;
3983
3987
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
3984
3988
  line-height: 1.15;
@@ -4083,7 +4087,7 @@ void main() {
4083
4087
  padding: 6px 12px;
4084
4088
  font: 600 12px/1.3 "Segoe UI Variable", "Segoe UI", sans-serif;
4085
4089
  }
4086
- `,document.head.append(n)}var $T="[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:As(e.mode),scene:e.scene,spatialScene:e.spatialScene??void 0,options:e.options?{...e.options,viewMode:e.options.viewMode??mu(As(e.mode)),initialFilter:e.options.initialFilter??null,atlasState:e.options.atlasState??null}:void 0}}function Cy(n,e,t={}){return{version:"2.0",mode:As(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??mu(As(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function Ry(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??mu(As(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=bn(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 Py(n=document,e={}){let t=new Map,i=[],r=[...n.querySelectorAll($T)];for(let s of r){let o=jT(s),a=As(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,m=e.viewer?.initialSelectionObjectId??o.options?.initialSelectionObjectId,y=e.viewer?.minimap??o.options?.minimap,g=e.viewer?.viewMode??o.options?.viewMode??mu(a),p=()=>WT(s,o.scene,e);if(a==="interactive-2d"||a==="interactive-3d")try{let _=p(),v=Oi(s,{...e.viewer,scene:o.scene,spatialScene:o.spatialScene,width:_.width,height:_.height,padding:e.padding??o.scene.padding,preset:d,theme:l,layers:c,subtitle:u,viewMode:g,initialFilter:h,initialViewpointId:f,initialSelectionObjectId:m,minimap:y});o.options?.atlasState&&v.setAtlasState(o.options.atlasState),t.set(s,v),i.push(Iy(s,()=>{let w=p();v.setRenderOptions({width:w.width,height:w.height})})),e.onMount?.(v,s)}catch(_){if(_ instanceof un&&a==="interactive-3d")s.innerHTML=Yf(_.message),e.onMount?.(null,s);else throw _}else{let _=()=>{let v=p();s.innerHTML=bn(o.scene,{width:v.width,height:v.height,padding:e.padding??o.scene.padding,preset:d,theme:l,layers:c,filter:h,selectedObjectId:m??null,subtitle:u})};_(),i.push(Iy(s,_)),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 WT(n,e,t){let i=n.getBoundingClientRect(),r=Ss(t.width)??Ss(n.clientWidth)??Ss(i.width)??e.width,s=Ss(t.height)??Ss(n.clientHeight)??Ss(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 Ss(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?Math.round(n):null}function Iy(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 jT(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 As(n){return!n||n==="interactive"?"interactive-2d":n}function mu(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 Ly="worldorbit-atlas-viewer-style";function gu(n,e){if(typeof document>"u")throw new Error("Atlas viewer requires a browser environment.");YT();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=XT(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=Jt(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=[],_;_=Oi(h,{...e,initialFilter:null,onSelectionChange(N){_&&D(),e.onSelectionChange?.(N)},onSelectionDetailsChange(N){_&&D(),e.onSelectionDetailsChange?.(N)},onFilterChange(N,X){_&&(L(N),U(),D()),e.onFilterChange?.(N,X)},onViewpointChange(N){_&&(R(),D()),e.onViewpointChange?.(N)},onAtlasStateChange(N){_&&D(),e.onAtlasStateChange?.(N)},onViewChange(N){_&&D(),e.onViewChange?.(N)}}),A(),b(),x(),L(_.getFilter()),j(),U(),D(),r?.addEventListener("input",()=>{m=r.value.trim(),A()}),s?.addEventListener("change",()=>{y=s.value||null,A()}),o?.addEventListener("change",()=>{g=o.value||null,A()}),a?.addEventListener("change",()=>{let N=v();if(!a.value){N.resetView(),A();return}N.goToViewpoint(a.value),D()}),l?.addEventListener("click",()=>{let N=v(),X=N.getActiveViewpoint()?.label??N.getSelectionDetails()?.objectId??`Bookmark ${p.length+1}`;p=[...p,N.captureBookmark(X,X)],j(),D()}),c?.addEventListener("click",N=>{let X=N.target?.closest("[data-bookmark-id]");if(!X)return;let k=p.find(ce=>ce.id===X.dataset.bookmarkId);if(!k)return;let le=v();le.applyBookmark(k),L(le.getFilter()),U(),D()}),u?.addEventListener("click",N=>{let X=N.target?.closest("[data-object-id]");X&&(v().focusObject(X.dataset.objectId??""),D())});function v(){if(!_)throw new Error("Atlas viewer is not initialized.");return _}return{element:n,get viewer(){return v()},getViewer(){return v()},setSource(N){v().setSource(N),P()},setDocument(N){v().setDocument(N),P()},setScene(N){v().setScene(N),P()},getAtlasState(){return v().getAtlasState()},setAtlasState(N){let X=v();X.setAtlasState(N),L(X.getFilter()),U(),D()},getInspectorSnapshot(){return $()},getSearchQuery(){return m},setSearchQuery(N){m=N.trim(),r&&(r.value=m),A()},getObjectTypeFilter(){return y},setObjectTypeFilter(N){y=N,s&&(s.value=N??""),A()},listSearchResults(N=6){return v().search(m,N)},listBookmarks(){return p.map(Dy)},captureBookmark(N,X){let k=v().captureBookmark(N,X);return p=[...p,k],j(),D(),Dy(k)},applyBookmark(N){let X=v(),k=X.applyBookmark(N);return k&&(L(X.getFilter()),U(),D()),k},goToViewpoint(N){let X=v().goToViewpoint(N);return X&&D(),X},exportSvg(){return v().exportSvg()},destroy(){v().destroy(),n.innerHTML="",n.classList.remove("wo-atlas-viewer")}};function P(){b(),x(),A(),j(),U(),D()}function A(){v().setFilter(E()),b(),U(),D()}function E(){return Jt({query:m||void 0,objectTypes:y?[y]:void 0,tags:f?.tags,groupIds:g?[g]:f?.groupIds,includeAncestors:f?.includeAncestors??!0})}function L(N){m=N?.query?.trim()??"",y=N?.objectTypes?.length===1?N.objectTypes[0]:null,g=N?.groupIds?.length===1?N.groupIds[0]:null,r&&document.activeElement!==r&&(r.value=m),s&&(s.value=y??""),o&&(o.value=g??"")}function b(){if(!a)return;let N=v(),X=N.getActiveViewpoint()?.id??"";a.innerHTML=['<option value="">Scene default</option>',...N.listViewpoints().map(k=>`<option value="${di(k.id)}">${di(k.label)}</option>`)].join(""),a.value=X}function x(){if(!o)return;let N=v();o.innerHTML=['<option value="">All groups</option>',...N.getScene().semanticGroups.map(X=>`<option value="${di(X.id)}">${di(X.label)}</option>`)].join(""),o.value=g??""}function R(){a&&(a.value=v().getActiveViewpoint()?.id??"")}function U(){if(!u)return;let N=v().search(m,6);u.innerHTML=N.map(X=>`<button type="button" class="wo-atlas-pill" data-object-id="${di(X.objectId)}">${di(X.objectId)} - ${di(X.type)}</button>`).join("")}function D(){let N=$();d&&(d.textContent=JSON.stringify(N,null,2)),e.onInspectorChange?.(N)}function $(){let N=v(),X=N.getScene(),k=X.camera;return{selection:N.getSelectionDetails(),activeViewpoint:N.getActiveViewpoint(),filter:N.getFilter(),atlasState:N.getAtlasState(),visibleObjectIds:N.getVisibleObjects().map(le=>le.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 j(){c&&(c.innerHTML=p.map(N=>`<button type="button" class="wo-atlas-pill" data-bookmark-id="${di(N.id)}">${di(N.label)}</button>`).join(""))}}function XT(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">
4087
4091
  <span>Search</span>
4088
4092
  <input data-atlas-search type="text" placeholder="Search objects, tags, or types" />
4089
4093
  </label>`:"",n.typeFilter?`<label class="wo-atlas-field">
@@ -4120,7 +4124,7 @@ void main() {
4120
4124
  <div class="wo-atlas-results" data-atlas-results></div>
4121
4125
  ${n.bookmarks?'<div class="wo-atlas-bookmarks" data-atlas-bookmarks></div>':""}
4122
4126
  </div>
4123
- </section>`}function YT(){if(document.getElementById(Ly))return;let n=document.createElement("style");n.id=Ly,n.textContent=`
4127
+ </section>`}function sI(){if(document.getElementById(Uy))return;let n=document.createElement("style");n.id=Uy,n.textContent=`
4124
4128
  .wo-atlas-shell { display: grid; gap: 16px; min-width: 0; }
4125
4129
  .wo-atlas-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
4126
4130
  .wo-atlas-workspace { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
@@ -4154,7 +4158,7 @@ void main() {
4154
4158
  .wo-atlas-workspace { grid-template-columns: 1fr; }
4155
4159
  .wo-atlas-inspector { min-height: 220px; }
4156
4160
  }
4157
- `,document.head.append(n)}function Dy(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 di(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function Oy(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=qT(i),o=hn(s),a=this.getAttribute("theme")??void 0;if(r==="static"){this.innerHTML=bn(o,{theme:a});return}if(r==="atlas"){this.viewer=gu(this,{scene:o,theme:a});return}try{this.viewer=Oi(this,{source:i,theme:a,viewMode:r==="interactive-3d"?"3d":"2d"})}catch(l){if(l instanceof un&&r==="interactive-3d"){this.innerHTML=Yf(l.message);return}throw l}}}customElements.define(n,e)}function qT(n){return $n(n).document}return Vy(ZT);})();
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);})();
4158
4162
  /**
4159
4163
  * @license
4160
4164
  * Copyright 2010-2024 Three.js Authors