worldorbit 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/core/dist/atlas-edit.js +1 -1
- package/dist/browser/core/dist/atlas-validate.js +1 -1
- package/dist/browser/core/dist/draft-parse.js +7 -5
- package/dist/browser/core/dist/draft.js +2 -2
- package/dist/browser/core/dist/format.js +5 -5
- package/dist/browser/core/dist/load.js +7 -3
- package/dist/browser/core/dist/scene.js +1 -1
- package/dist/browser/core/dist/types.d.ts +1 -1
- package/dist/unpkg/core/dist/atlas-edit.js +1 -1
- package/dist/unpkg/core/dist/atlas-validate.js +1 -1
- package/dist/unpkg/core/dist/draft-parse.js +7 -5
- package/dist/unpkg/core/dist/draft.js +2 -2
- package/dist/unpkg/core/dist/format.js +5 -5
- package/dist/unpkg/core/dist/load.js +7 -3
- package/dist/unpkg/core/dist/scene.js +1 -1
- package/dist/unpkg/core/dist/types.d.ts +1 -1
- package/dist/unpkg/worldorbit-core.min.js +7 -7
- package/dist/unpkg/worldorbit-editor.min.js +205 -205
- package/dist/unpkg/worldorbit-markdown.min.js +10 -10
- package/dist/unpkg/worldorbit-viewer.min.js +171 -171
- package/dist/unpkg/worldorbit.js +22 -16
- package/dist/unpkg/worldorbit.min.js +173 -173
- package/package.json +1 -1
- package/packages/core/dist/atlas-edit.js +1 -1
- package/packages/core/dist/atlas-validate.js +1 -1
- package/packages/core/dist/draft-parse.js +7 -5
- package/packages/core/dist/draft.js +2 -2
- package/packages/core/dist/format.js +5 -5
- package/packages/core/dist/load.js +7 -3
- package/packages/core/dist/scene.js +1 -1
- package/packages/core/dist/types.d.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var WorldOrbit=(()=>{var Uu=Object.defineProperty;var zv=Object.getOwnPropertyDescriptor;var Vv=Object.getOwnPropertyNames;var Hv=Object.prototype.hasOwnProperty;var Gv=(n,e)=>()=>(n&&(e=n(n=0)),e);var Sp=(n,e)=>{for(var t in e)Uu(n,t,{get:e[t],enumerable:!0})},$v=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vv(e))!Hv.call(n,r)&&r!==t&&Uu(n,r,{get:()=>e[r],enumerable:!(i=zv(e,r))||i.enumerable});return n};var Wv=n=>$v(Uu({},"__esModule",{value:!0}),n);var mv={};Sp(mv,{ACESFilmicToneMapping:()=>by,AddEquation:()=>Pi,AddOperation:()=>yy,AdditiveAnimationBlendMode:()=>cp,AdditiveBlending:()=>ih,AgXToneMapping:()=>My,AlphaFormat:()=>Cy,AlwaysCompare:()=>Xy,AlwaysDepth:()=>uy,AlwaysStencilFunc:()=>Dh,AmbientLight:()=>du,AnimationAction:()=>bu,AnimationClip:()=>Ar,AnimationLoader:()=>uf,AnimationMixer:()=>Tf,AnimationObjectGroup:()=>Ef,AnimationUtils:()=>RI,ArcCurve:()=>Cc,ArrayCamera:()=>mc,ArrowHelper:()=>qf,AttachedBindMode:()=>oh,Audio:()=>xu,AudioAnalyser:()=>Sf,AudioContext:()=>ha,AudioListener:()=>wf,AudioLoader:()=>_f,AxesHelper:()=>Zf,BackSide:()=>Yt,BasicDepthPacking:()=>ky,BasicShadowMap:()=>lM,BatchedMesh:()=>Sc,Bone:()=>Xo,BooleanKeyframeTrack:()=>di,Box2:()=>Nf,Box3:()=>Ot,Box3Helper:()=>Xf,BoxGeometry:()=>gr,BoxHelper:()=>jf,BufferAttribute:()=>nt,BufferGeometry:()=>Ye,BufferGeometryLoader:()=>yu,ByteType:()=>Ey,Cache:()=>ri,Camera:()=>bs,CameraHelper:()=>Wf,CanvasTexture:()=>sf,CapsuleGeometry:()=>Uc,CatmullRomCurve3:()=>Rc,CineonToneMapping:()=>_y,CircleGeometry:()=>Nc,ClampToEdgeWrapping:()=>vn,Clock:()=>vu,Color:()=>we,ColorKeyframeTrack:()=>la,ColorManagement:()=>at,CompressedArrayTexture:()=>nf,CompressedCubeTexture:()=>rf,CompressedTexture:()=>As,CompressedTextureLoader:()=>df,ConeGeometry:()=>Fc,ConstantAlphaFactor:()=>ay,ConstantColorFactor:()=>sy,CubeCamera:()=>fc,CubeReflectionMapping:()=>ci,CubeRefractionMapping:()=>Di,CubeTexture:()=>yr,CubeTextureLoader:()=>hf,CubeUVReflectionMapping:()=>Is,CubicBezierCurve:()=>qo,CubicBezierCurve3:()=>Pc,CubicInterpolant:()=>ru,CullFaceBack:()=>nh,CullFaceFront:()=>G0,CullFaceFrontBack:()=>aM,CullFaceNone:()=>H0,Curve:()=>cn,CurvePath:()=>Oc,CustomBlending:()=>W0,CustomToneMapping:()=>wy,CylinderGeometry:()=>Ts,Cylindrical:()=>Uf,Data3DTexture:()=>Bo,DataArrayTexture:()=>vs,DataTexture:()=>kn,DataTextureLoader:()=>ff,DataUtils:()=>mS,DecrementStencilOp:()=>xM,DecrementWrapStencilOp:()=>bM,DefaultLoadingManager:()=>fv,DepthFormat:()=>fr,DepthStencilFormat:()=>gs,DepthTexture:()=>Go,DetachedBindMode:()=>Ay,DirectionalLight:()=>uu,DirectionalLightHelper:()=>$f,DiscreteInterpolant:()=>su,DisplayP3ColorSpace:()=>Su,DodecahedronGeometry:()=>kc,DoubleSide:()=>Un,DstAlphaFactor:()=>ey,DstColorFactor:()=>ny,DynamicCopyUsage:()=>NM,DynamicDrawUsage:()=>RM,DynamicReadUsage:()=>DM,EdgesGeometry:()=>Bc,EllipseCurve:()=>Es,EqualCompare:()=>Gy,EqualDepth:()=>hy,EqualStencilFunc:()=>AM,EquirectangularReflectionMapping:()=>Eo,EquirectangularRefractionMapping:()=>To,Euler:()=>an,EventDispatcher:()=>Cn,ExtrudeGeometry:()=>zc,FileLoader:()=>Rn,Float16BufferAttribute:()=>Hh,Float32BufferAttribute:()=>Te,FloatType:()=>xn,Fog:()=>yc,FogExp2:()=>gc,FramebufferTexture:()=>tf,FrontSide:()=>li,Frustum:()=>vr,GLBufferAttribute:()=>Pf,GLSL1:()=>kM,GLSL3:()=>Oh,GreaterCompare:()=>$y,GreaterDepth:()=>py,GreaterEqualCompare:()=>jy,GreaterEqualDepth:()=>fy,GreaterEqualStencilFunc:()=>CM,GreaterStencilFunc:()=>TM,GridHelper:()=>Hf,Group:()=>Li,HalfFloatType:()=>pa,HemisphereLight:()=>au,HemisphereLightHelper:()=>Vf,IcosahedronGeometry:()=>Vc,ImageBitmapLoader:()=>xf,ImageLoader:()=>Er,ImageUtils:()=>dc,IncrementStencilOp:()=>vM,IncrementWrapStencilOp:()=>_M,InstancedBufferAttribute:()=>Ui,InstancedBufferGeometry:()=>gu,InstancedInterleavedBuffer:()=>Rf,InstancedMesh:()=>Mc,Int16BufferAttribute:()=>zh,Int32BufferAttribute:()=>Vh,Int8BufferAttribute:()=>Fh,IntType:()=>np,InterleavedBuffer:()=>Ss,InterleavedBufferAttribute:()=>xr,Interpolant:()=>wr,InterpolateDiscrete:()=>Ro,InterpolateLinear:()=>Po,InterpolateSmooth:()=>lc,InvertStencilOp:()=>wM,KeepStencilOp:()=>or,KeyframeTrack:()=>un,LOD:()=>_c,LatheGeometry:()=>ea,Layers:()=>xs,LessCompare:()=>Hy,LessDepth:()=>dy,LessEqualCompare:()=>up,LessEqualDepth:()=>Ao,LessEqualStencilFunc:()=>EM,LessStencilFunc:()=>SM,Light:()=>Hn,LightProbe:()=>pu,Line:()=>Vn,Line3:()=>Ff,LineBasicMaterial:()=>Ut,LineCurve:()=>Zo,LineCurve3:()=>Lc,LineDashedMaterial:()=>iu,LineLoop:()=>Tc,LineSegments:()=>_n,LinearDisplayP3ColorSpace:()=>ma,LinearFilter:()=>wt,LinearInterpolant:()=>aa,LinearMipMapLinearFilter:()=>hM,LinearMipMapNearestFilter:()=>dM,LinearMipmapLinearFilter:()=>Nn,LinearMipmapNearestFilter:()=>_o,LinearSRGBColorSpace:()=>fi,LinearToneMapping:()=>vy,LinearTransfer:()=>Do,Loader:()=>$t,LoaderUtils:()=>da,LoadingManager:()=>ca,LoopOnce:()=>Uy,LoopPingPong:()=>Fy,LoopRepeat:()=>Ny,LuminanceAlphaFormat:()=>Ly,LuminanceFormat:()=>Py,MOUSE:()=>sM,Material:()=>Dt,MaterialLoader:()=>mu,MathUtils:()=>tS,Matrix3:()=>He,Matrix4:()=>Ne,MaxEquation:()=>q0,Mesh:()=>vt,MeshBasicMaterial:()=>zn,MeshDepthMaterial:()=>$o,MeshDistanceMaterial:()=>Wo,MeshLambertMaterial:()=>tu,MeshMatcapMaterial:()=>nu,MeshNormalMaterial:()=>eu,MeshPhongMaterial:()=>Kc,MeshPhysicalMaterial:()=>Jc,MeshStandardMaterial:()=>oa,MeshToonMaterial:()=>Qc,MinEquation:()=>Y0,MirroredRepeatWrapping:()=>Co,MixOperation:()=>gy,MultiplyBlending:()=>sh,MultiplyOperation:()=>fa,NearestFilter:()=>Pt,NearestMipMapLinearFilter:()=>uM,NearestMipMapNearestFilter:()=>cM,NearestMipmapLinearFilter:()=>us,NearestMipmapNearestFilter:()=>ep,NeutralToneMapping:()=>Sy,NeverCompare:()=>Vy,NeverDepth:()=>cy,NeverStencilFunc:()=>MM,NoBlending:()=>si,NoColorSpace:()=>ei,NoToneMapping:()=>oi,NormalAnimationBlendMode:()=>Mu,NormalBlending:()=>hr,NotEqualCompare:()=>Wy,NotEqualDepth:()=>my,NotEqualStencilFunc:()=>IM,NumberKeyframeTrack:()=>Mr,Object3D:()=>rt,ObjectLoader:()=>vf,ObjectSpaceNormalMap:()=>zy,OctahedronGeometry:()=>ra,OneFactor:()=>J0,OneMinusConstantAlphaFactor:()=>ly,OneMinusConstantColorFactor:()=>oy,OneMinusDstAlphaFactor:()=>ty,OneMinusDstColorFactor:()=>iy,OneMinusSrcAlphaFactor:()=>uc,OneMinusSrcColorFactor:()=>Q0,OrthographicCamera:()=>Ms,P3Primaries:()=>Uo,PCFShadowMap:()=>Qf,PCFSoftShadowMap:()=>$0,PMREMGenerator:()=>Ho,Path:()=>_r,PerspectiveCamera:()=>Et,Plane:()=>On,PlaneGeometry:()=>ws,PlaneHelper:()=>Yf,PointLight:()=>cu,PointLightHelper:()=>zf,Points:()=>Ic,PointsMaterial:()=>Yo,PolarGridHelper:()=>Gf,PolyhedronGeometry:()=>Ni,PositionalAudio:()=>Mf,PropertyBinding:()=>ot,PropertyMixer:()=>_u,QuadraticBezierCurve:()=>Jo,QuadraticBezierCurve3:()=>Ko,Quaternion:()=>Gt,QuaternionKeyframeTrack:()=>Fi,QuaternionLinearInterpolant:()=>ou,RED_GREEN_RGTC2_Format:()=>Ph,RED_RGTC1_Format:()=>Oy,REVISION:()=>rM,RGBADepthPacking:()=>By,RGBAFormat:()=>rn,RGBAIntegerFormat:()=>lp,RGBA_ASTC_10x10_Format:()=>Ah,RGBA_ASTC_10x5_Format:()=>wh,RGBA_ASTC_10x6_Format:()=>Mh,RGBA_ASTC_10x8_Format:()=>Sh,RGBA_ASTC_12x10_Format:()=>Eh,RGBA_ASTC_12x12_Format:()=>Th,RGBA_ASTC_4x4_Format:()=>ph,RGBA_ASTC_5x4_Format:()=>mh,RGBA_ASTC_5x5_Format:()=>gh,RGBA_ASTC_6x5_Format:()=>yh,RGBA_ASTC_6x6_Format:()=>vh,RGBA_ASTC_8x5_Format:()=>xh,RGBA_ASTC_8x6_Format:()=>_h,RGBA_ASTC_8x8_Format:()=>bh,RGBA_BPTC_Format:()=>ac,RGBA_ETC2_EAC_Format:()=>fh,RGBA_PVRTC_2BPPV1_Format:()=>uh,RGBA_PVRTC_4BPPV1_Format:()=>ch,RGBA_S3TC_DXT1_Format:()=>rc,RGBA_S3TC_DXT3_Format:()=>sc,RGBA_S3TC_DXT5_Format:()=>oc,RGBFormat:()=>Ry,RGB_BPTC_SIGNED_Format:()=>Ih,RGB_BPTC_UNSIGNED_Format:()=>Ch,RGB_ETC1_Format:()=>dh,RGB_ETC2_Format:()=>hh,RGB_PVRTC_2BPPV1_Format:()=>lh,RGB_PVRTC_4BPPV1_Format:()=>ah,RGB_S3TC_DXT1_Format:()=>ic,RGFormat:()=>Dy,RGIntegerFormat:()=>ap,RawShaderMaterial:()=>Zc,Ray:()=>Oi,Raycaster:()=>Lf,Rec709Primaries:()=>Oo,RectAreaLight:()=>hu,RedFormat:()=>sp,RedIntegerFormat:()=>op,ReinhardToneMapping:()=>xy,RenderTarget:()=>hc,RepeatWrapping:()=>Io,ReplaceStencilOp:()=>yM,ReverseSubtractEquation:()=>X0,RingGeometry:()=>Hc,SIGNED_RED_GREEN_RGTC2_Format:()=>Lh,SIGNED_RED_RGTC1_Format:()=>Rh,SRGBColorSpace:()=>yn,SRGBTransfer:()=>dt,Scene:()=>vc,ShaderChunk:()=>We,ShaderLib:()=>In,ShaderMaterial:()=>ln,ShadowMaterial:()=>qc,Shape:()=>ai,ShapeGeometry:()=>Gc,ShapePath:()=>Jf,ShapeUtils:()=>Bn,ShortType:()=>Ty,Skeleton:()=>wc,SkeletonHelper:()=>Bf,SkinnedMesh:()=>bc,Source:()=>ni,Sphere:()=>Lt,SphereGeometry:()=>sa,Spherical:()=>Of,SphericalHarmonics3:()=>fu,SplineCurve:()=>Qo,SpotLight:()=>lu,SpotLightHelper:()=>kf,Sprite:()=>xc,SpriteMaterial:()=>jo,SrcAlphaFactor:()=>cc,SrcAlphaSaturateFactor:()=>ry,SrcColorFactor:()=>K0,StaticCopyUsage:()=>UM,StaticDrawUsage:()=>No,StaticReadUsage:()=>LM,StereoCamera:()=>bf,StreamCopyUsage:()=>FM,StreamDrawUsage:()=>PM,StreamReadUsage:()=>OM,StringKeyframeTrack:()=>hi,SubtractEquation:()=>j0,SubtractiveBlending:()=>rh,TOUCH:()=>oM,TangentSpaceNormalMap:()=>ki,TetrahedronGeometry:()=>$c,Texture:()=>Mt,TextureLoader:()=>pf,TorusGeometry:()=>Wc,TorusKnotGeometry:()=>jc,Triangle:()=>ii,TriangleFanDrawMode:()=>mM,TriangleStripDrawMode:()=>pM,TrianglesDrawMode:()=>fM,TubeGeometry:()=>Xc,UVMapping:()=>wu,Uint16BufferAttribute:()=>zo,Uint32BufferAttribute:()=>Vo,Uint8BufferAttribute:()=>kh,Uint8ClampedBufferAttribute:()=>Bh,Uniform:()=>If,UniformsGroup:()=>Cf,UniformsLib:()=>ye,UniformsUtils:()=>Qy,UnsignedByteType:()=>ui,UnsignedInt248Type:()=>Cs,UnsignedInt5999Type:()=>Iy,UnsignedIntType:()=>mr,UnsignedShort4444Type:()=>ip,UnsignedShort5551Type:()=>rp,UnsignedShortType:()=>tp,VSMShadowMap:()=>Dn,Vector2:()=>te,Vector3:()=>R,Vector4:()=>lt,VectorKeyframeTrack:()=>Sr,VideoTexture:()=>ef,WebGL3DRenderTarget:()=>Nh,WebGLArrayRenderTarget:()=>Uh,WebGLCoordinateSystem:()=>Fn,WebGLCubeRenderTarget:()=>pc,WebGLMultipleRenderTargets:()=>Kf,WebGLRenderTarget:()=>on,WebGLRenderer:()=>Jh,WebGLUtils:()=>ov,WebGPUCoordinateSystem:()=>Fo,WireframeGeometry:()=>Yc,WrapAroundEnding:()=>Lo,ZeroCurvatureEnding:()=>cr,ZeroFactor:()=>Z0,ZeroSlopeEnding:()=>ur,ZeroStencilOp:()=>gM,createCanvasElement:()=>qy});function sn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]).toLowerCase()}function yt(n,e,t){return Math.max(e,Math.min(t,n))}function dp(n,e){return(n%e+e)%e}function BM(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function zM(n,e,t){return n!==e?(t-n)/(e-n):0}function bo(n,e,t){return(1-t)*n+t*e}function VM(n,e,t,i){return bo(n,e,1-Math.exp(-t*i))}function HM(n,e=1){return e-Math.abs(dp(n,e*2)-e)}function GM(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function $M(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function WM(n,e){return n+Math.floor(Math.random()*(e-n+1))}function jM(n,e){return n+Math.random()*(e-n)}function XM(n){return n*(.5-Math.random())}function YM(n){n!==void 0&&(ug=n);let e=ug+=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 qM(n){return n*pr}function ZM(n){return n*ys}function JM(n){return(n&n-1)===0&&n!==0}function KM(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function QM(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function eS(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 Xt(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 Yy(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ds(n,e){return new nS[n](e)}function ko(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function qy(){let n=ko("canvas");return n.style.display="block",n}function Zy(n){n in dg||(dg[n]=!0,console.warn(n))}function ps(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function xd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function _d(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?dc.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 wd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){qi.fromArray(n,s);let a=r.x*Math.abs(qi.x)+r.y*Math.abs(qi.y)+r.z*Math.abs(qi.z),l=e.dot(qi),c=t.dot(qi),u=i.dot(qi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}function Ld(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 pS(){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 Jt(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=yt(n,-65504,65504),ti.floatView[0]=n;let e=ti.uint32View[0],t=e>>23&511;return ti.baseTable[t]+((e&8388607)>>ti.shiftTable[t])}function vo(n){let e=n>>10;return ti.uint32View[0]=ti.mantissaTable[ti.offsetTable[e]+(n&1023)]+ti.exponentTable[e],ti.floatView[0]}function yS(n,e,t,i,r,s,o,a){let l;if(e.side===Yt?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===li,a),l===null)return null;Tl.copy(a),Tl.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(Tl);return c<t.near||c>t.far?null:{distance:c,point:Tl.clone(),object:n}}function Il(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Kr),n.getVertexPosition(l,Qr),n.getVertexPosition(c,es);let u=yS(n,e,t,i,Kr,Qr,es,El);if(u){r&&(Ml.fromBufferAttribute(r,a),Sl.fromBufferAttribute(r,l),Al.fromBufferAttribute(r,c),u.uv=ii.getInterpolation(El,Kr,Qr,es,Ml,Sl,Al,new te)),s&&(Ml.fromBufferAttribute(s,a),Sl.fromBufferAttribute(s,l),Al.fromBufferAttribute(s,c),u.uv1=ii.getInterpolation(El,Kr,Qr,es,Ml,Sl,Al,new te)),o&&(Ag.fromBufferAttribute(o,a),Eg.fromBufferAttribute(o,l),Tg.fromBufferAttribute(o,c),u.normal=ii.getInterpolation(El,Kr,Qr,es,Ag,Eg,Tg,new R),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new R,materialIndex:0};ii.getNormal(Kr,Qr,es,d.normal),u.face=d}return u}function _s(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 jt(n){let e={};for(let t=0;t<n.length;t++){let i=_s(n[t]);for(let r in i)e[r]=i[r]}return e}function vS(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Ky(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:at.workingColorSpace}function ev(){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 MS(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 rE(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===Is)?(u===void 0&&(u=new vt(new gr(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:_s(In.backgroundCube.uniforms),vertexShader:In.backgroundCube.vertexShader,fragmentShader:In.backgroundCube.fragmentShader,side:Yt,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)),Ki.copy(v.backgroundRotation),Ki.x*=-1,Ki.y*=-1,Ki.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Ki.y*=-1,Ki.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(iE.makeRotationFromEuler(Ki)),u.material.toneMapped=at.getTransfer(b.colorSpace)!==dt,(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 vt(new ws(2,2),new ln({name:"BackgroundMaterial",uniforms:_s(In.background.uniforms),vertexShader:In.background.vertexShader,fragmentShader:In.background.fragmentShader,side:li,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=at.getTransfer(b.colorSpace)!==dt,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(Rl,Ky(n)),i.buffers.color.setClear(Rl.r,Rl.g,Rl.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 sE(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 Ke=Le.buffer,Z=Le.type,q=Le.bytesPerElement,pe=Z===n.INT||Z===n.UNSIGNED_INT||re.gpuType===np;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,Ke);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,Ke);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 oE(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 aE(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!==rn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let E=A===pa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==ui&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==xn&&!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 lE(n){let e=this,t=null,i=0,r=!1,s=!1,o=new On,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 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 cE(n){let e=new WeakMap;function t(o,a){return a===Eo?o.mapping=ci:a===To&&(o.mapping=Di),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===Eo||a===To)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 pc(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 uE(n){let e=[],t=[],i=[],r=n,s=n-hs+1+Rg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let l=1/a;o>n-hs?l=Rg[o-n+hs-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 Ye;L.setAttribute("position",new nt(x,y)),L.setAttribute("uv",new nt(v,g)),L.setAttribute("faceIndex",new nt(b,m)),e.push(L),r>hs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Dg(n,e,t){let i=new on(n,e,t);return i.texture.mapping=Is,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Pl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function dE(n,e,t){let i=new Float32Array(lr),r=new R(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:lr,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:hp(),fragmentShader:`
|
|
1
|
+
var WorldOrbit=(()=>{var Uu=Object.defineProperty;var zv=Object.getOwnPropertyDescriptor;var Vv=Object.getOwnPropertyNames;var Hv=Object.prototype.hasOwnProperty;var Gv=(n,e)=>()=>(n&&(e=n(n=0)),e);var Sp=(n,e)=>{for(var t in e)Uu(n,t,{get:e[t],enumerable:!0})},$v=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vv(e))!Hv.call(n,r)&&r!==t&&Uu(n,r,{get:()=>e[r],enumerable:!(i=zv(e,r))||i.enumerable});return n};var Wv=n=>$v(Uu({},"__esModule",{value:!0}),n);var mv={};Sp(mv,{ACESFilmicToneMapping:()=>by,AddEquation:()=>Pi,AddOperation:()=>yy,AdditiveAnimationBlendMode:()=>cp,AdditiveBlending:()=>ih,AgXToneMapping:()=>My,AlphaFormat:()=>Cy,AlwaysCompare:()=>Xy,AlwaysDepth:()=>uy,AlwaysStencilFunc:()=>Dh,AmbientLight:()=>du,AnimationAction:()=>bu,AnimationClip:()=>Ar,AnimationLoader:()=>uf,AnimationMixer:()=>Tf,AnimationObjectGroup:()=>Ef,AnimationUtils:()=>PI,ArcCurve:()=>Cc,ArrayCamera:()=>mc,ArrowHelper:()=>qf,AttachedBindMode:()=>oh,Audio:()=>xu,AudioAnalyser:()=>Sf,AudioContext:()=>ha,AudioListener:()=>wf,AudioLoader:()=>_f,AxesHelper:()=>Zf,BackSide:()=>Yt,BasicDepthPacking:()=>ky,BasicShadowMap:()=>cM,BatchedMesh:()=>Sc,Bone:()=>Xo,BooleanKeyframeTrack:()=>di,Box2:()=>Nf,Box3:()=>Ot,Box3Helper:()=>Xf,BoxGeometry:()=>gr,BoxHelper:()=>jf,BufferAttribute:()=>nt,BufferGeometry:()=>Ye,BufferGeometryLoader:()=>yu,ByteType:()=>Ey,Cache:()=>ri,Camera:()=>bs,CameraHelper:()=>Wf,CanvasTexture:()=>sf,CapsuleGeometry:()=>Uc,CatmullRomCurve3:()=>Rc,CineonToneMapping:()=>_y,CircleGeometry:()=>Nc,ClampToEdgeWrapping:()=>vn,Clock:()=>vu,Color:()=>we,ColorKeyframeTrack:()=>la,ColorManagement:()=>at,CompressedArrayTexture:()=>nf,CompressedCubeTexture:()=>rf,CompressedTexture:()=>As,CompressedTextureLoader:()=>df,ConeGeometry:()=>Fc,ConstantAlphaFactor:()=>ay,ConstantColorFactor:()=>sy,CubeCamera:()=>fc,CubeReflectionMapping:()=>ci,CubeRefractionMapping:()=>Di,CubeTexture:()=>yr,CubeTextureLoader:()=>hf,CubeUVReflectionMapping:()=>Is,CubicBezierCurve:()=>qo,CubicBezierCurve3:()=>Pc,CubicInterpolant:()=>ru,CullFaceBack:()=>nh,CullFaceFront:()=>G0,CullFaceFrontBack:()=>lM,CullFaceNone:()=>H0,Curve:()=>cn,CurvePath:()=>Oc,CustomBlending:()=>W0,CustomToneMapping:()=>wy,CylinderGeometry:()=>Ts,Cylindrical:()=>Uf,Data3DTexture:()=>Bo,DataArrayTexture:()=>vs,DataTexture:()=>kn,DataTextureLoader:()=>ff,DataUtils:()=>gS,DecrementStencilOp:()=>_M,DecrementWrapStencilOp:()=>wM,DefaultLoadingManager:()=>fv,DepthFormat:()=>fr,DepthStencilFormat:()=>gs,DepthTexture:()=>Go,DetachedBindMode:()=>Ay,DirectionalLight:()=>uu,DirectionalLightHelper:()=>$f,DiscreteInterpolant:()=>su,DisplayP3ColorSpace:()=>Su,DodecahedronGeometry:()=>kc,DoubleSide:()=>Un,DstAlphaFactor:()=>ey,DstColorFactor:()=>ny,DynamicCopyUsage:()=>FM,DynamicDrawUsage:()=>PM,DynamicReadUsage:()=>OM,EdgesGeometry:()=>Bc,EllipseCurve:()=>Es,EqualCompare:()=>Gy,EqualDepth:()=>hy,EqualStencilFunc:()=>EM,EquirectangularReflectionMapping:()=>Eo,EquirectangularRefractionMapping:()=>To,Euler:()=>an,EventDispatcher:()=>Cn,ExtrudeGeometry:()=>zc,FileLoader:()=>Rn,Float16BufferAttribute:()=>Hh,Float32BufferAttribute:()=>Te,FloatType:()=>xn,Fog:()=>yc,FogExp2:()=>gc,FramebufferTexture:()=>tf,FrontSide:()=>li,Frustum:()=>vr,GLBufferAttribute:()=>Pf,GLSL1:()=>BM,GLSL3:()=>Oh,GreaterCompare:()=>$y,GreaterDepth:()=>py,GreaterEqualCompare:()=>jy,GreaterEqualDepth:()=>fy,GreaterEqualStencilFunc:()=>RM,GreaterStencilFunc:()=>IM,GridHelper:()=>Hf,Group:()=>Li,HalfFloatType:()=>pa,HemisphereLight:()=>au,HemisphereLightHelper:()=>Vf,IcosahedronGeometry:()=>Vc,ImageBitmapLoader:()=>xf,ImageLoader:()=>Er,ImageUtils:()=>dc,IncrementStencilOp:()=>xM,IncrementWrapStencilOp:()=>bM,InstancedBufferAttribute:()=>Ui,InstancedBufferGeometry:()=>gu,InstancedInterleavedBuffer:()=>Rf,InstancedMesh:()=>Mc,Int16BufferAttribute:()=>zh,Int32BufferAttribute:()=>Vh,Int8BufferAttribute:()=>Fh,IntType:()=>np,InterleavedBuffer:()=>Ss,InterleavedBufferAttribute:()=>xr,Interpolant:()=>wr,InterpolateDiscrete:()=>Ro,InterpolateLinear:()=>Po,InterpolateSmooth:()=>lc,InvertStencilOp:()=>MM,KeepStencilOp:()=>or,KeyframeTrack:()=>un,LOD:()=>_c,LatheGeometry:()=>ea,Layers:()=>xs,LessCompare:()=>Hy,LessDepth:()=>dy,LessEqualCompare:()=>up,LessEqualDepth:()=>Ao,LessEqualStencilFunc:()=>TM,LessStencilFunc:()=>AM,Light:()=>Hn,LightProbe:()=>pu,Line:()=>Vn,Line3:()=>Ff,LineBasicMaterial:()=>Ut,LineCurve:()=>Zo,LineCurve3:()=>Lc,LineDashedMaterial:()=>iu,LineLoop:()=>Tc,LineSegments:()=>_n,LinearDisplayP3ColorSpace:()=>ma,LinearFilter:()=>wt,LinearInterpolant:()=>aa,LinearMipMapLinearFilter:()=>fM,LinearMipMapNearestFilter:()=>hM,LinearMipmapLinearFilter:()=>Nn,LinearMipmapNearestFilter:()=>_o,LinearSRGBColorSpace:()=>fi,LinearToneMapping:()=>vy,LinearTransfer:()=>Do,Loader:()=>$t,LoaderUtils:()=>da,LoadingManager:()=>ca,LoopOnce:()=>Uy,LoopPingPong:()=>Fy,LoopRepeat:()=>Ny,LuminanceAlphaFormat:()=>Ly,LuminanceFormat:()=>Py,MOUSE:()=>oM,Material:()=>Dt,MaterialLoader:()=>mu,MathUtils:()=>nS,Matrix3:()=>He,Matrix4:()=>Ne,MaxEquation:()=>q0,Mesh:()=>vt,MeshBasicMaterial:()=>zn,MeshDepthMaterial:()=>$o,MeshDistanceMaterial:()=>Wo,MeshLambertMaterial:()=>tu,MeshMatcapMaterial:()=>nu,MeshNormalMaterial:()=>eu,MeshPhongMaterial:()=>Kc,MeshPhysicalMaterial:()=>Jc,MeshStandardMaterial:()=>oa,MeshToonMaterial:()=>Qc,MinEquation:()=>Y0,MirroredRepeatWrapping:()=>Co,MixOperation:()=>gy,MultiplyBlending:()=>sh,MultiplyOperation:()=>fa,NearestFilter:()=>Pt,NearestMipMapLinearFilter:()=>dM,NearestMipMapNearestFilter:()=>uM,NearestMipmapLinearFilter:()=>us,NearestMipmapNearestFilter:()=>ep,NeutralToneMapping:()=>Sy,NeverCompare:()=>Vy,NeverDepth:()=>cy,NeverStencilFunc:()=>SM,NoBlending:()=>si,NoColorSpace:()=>ei,NoToneMapping:()=>oi,NormalAnimationBlendMode:()=>Mu,NormalBlending:()=>hr,NotEqualCompare:()=>Wy,NotEqualDepth:()=>my,NotEqualStencilFunc:()=>CM,NumberKeyframeTrack:()=>Mr,Object3D:()=>rt,ObjectLoader:()=>vf,ObjectSpaceNormalMap:()=>zy,OctahedronGeometry:()=>ra,OneFactor:()=>J0,OneMinusConstantAlphaFactor:()=>ly,OneMinusConstantColorFactor:()=>oy,OneMinusDstAlphaFactor:()=>ty,OneMinusDstColorFactor:()=>iy,OneMinusSrcAlphaFactor:()=>uc,OneMinusSrcColorFactor:()=>Q0,OrthographicCamera:()=>Ms,P3Primaries:()=>Uo,PCFShadowMap:()=>Qf,PCFSoftShadowMap:()=>$0,PMREMGenerator:()=>Ho,Path:()=>_r,PerspectiveCamera:()=>Et,Plane:()=>On,PlaneGeometry:()=>ws,PlaneHelper:()=>Yf,PointLight:()=>cu,PointLightHelper:()=>zf,Points:()=>Ic,PointsMaterial:()=>Yo,PolarGridHelper:()=>Gf,PolyhedronGeometry:()=>Ni,PositionalAudio:()=>Mf,PropertyBinding:()=>ot,PropertyMixer:()=>_u,QuadraticBezierCurve:()=>Jo,QuadraticBezierCurve3:()=>Ko,Quaternion:()=>Gt,QuaternionKeyframeTrack:()=>Fi,QuaternionLinearInterpolant:()=>ou,RED_GREEN_RGTC2_Format:()=>Ph,RED_RGTC1_Format:()=>Oy,REVISION:()=>sM,RGBADepthPacking:()=>By,RGBAFormat:()=>rn,RGBAIntegerFormat:()=>lp,RGBA_ASTC_10x10_Format:()=>Ah,RGBA_ASTC_10x5_Format:()=>wh,RGBA_ASTC_10x6_Format:()=>Mh,RGBA_ASTC_10x8_Format:()=>Sh,RGBA_ASTC_12x10_Format:()=>Eh,RGBA_ASTC_12x12_Format:()=>Th,RGBA_ASTC_4x4_Format:()=>ph,RGBA_ASTC_5x4_Format:()=>mh,RGBA_ASTC_5x5_Format:()=>gh,RGBA_ASTC_6x5_Format:()=>yh,RGBA_ASTC_6x6_Format:()=>vh,RGBA_ASTC_8x5_Format:()=>xh,RGBA_ASTC_8x6_Format:()=>_h,RGBA_ASTC_8x8_Format:()=>bh,RGBA_BPTC_Format:()=>ac,RGBA_ETC2_EAC_Format:()=>fh,RGBA_PVRTC_2BPPV1_Format:()=>uh,RGBA_PVRTC_4BPPV1_Format:()=>ch,RGBA_S3TC_DXT1_Format:()=>rc,RGBA_S3TC_DXT3_Format:()=>sc,RGBA_S3TC_DXT5_Format:()=>oc,RGBFormat:()=>Ry,RGB_BPTC_SIGNED_Format:()=>Ih,RGB_BPTC_UNSIGNED_Format:()=>Ch,RGB_ETC1_Format:()=>dh,RGB_ETC2_Format:()=>hh,RGB_PVRTC_2BPPV1_Format:()=>lh,RGB_PVRTC_4BPPV1_Format:()=>ah,RGB_S3TC_DXT1_Format:()=>ic,RGFormat:()=>Dy,RGIntegerFormat:()=>ap,RawShaderMaterial:()=>Zc,Ray:()=>Oi,Raycaster:()=>Lf,Rec709Primaries:()=>Oo,RectAreaLight:()=>hu,RedFormat:()=>sp,RedIntegerFormat:()=>op,ReinhardToneMapping:()=>xy,RenderTarget:()=>hc,RepeatWrapping:()=>Io,ReplaceStencilOp:()=>vM,ReverseSubtractEquation:()=>X0,RingGeometry:()=>Hc,SIGNED_RED_GREEN_RGTC2_Format:()=>Lh,SIGNED_RED_RGTC1_Format:()=>Rh,SRGBColorSpace:()=>yn,SRGBTransfer:()=>dt,Scene:()=>vc,ShaderChunk:()=>We,ShaderLib:()=>In,ShaderMaterial:()=>ln,ShadowMaterial:()=>qc,Shape:()=>ai,ShapeGeometry:()=>Gc,ShapePath:()=>Jf,ShapeUtils:()=>Bn,ShortType:()=>Ty,Skeleton:()=>wc,SkeletonHelper:()=>Bf,SkinnedMesh:()=>bc,Source:()=>ni,Sphere:()=>Lt,SphereGeometry:()=>sa,Spherical:()=>Of,SphericalHarmonics3:()=>fu,SplineCurve:()=>Qo,SpotLight:()=>lu,SpotLightHelper:()=>kf,Sprite:()=>xc,SpriteMaterial:()=>jo,SrcAlphaFactor:()=>cc,SrcAlphaSaturateFactor:()=>ry,SrcColorFactor:()=>K0,StaticCopyUsage:()=>NM,StaticDrawUsage:()=>No,StaticReadUsage:()=>DM,StereoCamera:()=>bf,StreamCopyUsage:()=>kM,StreamDrawUsage:()=>LM,StreamReadUsage:()=>UM,StringKeyframeTrack:()=>hi,SubtractEquation:()=>j0,SubtractiveBlending:()=>rh,TOUCH:()=>aM,TangentSpaceNormalMap:()=>ki,TetrahedronGeometry:()=>$c,Texture:()=>Mt,TextureLoader:()=>pf,TorusGeometry:()=>Wc,TorusKnotGeometry:()=>jc,Triangle:()=>ii,TriangleFanDrawMode:()=>gM,TriangleStripDrawMode:()=>mM,TrianglesDrawMode:()=>pM,TubeGeometry:()=>Xc,UVMapping:()=>wu,Uint16BufferAttribute:()=>zo,Uint32BufferAttribute:()=>Vo,Uint8BufferAttribute:()=>kh,Uint8ClampedBufferAttribute:()=>Bh,Uniform:()=>If,UniformsGroup:()=>Cf,UniformsLib:()=>ye,UniformsUtils:()=>Qy,UnsignedByteType:()=>ui,UnsignedInt248Type:()=>Cs,UnsignedInt5999Type:()=>Iy,UnsignedIntType:()=>mr,UnsignedShort4444Type:()=>ip,UnsignedShort5551Type:()=>rp,UnsignedShortType:()=>tp,VSMShadowMap:()=>Dn,Vector2:()=>te,Vector3:()=>R,Vector4:()=>lt,VectorKeyframeTrack:()=>Sr,VideoTexture:()=>ef,WebGL3DRenderTarget:()=>Nh,WebGLArrayRenderTarget:()=>Uh,WebGLCoordinateSystem:()=>Fn,WebGLCubeRenderTarget:()=>pc,WebGLMultipleRenderTargets:()=>Kf,WebGLRenderTarget:()=>on,WebGLRenderer:()=>Jh,WebGLUtils:()=>ov,WebGPUCoordinateSystem:()=>Fo,WireframeGeometry:()=>Yc,WrapAroundEnding:()=>Lo,ZeroCurvatureEnding:()=>cr,ZeroFactor:()=>Z0,ZeroSlopeEnding:()=>ur,ZeroStencilOp:()=>yM,createCanvasElement:()=>qy});function sn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]).toLowerCase()}function yt(n,e,t){return Math.max(e,Math.min(t,n))}function dp(n,e){return(n%e+e)%e}function zM(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function VM(n,e,t){return n!==e?(t-n)/(e-n):0}function bo(n,e,t){return(1-t)*n+t*e}function HM(n,e,t,i){return bo(n,e,1-Math.exp(-t*i))}function GM(n,e=1){return e-Math.abs(dp(n,e*2)-e)}function $M(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function WM(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function jM(n,e){return n+Math.floor(Math.random()*(e-n+1))}function XM(n,e){return n+Math.random()*(e-n)}function YM(n){return n*(.5-Math.random())}function qM(n){n!==void 0&&(ug=n);let e=ug+=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 ZM(n){return n*pr}function JM(n){return n*ys}function KM(n){return(n&n-1)===0&&n!==0}function QM(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function eS(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function tS(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 Xt(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 Yy(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ds(n,e){return new iS[n](e)}function ko(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function qy(){let n=ko("canvas");return n.style.display="block",n}function Zy(n){n in dg||(dg[n]=!0,console.warn(n))}function ps(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function xd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function _d(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?dc.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 wd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){qi.fromArray(n,s);let a=r.x*Math.abs(qi.x)+r.y*Math.abs(qi.y)+r.z*Math.abs(qi.z),l=e.dot(qi),c=t.dot(qi),u=i.dot(qi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}function Ld(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 mS(){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 Jt(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=yt(n,-65504,65504),ti.floatView[0]=n;let e=ti.uint32View[0],t=e>>23&511;return ti.baseTable[t]+((e&8388607)>>ti.shiftTable[t])}function vo(n){let e=n>>10;return ti.uint32View[0]=ti.mantissaTable[ti.offsetTable[e]+(n&1023)]+ti.exponentTable[e],ti.floatView[0]}function vS(n,e,t,i,r,s,o,a){let l;if(e.side===Yt?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===li,a),l===null)return null;Tl.copy(a),Tl.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(Tl);return c<t.near||c>t.far?null:{distance:c,point:Tl.clone(),object:n}}function Il(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Kr),n.getVertexPosition(l,Qr),n.getVertexPosition(c,es);let u=vS(n,e,t,i,Kr,Qr,es,El);if(u){r&&(Ml.fromBufferAttribute(r,a),Sl.fromBufferAttribute(r,l),Al.fromBufferAttribute(r,c),u.uv=ii.getInterpolation(El,Kr,Qr,es,Ml,Sl,Al,new te)),s&&(Ml.fromBufferAttribute(s,a),Sl.fromBufferAttribute(s,l),Al.fromBufferAttribute(s,c),u.uv1=ii.getInterpolation(El,Kr,Qr,es,Ml,Sl,Al,new te)),o&&(Ag.fromBufferAttribute(o,a),Eg.fromBufferAttribute(o,l),Tg.fromBufferAttribute(o,c),u.normal=ii.getInterpolation(El,Kr,Qr,es,Ag,Eg,Tg,new R),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new R,materialIndex:0};ii.getNormal(Kr,Qr,es,d.normal),u.face=d}return u}function _s(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 jt(n){let e={};for(let t=0;t<n.length;t++){let i=_s(n[t]);for(let r in i)e[r]=i[r]}return e}function xS(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Ky(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:at.workingColorSpace}function ev(){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 SS(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 sE(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===Is)?(u===void 0&&(u=new vt(new gr(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:_s(In.backgroundCube.uniforms),vertexShader:In.backgroundCube.vertexShader,fragmentShader:In.backgroundCube.fragmentShader,side:Yt,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)),Ki.copy(v.backgroundRotation),Ki.x*=-1,Ki.y*=-1,Ki.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Ki.y*=-1,Ki.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(rE.makeRotationFromEuler(Ki)),u.material.toneMapped=at.getTransfer(b.colorSpace)!==dt,(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 vt(new ws(2,2),new ln({name:"BackgroundMaterial",uniforms:_s(In.background.uniforms),vertexShader:In.background.vertexShader,fragmentShader:In.background.fragmentShader,side:li,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=at.getTransfer(b.colorSpace)!==dt,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(Rl,Ky(n)),i.buffers.color.setClear(Rl.r,Rl.g,Rl.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 oE(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 Ke=Le.buffer,Z=Le.type,q=Le.bytesPerElement,pe=Z===n.INT||Z===n.UNSIGNED_INT||re.gpuType===np;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,Ke);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,Ke);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 aE(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 lE(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!==rn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let E=A===pa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==ui&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==xn&&!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 cE(n){let e=this,t=null,i=0,r=!1,s=!1,o=new On,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 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 uE(n){let e=new WeakMap;function t(o,a){return a===Eo?o.mapping=ci:a===To&&(o.mapping=Di),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===Eo||a===To)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 pc(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 dE(n){let e=[],t=[],i=[],r=n,s=n-hs+1+Rg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let l=1/a;o>n-hs?l=Rg[o-n+hs-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 Ye;L.setAttribute("position",new nt(x,y)),L.setAttribute("uv",new nt(v,g)),L.setAttribute("faceIndex",new nt(b,m)),e.push(L),r>hs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Dg(n,e,t){let i=new on(n,e,t);return i.texture.mapping=Is,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Pl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function hE(n,e,t){let i=new Float32Array(lr),r=new R(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:lr,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:hp(),fragmentShader:`
|
|
2
2
|
|
|
3
3
|
precision mediump float;
|
|
4
4
|
precision mediump int;
|
|
@@ -148,15 +148,15 @@ var WorldOrbit=(()=>{var Uu=Object.defineProperty;var zv=Object.getOwnPropertyDe
|
|
|
148
148
|
gl_Position = vec4( position, 1.0 );
|
|
149
149
|
|
|
150
150
|
}
|
|
151
|
-
`}function hE(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===Eo||l===To,u=l===ci||l===Di;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 Ho(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 Ho(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 fE(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 pE(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(Yy(h)?Vo:zo)(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 mE(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 gE(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 yE(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 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 vs(E,L,A,d);D.type=xn,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 vE(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 Rs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Ng[r];if(s===void 0&&(s=new Float32Array(r),Ng[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 Au(n,e){let t=Fg[e];t===void 0&&(t=new Int32Array(e),Fg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function xE(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function _E(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 bE(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 wE(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 ME(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;zg.set(i),n.uniformMatrix2fv(this.addr,!1,zg),It(t,i)}}function SE(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;Bg.set(i),n.uniformMatrix3fv(this.addr,!1,Bg),It(t,i)}}function AE(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;kg.set(i),n.uniformMatrix4fv(this.addr,!1,kg),It(t,i)}}function EE(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function TE(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 IE(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 CE(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 RE(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function PE(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 LE(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 DE(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 OE(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?nv:tv;t.setTexture2D(e||s,r)}function UE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||rv,r)}function NE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||sv,r)}function FE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||iv,r)}function kE(n){switch(n){case 5126:return xE;case 35664:return _E;case 35665:return bE;case 35666:return wE;case 35674:return ME;case 35675:return SE;case 35676:return AE;case 5124:case 35670:return EE;case 35667:case 35671:return TE;case 35668:case 35672:return IE;case 35669:case 35673:return CE;case 5125:return RE;case 36294:return PE;case 36295:return LE;case 36296:return DE;case 35678:case 36198:case 36298:case 36306:case 35682:return OE;case 35679:case 36299:case 36307:return UE;case 35680:case 36300:case 36308:case 36293:return NE;case 36289:case 36303:case 36311:case 36292:return FE}}function BE(n,e){n.uniform1fv(this.addr,e)}function zE(n,e){let t=Rs(e,this.size,2);n.uniform2fv(this.addr,t)}function VE(n,e){let t=Rs(e,this.size,3);n.uniform3fv(this.addr,t)}function HE(n,e){let t=Rs(e,this.size,4);n.uniform4fv(this.addr,t)}function GE(n,e){let t=Rs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function $E(n,e){let t=Rs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function WE(n,e){let t=Rs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function jE(n,e){n.uniform1iv(this.addr,e)}function XE(n,e){n.uniform2iv(this.addr,e)}function YE(n,e){n.uniform3iv(this.addr,e)}function qE(n,e){n.uniform4iv(this.addr,e)}function ZE(n,e){n.uniform1uiv(this.addr,e)}function JE(n,e){n.uniform2uiv(this.addr,e)}function KE(n,e){n.uniform3uiv(this.addr,e)}function QE(n,e){n.uniform4uiv(this.addr,e)}function eT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||tv,s[o])}function tT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||rv,s[o])}function nT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||sv,s[o])}function iT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||iv,s[o])}function rT(n){switch(n){case 5126:return BE;case 35664:return zE;case 35665:return VE;case 35666:return HE;case 35674:return GE;case 35675:return $E;case 35676:return WE;case 5124:case 35670:return jE;case 35667:case 35671:return XE;case 35668:case 35672:return YE;case 35669:case 35673:return qE;case 5125:return ZE;case 36294:return JE;case 36295:return KE;case 36296:return QE;case 35678:case 36198:case 36298:case 36306:case 35682:return eT;case 35679:case 36299:case 36307:return tT;case 35680:case 36300:case 36308:case 36293:return nT;case 36289:case 36303:case 36311:case 36292:return iT}}function Vg(n,e){n.seq.push(e),n.map[e.id]=e}function sT(n,e,t){let i=n.name,r=i.length;for(Vd.lastIndex=0;;){let s=Vd.exec(i),o=Vd.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){Vg(t,c===void 0?new Gh(a,n,e):new $h(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new Wh(a),Vg(t,d)),t=d}}}function Hg(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function lT(n,e){let t=n.split(`
|
|
151
|
+
`}function fE(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===Eo||l===To,u=l===ci||l===Di;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 Ho(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 Ho(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 pE(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 mE(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(Yy(h)?Vo:zo)(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 gE(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 yE(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 vE(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 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 vs(E,L,A,d);D.type=xn,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 xE(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 Rs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Ng[r];if(s===void 0&&(s=new Float32Array(r),Ng[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 Au(n,e){let t=Fg[e];t===void 0&&(t=new Int32Array(e),Fg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function _E(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function bE(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 wE(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 ME(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 SE(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;zg.set(i),n.uniformMatrix2fv(this.addr,!1,zg),It(t,i)}}function AE(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;Bg.set(i),n.uniformMatrix3fv(this.addr,!1,Bg),It(t,i)}}function EE(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;kg.set(i),n.uniformMatrix4fv(this.addr,!1,kg),It(t,i)}}function TE(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function IE(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 CE(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 RE(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 PE(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function LE(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 DE(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 OE(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 UE(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?nv:tv;t.setTexture2D(e||s,r)}function NE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||rv,r)}function FE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||sv,r)}function kE(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||iv,r)}function BE(n){switch(n){case 5126:return _E;case 35664:return bE;case 35665:return wE;case 35666:return ME;case 35674:return SE;case 35675:return AE;case 35676:return EE;case 5124:case 35670:return TE;case 35667:case 35671:return IE;case 35668:case 35672:return CE;case 35669:case 35673:return RE;case 5125:return PE;case 36294:return LE;case 36295:return DE;case 36296:return OE;case 35678:case 36198:case 36298:case 36306:case 35682:return UE;case 35679:case 36299:case 36307:return NE;case 35680:case 36300:case 36308:case 36293:return FE;case 36289:case 36303:case 36311:case 36292:return kE}}function zE(n,e){n.uniform1fv(this.addr,e)}function VE(n,e){let t=Rs(e,this.size,2);n.uniform2fv(this.addr,t)}function HE(n,e){let t=Rs(e,this.size,3);n.uniform3fv(this.addr,t)}function GE(n,e){let t=Rs(e,this.size,4);n.uniform4fv(this.addr,t)}function $E(n,e){let t=Rs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function WE(n,e){let t=Rs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function jE(n,e){let t=Rs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function XE(n,e){n.uniform1iv(this.addr,e)}function YE(n,e){n.uniform2iv(this.addr,e)}function qE(n,e){n.uniform3iv(this.addr,e)}function ZE(n,e){n.uniform4iv(this.addr,e)}function JE(n,e){n.uniform1uiv(this.addr,e)}function KE(n,e){n.uniform2uiv(this.addr,e)}function QE(n,e){n.uniform3uiv(this.addr,e)}function eT(n,e){n.uniform4uiv(this.addr,e)}function tT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||tv,s[o])}function nT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||rv,s[o])}function iT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||sv,s[o])}function rT(n,e,t){let i=this.cache,r=e.length,s=Au(t,r);Tt(i,s)||(n.uniform1iv(this.addr,s),It(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||iv,s[o])}function sT(n){switch(n){case 5126:return zE;case 35664:return VE;case 35665:return HE;case 35666:return GE;case 35674:return $E;case 35675:return WE;case 35676:return jE;case 5124:case 35670:return XE;case 35667:case 35671:return YE;case 35668:case 35672:return qE;case 35669:case 35673:return ZE;case 5125:return JE;case 36294:return KE;case 36295:return QE;case 36296:return eT;case 35678:case 36198:case 36298:case 36306:case 35682:return tT;case 35679:case 36299:case 36307:return nT;case 35680:case 36300:case 36308:case 36293:return iT;case 36289:case 36303:case 36311:case 36292:return rT}}function Vg(n,e){n.seq.push(e),n.map[e.id]=e}function oT(n,e,t){let i=n.name,r=i.length;for(Vd.lastIndex=0;;){let s=Vd.exec(i),o=Vd.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){Vg(t,c===void 0?new Gh(a,n,e):new $h(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new Wh(a),Vg(t,d)),t=d}}}function Hg(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function cT(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
|
|
153
|
+
`)}function uT(n){let e=at.getPrimaries(at.workingColorSpace),t=at.getPrimaries(n),i;switch(e===t?i="":e===Uo&&t===Oo?i="LinearDisplayP3ToLinearSRGB":e===Oo&&t===Uo&&(i="LinearSRGBToLinearDisplayP3"),n){case fi:case ma:return[i,"LinearTransferOETF"];case yn:case Su:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function Gg(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
|
-
`+
|
|
158
|
-
`)}function
|
|
159
|
-
`)}function
|
|
157
|
+
`+cT(n.getShaderSource(e),o)}else return r}function dT(n,e){let t=uT(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function hT(n,e){let t;switch(e){case vy:t="Linear";break;case xy:t="Reinhard";break;case _y:t="OptimizedCineon";break;case by:t="ACESFilmic";break;case My:t="AgX";break;case Sy:t="Neutral";break;case wy:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function fT(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xo).join(`
|
|
158
|
+
`)}function pT(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
159
|
+
`)}function mT(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 xo(n){return n!==""}function $g(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 Wg(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function jh(n){return n.replace(gT,vT)}function vT(n,e){let t=We[e];if(t===void 0){let i=yT.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 jh(t)}function jg(n){return n.replace(xT,_T)}function _T(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 Xg(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,14 +176,14 @@ var WorldOrbit=(()=>{var Uu=Object.defineProperty;var zv=Object.getOwnPropertyDe
|
|
|
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
|
|
179
|
+
#define LOW_PRECISION`),e}function bT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Qf?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===$0?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Dn&&(e="SHADOWMAP_TYPE_VSM"),e}function wT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case ci:case Di:e="ENVMAP_TYPE_CUBE";break;case Is:e="ENVMAP_TYPE_CUBE_UV";break}return e}function MT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Di&&(e="ENVMAP_MODE_REFRACTION"),e}function ST(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case fa:e="ENVMAP_BLENDING_MULTIPLY";break;case gy:e="ENVMAP_BLENDING_MIX";break;case yy:e="ENVMAP_BLENDING_ADD";break}return e}function AT(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 ET(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=bT(t),c=wT(t),u=MT(t),d=ST(t),h=AT(t),f=fT(t),p=pT(s),y=r.createProgram(),g,m,x=t.glslVersion?"#version "+t.glslVersion+`
|
|
180
180
|
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(xo).join(`
|
|
181
181
|
`),g.length>0&&(g+=`
|
|
182
182
|
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(xo).join(`
|
|
183
183
|
`),m.length>0&&(m+=`
|
|
184
184
|
`)):(g=[Xg(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(xo).join(`
|
|
186
|
-
`),m=[Xg(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!==oi?"#define TONE_MAPPING":"",t.toneMapping!==oi?We.tonemapping_pars_fragment:"",t.toneMapping!==oi?
|
|
186
|
+
`),m=[Xg(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!==oi?"#define TONE_MAPPING":"",t.toneMapping!==oi?We.tonemapping_pars_fragment:"",t.toneMapping!==oi?hT("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,dT("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
187
187
|
`].filter(xo).join(`
|
|
188
188
|
`)),o=jh(o),o=$g(o,t),o=Wg(o,t),a=jh(a),a=$g(a,t),a=Wg(a,t),o=jg(o),a=jg(a),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
|
|
189
189
|
`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
@@ -197,11 +197,11 @@ Material Type: `+T.type+`
|
|
|
197
197
|
|
|
198
198
|
Program Info Log: `+U+`
|
|
199
199
|
`+X+`
|
|
200
|
-
`+k)}else U!==""?console.warn("THREE.WebGLProgram: Program Info Log:",U):(I===""||B==="")&&(F=!1);F&&(T.diagnostics={runnable:W,programLog:U,vertexShader:{log:I,prefix:g},fragmentShader:{log:B,prefix:m}})}r.deleteShader(L),r.deleteShader(A),D=new ms(r,y),M=pT(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,oT)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=aT++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=L,this.fragmentShader=A,this}function TT(n,e,t,i,r,s,o){let a=new xs,l=new Xh,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===Is?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 Ke,Z,q,pe;if(re){let tt=In[re];Ke=tt.vertexShader,Z=tt.fragmentShader}else Ke=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,je=ie&&!!M.iridescenceMap,Pe=ie&&!!M.iridescenceThicknessMap,Me=Ce&&!!M.sheenColorMap,De=Ce&&!!M.sheenRoughnessMap,Ze=!!M.specularMap,ft=!!M.specularColorMap,$e=!!M.specularIntensityMap,z=me&&!!M.transmissionMap,ae=me&&!!M.thicknessMap,Q=!!M.gradientMap,xe=!!M.alphaMap,be=M.alphaTest>0,Se=!!M.alphaHash,Qe=!!M.extensions,ct=oi;M.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ct=n.toneMapping);let pt={shaderID:re,shaderType:M.type,shaderName:M.name,vertexShader:Ke,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:fi,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===zy,normalMapTangentSpace:le&&M.normalMapType===ki,metalnessMap:P,roughnessMap:S,anisotropy:j,anisotropyMap:ge,clearcoat:ee,clearcoatMap:ke,clearcoatNormalMap:fe,clearcoatRoughnessMap:Re,dispersion:oe,iridescence:ie,iridescenceMap:je,iridescenceThicknessMap:Pe,sheen:Ce,sheenColorMap:Me,sheenRoughnessMap:De,specularMap:Ze,specularColorMap:ft,specularIntensityMap:$e,transmission:me,transmissionMap:z,thicknessMap:ae,gradientMap:Q,opaque:M.transparent===!1&&M.blending===hr&&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:je&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:Pe&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&y(M.sheenRoughnessMap.channel),specularMapUv:Ze&&y(M.specularMap.channel),specularColorMapUv:ft&&y(M.specularColorMap.channel),specularIntensityMapUv:$e&&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:ct,useLegacyLights:n._useLegacyLights,decodeVideoTexture:H&&M.map.isVideoTexture===!0&&at.getTransfer(M.map.colorSpace)===dt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Un,flipSided:M.side===Yt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Qe&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Qe&&M.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return pt.vertexUv1s=c.has(1),pt.vertexUv2s=c.has(2),pt.vertexUv3s=c.has(3),c.clear(),pt}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=In[w];T=Qy.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 AT(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 IT(){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 CT(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 Yg(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 qg(){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||CT),i.length>1&&i.sort(h||Yg),r.length>1&&r.sort(h||Yg)}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 RT(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new qg,n.set(i,[o])):r>=s.length?(o=new qg,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function PT(){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 LT(){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 OT(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function UT(n){let e=new PT,t=LT(),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(OT);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=DT++)}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 Zg(n){let e=new UT(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 NT(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new Zg(n),e.set(r,[a])):s>=o.length?(a=new Zg(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function BT(n,e,t){let i=new vr,r=new te,s=new te,o=new lt,a=new $o({depthPacking:By}),l=new Wo,c={},u=t.maxTextureSize,d={[li]:Yt,[Yt]:li,[Un]:Un},h=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:FT,fragmentShader:kT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ye;p.setAttribute("position",new nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new vt(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Qf;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(si),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let I=m!==Dn&&this.type===Dn,B=m===Dn&&this.type!==Dn;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!==Dn?{minFilter:Pt,magFilter:Pt}:{};k.map!==null&&k.map.dispose(),k.map=new on(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===Dn&&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 on(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===Dn?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===Dn)&&(!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 zT(n){function e(){let z=!1,ae=new lt,Q=null,xe=new lt(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,Qe,ct,pt){pt===!0&&(be*=ct,Se*=ct,Qe*=ct),ae.set(be,Se,Qe,ct),xe.equals(ae)===!1&&(n.clearColor(be,Se,Qe,ct),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 cy:n.depthFunc(n.NEVER);break;case uy:n.depthFunc(n.ALWAYS);break;case dy:n.depthFunc(n.LESS);break;case Ao:n.depthFunc(n.LEQUAL);break;case hy:n.depthFunc(n.EQUAL);break;case fy:n.depthFunc(n.GEQUAL);break;case py:n.depthFunc(n.GREATER);break;case my: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,Qe=null,ct=null,pt=null;return{setTest:function(tt){z||(tt?pe(n.STENCIL_TEST):ne(n.STENCIL_TEST))},setMask:function(tt){ae!==tt&&!z&&(n.stencilMask(tt),ae=tt)},setFunc:function(tt,qt,St){(Q!==tt||xe!==qt||be!==St)&&(n.stencilFunc(tt,qt,St),Q=tt,xe=qt,be=St)},setOp:function(tt,qt,St){(Se!==tt||Qe!==qt||ct!==St)&&(n.stencilOp(tt,qt,St),Se=tt,Qe=qt,ct=St)},setLocked:function(tt){z=tt},setClear:function(tt){pt!==tt&&(n.clearStencil(tt),pt=tt)},reset:function(){z=!1,ae=null,Q=null,xe=null,be=null,Se=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,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 lt().fromArray(se),Ke=new lt().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 Qe=0;Qe<Q;Qe++)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+Qe,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(Ao),de(!1),le(nh),pe(n.CULL_FACE),ce(si);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,Qe=be.length;Se<Qe;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={[Pi]:n.FUNC_ADD,[j0]:n.FUNC_SUBTRACT,[X0]:n.FUNC_REVERSE_SUBTRACT};Ue[Y0]=n.MIN,Ue[q0]=n.MAX;let J={[Z0]:n.ZERO,[J0]:n.ONE,[K0]:n.SRC_COLOR,[cc]:n.SRC_ALPHA,[ry]:n.SRC_ALPHA_SATURATE,[ny]:n.DST_COLOR,[ey]:n.DST_ALPHA,[Q0]:n.ONE_MINUS_SRC_COLOR,[uc]:n.ONE_MINUS_SRC_ALPHA,[iy]:n.ONE_MINUS_DST_COLOR,[ty]:n.ONE_MINUS_DST_ALPHA,[sy]:n.CONSTANT_COLOR,[oy]:n.ONE_MINUS_CONSTANT_COLOR,[ay]:n.CONSTANT_ALPHA,[ly]:n.ONE_MINUS_CONSTANT_ALPHA};function ce(z,ae,Q,xe,be,Se,Qe,ct,pt,tt){if(z===si){p===!0&&(ne(n.BLEND),p=!1);return}if(p===!1&&(pe(n.BLEND),p=!0),z!==W0){if(z!==y||tt!==D){if((g!==Pi||v!==Pi)&&(n.blendEquation(n.FUNC_ADD),g=Pi,v=Pi),tt)switch(z){case hr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ih:n.blendFunc(n.ONE,n.ONE);break;case rh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case sh: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 hr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ih:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case rh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case sh: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=tt}return}be=be||ae,Se=Se||Q,Qe=Qe||xe,(ae!==g||be!==v)&&(n.blendEquationSeparate(Ue[ae],Ue[be]),g=ae,v=be),(Q!==m||xe!==x||Se!==b||Qe!==L)&&(n.blendFuncSeparate(J[Q],J[xe],J[Se],J[Qe]),m=Q,x=xe,b=Se,L=Qe),(ct.equals(A)===!1||pt!==E)&&(n.blendColor(ct.r,ct.g,ct.b,pt),A.copy(ct),E=pt),y=z,D=!1}function K(z,ae){z.side===Un?ne(n.CULL_FACE):pe(n.CULL_FACE);let Q=z.side===Yt;ae&&(Q=!Q),de(Q),z.blending===hr&&z.transparent===!1?ce(si):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!==H0?(pe(n.CULL_FACE),z!==w&&(z===nh?n.cullFace(n.BACK):z===G0?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 je(){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){Ke.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),Ke.copy(z))}function Ze(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 ft(z,ae){let xe=l.get(ae).get(z);a.get(ae)!==xe&&(n.uniformBlockBinding(ae,xe,z.__bindingPointIndex),a.set(ae,xe))}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,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),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: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:je,texImage3D:Pe,updateUBOMapping:Ze,uniformBlockBinding:ft,texStorage2D:fe,texStorage3D:Re,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:ge,compressedTexSubImage3D:ke,scissor:Me,viewport:De,reset:$e}}function VT(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):ko("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!==Pt&&P.minFilter!==wt}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?Do:at.getTransfer(ee);j===n.FLOAT&&(ie=n.RGBA32F),j===n.HALF_FLOAT&&(ie=n.RGBA16F),j===n.UNSIGNED_BYTE&&(ie=Ce===dt?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!==Pt&&P.minFilter!==wt?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){Ke(j,P,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+S)}let X={[Io]:n.REPEAT,[vn]:n.CLAMP_TO_EDGE,[Co]:n.MIRRORED_REPEAT},k={[Pt]:n.NEAREST,[ep]:n.NEAREST_MIPMAP_NEAREST,[us]:n.NEAREST_MIPMAP_LINEAR,[wt]:n.LINEAR,[_o]:n.LINEAR_MIPMAP_NEAREST,[Nn]:n.LINEAR_MIPMAP_LINEAR},re={[Vy]:n.NEVER,[Xy]:n.ALWAYS,[Hy]:n.LESS,[up]:n.LEQUAL,[Gy]:n.EQUAL,[jy]:n.GEQUAL,[$y]:n.GREATER,[Wy]:n.NOTEQUAL};function se(P,S){if(S.type===xn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===wt||S.magFilter===_o||S.magFilter===us||S.magFilter===Nn||S.minFilter===wt||S.minFilter===_o||S.minFilter===us||S.minFilter===Nn)&&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===Pt||S.minFilter!==us&&S.minFilter!==Nn||S.type===xn&&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=at.getPrimaries(at.workingColorSpace),ge=S.colorSpace===ei?null:at.getPrimaries(S.colorSpace),ke=S.colorSpace===ei||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),je=s.convert(S.type),Pe=x(S.internalFormat,Re,je,S.colorSpace,S.isVideoTexture);se(ee,S);let Me,De=S.mipmaps,Ze=S.isVideoTexture!==!0,ft=Ce.__version===void 0||oe===!0,$e=ie.dataReady,z=v(S,fe);if(S.isDepthTexture)Pe=n.DEPTH_COMPONENT16,S.type===xn?Pe=n.DEPTH_COMPONENT32F:S.type===mr?Pe=n.DEPTH_COMPONENT24:S.type===Cs&&(Pe=n.DEPTH24_STENCIL8),ft&&(Ze?t.texStorage2D(n.TEXTURE_2D,1,Pe,fe.width,fe.height):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,je,null));else if(S.isDataTexture)if(De.length>0){Ze&&ft&&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],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,je,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,je,Me.data);S.generateMipmaps=!1}else Ze?(ft&&t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height),$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,fe.width,fe.height,Re,je,fe.data)):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,je,fe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){Ze&&ft&&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!==rn?Re!==null?Ze?$e&&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()"):Ze?$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,Me.width,Me.height,fe.depth,Re,je,Me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Pe,Me.width,Me.height,fe.depth,0,Re,je,Me.data)}else{Ze&&ft&&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!==rn?Re!==null?Ze?$e&&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()"):Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,je,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,je,Me.data)}else if(S.isDataArrayTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,fe.width,fe.height,fe.depth),$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,fe.width,fe.height,fe.depth,Re,je,fe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Pe,fe.width,fe.height,fe.depth,0,Re,je,fe.data);else if(S.isData3DTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_3D,z,Pe,fe.width,fe.height,fe.depth),$e&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,fe.width,fe.height,fe.depth,Re,je,fe.data)):t.texImage3D(n.TEXTURE_3D,0,Pe,fe.width,fe.height,fe.depth,0,Re,je,fe.data);else if(S.isFramebufferTexture){if(ft)if(Ze)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,je,null),ae>>=1,Q>>=1}}else if(De.length>0){if(Ze&&ft){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],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Re,je,Me):t.texImage2D(n.TEXTURE_2D,ae,Pe,Re,je,Me);S.generateMipmaps=!1}else if(Ze){if(ft){let ae=Ae(fe);t.texStorage2D(n.TEXTURE_2D,z,Pe,ae.width,ae.height)}$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Re,je,fe)}else t.texImage2D(n.TEXTURE_2D,0,Pe,Re,je,fe);g(S)&&m(ee),Ce.__version=ie.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Ke(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=at.getPrimaries(at.workingColorSpace),me=S.colorSpace===ei?null:at.getPrimaries(S.colorSpace),ge=S.colorSpace===ei||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 je=Re[0],Pe=s.convert(S.format,S.colorSpace),Me=s.convert(S.type),De=x(S.internalFormat,Pe,Me,S.colorSpace),Ze=S.isVideoTexture!==!0,ft=ie.__version===void 0||ee===!0,$e=oe.dataReady,z=v(S,je);se(n.TEXTURE_CUBE_MAP,S);let ae;if(ke){Ze&&ft&&t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,je.width,je.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!==rn?Pe!==null?Ze?$e&&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()"):Ze?$e&&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,Ze&&ft){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){Ze?$e&&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;Ze?$e&&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{Ze?$e&&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];Ze?$e&&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===xn?ee=n.DEPTH_COMPONENT32F:oe.type===mr&&(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===fr)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===gs)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),je=K(P);n.renderbufferStorageMultisample(n.RENDERBUFFER,je,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!==fi&&j!==ei&&(at.getTransfer(j)===dt?(ee!==rn||oe!==ui)&&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 ov(n,e){function t(i,r=ei){let s,o=at.getTransfer(r);if(i===ui)return n.UNSIGNED_BYTE;if(i===ip)return n.UNSIGNED_SHORT_4_4_4_4;if(i===rp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Iy)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Ey)return n.BYTE;if(i===Ty)return n.SHORT;if(i===tp)return n.UNSIGNED_SHORT;if(i===np)return n.INT;if(i===mr)return n.UNSIGNED_INT;if(i===xn)return n.FLOAT;if(i===pa)return n.HALF_FLOAT;if(i===Cy)return n.ALPHA;if(i===Ry)return n.RGB;if(i===rn)return n.RGBA;if(i===Py)return n.LUMINANCE;if(i===Ly)return n.LUMINANCE_ALPHA;if(i===fr)return n.DEPTH_COMPONENT;if(i===gs)return n.DEPTH_STENCIL;if(i===sp)return n.RED;if(i===op)return n.RED_INTEGER;if(i===Dy)return n.RG;if(i===ap)return n.RG_INTEGER;if(i===lp)return n.RGBA_INTEGER;if(i===ic||i===rc||i===sc||i===oc)if(o===dt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ic)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===sc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===oc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ic)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===sc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===oc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ah||i===lh||i===ch||i===uh)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===lh)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ch)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===uh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===dh||i===hh||i===fh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===dh||i===hh)return o===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===fh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===ph||i===mh||i===gh||i===yh||i===vh||i===xh||i===_h||i===bh||i===wh||i===Mh||i===Sh||i===Ah||i===Eh||i===Th)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===ph)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===mh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===gh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===yh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===vh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===xh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===_h)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===bh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===wh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Mh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Sh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ah)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Eh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Th)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ac||i===Ih||i===Ch)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===ac)return o===dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ih)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ch)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Oy||i===Rh||i===Ph||i===Lh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===ac)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Rh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ph)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Lh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Cs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function jT(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,Ky(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===Yt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===Yt&&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,Qi.copy(b),Qi.x*=-1,Qi.y*=-1,Qi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Qi.y*=-1,Qi.z*=-1),g.envMapRotation.value.setFromMatrix4(WT.makeRotationFromEuler(Qi)),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===Yt&&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 XT(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 Ol(n,e,t,i,r,s){as.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(uo.x=s*as.x-r*as.y,uo.y=r*as.x+s*as.y):uo.copy(as),n.copy(e),n.x+=uo.x,n.y+=uo.y,n.applyMatrix4(av)}function JT(n,e){return n.z-e.z}function KT(n,e){return e.z-n.z}function eI(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 Vl(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(Ac.fromBufferAttribute(o,r),Ec.fromBufferAttribute(o,s),t.distanceSqToSegment(Ac,Ec,Xd,d0)>i)return;Xd.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(Xd);if(!(l<e.near||l>e.far))return{distance:l,point:d0.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function m0(n,e,t,i,r,s,o){let a=Qh.distanceSqToPoint(n);if(a<t){let l=new R;Qh.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 fp(){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 g0(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 tI(n,e){let t=1-n;return t*t*e}function nI(n,e){return 2*(1-n)*n*e}function iI(n,e){return n*n*e}function Mo(n,e,t,i){return tI(n,e)+nI(n,t)+iI(n,i)}function rI(n,e){let t=1-n;return t*t*t*e}function sI(n,e){let t=1-n;return 3*t*t*n*e}function oI(n,e){return 3*(1-n)*n*n*e}function aI(n,e){return n*n*n*e}function So(n,e,t,i,r){return rI(n,e)+sI(n,t)+oI(n,i)+aI(n,r)}function lv(n,e,t,i,r){let s,o;if(r===SI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=y0(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=y0(s,n[s],n[s+1],o);return o&&Eu(o,o.next)&&(ia(o),o=o.next),o}function br(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Eu(t,t.next)||mt(t.prev,t,t.next)===0)){if(ia(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ta(n,e,t,i,r,s,o){if(!n)return;!o&&s&&vI(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?uI(n,i,r,s):cI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),ia(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=dI(br(n),e,t),ta(n,e,t,i,r,s,2)):o===2&&hI(n,e,t,i,r,s):ta(br(n),e,t,i,r,s,1);break}}}function cI(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,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&fs(r,a,s,l,o,c,p.x,p.y)&&mt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function uI(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,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=of(f,p,e,t,i),x=of(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&&fs(a,u,l,d,c,h,v.x,v.y)&&mt(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&&fs(a,u,l,d,c,h,b.x,b.y)&&mt(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&&fs(a,u,l,d,c,h,v.x,v.y)&&mt(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&&fs(a,u,l,d,c,h,b.x,b.y)&&mt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function dI(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!Eu(r,s)&&cv(r,i,i.next,s)&&na(r,s)&&na(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),ia(i),ia(i.next),i=n=s),i=i.next}while(i!==n);return br(i)}function hI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&bI(o,a)){let l=uv(o,a);o=br(o,o.next),l=br(l,l.next),ta(o,e,t,i,r,s,0),ta(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function fI(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=lv(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(_I(c));for(r.sort(pI),s=0;s<r.length;s++)t=mI(r[s],t);return t}function pI(n,e){return n.x-e.x}function mI(n,e){let t=gI(n,e);if(!t)return e;let i=uv(t,n);return br(i,i.next),br(t,t.next)}function gI(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&&fs(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),na(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&yI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function yI(n,e){return mt(n.prev,n,e.prev)<0&&mt(e.next,n,n.next)<0}function vI(n,e,t,i){let r=n;do r.z===0&&(r.z=of(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,xI(r)}function xI(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 of(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 _I(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 fs(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 bI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!wI(n,e)&&(na(n,e)&&na(e,n)&&MI(n,e)&&(mt(n.prev,n,e.prev)||mt(n,e.prev,e))||Eu(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 Eu(n,e){return n.x===e.x&&n.y===e.y}function cv(n,e,t,i){let r=ql(mt(n,e,t)),s=ql(mt(n,e,i)),o=ql(mt(t,i,n)),a=ql(mt(t,i,e));return!!(r!==s&&o!==a||r===0&&Yl(n,t,e)||s===0&&Yl(n,i,e)||o===0&&Yl(t,n,i)||a===0&&Yl(t,e,i))}function Yl(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 ql(n){return n>0?1:n<0?-1:0}function wI(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&&cv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function na(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 MI(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 uv(n,e){let t=new af(n.i,n.x,n.y),i=new af(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 y0(n,e,t,i){let r=new af(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 ia(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 af(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 SI(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 v0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function x0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function EI(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 TI(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 _0(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 dr(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 dv(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function hv(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 lf(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 pp(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 II(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=dr(d,c.times.constructor),c.values=dr(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 CI(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 Gt().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")Gt.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=cp,n}function PI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Mr;case"vector":case"vector2":case"vector3":case"vector4":return Sr;case"color":return la;case"quaternion":return Fi;case"bool":case"boolean":return di;case"string":return hi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function LI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=PI(n.type);if(n.times===void 0){let t=[],i=[];pp(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 C0(){return(typeof performance>"u"?Date:performance).now()}function D0(n,e){return n.distance-e.distance}function Df(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++)Df(r[s],e,t,!0)}}function pv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,pv(n.children[t]));return e}function xt(n,e,t,i,r,s,o){ec.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],ec.x,ec.y,ec.z)}}var rM,sM,oM,H0,nh,G0,aM,lM,Qf,$0,Dn,li,Yt,Un,si,hr,ih,rh,sh,W0,Pi,j0,X0,Y0,q0,Z0,J0,K0,Q0,cc,uc,ey,ty,ny,iy,ry,sy,oy,ay,ly,cy,uy,dy,Ao,hy,fy,py,my,fa,gy,yy,oi,vy,xy,_y,by,wy,My,Sy,oh,Ay,wu,ci,Di,Eo,To,Is,Io,vn,Co,Pt,ep,cM,us,uM,wt,_o,dM,Nn,hM,ui,Ey,Ty,tp,np,mr,xn,pa,ip,rp,Cs,Iy,Cy,Ry,rn,Py,Ly,fr,gs,sp,op,Dy,ap,lp,ic,rc,sc,oc,ah,lh,ch,uh,dh,hh,fh,ph,mh,gh,yh,vh,xh,_h,bh,wh,Mh,Sh,Ah,Eh,Th,ac,Ih,Ch,Oy,Rh,Ph,Lh,Uy,Ny,Fy,Ro,Po,lc,cr,ur,Lo,Mu,cp,fM,pM,mM,ky,By,ki,zy,ei,yn,fi,Su,ma,Do,dt,Oo,Uo,gM,or,yM,vM,xM,_M,bM,wM,MM,SM,AM,EM,TM,IM,CM,Dh,Vy,Hy,Gy,up,$y,Wy,jy,Xy,No,RM,PM,LM,DM,OM,UM,NM,FM,kM,Oh,Fn,Fo,Cn,zt,ug,pr,ys,tS,te,He,vd,nS,dg,hg,fg,dl,iS,at,Hr,dc,rS,ni,sS,Mt,lt,hc,on,vs,Uh,Bo,Nh,Gt,R,bd,pg,Ot,Yn,An,hl,Gr,$r,Wr,Mi,Si,Yi,so,fl,pl,qi,oS,oo,Md,Lt,qn,Sd,ml,Ai,Ad,gl,Ed,Oi,Ne,jr,En,aS,lS,Ei,yl,tn,mg,gg,an,xs,cS,yg,Xr,Zn,vl,ao,uS,dS,vg,xg,_g,bg,hS,Yr,Td,rt,Tn,Jn,Id,Kn,qr,Zr,wg,Cd,Rd,Pd,ii,Jy,Ti,xl,we,Vt,fS,Dt,zn,ti,mS,bt,_l,nt,Fh,kh,Bh,zh,zo,Vh,Vo,Hh,Te,gS,gn,Dd,Jr,nn,lo,Rt,Ye,Mg,Zi,bl,Sg,Kr,Qr,es,Od,wl,Ml,Sl,Al,Ag,Eg,Tg,El,Tl,vt,gr,Qy,xS,_S,ln,bs,Ii,Ig,Cg,Et,ts,ns,fc,yr,pc,Ud,bS,wS,On,Ji,Cl,vr,ws,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,N1,F1,k1,B1,z1,V1,H1,G1,$1,W1,j1,X1,Y1,q1,Z1,J1,K1,Q1,eA,tA,nA,iA,rA,sA,oA,aA,lA,cA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,_A,bA,wA,MA,SA,AA,EA,TA,IA,CA,RA,PA,LA,DA,OA,UA,NA,FA,kA,BA,zA,VA,HA,GA,$A,WA,jA,XA,YA,qA,ZA,JA,KA,QA,eE,tE,nE,We,ye,In,Rl,Ki,iE,Ms,hs,Rg,lr,Nd,Pg,Fd,kd,Bd,zd,ar,is,Lg,Ho,Go,tv,nv,iv,rv,sv,Ng,Fg,kg,Bg,zg,Gh,$h,Wh,Vd,ms,oT,aT,mT,gT,vT,ET,Xh,Yh,DT,$o,Wo,FT,kT,mc,Li,HT,wo,GT,$T,qh,Zh,Qi,WT,Jh,gc,yc,vc,Ss,Wt,xr,jo,rs,co,ss,os,as,uo,av,Ll,ho,Dl,Jg,Hd,Kg,xc,Ul,Qg,_c,e0,t0,n0,YT,i0,Nl,Gd,r0,$d,bc,Xo,kn,s0,qT,wc,Ui,ls,o0,Fl,a0,ZT,fo,po,Mc,Kh,cs,Ci,l0,QT,c0,Wd,kl,er,mo,jd,Ht,Bl,Sc,Ut,Ac,Ec,u0,go,zl,Xd,d0,Vn,h0,f0,_n,Tc,Yo,p0,Qh,Hl,Gl,Ic,ef,tf,As,nf,rf,sf,cn,Es,Cc,$l,Yd,qd,Zd,Rc,qo,Pc,Zo,Lc,Jo,Ko,Qo,Dc,Oc,_r,ea,Uc,Nc,Ts,Fc,Ni,kc,Wl,jl,Jd,Xl,Bc,ai,lI,Bn,zc,AI,Vc,ra,Hc,Gc,sa,$c,Wc,jc,Xc,Yc,b0,qc,Zc,oa,Jc,Kc,Qc,eu,tu,nu,iu,RI,wr,ru,aa,su,un,di,la,Mr,ou,Fi,hi,Sr,Ar,ri,ca,fv,$t,Qn,cf,Rn,uf,df,Er,hf,ff,pf,Hn,au,Kd,w0,M0,ua,mf,lu,S0,yo,Qd,gf,cu,yf,uu,du,hu,fu,pu,mu,da,gu,yu,vf,DI,A0,E0,xf,Zl,ha,_f,T0,I0,tr,bf,vu,nr,R0,OI,ir,wf,xu,rr,P0,UI,sr,Mf,Sf,_u,mp,NI,gp,FI,kI,BI,zI,VI,HI,GI,Af,ot,Ef,bu,$I,Tf,If,WI,Cf,Rf,Pf,L0,Lf,Of,Uf,O0,Nf,U0,Jl,Ff,N0,kf,Ri,Kl,eh,Bf,zf,jI,F0,k0,Vf,Hf,Gf,B0,Ql,z0,$f,ec,gt,Wf,tc,jf,Xf,Yf,V0,nc,th,qf,Zf,Jf,Kf,gv=Gv(()=>{"use strict";rM="164",sM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},oM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},H0=0,nh=1,G0=2,aM=3,lM=0,Qf=1,$0=2,Dn=3,li=0,Yt=1,Un=2,si=0,hr=1,ih=2,rh=3,sh=4,W0=5,Pi=100,j0=101,X0=102,Y0=103,q0=104,Z0=200,J0=201,K0=202,Q0=203,cc=204,uc=205,ey=206,ty=207,ny=208,iy=209,ry=210,sy=211,oy=212,ay=213,ly=214,cy=0,uy=1,dy=2,Ao=3,hy=4,fy=5,py=6,my=7,fa=0,gy=1,yy=2,oi=0,vy=1,xy=2,_y=3,by=4,wy=5,My=6,Sy=7,oh="attached",Ay="detached",wu=300,ci=301,Di=302,Eo=303,To=304,Is=306,Io=1e3,vn=1001,Co=1002,Pt=1003,ep=1004,cM=1004,us=1005,uM=1005,wt=1006,_o=1007,dM=1007,Nn=1008,hM=1008,ui=1009,Ey=1010,Ty=1011,tp=1012,np=1013,mr=1014,xn=1015,pa=1016,ip=1017,rp=1018,Cs=1020,Iy=35902,Cy=1021,Ry=1022,rn=1023,Py=1024,Ly=1025,fr=1026,gs=1027,sp=1028,op=1029,Dy=1030,ap=1031,lp=1033,ic=33776,rc=33777,sc=33778,oc=33779,ah=35840,lh=35841,ch=35842,uh=35843,dh=36196,hh=37492,fh=37496,ph=37808,mh=37809,gh=37810,yh=37811,vh=37812,xh=37813,_h=37814,bh=37815,wh=37816,Mh=37817,Sh=37818,Ah=37819,Eh=37820,Th=37821,ac=36492,Ih=36494,Ch=36495,Oy=36283,Rh=36284,Ph=36285,Lh=36286,Uy=2200,Ny=2201,Fy=2202,Ro=2300,Po=2301,lc=2302,cr=2400,ur=2401,Lo=2402,Mu=2500,cp=2501,fM=0,pM=1,mM=2,ky=3200,By=3201,ki=0,zy=1,ei="",yn="srgb",fi="srgb-linear",Su="display-p3",ma="display-p3-linear",Do="linear",dt="srgb",Oo="rec709",Uo="p3",gM=0,or=7680,yM=7681,vM=7682,xM=7683,_M=34055,bM=34056,wM=5386,MM=512,SM=513,AM=514,EM=515,TM=516,IM=517,CM=518,Dh=519,Vy=512,Hy=513,Gy=514,up=515,$y=516,Wy=517,jy=518,Xy=519,No=35044,RM=35048,PM=35040,LM=35045,DM=35049,OM=35041,UM=35046,NM=35050,FM=35042,kM="100",Oh="300 es",Fn=2e3,Fo=2001,Cn=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}}},zt=["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"],ug=1234567,pr=Math.PI/180,ys=180/Math.PI;tS={DEG2RAD:pr,RAD2DEG:ys,generateUUID:sn,clamp:yt,euclideanModulo:dp,mapLinear:BM,inverseLerp:zM,lerp:bo,damp:VM,pingpong:HM,smoothstep:GM,smootherstep:$M,randInt:WM,randFloat:jM,randFloatSpread:XM,seededRandom:YM,degToRad:qM,radToDeg:ZM,isPowerOfTwo:JM,ceilPowerOfTwo:KM,floorPowerOfTwo:QM,setQuaternionFromProperEuler:eS,normalize:Ge,denormalize:Xt},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(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],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(vd.makeScale(e,t)),this}rotate(e){return this.premultiply(vd.makeRotation(-e)),this}translate(e,t){return this.premultiply(vd.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)}},vd=new He;nS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};dg={};hg=new He().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),fg=new He().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),dl={[fi]:{transfer:Do,primaries:Oo,toReference:n=>n,fromReference:n=>n},[yn]:{transfer:dt,primaries:Oo,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[ma]:{transfer:Do,primaries:Uo,toReference:n=>n.applyMatrix3(fg),fromReference:n=>n.applyMatrix3(hg)},[Su]:{transfer:dt,primaries:Uo,toReference:n=>n.convertSRGBToLinear().applyMatrix3(fg),fromReference:n=>n.applyMatrix3(hg).convertLinearToSRGB()}},iS=new Set([fi,ma]),at={enabled:!0,_workingColorSpace:fi,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!iS.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=dl[e].toReference,r=dl[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 dl[n].primaries},getTransfer:function(n){return n===ei?Do:dl[n].transfer}};dc=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{Hr===void 0&&(Hr=ko("canvas")),Hr.width=e.width,Hr.height=e.height;let i=Hr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Hr}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=ko("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]=ps(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(ps(t[i]/255)*255):t[i]=ps(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}},rS=0,ni=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:rS++}),this.uuid=sn(),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(_d(r[o].image)):s.push(_d(r[o]))}else s=_d(r);i.url=s}return t||(e.images[this.uuid]=i),i}};sS=0,Mt=class n extends Cn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=vn,r=vn,s=wt,o=Nn,a=rn,l=ui,c=n.DEFAULT_ANISOTROPY,u=ei){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:sS++}),this.uuid=sn(),this.name="",this.source=new ni(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 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!==wu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Io:e.x=e.x-Math.floor(e.x);break;case vn:e.x=e.x<0?0:1;break;case Co: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 Io:e.y=e.y-Math.floor(e.y);break;case vn:e.y=e.y<0?0:1;break;case Co: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=wu;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],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}},hc=class extends Cn{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 ni(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"})}},on=class extends hc{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},vs=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=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Uh=class extends on{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new vs(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Bo=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=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Nh=class extends on{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Bo(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Gt=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(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}},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(pg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(pg.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 bd.copy(this).projectOnVector(e),this.sub(bd)}reflect(e){return this.sub(bd.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}},bd=new R,pg=new Gt,Ot=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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(An.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=An.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,An):An.fromBufferAttribute(s,o),An.applyMatrix4(e.matrixWorld),this.expandByPoint(An);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),hl.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),hl.copy(i.boundingBox)),hl.applyMatrix4(e.matrixWorld),this.union(hl)}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,An),An.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(so),fl.subVectors(this.max,so),Gr.subVectors(e.a,so),$r.subVectors(e.b,so),Wr.subVectors(e.c,so),Mi.subVectors($r,Gr),Si.subVectors(Wr,$r),Yi.subVectors(Gr,Wr);let t=[0,-Mi.z,Mi.y,0,-Si.z,Si.y,0,-Yi.z,Yi.y,Mi.z,0,-Mi.x,Si.z,0,-Si.x,Yi.z,0,-Yi.x,-Mi.y,Mi.x,0,-Si.y,Si.x,0,-Yi.y,Yi.x,0];return!wd(t,Gr,$r,Wr,fl)||(t=[1,0,0,0,1,0,0,0,1],!wd(t,Gr,$r,Wr,fl))?!1:(pl.crossVectors(Mi,Si),t=[pl.x,pl.y,pl.z],wd(t,Gr,$r,Wr,fl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(An).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:(Yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yn),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)}},Yn=[new R,new R,new R,new R,new R,new R,new R,new R],An=new R,hl=new Ot,Gr=new R,$r=new R,Wr=new R,Mi=new R,Si=new R,Yi=new R,so=new R,fl=new R,pl=new R,qi=new R;oS=new Ot,oo=new R,Md=new R,Lt=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):oS.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;oo.subVectors(e,this.center);let t=oo.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(oo,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):(Md.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oo.copy(e.center).add(Md)),this.expandByPoint(oo.copy(e.center).sub(Md))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},qn=new R,Sd=new R,ml=new R,Ai=new R,Ad=new R,gl=new R,Ed=new R,Oi=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,qn)),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=qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qn.copy(this.origin).addScaledVector(this.direction,t),qn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Sd.copy(e).add(t).multiplyScalar(.5),ml.copy(t).sub(e).normalize(),Ai.copy(this.origin).sub(Sd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(ml),a=Ai.dot(this.direction),l=-Ai.dot(ml),c=Ai.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(Sd).addScaledVector(ml,h),f}intersectSphere(e,t){qn.subVectors(e.center,this.origin);let i=qn.dot(this.direction),r=qn.dot(qn)-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,qn)!==null}intersectTriangle(e,t,i,r,s){Ad.subVectors(t,e),gl.subVectors(i,e),Ed.crossVectors(Ad,gl);let o=this.direction.dot(Ed),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ai.subVectors(this.origin,e);let l=a*this.direction.dot(gl.crossVectors(Ai,gl));if(l<0)return null;let c=a*this.direction.dot(Ad.cross(Ai));if(c<0||l+c>o)return null;let u=-a*Ai.dot(Ed);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/jr.setFromMatrixColumn(e,0).length(),s=1/jr.setFromMatrixColumn(e,1).length(),o=1/jr.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(aS,e,lS)}lookAt(e,t,i){let r=this.elements;return tn.subVectors(e,t),tn.lengthSq()===0&&(tn.z=1),tn.normalize(),Ei.crossVectors(i,tn),Ei.lengthSq()===0&&(Math.abs(i.z)===1?tn.x+=1e-4:tn.z+=1e-4,tn.normalize(),Ei.crossVectors(i,tn)),Ei.normalize(),yl.crossVectors(tn,Ei),r[0]=Ei.x,r[4]=yl.x,r[8]=tn.x,r[1]=Ei.y,r[5]=yl.y,r[9]=tn.y,r[2]=Ei.z,r[6]=yl.z,r[10]=tn.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=jr.set(r[0],r[1],r[2]).length(),o=jr.set(r[4],r[5],r[6]).length(),a=jr.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],En.copy(this);let c=1/s,u=1/o,d=1/a;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=u,En.elements[5]*=u,En.elements[6]*=u,En.elements[8]*=d,En.elements[9]*=d,En.elements[10]*=d,t.setFromRotationMatrix(En),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Fn){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===Fn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===Fo)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=Fn){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===Fn)p=(o+s)*d,y=-2*d;else if(a===Fo)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}},jr=new R,En=new Ne,aS=new R(0,0,0),lS=new R(1,1,1),Ei=new R,yl=new R,tn=new R,mg=new Ne,gg=new Gt,an=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 mg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gg.setFromEuler(this),this.setFromQuaternion(gg,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}};an.DEFAULT_ORDER="XYZ";xs=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}},cS=0,yg=new R,Xr=new Gt,Zn=new Ne,vl=new R,ao=new R,uS=new R,dS=new Gt,vg=new R(1,0,0),xg=new R(0,1,0),_g=new R(0,0,1),bg={type:"added"},hS={type:"removed"},Yr={type:"childadded",child:null},Td={type:"childremoved",child:null},rt=class n extends Cn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cS++}),this.uuid=sn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new R,t=new an,i=new Gt,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 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 xs,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 Xr.setFromAxisAngle(e,t),this.quaternion.multiply(Xr),this}rotateOnWorldAxis(e,t){return Xr.setFromAxisAngle(e,t),this.quaternion.premultiply(Xr),this}rotateX(e){return this.rotateOnAxis(vg,e)}rotateY(e){return this.rotateOnAxis(xg,e)}rotateZ(e){return this.rotateOnAxis(_g,e)}translateOnAxis(e,t){return yg.copy(e).applyQuaternion(this.quaternion),this.position.add(yg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vg,e)}translateY(e){return this.translateOnAxis(xg,e)}translateZ(e){return this.translateOnAxis(_g,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?vl.copy(e):vl.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),ao.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(ao,vl,this.up):Zn.lookAt(vl,ao,this.up),this.quaternion.setFromRotationMatrix(Zn),r&&(Zn.extractRotation(r.matrixWorld),Xr.setFromRotationMatrix(Zn),this.quaternion.premultiply(Xr.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(bg),Yr.child=e,this.dispatchEvent(Yr),Yr.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(hS),Td.child=e,this.dispatchEvent(Td),Td.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),Zn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bg),Yr.child=e,this.dispatchEvent(Yr),Yr.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(ao,e,uS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ao,dS,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}};rt.DEFAULT_UP=new R(0,1,0);rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Tn=new R,Jn=new R,Id=new R,Kn=new R,qr=new R,Zr=new R,wg=new R,Cd=new R,Rd=new R,Pd=new R,ii=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),Tn.subVectors(e,t),r.cross(Tn);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){Tn.subVectors(r,t),Jn.subVectors(i,t),Id.subVectors(e,t);let o=Tn.dot(Tn),a=Tn.dot(Jn),l=Tn.dot(Id),c=Jn.dot(Jn),u=Jn.dot(Id),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,Kn)===null?!1:Kn.x>=0&&Kn.y>=0&&Kn.x+Kn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Kn)===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,Kn.x),l.addScaledVector(o,Kn.y),l.addScaledVector(a,Kn.z),l)}static isFrontFacing(e,t,i,r){return Tn.subVectors(i,t),Jn.subVectors(e,t),Tn.cross(Jn).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 Tn.subVectors(this.c,this.b),Jn.subVectors(this.a,this.b),Tn.cross(Jn).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;qr.subVectors(r,i),Zr.subVectors(s,i),Cd.subVectors(e,i);let l=qr.dot(Cd),c=Zr.dot(Cd);if(l<=0&&c<=0)return t.copy(i);Rd.subVectors(e,r);let u=qr.dot(Rd),d=Zr.dot(Rd);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(qr,o);Pd.subVectors(e,s);let f=qr.dot(Pd),p=Zr.dot(Pd);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(Zr,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return wg.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(wg,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(qr,o).addScaledVector(Zr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Jy={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},Ti={h:0,s:0,l:0},xl={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=yn){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=dp(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=Ld(o,s,e+1/3),this.g=Ld(o,s,e),this.b=Ld(o,s,e-1/3)}return at.toWorkingColorSpace(this,r),this}setStyle(e,t=yn){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=yn){let i=Jy[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=ps(e.r),this.g=ps(e.g),this.b=ps(e.b),this}copyLinearToSRGB(e){return this.r=xd(e.r),this.g=xd(e.g),this.b=xd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yn){return at.fromWorkingColorSpace(Vt.copy(this),e),Math.round(yt(Vt.r*255,0,255))*65536+Math.round(yt(Vt.g*255,0,255))*256+Math.round(yt(Vt.b*255,0,255))}getHexString(e=yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=at.workingColorSpace){at.fromWorkingColorSpace(Vt.copy(this),t);let i=Vt.r,r=Vt.g,s=Vt.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(Vt.copy(this),t),e.r=Vt.r,e.g=Vt.g,e.b=Vt.b,e}getStyle(e=yn){at.fromWorkingColorSpace(Vt.copy(this),e);let t=Vt.r,i=Vt.g,r=Vt.b;return e!==yn?`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(Ti),this.setHSL(Ti.h+e,Ti.s+t,Ti.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(Ti),e.getHSL(xl);let i=bo(Ti.h,xl.h,t),r=bo(Ti.s,xl.s,t),s=bo(Ti.l,xl.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}},Vt=new we;we.NAMES=Jy;fS=0,Dt=class extends Cn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:fS++}),this.uuid=sn(),this.name="",this.type="Material",this.blending=hr,this.side=li,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cc,this.blendDst=uc,this.blendEquation=Pi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=Ao,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Dh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=or,this.stencilZFail=or,this.stencilZPass=or,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!==hr&&(i.blending=this.blending),this.side!==li&&(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!==cc&&(i.blendSrc=this.blendSrc),this.blendDst!==uc&&(i.blendDst=this.blendDst),this.blendEquation!==Pi&&(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!==Ao&&(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!==Dh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==or&&(i.stencilFail=this.stencilFail),this.stencilZFail!==or&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==or&&(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++}},zn=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 an,this.combine=fa,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}},ti=pS();mS={toHalfFloat:Jt,fromHalfFloat:vo},bt=new R,_l=new te,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=No,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Zy("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++)_l.fromBufferAttribute(this,t),_l.applyMatrix3(e),this.setXY(t,_l.x,_l.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=Xt(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=Xt(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=Xt(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=Xt(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=Xt(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!==No&&(e.usage=this.usage),e}},Fh=class extends nt{constructor(e,t,i){super(new Int8Array(e),t,i)}},kh=class extends nt{constructor(e,t,i){super(new Uint8Array(e),t,i)}},Bh=class extends nt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},zh=class extends nt{constructor(e,t,i){super(new Int16Array(e),t,i)}},zo=class extends nt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},Vh=class extends nt{constructor(e,t,i){super(new Int32Array(e),t,i)}},Vo=class extends nt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},Hh=class extends nt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=vo(this.array[e*this.itemSize]);return this.normalized&&(t=Xt(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize]=Jt(t),this}getY(e){let t=vo(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xt(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+1]=Jt(t),this}getZ(e){let t=vo(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+2]=Jt(t),this}getW(e){let t=vo(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xt(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+3]=Jt(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]=Jt(t),this.array[e+1]=Jt(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]=Jt(t),this.array[e+1]=Jt(i),this.array[e+2]=Jt(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]=Jt(t),this.array[e+1]=Jt(i),this.array[e+2]=Jt(r),this.array[e+3]=Jt(s),this}},Te=class extends nt{constructor(e,t,i){super(new Float32Array(e),t,i)}},gS=0,gn=new Ne,Dd=new rt,Jr=new R,nn=new Ot,lo=new Ot,Rt=new R,Ye=class n extends Cn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gS++}),this.uuid=sn(),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(Yy(e)?Vo:zo)(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 gn.makeRotationFromQuaternion(e),this.applyMatrix4(gn),this}rotateX(e){return gn.makeRotationX(e),this.applyMatrix4(gn),this}rotateY(e){return gn.makeRotationY(e),this.applyMatrix4(gn),this}rotateZ(e){return gn.makeRotationZ(e),this.applyMatrix4(gn),this}translate(e,t,i){return gn.makeTranslation(e,t,i),this.applyMatrix4(gn),this}scale(e,t,i){return gn.makeScale(e,t,i),this.applyMatrix4(gn),this}lookAt(e){return Dd.lookAt(e),Dd.updateMatrix(),this.applyMatrix4(Dd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jr).negate(),this.translate(Jr.x,Jr.y,Jr.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 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];nn.setFromBufferAttribute(s),this.morphTargetsRelative?(Rt.addVectors(this.boundingBox.min,nn.min),this.boundingBox.expandByPoint(Rt),Rt.addVectors(this.boundingBox.max,nn.max),this.boundingBox.expandByPoint(Rt)):(this.boundingBox.expandByPoint(nn.min),this.boundingBox.expandByPoint(nn.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 R,1/0);return}if(e){let i=this.boundingSphere.center;if(nn.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];lo.setFromBufferAttribute(a),this.morphTargetsRelative?(Rt.addVectors(nn.min,lo.min),nn.expandByPoint(Rt),Rt.addVectors(nn.max,lo.max),nn.expandByPoint(Rt)):(nn.expandByPoint(lo.min),nn.expandByPoint(lo.max))}nn.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&&(Jr.fromBufferAttribute(e,c),Rt.add(Jr)),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 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 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 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++)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,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 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"})}},Mg=new Ne,Zi=new Oi,bl=new Lt,Sg=new R,Kr=new R,Qr=new R,es=new R,Od=new R,wl=new R,Ml=new te,Sl=new te,Al=new te,Ag=new R,Eg=new R,Tg=new R,El=new R,Tl=new R,vt=class extends rt{constructor(e=new Ye,t=new zn){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){wl.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],d=s[l];u!==0&&(Od.fromBufferAttribute(d,e),o?wl.addScaledVector(Od,u):wl.addScaledVector(Od.sub(t),u))}t.add(wl)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),bl.copy(i.boundingSphere),bl.applyMatrix4(s),Zi.copy(e.ray).recast(e.near),!(bl.containsPoint(Zi.origin)===!1&&(Zi.intersectSphere(bl,Sg)===null||Zi.origin.distanceToSquared(Sg)>(e.far-e.near)**2))&&(Mg.copy(s).invert(),Zi.copy(e.ray).applyMatrix4(Mg),!(i.boundingBox!==null&&Zi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Zi)))}_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=Il(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=Il(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=Il(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=Il(this,o,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};gr=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;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 Ke=Le*w-U;re[y]=Ke*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,Ke=h+ve+W*(se+1),Z=h+(ve+1)+W*(se+1),q=h+(ve+1)+W*se;l.push(Le,Ke,q),l.push(Ke,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)}};Qy={clone:_s,merge:jt},xS=`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 ms(r,y),M=mT(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,aT)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=lT++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=L,this.fragmentShader=A,this}function IT(n,e,t,i,r,s,o){let a=new xs,l=new Xh,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===Is?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 Ke,Z,q,pe;if(re){let tt=In[re];Ke=tt.vertexShader,Z=tt.fragmentShader}else Ke=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,je=ie&&!!M.iridescenceMap,Pe=ie&&!!M.iridescenceThicknessMap,Me=Ce&&!!M.sheenColorMap,De=Ce&&!!M.sheenRoughnessMap,Ze=!!M.specularMap,ft=!!M.specularColorMap,$e=!!M.specularIntensityMap,z=me&&!!M.transmissionMap,ae=me&&!!M.thicknessMap,Q=!!M.gradientMap,xe=!!M.alphaMap,be=M.alphaTest>0,Se=!!M.alphaHash,Qe=!!M.extensions,ct=oi;M.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ct=n.toneMapping);let pt={shaderID:re,shaderType:M.type,shaderName:M.name,vertexShader:Ke,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:fi,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===zy,normalMapTangentSpace:le&&M.normalMapType===ki,metalnessMap:P,roughnessMap:S,anisotropy:j,anisotropyMap:ge,clearcoat:ee,clearcoatMap:ke,clearcoatNormalMap:fe,clearcoatRoughnessMap:Re,dispersion:oe,iridescence:ie,iridescenceMap:je,iridescenceThicknessMap:Pe,sheen:Ce,sheenColorMap:Me,sheenRoughnessMap:De,specularMap:Ze,specularColorMap:ft,specularIntensityMap:$e,transmission:me,transmissionMap:z,thicknessMap:ae,gradientMap:Q,opaque:M.transparent===!1&&M.blending===hr&&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:je&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:Pe&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&y(M.sheenRoughnessMap.channel),specularMapUv:Ze&&y(M.specularMap.channel),specularColorMapUv:ft&&y(M.specularColorMap.channel),specularIntensityMapUv:$e&&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:ct,useLegacyLights:n._useLegacyLights,decodeVideoTexture:H&&M.map.isVideoTexture===!0&&at.getTransfer(M.map.colorSpace)===dt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Un,flipSided:M.side===Yt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Qe&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Qe&&M.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return pt.vertexUv1s=c.has(1),pt.vertexUv2s=c.has(2),pt.vertexUv3s=c.has(3),c.clear(),pt}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=In[w];T=Qy.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 ET(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 CT(){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 RT(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 Yg(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 qg(){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||RT),i.length>1&&i.sort(h||Yg),r.length>1&&r.sort(h||Yg)}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 PT(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new qg,n.set(i,[o])):r>=s.length?(o=new qg,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function LT(){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 DT(){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 UT(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function NT(n){let e=new LT,t=DT(),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(UT);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=OT++)}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 Zg(n){let e=new NT(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 FT(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new Zg(n),e.set(r,[a])):s>=o.length?(a=new Zg(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function zT(n,e,t){let i=new vr,r=new te,s=new te,o=new lt,a=new $o({depthPacking:By}),l=new Wo,c={},u=t.maxTextureSize,d={[li]:Yt,[Yt]:li,[Un]:Un},h=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:kT,fragmentShader:BT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ye;p.setAttribute("position",new nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new vt(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Qf;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(si),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let I=m!==Dn&&this.type===Dn,B=m===Dn&&this.type!==Dn;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!==Dn?{minFilter:Pt,magFilter:Pt}:{};k.map!==null&&k.map.dispose(),k.map=new on(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===Dn&&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 on(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===Dn?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===Dn)&&(!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 VT(n){function e(){let z=!1,ae=new lt,Q=null,xe=new lt(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,Qe,ct,pt){pt===!0&&(be*=ct,Se*=ct,Qe*=ct),ae.set(be,Se,Qe,ct),xe.equals(ae)===!1&&(n.clearColor(be,Se,Qe,ct),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 cy:n.depthFunc(n.NEVER);break;case uy:n.depthFunc(n.ALWAYS);break;case dy:n.depthFunc(n.LESS);break;case Ao:n.depthFunc(n.LEQUAL);break;case hy:n.depthFunc(n.EQUAL);break;case fy:n.depthFunc(n.GEQUAL);break;case py:n.depthFunc(n.GREATER);break;case my: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,Qe=null,ct=null,pt=null;return{setTest:function(tt){z||(tt?pe(n.STENCIL_TEST):ne(n.STENCIL_TEST))},setMask:function(tt){ae!==tt&&!z&&(n.stencilMask(tt),ae=tt)},setFunc:function(tt,qt,St){(Q!==tt||xe!==qt||be!==St)&&(n.stencilFunc(tt,qt,St),Q=tt,xe=qt,be=St)},setOp:function(tt,qt,St){(Se!==tt||Qe!==qt||ct!==St)&&(n.stencilOp(tt,qt,St),Se=tt,Qe=qt,ct=St)},setLocked:function(tt){z=tt},setClear:function(tt){pt!==tt&&(n.clearStencil(tt),pt=tt)},reset:function(){z=!1,ae=null,Q=null,xe=null,be=null,Se=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,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 lt().fromArray(se),Ke=new lt().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 Qe=0;Qe<Q;Qe++)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+Qe,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(Ao),de(!1),le(nh),pe(n.CULL_FACE),ce(si);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,Qe=be.length;Se<Qe;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={[Pi]:n.FUNC_ADD,[j0]:n.FUNC_SUBTRACT,[X0]:n.FUNC_REVERSE_SUBTRACT};Ue[Y0]=n.MIN,Ue[q0]=n.MAX;let J={[Z0]:n.ZERO,[J0]:n.ONE,[K0]:n.SRC_COLOR,[cc]:n.SRC_ALPHA,[ry]:n.SRC_ALPHA_SATURATE,[ny]:n.DST_COLOR,[ey]:n.DST_ALPHA,[Q0]:n.ONE_MINUS_SRC_COLOR,[uc]:n.ONE_MINUS_SRC_ALPHA,[iy]:n.ONE_MINUS_DST_COLOR,[ty]:n.ONE_MINUS_DST_ALPHA,[sy]:n.CONSTANT_COLOR,[oy]:n.ONE_MINUS_CONSTANT_COLOR,[ay]:n.CONSTANT_ALPHA,[ly]:n.ONE_MINUS_CONSTANT_ALPHA};function ce(z,ae,Q,xe,be,Se,Qe,ct,pt,tt){if(z===si){p===!0&&(ne(n.BLEND),p=!1);return}if(p===!1&&(pe(n.BLEND),p=!0),z!==W0){if(z!==y||tt!==D){if((g!==Pi||v!==Pi)&&(n.blendEquation(n.FUNC_ADD),g=Pi,v=Pi),tt)switch(z){case hr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ih:n.blendFunc(n.ONE,n.ONE);break;case rh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case sh: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 hr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ih:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case rh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case sh: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=tt}return}be=be||ae,Se=Se||Q,Qe=Qe||xe,(ae!==g||be!==v)&&(n.blendEquationSeparate(Ue[ae],Ue[be]),g=ae,v=be),(Q!==m||xe!==x||Se!==b||Qe!==L)&&(n.blendFuncSeparate(J[Q],J[xe],J[Se],J[Qe]),m=Q,x=xe,b=Se,L=Qe),(ct.equals(A)===!1||pt!==E)&&(n.blendColor(ct.r,ct.g,ct.b,pt),A.copy(ct),E=pt),y=z,D=!1}function K(z,ae){z.side===Un?ne(n.CULL_FACE):pe(n.CULL_FACE);let Q=z.side===Yt;ae&&(Q=!Q),de(Q),z.blending===hr&&z.transparent===!1?ce(si):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!==H0?(pe(n.CULL_FACE),z!==w&&(z===nh?n.cullFace(n.BACK):z===G0?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 je(){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){Ke.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),Ke.copy(z))}function Ze(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 ft(z,ae){let xe=l.get(ae).get(z);a.get(ae)!==xe&&(n.uniformBlockBinding(ae,xe,z.__bindingPointIndex),a.set(ae,xe))}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,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),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: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:je,texImage3D:Pe,updateUBOMapping:Ze,uniformBlockBinding:ft,texStorage2D:fe,texStorage3D:Re,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:ge,compressedTexSubImage3D:ke,scissor:Me,viewport:De,reset:$e}}function HT(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):ko("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!==Pt&&P.minFilter!==wt}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?Do:at.getTransfer(ee);j===n.FLOAT&&(ie=n.RGBA32F),j===n.HALF_FLOAT&&(ie=n.RGBA16F),j===n.UNSIGNED_BYTE&&(ie=Ce===dt?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!==Pt&&P.minFilter!==wt?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){Ke(j,P,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+S)}let X={[Io]:n.REPEAT,[vn]:n.CLAMP_TO_EDGE,[Co]:n.MIRRORED_REPEAT},k={[Pt]:n.NEAREST,[ep]:n.NEAREST_MIPMAP_NEAREST,[us]:n.NEAREST_MIPMAP_LINEAR,[wt]:n.LINEAR,[_o]:n.LINEAR_MIPMAP_NEAREST,[Nn]:n.LINEAR_MIPMAP_LINEAR},re={[Vy]:n.NEVER,[Xy]:n.ALWAYS,[Hy]:n.LESS,[up]:n.LEQUAL,[Gy]:n.EQUAL,[jy]:n.GEQUAL,[$y]:n.GREATER,[Wy]:n.NOTEQUAL};function se(P,S){if(S.type===xn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===wt||S.magFilter===_o||S.magFilter===us||S.magFilter===Nn||S.minFilter===wt||S.minFilter===_o||S.minFilter===us||S.minFilter===Nn)&&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===Pt||S.minFilter!==us&&S.minFilter!==Nn||S.type===xn&&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=at.getPrimaries(at.workingColorSpace),ge=S.colorSpace===ei?null:at.getPrimaries(S.colorSpace),ke=S.colorSpace===ei||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),je=s.convert(S.type),Pe=x(S.internalFormat,Re,je,S.colorSpace,S.isVideoTexture);se(ee,S);let Me,De=S.mipmaps,Ze=S.isVideoTexture!==!0,ft=Ce.__version===void 0||oe===!0,$e=ie.dataReady,z=v(S,fe);if(S.isDepthTexture)Pe=n.DEPTH_COMPONENT16,S.type===xn?Pe=n.DEPTH_COMPONENT32F:S.type===mr?Pe=n.DEPTH_COMPONENT24:S.type===Cs&&(Pe=n.DEPTH24_STENCIL8),ft&&(Ze?t.texStorage2D(n.TEXTURE_2D,1,Pe,fe.width,fe.height):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,je,null));else if(S.isDataTexture)if(De.length>0){Ze&&ft&&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],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,je,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,je,Me.data);S.generateMipmaps=!1}else Ze?(ft&&t.texStorage2D(n.TEXTURE_2D,z,Pe,fe.width,fe.height),$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,fe.width,fe.height,Re,je,fe.data)):t.texImage2D(n.TEXTURE_2D,0,Pe,fe.width,fe.height,0,Re,je,fe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){Ze&&ft&&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!==rn?Re!==null?Ze?$e&&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()"):Ze?$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,Me.width,Me.height,fe.depth,Re,je,Me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Pe,Me.width,Me.height,fe.depth,0,Re,je,Me.data)}else{Ze&&ft&&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!==rn?Re!==null?Ze?$e&&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()"):Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Me.width,Me.height,Re,je,Me.data):t.texImage2D(n.TEXTURE_2D,ae,Pe,Me.width,Me.height,0,Re,je,Me.data)}else if(S.isDataArrayTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Pe,fe.width,fe.height,fe.depth),$e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,fe.width,fe.height,fe.depth,Re,je,fe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Pe,fe.width,fe.height,fe.depth,0,Re,je,fe.data);else if(S.isData3DTexture)Ze?(ft&&t.texStorage3D(n.TEXTURE_3D,z,Pe,fe.width,fe.height,fe.depth),$e&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,fe.width,fe.height,fe.depth,Re,je,fe.data)):t.texImage3D(n.TEXTURE_3D,0,Pe,fe.width,fe.height,fe.depth,0,Re,je,fe.data);else if(S.isFramebufferTexture){if(ft)if(Ze)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,je,null),ae>>=1,Q>>=1}}else if(De.length>0){if(Ze&&ft){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],Ze?$e&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Re,je,Me):t.texImage2D(n.TEXTURE_2D,ae,Pe,Re,je,Me);S.generateMipmaps=!1}else if(Ze){if(ft){let ae=Ae(fe);t.texStorage2D(n.TEXTURE_2D,z,Pe,ae.width,ae.height)}$e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Re,je,fe)}else t.texImage2D(n.TEXTURE_2D,0,Pe,Re,je,fe);g(S)&&m(ee),Ce.__version=ie.version,S.onUpdate&&S.onUpdate(S)}P.__version=S.version}function Ke(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=at.getPrimaries(at.workingColorSpace),me=S.colorSpace===ei?null:at.getPrimaries(S.colorSpace),ge=S.colorSpace===ei||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 je=Re[0],Pe=s.convert(S.format,S.colorSpace),Me=s.convert(S.type),De=x(S.internalFormat,Pe,Me,S.colorSpace),Ze=S.isVideoTexture!==!0,ft=ie.__version===void 0||ee===!0,$e=oe.dataReady,z=v(S,je);se(n.TEXTURE_CUBE_MAP,S);let ae;if(ke){Ze&&ft&&t.texStorage2D(n.TEXTURE_CUBE_MAP,z,De,je.width,je.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!==rn?Pe!==null?Ze?$e&&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()"):Ze?$e&&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,Ze&&ft){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){Ze?$e&&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;Ze?$e&&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{Ze?$e&&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];Ze?$e&&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===xn?ee=n.DEPTH_COMPONENT32F:oe.type===mr&&(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===fr)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===gs)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),je=K(P);n.renderbufferStorageMultisample(n.RENDERBUFFER,je,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!==fi&&j!==ei&&(at.getTransfer(j)===dt?(ee!==rn||oe!==ui)&&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 ov(n,e){function t(i,r=ei){let s,o=at.getTransfer(r);if(i===ui)return n.UNSIGNED_BYTE;if(i===ip)return n.UNSIGNED_SHORT_4_4_4_4;if(i===rp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Iy)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Ey)return n.BYTE;if(i===Ty)return n.SHORT;if(i===tp)return n.UNSIGNED_SHORT;if(i===np)return n.INT;if(i===mr)return n.UNSIGNED_INT;if(i===xn)return n.FLOAT;if(i===pa)return n.HALF_FLOAT;if(i===Cy)return n.ALPHA;if(i===Ry)return n.RGB;if(i===rn)return n.RGBA;if(i===Py)return n.LUMINANCE;if(i===Ly)return n.LUMINANCE_ALPHA;if(i===fr)return n.DEPTH_COMPONENT;if(i===gs)return n.DEPTH_STENCIL;if(i===sp)return n.RED;if(i===op)return n.RED_INTEGER;if(i===Dy)return n.RG;if(i===ap)return n.RG_INTEGER;if(i===lp)return n.RGBA_INTEGER;if(i===ic||i===rc||i===sc||i===oc)if(o===dt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ic)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===sc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===oc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ic)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===sc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===oc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ah||i===lh||i===ch||i===uh)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===lh)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ch)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===uh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===dh||i===hh||i===fh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===dh||i===hh)return o===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===fh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===ph||i===mh||i===gh||i===yh||i===vh||i===xh||i===_h||i===bh||i===wh||i===Mh||i===Sh||i===Ah||i===Eh||i===Th)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===ph)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===mh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===gh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===yh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===vh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===xh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===_h)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===bh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===wh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Mh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Sh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ah)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Eh)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Th)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ac||i===Ih||i===Ch)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===ac)return o===dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ih)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ch)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Oy||i===Rh||i===Ph||i===Lh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===ac)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Rh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ph)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Lh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Cs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function XT(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,Ky(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===Yt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===Yt&&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,Qi.copy(b),Qi.x*=-1,Qi.y*=-1,Qi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Qi.y*=-1,Qi.z*=-1),g.envMapRotation.value.setFromMatrix4(jT.makeRotationFromEuler(Qi)),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===Yt&&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 YT(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 Ol(n,e,t,i,r,s){as.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(uo.x=s*as.x-r*as.y,uo.y=r*as.x+s*as.y):uo.copy(as),n.copy(e),n.x+=uo.x,n.y+=uo.y,n.applyMatrix4(av)}function KT(n,e){return n.z-e.z}function QT(n,e){return e.z-n.z}function tI(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 Vl(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(Ac.fromBufferAttribute(o,r),Ec.fromBufferAttribute(o,s),t.distanceSqToSegment(Ac,Ec,Xd,d0)>i)return;Xd.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(Xd);if(!(l<e.near||l>e.far))return{distance:l,point:d0.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function m0(n,e,t,i,r,s,o){let a=Qh.distanceSqToPoint(n);if(a<t){let l=new R;Qh.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 fp(){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 g0(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 nI(n,e){let t=1-n;return t*t*e}function iI(n,e){return 2*(1-n)*n*e}function rI(n,e){return n*n*e}function Mo(n,e,t,i){return nI(n,e)+iI(n,t)+rI(n,i)}function sI(n,e){let t=1-n;return t*t*t*e}function oI(n,e){let t=1-n;return 3*t*t*n*e}function aI(n,e){return 3*(1-n)*n*n*e}function lI(n,e){return n*n*n*e}function So(n,e,t,i,r){return sI(n,e)+oI(n,t)+aI(n,i)+lI(n,r)}function lv(n,e,t,i,r){let s,o;if(r===AI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=y0(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=y0(s,n[s],n[s+1],o);return o&&Eu(o,o.next)&&(ia(o),o=o.next),o}function br(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Eu(t,t.next)||mt(t.prev,t,t.next)===0)){if(ia(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ta(n,e,t,i,r,s,o){if(!n)return;!o&&s&&xI(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?dI(n,i,r,s):uI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),ia(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=hI(br(n),e,t),ta(n,e,t,i,r,s,2)):o===2&&fI(n,e,t,i,r,s):ta(br(n),e,t,i,r,s,1);break}}}function uI(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,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&fs(r,a,s,l,o,c,p.x,p.y)&&mt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function dI(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,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=of(f,p,e,t,i),x=of(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&&fs(a,u,l,d,c,h,v.x,v.y)&&mt(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&&fs(a,u,l,d,c,h,b.x,b.y)&&mt(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&&fs(a,u,l,d,c,h,v.x,v.y)&&mt(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&&fs(a,u,l,d,c,h,b.x,b.y)&&mt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hI(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!Eu(r,s)&&cv(r,i,i.next,s)&&na(r,s)&&na(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),ia(i),ia(i.next),i=n=s),i=i.next}while(i!==n);return br(i)}function fI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&wI(o,a)){let l=uv(o,a);o=br(o,o.next),l=br(l,l.next),ta(o,e,t,i,r,s,0),ta(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function pI(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=lv(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(bI(c));for(r.sort(mI),s=0;s<r.length;s++)t=gI(r[s],t);return t}function mI(n,e){return n.x-e.x}function gI(n,e){let t=yI(n,e);if(!t)return e;let i=uv(t,n);return br(i,i.next),br(t,t.next)}function yI(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&&fs(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),na(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&vI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function vI(n,e){return mt(n.prev,n,e.prev)<0&&mt(e.next,n,n.next)<0}function xI(n,e,t,i){let r=n;do r.z===0&&(r.z=of(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,_I(r)}function _I(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 of(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 bI(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 fs(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 wI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!MI(n,e)&&(na(n,e)&&na(e,n)&&SI(n,e)&&(mt(n.prev,n,e.prev)||mt(n,e.prev,e))||Eu(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 Eu(n,e){return n.x===e.x&&n.y===e.y}function cv(n,e,t,i){let r=ql(mt(n,e,t)),s=ql(mt(n,e,i)),o=ql(mt(t,i,n)),a=ql(mt(t,i,e));return!!(r!==s&&o!==a||r===0&&Yl(n,t,e)||s===0&&Yl(n,i,e)||o===0&&Yl(t,n,i)||a===0&&Yl(t,e,i))}function Yl(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 ql(n){return n>0?1:n<0?-1:0}function MI(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&&cv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function na(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 SI(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 uv(n,e){let t=new af(n.i,n.x,n.y),i=new af(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 y0(n,e,t,i){let r=new af(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 ia(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 af(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 AI(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 v0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function x0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function TI(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 II(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 _0(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 dr(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 dv(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function hv(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 lf(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 pp(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 CI(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=dr(d,c.times.constructor),c.values=dr(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 RI(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 Gt().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")Gt.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=cp,n}function LI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Mr;case"vector":case"vector2":case"vector3":case"vector4":return Sr;case"color":return la;case"quaternion":return Fi;case"bool":case"boolean":return di;case"string":return hi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function DI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=LI(n.type);if(n.times===void 0){let t=[],i=[];pp(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 C0(){return(typeof performance>"u"?Date:performance).now()}function D0(n,e){return n.distance-e.distance}function Df(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++)Df(r[s],e,t,!0)}}function pv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,pv(n.children[t]));return e}function xt(n,e,t,i,r,s,o){ec.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],ec.x,ec.y,ec.z)}}var sM,oM,aM,H0,nh,G0,lM,cM,Qf,$0,Dn,li,Yt,Un,si,hr,ih,rh,sh,W0,Pi,j0,X0,Y0,q0,Z0,J0,K0,Q0,cc,uc,ey,ty,ny,iy,ry,sy,oy,ay,ly,cy,uy,dy,Ao,hy,fy,py,my,fa,gy,yy,oi,vy,xy,_y,by,wy,My,Sy,oh,Ay,wu,ci,Di,Eo,To,Is,Io,vn,Co,Pt,ep,uM,us,dM,wt,_o,hM,Nn,fM,ui,Ey,Ty,tp,np,mr,xn,pa,ip,rp,Cs,Iy,Cy,Ry,rn,Py,Ly,fr,gs,sp,op,Dy,ap,lp,ic,rc,sc,oc,ah,lh,ch,uh,dh,hh,fh,ph,mh,gh,yh,vh,xh,_h,bh,wh,Mh,Sh,Ah,Eh,Th,ac,Ih,Ch,Oy,Rh,Ph,Lh,Uy,Ny,Fy,Ro,Po,lc,cr,ur,Lo,Mu,cp,pM,mM,gM,ky,By,ki,zy,ei,yn,fi,Su,ma,Do,dt,Oo,Uo,yM,or,vM,xM,_M,bM,wM,MM,SM,AM,EM,TM,IM,CM,RM,Dh,Vy,Hy,Gy,up,$y,Wy,jy,Xy,No,PM,LM,DM,OM,UM,NM,FM,kM,BM,Oh,Fn,Fo,Cn,zt,ug,pr,ys,nS,te,He,vd,iS,dg,hg,fg,dl,rS,at,Hr,dc,sS,ni,oS,Mt,lt,hc,on,vs,Uh,Bo,Nh,Gt,R,bd,pg,Ot,Yn,An,hl,Gr,$r,Wr,Mi,Si,Yi,so,fl,pl,qi,aS,oo,Md,Lt,qn,Sd,ml,Ai,Ad,gl,Ed,Oi,Ne,jr,En,lS,cS,Ei,yl,tn,mg,gg,an,xs,uS,yg,Xr,Zn,vl,ao,dS,hS,vg,xg,_g,bg,fS,Yr,Td,rt,Tn,Jn,Id,Kn,qr,Zr,wg,Cd,Rd,Pd,ii,Jy,Ti,xl,we,Vt,pS,Dt,zn,ti,gS,bt,_l,nt,Fh,kh,Bh,zh,zo,Vh,Vo,Hh,Te,yS,gn,Dd,Jr,nn,lo,Rt,Ye,Mg,Zi,bl,Sg,Kr,Qr,es,Od,wl,Ml,Sl,Al,Ag,Eg,Tg,El,Tl,vt,gr,Qy,_S,bS,ln,bs,Ii,Ig,Cg,Et,ts,ns,fc,yr,pc,Ud,wS,MS,On,Ji,Cl,vr,ws,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,N1,F1,k1,B1,z1,V1,H1,G1,$1,W1,j1,X1,Y1,q1,Z1,J1,K1,Q1,eA,tA,nA,iA,rA,sA,oA,aA,lA,cA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,_A,bA,wA,MA,SA,AA,EA,TA,IA,CA,RA,PA,LA,DA,OA,UA,NA,FA,kA,BA,zA,VA,HA,GA,$A,WA,jA,XA,YA,qA,ZA,JA,KA,QA,eE,tE,nE,iE,We,ye,In,Rl,Ki,rE,Ms,hs,Rg,lr,Nd,Pg,Fd,kd,Bd,zd,ar,is,Lg,Ho,Go,tv,nv,iv,rv,sv,Ng,Fg,kg,Bg,zg,Gh,$h,Wh,Vd,ms,aT,lT,gT,yT,xT,TT,Xh,Yh,OT,$o,Wo,kT,BT,mc,Li,GT,wo,$T,WT,qh,Zh,Qi,jT,Jh,gc,yc,vc,Ss,Wt,xr,jo,rs,co,ss,os,as,uo,av,Ll,ho,Dl,Jg,Hd,Kg,xc,Ul,Qg,_c,e0,t0,n0,qT,i0,Nl,Gd,r0,$d,bc,Xo,kn,s0,ZT,wc,Ui,ls,o0,Fl,a0,JT,fo,po,Mc,Kh,cs,Ci,l0,eI,c0,Wd,kl,er,mo,jd,Ht,Bl,Sc,Ut,Ac,Ec,u0,go,zl,Xd,d0,Vn,h0,f0,_n,Tc,Yo,p0,Qh,Hl,Gl,Ic,ef,tf,As,nf,rf,sf,cn,Es,Cc,$l,Yd,qd,Zd,Rc,qo,Pc,Zo,Lc,Jo,Ko,Qo,Dc,Oc,_r,ea,Uc,Nc,Ts,Fc,Ni,kc,Wl,jl,Jd,Xl,Bc,ai,cI,Bn,zc,EI,Vc,ra,Hc,Gc,sa,$c,Wc,jc,Xc,Yc,b0,qc,Zc,oa,Jc,Kc,Qc,eu,tu,nu,iu,PI,wr,ru,aa,su,un,di,la,Mr,ou,Fi,hi,Sr,Ar,ri,ca,fv,$t,Qn,cf,Rn,uf,df,Er,hf,ff,pf,Hn,au,Kd,w0,M0,ua,mf,lu,S0,yo,Qd,gf,cu,yf,uu,du,hu,fu,pu,mu,da,gu,yu,vf,OI,A0,E0,xf,Zl,ha,_f,T0,I0,tr,bf,vu,nr,R0,UI,ir,wf,xu,rr,P0,NI,sr,Mf,Sf,_u,mp,FI,gp,kI,BI,zI,VI,HI,GI,$I,Af,ot,Ef,bu,WI,Tf,If,jI,Cf,Rf,Pf,L0,Lf,Of,Uf,O0,Nf,U0,Jl,Ff,N0,kf,Ri,Kl,eh,Bf,zf,XI,F0,k0,Vf,Hf,Gf,B0,Ql,z0,$f,ec,gt,Wf,tc,jf,Xf,Yf,V0,nc,th,qf,Zf,Jf,Kf,gv=Gv(()=>{"use strict";sM="164",oM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},aM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},H0=0,nh=1,G0=2,lM=3,cM=0,Qf=1,$0=2,Dn=3,li=0,Yt=1,Un=2,si=0,hr=1,ih=2,rh=3,sh=4,W0=5,Pi=100,j0=101,X0=102,Y0=103,q0=104,Z0=200,J0=201,K0=202,Q0=203,cc=204,uc=205,ey=206,ty=207,ny=208,iy=209,ry=210,sy=211,oy=212,ay=213,ly=214,cy=0,uy=1,dy=2,Ao=3,hy=4,fy=5,py=6,my=7,fa=0,gy=1,yy=2,oi=0,vy=1,xy=2,_y=3,by=4,wy=5,My=6,Sy=7,oh="attached",Ay="detached",wu=300,ci=301,Di=302,Eo=303,To=304,Is=306,Io=1e3,vn=1001,Co=1002,Pt=1003,ep=1004,uM=1004,us=1005,dM=1005,wt=1006,_o=1007,hM=1007,Nn=1008,fM=1008,ui=1009,Ey=1010,Ty=1011,tp=1012,np=1013,mr=1014,xn=1015,pa=1016,ip=1017,rp=1018,Cs=1020,Iy=35902,Cy=1021,Ry=1022,rn=1023,Py=1024,Ly=1025,fr=1026,gs=1027,sp=1028,op=1029,Dy=1030,ap=1031,lp=1033,ic=33776,rc=33777,sc=33778,oc=33779,ah=35840,lh=35841,ch=35842,uh=35843,dh=36196,hh=37492,fh=37496,ph=37808,mh=37809,gh=37810,yh=37811,vh=37812,xh=37813,_h=37814,bh=37815,wh=37816,Mh=37817,Sh=37818,Ah=37819,Eh=37820,Th=37821,ac=36492,Ih=36494,Ch=36495,Oy=36283,Rh=36284,Ph=36285,Lh=36286,Uy=2200,Ny=2201,Fy=2202,Ro=2300,Po=2301,lc=2302,cr=2400,ur=2401,Lo=2402,Mu=2500,cp=2501,pM=0,mM=1,gM=2,ky=3200,By=3201,ki=0,zy=1,ei="",yn="srgb",fi="srgb-linear",Su="display-p3",ma="display-p3-linear",Do="linear",dt="srgb",Oo="rec709",Uo="p3",yM=0,or=7680,vM=7681,xM=7682,_M=7683,bM=34055,wM=34056,MM=5386,SM=512,AM=513,EM=514,TM=515,IM=516,CM=517,RM=518,Dh=519,Vy=512,Hy=513,Gy=514,up=515,$y=516,Wy=517,jy=518,Xy=519,No=35044,PM=35048,LM=35040,DM=35045,OM=35049,UM=35041,NM=35046,FM=35050,kM=35042,BM="100",Oh="300 es",Fn=2e3,Fo=2001,Cn=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}}},zt=["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"],ug=1234567,pr=Math.PI/180,ys=180/Math.PI;nS={DEG2RAD:pr,RAD2DEG:ys,generateUUID:sn,clamp:yt,euclideanModulo:dp,mapLinear:zM,inverseLerp:VM,lerp:bo,damp:HM,pingpong:GM,smoothstep:$M,smootherstep:WM,randInt:jM,randFloat:XM,randFloatSpread:YM,seededRandom:qM,degToRad:ZM,radToDeg:JM,isPowerOfTwo:KM,ceilPowerOfTwo:QM,floorPowerOfTwo:eS,setQuaternionFromProperEuler:tS,normalize:Ge,denormalize:Xt},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(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],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(vd.makeScale(e,t)),this}rotate(e){return this.premultiply(vd.makeRotation(-e)),this}translate(e,t){return this.premultiply(vd.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)}},vd=new He;iS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};dg={};hg=new He().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),fg=new He().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),dl={[fi]:{transfer:Do,primaries:Oo,toReference:n=>n,fromReference:n=>n},[yn]:{transfer:dt,primaries:Oo,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[ma]:{transfer:Do,primaries:Uo,toReference:n=>n.applyMatrix3(fg),fromReference:n=>n.applyMatrix3(hg)},[Su]:{transfer:dt,primaries:Uo,toReference:n=>n.convertSRGBToLinear().applyMatrix3(fg),fromReference:n=>n.applyMatrix3(hg).convertLinearToSRGB()}},rS=new Set([fi,ma]),at={enabled:!0,_workingColorSpace:fi,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!rS.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=dl[e].toReference,r=dl[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 dl[n].primaries},getTransfer:function(n){return n===ei?Do:dl[n].transfer}};dc=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{Hr===void 0&&(Hr=ko("canvas")),Hr.width=e.width,Hr.height=e.height;let i=Hr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Hr}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=ko("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]=ps(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(ps(t[i]/255)*255):t[i]=ps(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}},sS=0,ni=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:sS++}),this.uuid=sn(),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(_d(r[o].image)):s.push(_d(r[o]))}else s=_d(r);i.url=s}return t||(e.images[this.uuid]=i),i}};oS=0,Mt=class n extends Cn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=vn,r=vn,s=wt,o=Nn,a=rn,l=ui,c=n.DEFAULT_ANISOTROPY,u=ei){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:oS++}),this.uuid=sn(),this.name="",this.source=new ni(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 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!==wu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Io:e.x=e.x-Math.floor(e.x);break;case vn:e.x=e.x<0?0:1;break;case Co: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 Io:e.y=e.y-Math.floor(e.y);break;case vn:e.y=e.y<0?0:1;break;case Co: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=wu;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],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}},hc=class extends Cn{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 ni(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"})}},on=class extends hc{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},vs=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=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Uh=class extends on{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new vs(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Bo=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=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Nh=class extends on{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Bo(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Gt=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(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}},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(pg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(pg.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 bd.copy(this).projectOnVector(e),this.sub(bd)}reflect(e){return this.sub(bd.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}},bd=new R,pg=new Gt,Ot=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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(An.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=An.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,An):An.fromBufferAttribute(s,o),An.applyMatrix4(e.matrixWorld),this.expandByPoint(An);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),hl.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),hl.copy(i.boundingBox)),hl.applyMatrix4(e.matrixWorld),this.union(hl)}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,An),An.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(so),fl.subVectors(this.max,so),Gr.subVectors(e.a,so),$r.subVectors(e.b,so),Wr.subVectors(e.c,so),Mi.subVectors($r,Gr),Si.subVectors(Wr,$r),Yi.subVectors(Gr,Wr);let t=[0,-Mi.z,Mi.y,0,-Si.z,Si.y,0,-Yi.z,Yi.y,Mi.z,0,-Mi.x,Si.z,0,-Si.x,Yi.z,0,-Yi.x,-Mi.y,Mi.x,0,-Si.y,Si.x,0,-Yi.y,Yi.x,0];return!wd(t,Gr,$r,Wr,fl)||(t=[1,0,0,0,1,0,0,0,1],!wd(t,Gr,$r,Wr,fl))?!1:(pl.crossVectors(Mi,Si),t=[pl.x,pl.y,pl.z],wd(t,Gr,$r,Wr,fl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(An).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:(Yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yn),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)}},Yn=[new R,new R,new R,new R,new R,new R,new R,new R],An=new R,hl=new Ot,Gr=new R,$r=new R,Wr=new R,Mi=new R,Si=new R,Yi=new R,so=new R,fl=new R,pl=new R,qi=new R;aS=new Ot,oo=new R,Md=new R,Lt=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):aS.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;oo.subVectors(e,this.center);let t=oo.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(oo,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):(Md.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oo.copy(e.center).add(Md)),this.expandByPoint(oo.copy(e.center).sub(Md))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},qn=new R,Sd=new R,ml=new R,Ai=new R,Ad=new R,gl=new R,Ed=new R,Oi=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,qn)),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=qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qn.copy(this.origin).addScaledVector(this.direction,t),qn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Sd.copy(e).add(t).multiplyScalar(.5),ml.copy(t).sub(e).normalize(),Ai.copy(this.origin).sub(Sd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(ml),a=Ai.dot(this.direction),l=-Ai.dot(ml),c=Ai.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(Sd).addScaledVector(ml,h),f}intersectSphere(e,t){qn.subVectors(e.center,this.origin);let i=qn.dot(this.direction),r=qn.dot(qn)-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,qn)!==null}intersectTriangle(e,t,i,r,s){Ad.subVectors(t,e),gl.subVectors(i,e),Ed.crossVectors(Ad,gl);let o=this.direction.dot(Ed),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ai.subVectors(this.origin,e);let l=a*this.direction.dot(gl.crossVectors(Ai,gl));if(l<0)return null;let c=a*this.direction.dot(Ad.cross(Ai));if(c<0||l+c>o)return null;let u=-a*Ai.dot(Ed);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/jr.setFromMatrixColumn(e,0).length(),s=1/jr.setFromMatrixColumn(e,1).length(),o=1/jr.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(lS,e,cS)}lookAt(e,t,i){let r=this.elements;return tn.subVectors(e,t),tn.lengthSq()===0&&(tn.z=1),tn.normalize(),Ei.crossVectors(i,tn),Ei.lengthSq()===0&&(Math.abs(i.z)===1?tn.x+=1e-4:tn.z+=1e-4,tn.normalize(),Ei.crossVectors(i,tn)),Ei.normalize(),yl.crossVectors(tn,Ei),r[0]=Ei.x,r[4]=yl.x,r[8]=tn.x,r[1]=Ei.y,r[5]=yl.y,r[9]=tn.y,r[2]=Ei.z,r[6]=yl.z,r[10]=tn.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=jr.set(r[0],r[1],r[2]).length(),o=jr.set(r[4],r[5],r[6]).length(),a=jr.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],En.copy(this);let c=1/s,u=1/o,d=1/a;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=u,En.elements[5]*=u,En.elements[6]*=u,En.elements[8]*=d,En.elements[9]*=d,En.elements[10]*=d,t.setFromRotationMatrix(En),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Fn){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===Fn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===Fo)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=Fn){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===Fn)p=(o+s)*d,y=-2*d;else if(a===Fo)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}},jr=new R,En=new Ne,lS=new R(0,0,0),cS=new R(1,1,1),Ei=new R,yl=new R,tn=new R,mg=new Ne,gg=new Gt,an=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 mg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gg.setFromEuler(this),this.setFromQuaternion(gg,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}};an.DEFAULT_ORDER="XYZ";xs=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}},uS=0,yg=new R,Xr=new Gt,Zn=new Ne,vl=new R,ao=new R,dS=new R,hS=new Gt,vg=new R(1,0,0),xg=new R(0,1,0),_g=new R(0,0,1),bg={type:"added"},fS={type:"removed"},Yr={type:"childadded",child:null},Td={type:"childremoved",child:null},rt=class n extends Cn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uS++}),this.uuid=sn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new R,t=new an,i=new Gt,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 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 xs,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 Xr.setFromAxisAngle(e,t),this.quaternion.multiply(Xr),this}rotateOnWorldAxis(e,t){return Xr.setFromAxisAngle(e,t),this.quaternion.premultiply(Xr),this}rotateX(e){return this.rotateOnAxis(vg,e)}rotateY(e){return this.rotateOnAxis(xg,e)}rotateZ(e){return this.rotateOnAxis(_g,e)}translateOnAxis(e,t){return yg.copy(e).applyQuaternion(this.quaternion),this.position.add(yg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vg,e)}translateY(e){return this.translateOnAxis(xg,e)}translateZ(e){return this.translateOnAxis(_g,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?vl.copy(e):vl.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),ao.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(ao,vl,this.up):Zn.lookAt(vl,ao,this.up),this.quaternion.setFromRotationMatrix(Zn),r&&(Zn.extractRotation(r.matrixWorld),Xr.setFromRotationMatrix(Zn),this.quaternion.premultiply(Xr.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(bg),Yr.child=e,this.dispatchEvent(Yr),Yr.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(fS),Td.child=e,this.dispatchEvent(Td),Td.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),Zn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bg),Yr.child=e,this.dispatchEvent(Yr),Yr.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(ao,e,dS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ao,hS,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}};rt.DEFAULT_UP=new R(0,1,0);rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Tn=new R,Jn=new R,Id=new R,Kn=new R,qr=new R,Zr=new R,wg=new R,Cd=new R,Rd=new R,Pd=new R,ii=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),Tn.subVectors(e,t),r.cross(Tn);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){Tn.subVectors(r,t),Jn.subVectors(i,t),Id.subVectors(e,t);let o=Tn.dot(Tn),a=Tn.dot(Jn),l=Tn.dot(Id),c=Jn.dot(Jn),u=Jn.dot(Id),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,Kn)===null?!1:Kn.x>=0&&Kn.y>=0&&Kn.x+Kn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Kn)===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,Kn.x),l.addScaledVector(o,Kn.y),l.addScaledVector(a,Kn.z),l)}static isFrontFacing(e,t,i,r){return Tn.subVectors(i,t),Jn.subVectors(e,t),Tn.cross(Jn).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 Tn.subVectors(this.c,this.b),Jn.subVectors(this.a,this.b),Tn.cross(Jn).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;qr.subVectors(r,i),Zr.subVectors(s,i),Cd.subVectors(e,i);let l=qr.dot(Cd),c=Zr.dot(Cd);if(l<=0&&c<=0)return t.copy(i);Rd.subVectors(e,r);let u=qr.dot(Rd),d=Zr.dot(Rd);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(qr,o);Pd.subVectors(e,s);let f=qr.dot(Pd),p=Zr.dot(Pd);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(Zr,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return wg.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(wg,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(qr,o).addScaledVector(Zr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Jy={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},Ti={h:0,s:0,l:0},xl={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=yn){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=dp(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=Ld(o,s,e+1/3),this.g=Ld(o,s,e),this.b=Ld(o,s,e-1/3)}return at.toWorkingColorSpace(this,r),this}setStyle(e,t=yn){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=yn){let i=Jy[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=ps(e.r),this.g=ps(e.g),this.b=ps(e.b),this}copyLinearToSRGB(e){return this.r=xd(e.r),this.g=xd(e.g),this.b=xd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yn){return at.fromWorkingColorSpace(Vt.copy(this),e),Math.round(yt(Vt.r*255,0,255))*65536+Math.round(yt(Vt.g*255,0,255))*256+Math.round(yt(Vt.b*255,0,255))}getHexString(e=yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=at.workingColorSpace){at.fromWorkingColorSpace(Vt.copy(this),t);let i=Vt.r,r=Vt.g,s=Vt.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(Vt.copy(this),t),e.r=Vt.r,e.g=Vt.g,e.b=Vt.b,e}getStyle(e=yn){at.fromWorkingColorSpace(Vt.copy(this),e);let t=Vt.r,i=Vt.g,r=Vt.b;return e!==yn?`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(Ti),this.setHSL(Ti.h+e,Ti.s+t,Ti.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(Ti),e.getHSL(xl);let i=bo(Ti.h,xl.h,t),r=bo(Ti.s,xl.s,t),s=bo(Ti.l,xl.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}},Vt=new we;we.NAMES=Jy;pS=0,Dt=class extends Cn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:pS++}),this.uuid=sn(),this.name="",this.type="Material",this.blending=hr,this.side=li,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cc,this.blendDst=uc,this.blendEquation=Pi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=Ao,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Dh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=or,this.stencilZFail=or,this.stencilZPass=or,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!==hr&&(i.blending=this.blending),this.side!==li&&(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!==cc&&(i.blendSrc=this.blendSrc),this.blendDst!==uc&&(i.blendDst=this.blendDst),this.blendEquation!==Pi&&(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!==Ao&&(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!==Dh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==or&&(i.stencilFail=this.stencilFail),this.stencilZFail!==or&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==or&&(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++}},zn=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 an,this.combine=fa,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}},ti=mS();gS={toHalfFloat:Jt,fromHalfFloat:vo},bt=new R,_l=new te,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=No,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Zy("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++)_l.fromBufferAttribute(this,t),_l.applyMatrix3(e),this.setXY(t,_l.x,_l.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=Xt(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=Xt(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=Xt(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=Xt(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=Xt(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!==No&&(e.usage=this.usage),e}},Fh=class extends nt{constructor(e,t,i){super(new Int8Array(e),t,i)}},kh=class extends nt{constructor(e,t,i){super(new Uint8Array(e),t,i)}},Bh=class extends nt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},zh=class extends nt{constructor(e,t,i){super(new Int16Array(e),t,i)}},zo=class extends nt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},Vh=class extends nt{constructor(e,t,i){super(new Int32Array(e),t,i)}},Vo=class extends nt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},Hh=class extends nt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=vo(this.array[e*this.itemSize]);return this.normalized&&(t=Xt(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize]=Jt(t),this}getY(e){let t=vo(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xt(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+1]=Jt(t),this}getZ(e){let t=vo(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+2]=Jt(t),this}getW(e){let t=vo(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xt(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ge(t,this.array)),this.array[e*this.itemSize+3]=Jt(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]=Jt(t),this.array[e+1]=Jt(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]=Jt(t),this.array[e+1]=Jt(i),this.array[e+2]=Jt(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]=Jt(t),this.array[e+1]=Jt(i),this.array[e+2]=Jt(r),this.array[e+3]=Jt(s),this}},Te=class extends nt{constructor(e,t,i){super(new Float32Array(e),t,i)}},yS=0,gn=new Ne,Dd=new rt,Jr=new R,nn=new Ot,lo=new Ot,Rt=new R,Ye=class n extends Cn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:yS++}),this.uuid=sn(),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(Yy(e)?Vo:zo)(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 gn.makeRotationFromQuaternion(e),this.applyMatrix4(gn),this}rotateX(e){return gn.makeRotationX(e),this.applyMatrix4(gn),this}rotateY(e){return gn.makeRotationY(e),this.applyMatrix4(gn),this}rotateZ(e){return gn.makeRotationZ(e),this.applyMatrix4(gn),this}translate(e,t,i){return gn.makeTranslation(e,t,i),this.applyMatrix4(gn),this}scale(e,t,i){return gn.makeScale(e,t,i),this.applyMatrix4(gn),this}lookAt(e){return Dd.lookAt(e),Dd.updateMatrix(),this.applyMatrix4(Dd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jr).negate(),this.translate(Jr.x,Jr.y,Jr.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 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];nn.setFromBufferAttribute(s),this.morphTargetsRelative?(Rt.addVectors(this.boundingBox.min,nn.min),this.boundingBox.expandByPoint(Rt),Rt.addVectors(this.boundingBox.max,nn.max),this.boundingBox.expandByPoint(Rt)):(this.boundingBox.expandByPoint(nn.min),this.boundingBox.expandByPoint(nn.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 R,1/0);return}if(e){let i=this.boundingSphere.center;if(nn.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];lo.setFromBufferAttribute(a),this.morphTargetsRelative?(Rt.addVectors(nn.min,lo.min),nn.expandByPoint(Rt),Rt.addVectors(nn.max,lo.max),nn.expandByPoint(Rt)):(nn.expandByPoint(lo.min),nn.expandByPoint(lo.max))}nn.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&&(Jr.fromBufferAttribute(e,c),Rt.add(Jr)),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 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 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 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++)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,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 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"})}},Mg=new Ne,Zi=new Oi,bl=new Lt,Sg=new R,Kr=new R,Qr=new R,es=new R,Od=new R,wl=new R,Ml=new te,Sl=new te,Al=new te,Ag=new R,Eg=new R,Tg=new R,El=new R,Tl=new R,vt=class extends rt{constructor(e=new Ye,t=new zn){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){wl.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],d=s[l];u!==0&&(Od.fromBufferAttribute(d,e),o?wl.addScaledVector(Od,u):wl.addScaledVector(Od.sub(t),u))}t.add(wl)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),bl.copy(i.boundingSphere),bl.applyMatrix4(s),Zi.copy(e.ray).recast(e.near),!(bl.containsPoint(Zi.origin)===!1&&(Zi.intersectSphere(bl,Sg)===null||Zi.origin.distanceToSquared(Sg)>(e.far-e.near)**2))&&(Mg.copy(s).invert(),Zi.copy(e.ray).applyMatrix4(Mg),!(i.boundingBox!==null&&Zi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Zi)))}_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=Il(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=Il(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=Il(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=Il(this,o,e,i,c,u,d,x,v,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};gr=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;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 Ke=Le*w-U;re[y]=Ke*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,Ke=h+ve+W*(se+1),Z=h+(ve+1)+W*(se+1),q=h+(ve+1)+W*se;l.push(Le,Ke,q),l.push(Ke,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)}};Qy={clone:_s,merge:jt},_S=`void main() {
|
|
201
201
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
202
|
-
}`,
|
|
202
|
+
}`,bS=`void main() {
|
|
203
203
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
204
|
-
}`,ln=class extends Dt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=
|
|
204
|
+
}`,ln=class extends Dt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_S,this.fragmentShader=bS,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=_s(e.uniforms),this.uniformsGroups=xS(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}},bs=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=Fn}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)}},Ii=new R,Ig=new te,Cg=new te,Et=class extends bs{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=ys*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(pr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ys*2*Math.atan(Math.tan(pr*.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){Ii.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ii.x,Ii.y).multiplyScalar(-e/Ii.z),Ii.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ii.x,Ii.y).multiplyScalar(-e/Ii.z)}getViewSize(e,t){return this.getViewBounds(e,Ig,Cg),t.subVectors(Cg,Ig)}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(pr*.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}},ts=-90,ns=1,fc=class extends rt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Et(ts,ns,e,t);r.layers=this.layers,this.add(r);let s=new Et(ts,ns,e,t);s.layers=this.layers,this.add(s);let o=new Et(ts,ns,e,t);o.layers=this.layers,this.add(o);let a=new Et(ts,ns,e,t);a.layers=this.layers,this.add(a);let l=new Et(ts,ns,e,t);l.layers=this.layers,this.add(l);let c=new Et(ts,ns,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===Fn)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===Fo)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}},yr=class extends Mt{constructor(e,t,i,r,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:ci,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}},pc=class extends on{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 yr(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:`
|
|
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 gr(5,5,5),s=new ln({name:"CubemapFromEquirect",uniforms:_s(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Yt,blending:si});s.uniforms.tEquirect.value=t;let o=new vt(r,s),a=t.minFilter;return t.minFilter===Nn&&(t.minFilter=wt),new fc(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)}},Ud=new R,
|
|
239
|
+
`},r=new gr(5,5,5),s=new ln({name:"CubemapFromEquirect",uniforms:_s(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Yt,blending:si});s.uniforms.tEquirect.value=t;let o=new vt(r,s),a=t.minFilter;return t.minFilter===Nn&&(t.minFilter=wt),new fc(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)}},Ud=new R,wS=new R,MS=new He,On=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=Ud.subVectors(i,t).cross(wS.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(Ud),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||MS.getNormalMatrix(e),r=this.coplanarPoint(Ud).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)}},Ji=new Lt,Cl=new R,vr=class{constructor(e=new On,t=new On,i=new On,r=new On,s=new On,o=new On){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=Fn){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===Fn)i[5].setComponents(l+a,h+d,g+y,b+v).normalize();else if(t===Fo)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(),Ji.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ji.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ji)}intersectsSprite(e){return Ji.center.set(0,0,0),Ji.radius=.7071067811865476,Ji.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ji)}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(Cl.x=r.normal.x>0?e.max.x:e.min.x,Cl.y=r.normal.y>0?e.max.y:e.min.y,Cl.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Cl)<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)}};ws=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=[],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)}},AS=`#ifdef USE_ALPHAHASH
|
|
240
240
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
241
|
-
#endif`,
|
|
241
|
+
#endif`,ES=`#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`,ES=`#ifdef USE_ALPHAMAP
|
|
277
|
-
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
278
276
|
#endif`,TS=`#ifdef USE_ALPHAMAP
|
|
277
|
+
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
278
|
+
#endif`,IS=`#ifdef USE_ALPHAMAP
|
|
279
279
|
uniform sampler2D alphaMap;
|
|
280
|
-
#endif`,
|
|
280
|
+
#endif`,CS=`#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`,
|
|
287
|
+
#endif`,RS=`#ifdef USE_ALPHATEST
|
|
288
288
|
uniform float alphaTest;
|
|
289
|
-
#endif`,
|
|
289
|
+
#endif`,PS=`#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`,
|
|
302
|
+
#endif`,LS=`#ifdef USE_AOMAP
|
|
303
303
|
uniform sampler2D aoMap;
|
|
304
304
|
uniform float aoMapIntensity;
|
|
305
|
-
#endif`,
|
|
305
|
+
#endif`,DS=`#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`,
|
|
319
|
+
#endif`,OS=`#ifdef USE_BATCHING
|
|
320
320
|
mat4 batchingMatrix = getBatchingMatrix( batchId );
|
|
321
|
-
#endif`,
|
|
321
|
+
#endif`,US=`vec3 transformed = vec3( position );
|
|
322
322
|
#ifdef USE_ALPHAHASH
|
|
323
323
|
vPosition = vec3( position );
|
|
324
|
-
#endif`,
|
|
324
|
+
#endif`,NS=`vec3 objectNormal = vec3( normal );
|
|
325
325
|
#ifdef USE_TANGENT
|
|
326
326
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
327
|
-
#endif`,
|
|
327
|
+
#endif`,FS=`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`,
|
|
341
|
+
} // validated`,kS=`#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`,
|
|
404
|
+
#endif`,BS=`#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`,
|
|
425
|
+
#endif`,zS=`#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`,zS=`#if NUM_CLIPPING_PLANES > 0
|
|
472
|
-
varying vec3 vClipPosition;
|
|
473
|
-
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
474
471
|
#endif`,VS=`#if NUM_CLIPPING_PLANES > 0
|
|
475
472
|
varying vec3 vClipPosition;
|
|
473
|
+
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
476
474
|
#endif`,HS=`#if NUM_CLIPPING_PLANES > 0
|
|
475
|
+
varying vec3 vClipPosition;
|
|
476
|
+
#endif`,GS=`#if NUM_CLIPPING_PLANES > 0
|
|
477
477
|
vClipPosition = - mvPosition.xyz;
|
|
478
|
-
#endif
|
|
478
|
+
#endif`,$S=`#if defined( USE_COLOR_ALPHA )
|
|
479
479
|
diffuseColor *= vColor;
|
|
480
480
|
#elif defined( USE_COLOR )
|
|
481
481
|
diffuseColor.rgb *= vColor;
|
|
482
|
-
#endif
|
|
482
|
+
#endif`,WS=`#if defined( USE_COLOR_ALPHA )
|
|
483
483
|
varying vec4 vColor;
|
|
484
484
|
#elif defined( USE_COLOR )
|
|
485
485
|
varying vec3 vColor;
|
|
486
|
-
#endif`,
|
|
486
|
+
#endif`,jS=`#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`,
|
|
490
|
+
#endif`,XS=`#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`,
|
|
500
|
+
#endif`,YS=`#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`,
|
|
578
|
+
} // validated`,qS=`#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`,
|
|
671
|
+
#endif`,ZS=`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`,
|
|
700
|
+
#endif`,JS=`#ifdef USE_DISPLACEMENTMAP
|
|
701
701
|
uniform sampler2D displacementMap;
|
|
702
702
|
uniform float displacementScale;
|
|
703
703
|
uniform float displacementBias;
|
|
704
|
-
#endif`,
|
|
704
|
+
#endif`,KS=`#ifdef USE_DISPLACEMENTMAP
|
|
705
705
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
706
|
-
#endif`,
|
|
706
|
+
#endif`,QS=`#ifdef USE_EMISSIVEMAP
|
|
707
707
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
708
708
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
709
|
-
#endif`,
|
|
709
|
+
#endif`,e1=`#ifdef USE_EMISSIVEMAP
|
|
710
710
|
uniform sampler2D emissiveMap;
|
|
711
|
-
#endif`,
|
|
711
|
+
#endif`,t1="gl_FragColor = linearToOutputTexel( gl_FragColor );",n1=`
|
|
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
|
-
}`,
|
|
739
|
+
}`,i1=`#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`,
|
|
768
|
+
#endif`,r1=`#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`,
|
|
778
|
+
#endif`,s1=`#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`,
|
|
789
|
+
#endif`,o1=`#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`,
|
|
800
|
+
#endif`,a1=`#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`,a1=`#ifdef USE_FOG
|
|
818
|
-
vFogDepth = - mvPosition.z;
|
|
819
817
|
#endif`,l1=`#ifdef USE_FOG
|
|
820
|
-
|
|
818
|
+
vFogDepth = - mvPosition.z;
|
|
821
819
|
#endif`,c1=`#ifdef USE_FOG
|
|
820
|
+
varying float vFogDepth;
|
|
821
|
+
#endif`,u1=`#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`,
|
|
828
|
+
#endif`,d1=`#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`,
|
|
837
|
+
#endif`,h1=`#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
|
-
}`,
|
|
849
|
+
}`,f1=`#ifdef USE_LIGHTMAP
|
|
850
850
|
uniform sampler2D lightMap;
|
|
851
851
|
uniform float lightMapIntensity;
|
|
852
|
-
#endif`,
|
|
852
|
+
#endif`,p1=`LambertMaterial material;
|
|
853
853
|
material.diffuseColor = diffuseColor.rgb;
|
|
854
|
-
material.specularStrength = specularStrength;`,
|
|
854
|
+
material.specularStrength = specularStrength;`,m1=`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`,
|
|
868
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,g1=`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`,
|
|
991
|
+
#endif`,y1=`#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`,
|
|
1025
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
1024
|
+
#endif`,v1=`ToonMaterial material;
|
|
1025
|
+
material.diffuseColor = diffuseColor.rgb;`,x1=`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`,
|
|
1037
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,_1=`BlinnPhongMaterial material;
|
|
1038
1038
|
material.diffuseColor = diffuseColor.rgb;
|
|
1039
1039
|
material.specularColor = specular;
|
|
1040
1040
|
material.specularShininess = shininess;
|
|
1041
|
-
material.specularStrength = specularStrength;`,
|
|
1041
|
+
material.specularStrength = specularStrength;`,b1=`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`,
|
|
1058
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,w1=`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`,
|
|
1144
|
+
#endif`,M1=`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
|
-
}`,
|
|
1445
|
+
}`,S1=`
|
|
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`,
|
|
1560
|
+
#endif`,A1=`#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`,
|
|
1579
|
+
#endif`,E1=`#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`,E1=`#if defined( USE_LOGDEPTHBUF )
|
|
1585
|
-
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1586
1584
|
#endif`,T1=`#if defined( USE_LOGDEPTHBUF )
|
|
1585
|
+
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1586
|
+
#endif`,I1=`#if defined( USE_LOGDEPTHBUF )
|
|
1587
1587
|
uniform float logDepthBufFC;
|
|
1588
1588
|
varying float vFragDepth;
|
|
1589
1589
|
varying float vIsPerspective;
|
|
1590
|
-
#endif`,
|
|
1590
|
+
#endif`,C1=`#ifdef USE_LOGDEPTHBUF
|
|
1591
1591
|
varying float vFragDepth;
|
|
1592
1592
|
varying float vIsPerspective;
|
|
1593
|
-
#endif`,
|
|
1593
|
+
#endif`,R1=`#ifdef USE_LOGDEPTHBUF
|
|
1594
1594
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1595
1595
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1596
|
-
#endif`,
|
|
1596
|
+
#endif`,P1=`#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`,
|
|
1603
|
+
#endif`,L1=`#ifdef USE_MAP
|
|
1604
1604
|
uniform sampler2D map;
|
|
1605
|
-
#endif`,
|
|
1605
|
+
#endif`,D1=`#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`,
|
|
1617
|
+
#endif`,O1=`#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`,
|
|
1629
|
+
#endif`,U1=`float metalnessFactor = metalness;
|
|
1630
1630
|
#ifdef USE_METALNESSMAP
|
|
1631
1631
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1632
1632
|
metalnessFactor *= texelMetalness.b;
|
|
1633
|
-
#endif`,
|
|
1633
|
+
#endif`,N1=`#ifdef USE_METALNESSMAP
|
|
1634
1634
|
uniform sampler2D metalnessMap;
|
|
1635
|
-
#endif`,
|
|
1635
|
+
#endif`,F1=`#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`,
|
|
1641
|
+
#endif`,k1=`#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`,
|
|
1650
|
+
#endif`,B1=`#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`,
|
|
1662
|
+
#endif`,z1=`#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`,
|
|
1686
|
+
#endif`,V1=`#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`,
|
|
1704
|
+
#endif`,H1=`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;`,
|
|
1745
|
+
vec3 nonPerturbedNormal = normal;`,G1=`#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;`,H1=`#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
|
|
1760
|
+
#endif`,$1=`#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
|
|
1766
|
+
#endif`,W1=`#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`,
|
|
1772
|
+
#endif`,j1=`#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`,
|
|
1778
|
+
#endif`,X1=`#ifdef USE_NORMALMAP
|
|
1779
1779
|
uniform sampler2D normalMap;
|
|
1780
1780
|
uniform vec2 normalScale;
|
|
1781
1781
|
#endif
|
|
@@ -1797,13 +1797,13 @@ vec3 nonPerturbedNormal = normal;`,H1=`#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`,
|
|
1800
|
+
#endif`,Y1=`#ifdef USE_CLEARCOAT
|
|
1801
1801
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1802
|
-
#endif`,
|
|
1802
|
+
#endif`,q1=`#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`,
|
|
1806
|
+
#endif`,Z1=`#ifdef USE_CLEARCOATMAP
|
|
1807
1807
|
uniform sampler2D clearcoatMap;
|
|
1808
1808
|
#endif
|
|
1809
1809
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1812,18 +1812,18 @@ vec3 nonPerturbedNormal = normal;`,H1=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1812
1812
|
#endif
|
|
1813
1813
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1814
1814
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1815
|
-
#endif`,
|
|
1815
|
+
#endif`,J1=`#ifdef USE_IRIDESCENCEMAP
|
|
1816
1816
|
uniform sampler2D iridescenceMap;
|
|
1817
1817
|
#endif
|
|
1818
1818
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1819
1819
|
uniform sampler2D iridescenceThicknessMap;
|
|
1820
|
-
#endif`,
|
|
1820
|
+
#endif`,K1=`#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 );`,
|
|
1826
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Q1=`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
|
-
}`,
|
|
1867
|
+
}`,eA=`#ifdef PREMULTIPLIED_ALPHA
|
|
1868
1868
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1869
|
-
#endif`,
|
|
1869
|
+
#endif`,tA=`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;`,
|
|
1877
|
+
gl_Position = projectionMatrix * mvPosition;`,nA=`#ifdef DITHERING
|
|
1878
1878
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1879
|
-
#endif`,
|
|
1879
|
+
#endif`,iA=`#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`,
|
|
1886
|
+
#endif`,rA=`float roughnessFactor = roughness;
|
|
1887
1887
|
#ifdef USE_ROUGHNESSMAP
|
|
1888
1888
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1889
1889
|
roughnessFactor *= texelRoughness.g;
|
|
1890
|
-
#endif`,
|
|
1890
|
+
#endif`,sA=`#ifdef USE_ROUGHNESSMAP
|
|
1891
1891
|
uniform sampler2D roughnessMap;
|
|
1892
|
-
#endif`,
|
|
1892
|
+
#endif`,oA=`#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;`,tA=`#ifdef DITHERING
|
|
|
2072
2072
|
}
|
|
2073
2073
|
return shadow;
|
|
2074
2074
|
}
|
|
2075
|
-
#endif`,
|
|
2075
|
+
#endif`,aA=`#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;`,tA=`#ifdef DITHERING
|
|
|
2110
2110
|
};
|
|
2111
2111
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2112
2112
|
#endif
|
|
2113
|
-
#endif`,
|
|
2113
|
+
#endif`,lA=`#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;`,tA=`#ifdef DITHERING
|
|
|
2142
2142
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2143
2143
|
}
|
|
2144
2144
|
#pragma unroll_loop_end
|
|
2145
|
-
#endif`,
|
|
2145
|
+
#endif`,cA=`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;`,tA=`#ifdef DITHERING
|
|
|
2174
2174
|
#endif
|
|
2175
2175
|
#endif
|
|
2176
2176
|
return shadow;
|
|
2177
|
-
}`,
|
|
2177
|
+
}`,uA=`#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`,
|
|
2182
|
+
#endif`,dA=`#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;`,tA=`#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`,
|
|
2197
|
+
#endif`,hA=`#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;`,tA=`#ifdef DITHERING
|
|
|
2202
2202
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2203
2203
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2204
2204
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2205
|
-
#endif`,
|
|
2205
|
+
#endif`,fA=`#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;`,tA=`#ifdef DITHERING
|
|
|
2213
2213
|
#ifdef USE_TANGENT
|
|
2214
2214
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2215
2215
|
#endif
|
|
2216
|
-
#endif`,
|
|
2216
|
+
#endif`,pA=`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`,
|
|
2222
|
+
#endif`,mA=`#ifdef USE_SPECULARMAP
|
|
2223
2223
|
uniform sampler2D specularMap;
|
|
2224
|
-
#endif`,
|
|
2224
|
+
#endif`,gA=`#if defined( TONE_MAPPING )
|
|
2225
2225
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2226
|
-
#endif`,
|
|
2226
|
+
#endif`,yA=`#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; }`,
|
|
2323
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,vA=`#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; }`,yA=`#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`,
|
|
2344
|
+
#endif`,xA=`#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; }`,yA=`#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`,
|
|
2475
|
+
#endif`,_A=`#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; }`,yA=`#ifdef USE_TRANSMISS
|
|
|
2542
2542
|
#ifdef USE_THICKNESSMAP
|
|
2543
2543
|
uniform mat3 thicknessMapTransform;
|
|
2544
2544
|
varying vec2 vThicknessMapUv;
|
|
2545
|
-
#endif`,
|
|
2545
|
+
#endif`,bA=`#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; }`,yA=`#ifdef USE_TRANSMISS
|
|
|
2636
2636
|
#ifdef USE_THICKNESSMAP
|
|
2637
2637
|
uniform mat3 thicknessMapTransform;
|
|
2638
2638
|
varying vec2 vThicknessMapUv;
|
|
2639
|
-
#endif`,
|
|
2639
|
+
#endif`,wA=`#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; }`,yA=`#ifdef USE_TRANSMISS
|
|
|
2707
2707
|
#endif
|
|
2708
2708
|
#ifdef USE_THICKNESSMAP
|
|
2709
2709
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2710
|
-
#endif`,
|
|
2710
|
+
#endif`,MA=`#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; }`,yA=`#ifdef USE_TRANSMISS
|
|
|
2716
2716
|
worldPosition = instanceMatrix * worldPosition;
|
|
2717
2717
|
#endif
|
|
2718
2718
|
worldPosition = modelMatrix * worldPosition;
|
|
2719
|
-
#endif`,
|
|
2719
|
+
#endif`,SA=`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
|
-
}`,
|
|
2724
|
+
}`,AA=`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
|
-
}`,
|
|
2736
|
+
}`,EA=`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
|
-
}`,
|
|
2743
|
+
}`,TA=`#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
|
-
}`,
|
|
2766
|
+
}`,IA=`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
|
-
}`,
|
|
2773
|
+
}`,CA=`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
|
-
}`,
|
|
2783
|
+
}`,RA=`#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
|
-
}`,
|
|
2810
|
+
}`,PA=`#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
|
-
}`,
|
|
2840
|
+
}`,LA=`#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
|
-
}`,
|
|
2867
|
+
}`,DA=`#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
|
-
}`,
|
|
2891
|
+
}`,OA=`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
|
-
}`,
|
|
2897
|
+
}`,UA=`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
|
-
}`,
|
|
2906
|
+
}`,NA=`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
|
-
}`,
|
|
2928
|
+
}`,FA=`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
|
-
}`,
|
|
2956
|
+
}`,kA=`#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
|
-
}`,
|
|
2988
|
+
}`,BA=`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
|
-
}`,
|
|
3036
|
+
}`,zA=`#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
|
-
}`,
|
|
3075
|
+
}`,VA=`#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
|
-
}`,
|
|
3132
|
+
}`,HA=`#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
|
-
}`,
|
|
3166
|
+
}`,GA=`#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
|
-
}
|
|
3212
|
+
}`,$A=`#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
|
-
}
|
|
3245
|
+
}`,WA=`#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
|
-
}`,
|
|
3267
|
+
}`,jA=`#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
|
-
}`,
|
|
3306
|
+
}`,XA=`#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
|
-
}`,
|
|
3365
|
+
}`,YA=`#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
|
-
}`,
|
|
3408
|
+
}`,qA=`#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
|
-
}`,
|
|
3533
|
+
}`,ZA=`#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
|
-
}`,
|
|
3570
|
+
}`,JA=`#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
|
-
}`,
|
|
3623
|
+
}`,KA=`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
|
-
}`,
|
|
3654
|
+
}`,QA=`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
|
-
}`,
|
|
3679
|
+
}`,eE=`#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
|
-
}`,
|
|
3702
|
+
}`,tE=`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
|
-
}`,
|
|
3718
|
+
}`,nE=`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
|
-
}`,
|
|
3744
|
+
}`,iE=`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:SS,alphahash_pars_fragment:AS,alphamap_fragment:ES,alphamap_pars_fragment:TS,alphatest_fragment:IS,alphatest_pars_fragment:CS,aomap_fragment:RS,aomap_pars_fragment:PS,batching_pars_vertex:LS,batching_vertex:DS,begin_vertex:OS,beginnormal_vertex:US,bsdfs:NS,iridescence_fragment:FS,bumpmap_pars_fragment:kS,clipping_planes_fragment:BS,clipping_planes_pars_fragment:zS,clipping_planes_pars_vertex:VS,clipping_planes_vertex:HS,color_fragment:GS,color_pars_fragment:$S,color_pars_vertex:WS,color_vertex:jS,common:XS,cube_uv_reflection_fragment:YS,defaultnormal_vertex:qS,displacementmap_pars_vertex:ZS,displacementmap_vertex:JS,emissivemap_fragment:KS,emissivemap_pars_fragment:QS,colorspace_fragment:e1,colorspace_pars_fragment:t1,envmap_fragment:n1,envmap_common_pars_fragment:i1,envmap_pars_fragment:r1,envmap_pars_vertex:s1,envmap_physical_pars_fragment:g1,envmap_vertex:o1,fog_vertex:a1,fog_pars_vertex:l1,fog_fragment:c1,fog_pars_fragment:u1,gradientmap_pars_fragment:d1,lightmap_pars_fragment:h1,lights_lambert_fragment:f1,lights_lambert_pars_fragment:p1,lights_pars_begin:m1,lights_toon_fragment:y1,lights_toon_pars_fragment:v1,lights_phong_fragment:x1,lights_phong_pars_fragment:_1,lights_physical_fragment:b1,lights_physical_pars_fragment:w1,lights_fragment_begin:M1,lights_fragment_maps:S1,lights_fragment_end:A1,logdepthbuf_fragment:E1,logdepthbuf_pars_fragment:T1,logdepthbuf_pars_vertex:I1,logdepthbuf_vertex:C1,map_fragment:R1,map_pars_fragment:P1,map_particle_fragment:L1,map_particle_pars_fragment:D1,metalnessmap_fragment:O1,metalnessmap_pars_fragment:U1,morphinstance_vertex:N1,morphcolor_vertex:F1,morphnormal_vertex:k1,morphtarget_pars_vertex:B1,morphtarget_vertex:z1,normal_fragment_begin:V1,normal_fragment_maps:H1,normal_pars_fragment:G1,normal_pars_vertex:$1,normal_vertex:W1,normalmap_pars_fragment:j1,clearcoat_normal_fragment_begin:X1,clearcoat_normal_fragment_maps:Y1,clearcoat_pars_fragment:q1,iridescence_pars_fragment:Z1,opaque_fragment:J1,packing:K1,premultiplied_alpha_fragment:Q1,project_vertex:eA,dithering_fragment:tA,dithering_pars_fragment:nA,roughnessmap_fragment:iA,roughnessmap_pars_fragment:rA,shadowmap_pars_fragment:sA,shadowmap_pars_vertex:oA,shadowmap_vertex:aA,shadowmask_pars_fragment:lA,skinbase_vertex:cA,skinning_pars_vertex:uA,skinning_vertex:dA,skinnormal_vertex:hA,specularmap_fragment:fA,specularmap_pars_fragment:pA,tonemapping_fragment:mA,tonemapping_pars_fragment:gA,transmission_fragment:yA,transmission_pars_fragment:vA,uv_pars_fragment:xA,uv_pars_vertex:_A,uv_vertex:bA,worldpos_vertex:wA,background_vert:MA,background_frag:SA,backgroundCube_vert:AA,backgroundCube_frag:EA,cube_vert:TA,cube_frag:IA,depth_vert:CA,depth_frag:RA,distanceRGBA_vert:PA,distanceRGBA_frag:LA,equirect_vert:DA,equirect_frag:OA,linedashed_vert:UA,linedashed_frag:NA,meshbasic_vert:FA,meshbasic_frag:kA,meshlambert_vert:BA,meshlambert_frag:zA,meshmatcap_vert:VA,meshmatcap_frag:HA,meshnormal_vert:GA,meshnormal_frag:$A,meshphong_vert:WA,meshphong_frag:jA,meshphysical_vert:XA,meshphysical_frag:YA,meshtoon_vert:qA,meshtoon_frag:ZA,points_vert:JA,points_frag:KA,shadow_vert:QA,shadow_frag:eE,sprite_vert:tE,sprite_frag:nE},ye={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 te(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 te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},In={basic:{uniforms:jt([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:jt([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:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:jt([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:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:jt([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:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:jt([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:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:jt([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:jt([ye.points,ye.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:jt([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:jt([ye.common,ye.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:jt([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:jt([ye.sprite,ye.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:jt([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distanceRGBA_vert,fragmentShader:We.distanceRGBA_frag},shadow:{uniforms:jt([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};In.physical={uniforms:jt([In.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new te(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 te},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 te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};Rl={r:0,b:0,g:0},Ki=new an,iE=new Ne;Ms=class extends bs{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}},hs=4,Rg=[.125,.215,.35,.446,.526,.582],lr=20,Nd=new Ms,Pg=new we,Fd=null,kd=0,Bd=0,zd=!1,ar=(1+Math.sqrt(5))/2,is=1/ar,Lg=[new R(-ar,is,0),new R(ar,is,0),new R(-is,0,ar),new R(is,0,ar),new R(0,ar,-is),new R(0,ar,is),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)],Ho=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){Fd=this._renderer.getRenderTarget(),kd=this._renderer.getActiveCubeFace(),Bd=this._renderer.getActiveMipmapLevel(),zd=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=Ug(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Og(),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(Fd,kd,Bd),this._renderer.xr.enabled=zd,e.scissorTest=!1,Pl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ci||e.mapping===Di?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fd=this._renderer.getRenderTarget(),kd=this._renderer.getActiveCubeFace(),Bd=this._renderer.getActiveMipmapLevel(),zd=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:pa,format:rn,colorSpace:fi,depthBuffer:!1},r=Dg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Dg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=uE(s)),this._blurMaterial=dE(s,e,t)}return r}_compileMaterial(e){let t=new vt(this._lodPlanes[0],e);this._renderer.compile(t,Nd)}_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(Pg),u.toneMapping=oi,u.autoClear=!1;let f=new zn({name:"PMREM.Background",side:Yt,depthWrite:!1,depthTest:!1}),p=new vt(new gr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Pg),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;Pl(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===ci||e.mapping===Di;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ug()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Og());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;Pl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,Nd)}_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=Lg[(r-s-1)%Lg.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,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*lr-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):lr;g>lr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${lr}`);let m=[],x=0;for(let E=0;E<lr;++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-hs?r-v+hs:0),A=4*(this._cubeSize-b);Pl(t,L,A,3*b,2*b),l.setRenderTarget(t),l.render(d,Nd)}};Go=class extends Mt{constructor(e,t,i,r,s,o,a,l,c,u){if(u=u!==void 0?u:fr,u!==fr&&u!==gs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===fr&&(i=mr),i===void 0&&u===gs&&(i=Cs),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}},tv=new Mt,nv=new Go(1,1);nv.compareFunction=up;iv=new vs,rv=new Bo,sv=new yr,Ng=[],Fg=[],kg=new Float32Array(16),Bg=new Float32Array(9),zg=new Float32Array(4);Gh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=kE(t.type)}},$h=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=rT(t.type)}},Wh=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)}}},Vd=/(\w+)(\])?(\[|\.)?/g;ms=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);sT(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}};oT=37297,aT=0;mT=/^[ \t]*#include +<([\w\d./]+)>/gm;gT=new Map;vT=/#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;ET=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 Yh(e),t.set(e,i)),i}},Yh=class{constructor(e){this.id=ET++,this.code=e,this.usedTimes=0}};DT=0;$o=class extends Dt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ky,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}},Wo=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}},FT=`void main() {
|
|
3769
|
+
}`,We={alphahash_fragment:AS,alphahash_pars_fragment:ES,alphamap_fragment:TS,alphamap_pars_fragment:IS,alphatest_fragment:CS,alphatest_pars_fragment:RS,aomap_fragment:PS,aomap_pars_fragment:LS,batching_pars_vertex:DS,batching_vertex:OS,begin_vertex:US,beginnormal_vertex:NS,bsdfs:FS,iridescence_fragment:kS,bumpmap_pars_fragment:BS,clipping_planes_fragment:zS,clipping_planes_pars_fragment:VS,clipping_planes_pars_vertex:HS,clipping_planes_vertex:GS,color_fragment:$S,color_pars_fragment:WS,color_pars_vertex:jS,color_vertex:XS,common:YS,cube_uv_reflection_fragment:qS,defaultnormal_vertex:ZS,displacementmap_pars_vertex:JS,displacementmap_vertex:KS,emissivemap_fragment:QS,emissivemap_pars_fragment:e1,colorspace_fragment:t1,colorspace_pars_fragment:n1,envmap_fragment:i1,envmap_common_pars_fragment:r1,envmap_pars_fragment:s1,envmap_pars_vertex:o1,envmap_physical_pars_fragment:y1,envmap_vertex:a1,fog_vertex:l1,fog_pars_vertex:c1,fog_fragment:u1,fog_pars_fragment:d1,gradientmap_pars_fragment:h1,lightmap_pars_fragment:f1,lights_lambert_fragment:p1,lights_lambert_pars_fragment:m1,lights_pars_begin:g1,lights_toon_fragment:v1,lights_toon_pars_fragment:x1,lights_phong_fragment:_1,lights_phong_pars_fragment:b1,lights_physical_fragment:w1,lights_physical_pars_fragment:M1,lights_fragment_begin:S1,lights_fragment_maps:A1,lights_fragment_end:E1,logdepthbuf_fragment:T1,logdepthbuf_pars_fragment:I1,logdepthbuf_pars_vertex:C1,logdepthbuf_vertex:R1,map_fragment:P1,map_pars_fragment:L1,map_particle_fragment:D1,map_particle_pars_fragment:O1,metalnessmap_fragment:U1,metalnessmap_pars_fragment:N1,morphinstance_vertex:F1,morphcolor_vertex:k1,morphnormal_vertex:B1,morphtarget_pars_vertex:z1,morphtarget_vertex:V1,normal_fragment_begin:H1,normal_fragment_maps:G1,normal_pars_fragment:$1,normal_pars_vertex:W1,normal_vertex:j1,normalmap_pars_fragment:X1,clearcoat_normal_fragment_begin:Y1,clearcoat_normal_fragment_maps:q1,clearcoat_pars_fragment:Z1,iridescence_pars_fragment:J1,opaque_fragment:K1,packing:Q1,premultiplied_alpha_fragment:eA,project_vertex:tA,dithering_fragment:nA,dithering_pars_fragment:iA,roughnessmap_fragment:rA,roughnessmap_pars_fragment:sA,shadowmap_pars_fragment:oA,shadowmap_pars_vertex:aA,shadowmap_vertex:lA,shadowmask_pars_fragment:cA,skinbase_vertex:uA,skinning_pars_vertex:dA,skinning_vertex:hA,skinnormal_vertex:fA,specularmap_fragment:pA,specularmap_pars_fragment:mA,tonemapping_fragment:gA,tonemapping_pars_fragment:yA,transmission_fragment:vA,transmission_pars_fragment:xA,uv_pars_fragment:_A,uv_pars_vertex:bA,uv_vertex:wA,worldpos_vertex:MA,background_vert:SA,background_frag:AA,backgroundCube_vert:EA,backgroundCube_frag:TA,cube_vert:IA,cube_frag:CA,depth_vert:RA,depth_frag:PA,distanceRGBA_vert:LA,distanceRGBA_frag:DA,equirect_vert:OA,equirect_frag:UA,linedashed_vert:NA,linedashed_frag:FA,meshbasic_vert:kA,meshbasic_frag:BA,meshlambert_vert:zA,meshlambert_frag:VA,meshmatcap_vert:HA,meshmatcap_frag:GA,meshnormal_vert:$A,meshnormal_frag:WA,meshphong_vert:jA,meshphong_frag:XA,meshphysical_vert:YA,meshphysical_frag:qA,meshtoon_vert:ZA,meshtoon_frag:JA,points_vert:KA,points_frag:QA,shadow_vert:eE,shadow_frag:tE,sprite_vert:nE,sprite_frag:iE},ye={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 te(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 te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},In={basic:{uniforms:jt([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:jt([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:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:jt([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:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:jt([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:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:jt([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:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:jt([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:jt([ye.points,ye.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:jt([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:jt([ye.common,ye.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:jt([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:jt([ye.sprite,ye.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:jt([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distanceRGBA_vert,fragmentShader:We.distanceRGBA_frag},shadow:{uniforms:jt([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};In.physical={uniforms:jt([In.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new te(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 te},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 te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};Rl={r:0,b:0,g:0},Ki=new an,rE=new Ne;Ms=class extends bs{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}},hs=4,Rg=[.125,.215,.35,.446,.526,.582],lr=20,Nd=new Ms,Pg=new we,Fd=null,kd=0,Bd=0,zd=!1,ar=(1+Math.sqrt(5))/2,is=1/ar,Lg=[new R(-ar,is,0),new R(ar,is,0),new R(-is,0,ar),new R(is,0,ar),new R(0,ar,-is),new R(0,ar,is),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)],Ho=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){Fd=this._renderer.getRenderTarget(),kd=this._renderer.getActiveCubeFace(),Bd=this._renderer.getActiveMipmapLevel(),zd=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=Ug(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Og(),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(Fd,kd,Bd),this._renderer.xr.enabled=zd,e.scissorTest=!1,Pl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ci||e.mapping===Di?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fd=this._renderer.getRenderTarget(),kd=this._renderer.getActiveCubeFace(),Bd=this._renderer.getActiveMipmapLevel(),zd=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:pa,format:rn,colorSpace:fi,depthBuffer:!1},r=Dg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Dg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=dE(s)),this._blurMaterial=hE(s,e,t)}return r}_compileMaterial(e){let t=new vt(this._lodPlanes[0],e);this._renderer.compile(t,Nd)}_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(Pg),u.toneMapping=oi,u.autoClear=!1;let f=new zn({name:"PMREM.Background",side:Yt,depthWrite:!1,depthTest:!1}),p=new vt(new gr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Pg),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;Pl(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===ci||e.mapping===Di;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ug()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Og());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;Pl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,Nd)}_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=Lg[(r-s-1)%Lg.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,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*lr-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):lr;g>lr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${lr}`);let m=[],x=0;for(let E=0;E<lr;++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-hs?r-v+hs:0),A=4*(this._cubeSize-b);Pl(t,L,A,3*b,2*b),l.setRenderTarget(t),l.render(d,Nd)}};Go=class extends Mt{constructor(e,t,i,r,s,o,a,l,c,u){if(u=u!==void 0?u:fr,u!==fr&&u!==gs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===fr&&(i=mr),i===void 0&&u===gs&&(i=Cs),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}},tv=new Mt,nv=new Go(1,1);nv.compareFunction=up;iv=new vs,rv=new Bo,sv=new yr,Ng=[],Fg=[],kg=new Float32Array(16),Bg=new Float32Array(9),zg=new Float32Array(4);Gh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=BE(t.type)}},$h=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=sT(t.type)}},Wh=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)}}},Vd=/(\w+)(\])?(\[|\.)?/g;ms=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);oT(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}};aT=37297,lT=0;gT=/^[ \t]*#include +<([\w\d./]+)>/gm;yT=new Map;xT=/#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;TT=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 Yh(e),t.set(e,i)),i}},Yh=class{constructor(e){this.id=TT++,this.code=e,this.usedTimes=0}};OT=0;$o=class extends Dt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ky,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}},Wo=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}},kT=`void main() {
|
|
3770
3770
|
gl_Position = vec4( position, 1.0 );
|
|
3771
|
-
}`,
|
|
3771
|
+
}`,BT=`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
|
-
}`;mc=class extends Et{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Li=class extends rt{constructor(){super(),this.isGroup=!0,this.type="Group"}},
|
|
3797
|
+
}`;mc=class extends Et{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Li=class extends rt{constructor(){super(),this.isGroup=!0,this.type="Group"}},GT={type:"move"},wo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Li,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 Li,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 Li,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(GT)))}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 Li;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},$T=`
|
|
3798
3798
|
void main() {
|
|
3799
3799
|
|
|
3800
3800
|
gl_Position = vec4( position, 1.0 );
|
|
3801
3801
|
|
|
3802
|
-
}
|
|
3802
|
+
}`,WT=`
|
|
3803
3803
|
uniform sampler2DArray depthColor;
|
|
3804
3804
|
uniform float depthWidth;
|
|
3805
3805
|
uniform float depthHeight;
|
|
@@ -3818,22 +3818,22 @@ void main() {
|
|
|
3818
3818
|
|
|
3819
3819
|
}
|
|
3820
3820
|
|
|
3821
|
-
}`,qh=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 ln({vertexShader:GT,fragmentShader:$T,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new vt(new ws(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},Zh=class extends Cn{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 qh,g=t.getContextAttributes(),m=null,x=null,v=[],b=[],L=new te,A=null,E=new Et;E.layers.enable(1),E.viewport=new lt;let D=new Et;D.layers.enable(2),D.viewport=new lt;let M=[E,D],w=new mc;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 wo,v[Z]=q),q.getTargetRaySpace()},this.getControllerGrip=function(Z){let q=v[Z];return q===void 0&&(q=new wo,v[Z]=q),q.getGripSpace()},this.getHand=function(Z){let q=v[Z];return q===void 0&&(q=new wo,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,Ke.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 on(f.framebufferWidth,f.framebufferHeight,{format:rn,type:ui,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?gs:fr,pe=g.stencil?Cs:mr);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 on(h.textureWidth,h.textureHeight,{format:rn,type:ui,depthTexture:new Go(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),Ke.setContext(r),Ke.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=ys*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 Et,J.layers.enable(_e),J.viewport=new lt,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 Ke=new ev;Ke.setAnimationLoop(Le),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}},Qi=new an,WT=new Ne;Jh=class{constructor(e={}){let{canvas:t=qy(),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=yn,this._useLegacyLights=!1,this.toneMapping=oi,this.toneMappingExposure=1;let v=this,b=!1,L=0,A=0,E=null,D=-1,M=null,w=new lt,T=new lt,U=null,I=new we(0),B=0,W=t.width,F=t.height,X=1,k=null,re=null,se=new lt(0,0,W,F),ve=new lt(0,0,W,F),Le=!1,Ke=new vr,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,je,Pe,Me,De,Ze;function ft(){J=new fE(H),J.init(),Me=new ov(H,J),ce=new aE(H,J,e,Me),K=new zT(H),de=new gE(H),le=new IT,he=new VT(H,J,K,le,ce,Me,de),Ae=new cE(v),P=new hE(v),S=new MS(H),De=new sE(H,S),j=new pE(H,S,de,De),ee=new vE(H,j,S,de),Re=new yE(H,ce,he),ge=new lE(le),oe=new TT(v,Ae,P,J,ce,De,ge),ie=new jT(v,le),Ce=new RT,me=new NT(J),fe=new rE(v,Ae,P,K,ee,h,l),ke=new BT(v,ee,ce),Ze=new XT(H,de,ce,K),je=new oE(H,J,de),Pe=new mE(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}ft();let $e=new Zh(v,H);this.xr=$e,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($e.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===lp||ue===ap||ue===op}if($){let ue=E.texture.type,Ee=ue===ui||ue===mr||ue===tp||ue===Cs||ue===ip||ue===rp,Ie=fe.getClearColor(),Oe=fe.getClearAlpha(),Be=Ie.r,Xe=Ie.g,qe=Ie.b;Ee?(f[0]=Be,f[1]=Xe,f[2]=qe,f[3]=Oe,H.clearBufferuiv(H.COLOR,0,f)):(p[0]=Be,p[1]=Xe,p[2]=qe,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(),Ze.dispose(),oe.dispose(),$e.dispose(),$e.removeEventListener("sessionstart",tt),$e.removeEventListener("sessionend",qt),St.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;ft(),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=Pu(_,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 Xe=V.drawRange,qe=V.attributes.position,_t=Xe.start*Be,Nt=(Xe.start+Xe.count)*Be;ue!==null&&(_t=Math.max(_t,ue.start*Be),Nt=Math.min(Nt,(ue.start+ue.count)*Be)),Oe!==null?(_t=Math.max(_t,0),Nt=Math.min(Nt,Oe.count)):qe!=null&&(_t=Math.max(_t,0),Nt=Math.min(Nt,qe.count));let Kt=Nt-_t;if(Kt<0||Kt===1/0)return;De.setup($,N,Ie,V,Oe);let $n,it=je;if(Oe!==null&&($n=S.get(Oe),it=Pe,it.setIndex($n)),$.isMesh)N.wireframe===!0?(K.setLineWidth(N.wireframeLinewidth*_e()),it.setMode(H.LINES)):it.setMode(H.TRIANGLES);else if($.isLine){let Ve=N.linewidth;Ve===void 0&&(Ve=1),K.setLineWidth(Ve*_e()),$.isLineSegments?it.setMode(H.LINES):$.isLineLoop?it.setMode(H.LINE_LOOP):it.setMode(H.LINE_STRIP)}else $.isPoints?it.setMode(H.POINTS):$.isSprite&&it.setMode(H.TRIANGLES);if($.isBatchedMesh)$._multiDrawInstances!==null?it.renderMultiDrawInstances($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount,$._multiDrawInstances):it.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else if($.isInstancedMesh)it.renderInstances(_t,Kt,$.count);else if(V.isInstancedBufferGeometry){let Ve=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Ns=Math.min(V.instanceCount,Ve);it.renderInstances(_t,Kt,Ns)}else it.render(_t,Kt)};function Qe(_,O,V){_.transparent===!0&&_.side===Un&&_.forceSinglePass===!1?(_.side=Yt,_.needsUpdate=!0,Rr(_,O,V),_.side=li,_.needsUpdate=!0,Rr(_,O,V),_.side=Un):Rr(_,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];Qe(Ie,V,$),N.add(Ie)}else Qe(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 ct=null;function pt(_){ct&&ct(_)}function tt(){St.stop()}function qt(){St.start()}let St=new ev;St.setAnimationLoop(pt),typeof self<"u"&&St.setContext(self),this.setAnimationLoop=function(_){ct=_,$e.setAnimationLoop(_),_===null?St.stop():St.start()},$e.addEventListener("sessionstart",tt),$e.addEventListener("sessionend",qt),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(),$e.enabled===!0&&$e.isPresenting===!0&&($e.cameraAutoUpdate===!0&&$e.updateCamera(O),O=$e.getCamera()),_.isScene===!0&&_.onBeforeRender(v,_,O,E),g=me.get(_,x.length),g.init(O),x.push(g),pe.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ke.setFromProjectionMatrix(pe),q=this.localClippingEnabled,Z=ge.init(this.clippingPlanes,q),y=Ce.get(_,m.length),y.init(),m.push(y),_a(_,O,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,re);let V=$e.enabled===!1||$e.isPresenting===!1||$e.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];ba($,ue,_,Be)}V&&fe.render(_);for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];Os(y,_,Be,Be.viewport)}}else ue.length>0&&ba($,ue,_,O),V&&fe.render(_),Os(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 _a(_,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||Ke.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||Ke.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,Xe=Oe.length;Be<Xe;Be++){let qe=Oe[Be],_t=Ie[qe.materialIndex];_t&&_t.visible&&y.push(_,Ee,_t,V,ne.z,qe)}}else Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}let ue=_.children;for(let Ee=0,Ie=ue.length;Ee<Ie;Ee++)_a(ue[Ee],O,V,N)}function Os(_,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&&Cr($,O,V),ue.length>0&&Cr(ue,O,V),Ee.length>0&&Cr(Ee,O,V),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function ba(_,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 on(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?pa:ui,minFilter:Nn,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=oi;let Be=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),g.setupLightsView(N),Z===!0&&ge.setGlobalState(v.clippingPlanes,N),Cr(_,V,N),he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue),J.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let qe=0,_t=O.length;qe<_t;qe++){let Nt=O[qe],Kt=Nt.object,$n=Nt.geometry,it=Nt.material,Ve=Nt.group;if(it.side===Un&&Kt.layers.test(N.layers)){let Ns=it.side;it.side=Yt,it.needsUpdate=!0,wa(Kt,V,N,$n,it,Ve),it.side=Ns,it.needsUpdate=!0,Xe=!0}}Xe===!0&&(he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue))}v.setRenderTarget(Ie),v.setClearColor(I,B),Be!==void 0&&(N.viewport=Be),v.toneMapping=Oe}function Cr(_,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,Xe=Ee.group;Ie.layers.test(V.layers)&&wa(Ie,O,V,Oe,Be,Xe)}}function wa(_,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===Un&&$.forceSinglePass===!1?($.side=Yt,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=li,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=Un):v.renderBufferDirect(V,O,N,$,_,ue),_.onAfterRender(v,O,V,N,$,ue)}function Rr(_,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 Xe=Be.get(Oe);if(Xe!==void 0){if(N.currentProgram===Xe&&N.lightsStateVersion===Ee)return Ma(_,Ie),Xe}else Ie.uniforms=oe.getUniforms(_),_.onBuild(V,Ie,v),_.onBeforeCompile(Ie,v),Xe=oe.acquireProgram(Ie,Oe),Be.set(Oe,Xe),N.uniforms=Ie.uniforms;let qe=N.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(qe.clippingPlanes=ge.uniform),Ma(_,Ie),N.needsLights=G(_),N.lightsStateVersion=Ee,N.needsLights&&(qe.ambientLightColor.value=$.state.ambient,qe.lightProbe.value=$.state.probe,qe.directionalLights.value=$.state.directional,qe.directionalLightShadows.value=$.state.directionalShadow,qe.spotLights.value=$.state.spot,qe.spotLightShadows.value=$.state.spotShadow,qe.rectAreaLights.value=$.state.rectArea,qe.ltc_1.value=$.state.rectAreaLTC1,qe.ltc_2.value=$.state.rectAreaLTC2,qe.pointLights.value=$.state.point,qe.pointLightShadows.value=$.state.pointShadow,qe.hemisphereLights.value=$.state.hemi,qe.directionalShadowMap.value=$.state.directionalShadowMap,qe.directionalShadowMatrix.value=$.state.directionalShadowMatrix,qe.spotShadowMap.value=$.state.spotShadowMap,qe.spotLightMatrix.value=$.state.spotLightMatrix,qe.spotLightMap.value=$.state.spotLightMap,qe.pointShadowMap.value=$.state.pointShadowMap,qe.pointShadowMatrix.value=$.state.pointShadowMatrix),N.currentProgram=Xe,N.uniformsList=null,Xe}function Us(_){if(_.uniformsList===null){let O=_.currentProgram.getUniforms();_.uniformsList=ms.seqWithValue(O.seq,_.uniforms)}return _.uniformsList}function Ma(_,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 Pu(_,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:fi,Oe=(N.isMeshStandardMaterial?P:Ae).get(N.envMap||Ee),Be=N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Xe=!!V.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),qe=!!V.morphAttributes.position,_t=!!V.morphAttributes.normal,Nt=!!V.morphAttributes.color,Kt=oi;N.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Kt=v.toneMapping);let $n=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,it=$n!==void 0?$n.length:0,Ve=le.get(N),Ns=g.state.lights;if(Z===!0&&(q===!0||_!==M)){let dn=_===M&&N.id===D;ge.setState(N,_,dn)}let ht=!1;N.version===Ve.__version?(Ve.needsLights&&Ve.lightsStateVersion!==Ns.state.version||Ve.outputColorSpace!==Ie||$.isBatchedMesh&&Ve.batching===!1||!$.isBatchedMesh&&Ve.batching===!0||$.isInstancedMesh&&Ve.instancing===!1||!$.isInstancedMesh&&Ve.instancing===!0||$.isSkinnedMesh&&Ve.skinning===!1||!$.isSkinnedMesh&&Ve.skinning===!0||$.isInstancedMesh&&Ve.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&Ve.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&Ve.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&Ve.instancingMorph===!1&&$.morphTexture!==null||Ve.envMap!==Oe||N.fog===!0&&Ve.fog!==ue||Ve.numClippingPlanes!==void 0&&(Ve.numClippingPlanes!==ge.numPlanes||Ve.numIntersection!==ge.numIntersection)||Ve.vertexAlphas!==Be||Ve.vertexTangents!==Xe||Ve.morphTargets!==qe||Ve.morphNormals!==_t||Ve.morphColors!==Nt||Ve.toneMapping!==Kt||Ve.morphTargetsCount!==it)&&(ht=!0):(ht=!0,Ve.__version=N.version);let zi=Ve.currentProgram;ht===!0&&(zi=Rr(N,O,$));let wp=!1,Fs=!1,Lu=!1,Ft=zi.getUniforms(),mi=Ve.uniforms;if(K.useProgram(zi.program)&&(wp=!0,Fs=!0,Lu=!0),N.id!==D&&(D=N.id,Fs=!0),wp||M!==_){Ft.setValue(H,"projectionMatrix",_.projectionMatrix),Ft.setValue(H,"viewMatrix",_.matrixWorldInverse);let dn=Ft.map.cameraPosition;dn!==void 0&&dn.setValue(H,ne.setFromMatrixPosition(_.matrixWorld)),ce.logarithmicDepthBuffer&&Ft.setValue(H,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&Ft.setValue(H,"isOrthographic",_.isOrthographicCamera===!0),M!==_&&(M=_,Fs=!0,Lu=!0)}if($.isSkinnedMesh){Ft.setOptional(H,$,"bindMatrix"),Ft.setOptional(H,$,"bindMatrixInverse");let dn=$.skeleton;dn&&(dn.boneTexture===null&&dn.computeBoneTexture(),Ft.setValue(H,"boneTexture",dn.boneTexture,he))}$.isBatchedMesh&&(Ft.setOptional(H,$,"batchingTexture"),Ft.setValue(H,"batchingTexture",$._matricesTexture,he));let Du=V.morphAttributes;if((Du.position!==void 0||Du.normal!==void 0||Du.color!==void 0)&&Re.update($,V,zi),(Fs||Ve.receiveShadow!==$.receiveShadow)&&(Ve.receiveShadow=$.receiveShadow,Ft.setValue(H,"receiveShadow",$.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(mi.envMap.value=Oe,mi.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&O.environment!==null&&(mi.envMapIntensity.value=O.environmentIntensity),Fs&&(Ft.setValue(H,"toneMappingExposure",v.toneMappingExposure),Ve.needsLights&&C(mi,Lu),ue&&N.fog===!0&&ie.refreshFogUniforms(mi,ue),ie.refreshMaterialUniforms(mi,N,X,F,g.state.transmissionRenderTarget[_.id]),ms.upload(H,Us(Ve),mi,he)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(ms.upload(H,Us(Ve),mi,he),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&Ft.setValue(H,"center",$.center),Ft.setValue(H,"modelViewMatrix",$.modelViewMatrix),Ft.setValue(H,"normalMatrix",$.normalMatrix),Ft.setValue(H,"modelMatrix",$.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){let dn=N.uniformsGroups;for(let Ou=0,Bv=dn.length;Ou<Bv;Ou++){let Mp=dn[Ou];Ze.update(Mp,zi),Ze.bind(Mp,zi)}}return zi}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 Xe=le.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(Xe[O])?$=Xe[O][V]:$=Xe[O],ue=!0):_.samples>0&&he.useMultisampledRTT(_)===!1?$=le.get(_).__webglMultisampledFramebuffer:Array.isArray(Xe)?$=Xe[V]:$=Xe,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,Xe=Oe.type;if(!ce.textureFormatReadable(Be)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ce.textureTypeReadable(Xe)){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(Xe),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),Xe;if(N.isData3DTexture)he.setTexture3D(N,0),Xe=H.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)he.setTexture2DArray(N,0),Xe=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 qe=H.getParameter(H.UNPACK_ROW_LENGTH),_t=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Nt=H.getParameter(H.UNPACK_SKIP_PIXELS),Kt=H.getParameter(H.UNPACK_SKIP_ROWS),$n=H.getParameter(H.UNPACK_SKIP_IMAGES),it=V.isCompressedTexture?V.mipmaps[$]:V.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,it.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,it.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(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,it.data):N.isCompressedArrayTexture?H.compressedTexSubImage3D(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,it.data):H.texSubImage3D(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,it),H.pixelStorei(H.UNPACK_ROW_LENGTH,qe),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,_t),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Nt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Kt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,$n),$===0&&N.generateMipmaps&&H.generateMipmap(Xe),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 Fn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Su?"display-p3":"srgb",t.unpackColorSpace=at.workingColorSpace===ma?"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}},gc=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}}},yc=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}}},vc=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 an,this.environmentIntensity=1,this.environmentRotation=new an,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}},Ss=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=No,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=sn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Zy("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=sn()),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=sn()),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}}},Wt=new R,xr=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++)Wt.fromBufferAttribute(this,t),Wt.applyMatrix4(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Wt.fromBufferAttribute(this,t),Wt.applyNormalMatrix(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Wt.fromBufferAttribute(this,t),Wt.transformDirection(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xt(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=Xt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xt(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}}},jo=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}},co=new R,ss=new R,os=new R,as=new te,uo=new te,av=new Ne,Ll=new R,ho=new R,Dl=new R,Jg=new te,Hd=new te,Kg=new te,xc=class extends rt{constructor(e=new jo){if(super(),this.isSprite=!0,this.type="Sprite",rs===void 0){rs=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 Ss(t,5);rs.setIndex([0,1,2,0,2,3]),rs.setAttribute("position",new xr(i,3,0,!1)),rs.setAttribute("uv",new xr(i,2,3,!1))}this.geometry=rs,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.'),ss.setFromMatrixScale(this.matrixWorld),av.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),os.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ss.multiplyScalar(-os.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Ol(Ll.set(-.5,-.5,0),os,o,ss,r,s),Ol(ho.set(.5,-.5,0),os,o,ss,r,s),Ol(Dl.set(.5,.5,0),os,o,ss,r,s),Jg.set(0,0),Hd.set(1,0),Kg.set(1,1);let a=e.ray.intersectTriangle(Ll,ho,Dl,!1,co);if(a===null&&(Ol(ho.set(-.5,.5,0),os,o,ss,r,s),Hd.set(0,1),a=e.ray.intersectTriangle(Ll,Dl,ho,!1,co),a===null))return;let l=e.ray.origin.distanceTo(co);l<e.near||l>e.far||t.push({distance:l,point:co.clone(),uv:ii.getInterpolation(co,Ll,ho,Dl,Jg,Hd,Kg,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}};Ul=new R,Qg=new R,_c=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){Ul.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Ul);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Ul.setFromMatrixPosition(e.matrixWorld),Qg.setFromMatrixPosition(this.matrixWorld);let i=Ul.distanceTo(Qg)/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}},e0=new R,t0=new lt,n0=new lt,YT=new R,i0=new Ne,Nl=new R,Gd=new Lt,r0=new Ne,$d=new Oi,bc=class extends vt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=oh,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,Nl),this.boundingBox.expandByPoint(Nl)}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,Nl),this.boundingSphere.expandByPoint(Nl)}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&&(r0.copy(r).invert(),$d.copy(e.ray).applyMatrix4(r0),!(this.boundingBox!==null&&$d.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,$d)))}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===oh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Ay?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;t0.fromBufferAttribute(r.attributes.skinIndex,e),n0.fromBufferAttribute(r.attributes.skinWeight,e),e0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=n0.getComponent(s);if(o!==0){let a=t0.getComponent(s);i0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(YT.copy(e0).applyMatrix4(i0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},Xo=class extends rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},kn=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}},s0=new Ne,qT=new Ne,wc=class n{constructor(e=[],t=[]){this.uuid=sn(),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:qT;s0.multiplyMatrices(a,t[s]),s0.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 kn(t,e,e,rn,xn);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 Xo),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}},Ui=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}},ls=new Ne,o0=new Ne,Fl=[],a0=new Ot,ZT=new Ne,fo=new vt,po=new Lt,Mc=class extends vt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ui(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,ZT)}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,ls),a0.copy(e.boundingBox).applyMatrix4(ls),this.boundingBox.union(a0)}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,ls),po.copy(e.boundingSphere).applyMatrix4(ls),this.boundingSphere.union(po)}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(fo.geometry=this.geometry,fo.material=this.material,fo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),po.copy(this.boundingSphere),po.applyMatrix4(i),e.ray.intersectsSphere(po)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,ls),o0.multiplyMatrices(i,ls),fo.matrixWorld=o0,fo.raycast(e,Fl);for(let o=0,a=Fl.length;o<a;o++){let l=Fl[o];l.instanceId=s,l.object=this,t.push(l)}Fl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ui(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 kn(new Float32Array(r*this.count),r,this.count,sp,xn));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}};Kh=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}},cs="batchId",Ci=new Ne,l0=new Ne,QT=new Ne,c0=new Ne,Wd=new vr,kl=new Ot,er=new Lt,mo=new R,jd=new Kh,Ht=new vt,Bl=[];Sc=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 kn(t,e,e,rn,xn);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(cs,new nt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(cs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${cs}"`);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===cs)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,Ci),this.getBoundingBoxAt(r,kl).applyMatrix4(Ci),t.union(kl))}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,Ci),this.getBoundingSphereAt(r,er).applyMatrix4(Ci),t.union(er))}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++,QT.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 Ot,sphereInitialized:!1,sphere:new Lt});let g=this.geometry.getAttribute(cs);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===cs)continue;let p=t.getAttribute(f),y=i.getAttribute(f);eI(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(mo.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,kl),kl.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)),mo.fromBufferAttribute(l,f),u=Math.max(u,s.center.distanceToSquared(mo))}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;Ht.material=this.material,Ht.geometry.index=l.index,Ht.geometry.attributes=l.attributes,Ht.geometry.boundingBox===null&&(Ht.geometry.boundingBox=new Ot),Ht.geometry.boundingSphere===null&&(Ht.geometry.boundingSphere=new Lt);for(let c=0;c<o;c++){if(!i[c]||!r[c])continue;let u=s[c];Ht.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Ht.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,Ht.geometry.boundingBox),this.getBoundingSphereAt(c,Ht.geometry.boundingSphere),Ht.raycast(e,Bl);for(let d=0,h=Bl.length;d<h;d++){let f=Bl[d];f.object=this,f.batchId=c,t.push(f)}Bl.length=0}Ht.material=null,Ht.geometry.index=null,Ht.geometry.attributes={},Ht.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&&(c0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Wd.setFromProjectionMatrix(c0,e.coordinateSystem));let p=0;if(this.sortObjects){l0.copy(this.matrixWorld).invert(),mo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(l0);for(let m=0,x=c.length;m<x;m++)if(c[m]&&l[m]){this.getMatrixAt(m,Ci),this.getBoundingSphereAt(m,er).applyMatrix4(Ci);let v=!1;if(f&&(v=!Wd.intersectsSphere(er)),!v){let b=mo.distanceTo(er.center);jd.push(h[m],b)}}let y=jd.list,g=this.customSort;g===null?y.sort(s.transparent?KT:JT):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++}jd.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,Ci),this.getBoundingSphereAt(y,er).applyMatrix4(Ci),m=!Wd.intersectsSphere(er)),!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)}},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}},Ac=new R,Ec=new R,u0=new Ne,go=new Oi,zl=new Lt,Xd=new R,d0=new R,Vn=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++)Ac.fromBufferAttribute(t,r-1),Ec.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Ac.distanceTo(Ec);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(),zl.copy(i.boundingSphere),zl.applyMatrix4(r),zl.radius+=s,e.ray.intersectsSphere(zl)===!1)return;u0.copy(r).invert(),go.copy(e.ray).applyMatrix4(u0);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=Vl(this,e,go,l,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=Vl(this,e,go,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=Vl(this,e,go,l,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=Vl(this,e,go,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}}}}};h0=new R,f0=new R,_n=class extends Vn{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)h0.fromBufferAttribute(t,r),f0.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+h0.distanceTo(f0);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Tc=class extends Vn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Yo=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}},p0=new Ne,Qh=new Oi,Hl=new Lt,Gl=new R,Ic=class extends rt{constructor(e=new Ye,t=new Yo){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(),Hl.copy(i.boundingSphere),Hl.applyMatrix4(r),Hl.radius+=s,e.ray.intersectsSphere(Hl)===!1)return;p0.copy(r).invert(),Qh.copy(e.ray).applyMatrix4(p0);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);Gl.fromBufferAttribute(d,g),m0(Gl,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++)Gl.fromBufferAttribute(d,p),m0(Gl,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}}}}};ef=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)}},tf=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}},As=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}},nf=class extends As{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=vn}},rf=class extends As{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ci),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},sf=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}},cn=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(yt(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(yt(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}},Es=class extends cn{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}},Cc=class extends Es{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};$l=new R,Yd=new fp,qd=new fp,Zd=new fp,Rc=class extends cn{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]:($l.subVectors(r[0],r[1]).add(r[0]),c=$l);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:($l.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=$l),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),Yd.initNonuniformCatmullRom(c.x,d.x,h.x,u.x,p,y,g),qd.initNonuniformCatmullRom(c.y,d.y,h.y,u.y,p,y,g),Zd.initNonuniformCatmullRom(c.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(Yd.initCatmullRom(c.x,d.x,h.x,u.x,this.tension),qd.initCatmullRom(c.y,d.y,h.y,u.y,this.tension),Zd.initCatmullRom(c.z,d.z,h.z,u.z,this.tension));return i.set(Yd.calc(l),qd.calc(l),Zd.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}};qo=class extends cn{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(So(e,r.x,s.x,o.x,a.x),So(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}},Pc=class extends cn{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(So(e,r.x,s.x,o.x,a.x),So(e,r.y,s.y,o.y,a.y),So(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}},Zo=class extends cn{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}},Lc=class extends cn{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}},Jo=class extends cn{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(Mo(e,r.x,s.x,o.x),Mo(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}},Ko=class extends cn{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(Mo(e,r.x,s.x,o.x),Mo(e,r.y,s.y,o.y),Mo(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}},Qo=class extends cn{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(g0(a,l.x,c.x,u.x,d.x),g0(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}},Dc=Object.freeze({__proto__:null,ArcCurve:Cc,CatmullRomCurve3:Rc,CubicBezierCurve:qo,CubicBezierCurve3:Pc,EllipseCurve:Es,LineCurve:Zo,LineCurve3:Lc,QuadraticBezierCurve:Jo,QuadraticBezierCurve3:Ko,SplineCurve:Qo}),Oc=class extends cn{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 Dc[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 Dc[r.type]().fromJSON(r))}return this}},_r=class extends Oc{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 Zo(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 Jo(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 qo(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 Qo(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 Es(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}},ea=class n extends Ye{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=yt(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)}},Uc=class n extends ea{constructor(e=1,t=1,i=4,r=8){let s=new _r;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)}},Nc=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 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)}},Ts=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=[],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)}},Fc=class n extends Ts{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)}},Ni=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(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)}},kc=class n extends Ni{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)}},Wl=new R,jl=new R,Jd=new R,Xl=new ii,Bc=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(pr*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}=Xl;if(y.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),Xl.getNormal(Jd),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=Xl[u[x]],E=Xl[u[v]],D=`${b}_${L}`,M=`${L}_${b}`;M in h&&h[M]?(Jd.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:Jd.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];Wl.fromBufferAttribute(a,y),jl.fromBufferAttribute(a,g),f.push(Wl.x,Wl.y,Wl.z),f.push(jl.x,jl.y,jl.z)}this.setAttribute("position",new Te(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ai=class extends _r{constructor(e){super(e),this.uuid=sn(),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 _r().fromJSON(r))}return this}},lI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=lv(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=fI(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 ta(s,o,t,a,l,f,0),o}};Bn=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=[];v0(e),x0(i,e);let o=e.length;t.forEach(v0);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,x0(i,t[l]);let a=lI.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};zc=class n extends Ye{constructor(e=new ai([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:AI,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(!Bn.isClockWise(w)){w=w.reverse();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];Bn.isClockWise(K)&&(T[J]=K.reverse())}}let I=Bn.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 je=de*de+le*le;if(je<=2)return new te(de,le);he=Math.sqrt(je/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 Ke=p+y;for(let J=0;J<F;J++){let ce=h?W(w[J],Le[J],Ke):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],Ke):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 EI(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 Dc[r.type]().fromJSON(r)),new n(i,e.options)}},AI={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)]}};Vc=class n extends Ni{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)}},ra=class n extends Ni{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)}},Hc=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 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)}},Gc=class n extends Ye{constructor(e=new ai([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;Bn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Bn.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Bn.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 TI(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)}};sa=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 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)}},$c=class n extends Ni{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)}},Wc=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 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)}},jc=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 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)}},Xc=class n extends Ye{constructor(e=new Ko(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 Dc[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},Yc=class extends Ye{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),_0(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),_0(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}};b0=Object.freeze({__proto__:null,BoxGeometry:gr,CapsuleGeometry:Uc,CircleGeometry:Nc,ConeGeometry:Fc,CylinderGeometry:Ts,DodecahedronGeometry:kc,EdgesGeometry:Bc,ExtrudeGeometry:zc,IcosahedronGeometry:Vc,LatheGeometry:ea,OctahedronGeometry:ra,PlaneGeometry:ws,PolyhedronGeometry:Ni,RingGeometry:Hc,ShapeGeometry:Gc,SphereGeometry:sa,TetrahedronGeometry:$c,TorusGeometry:Wc,TorusKnotGeometry:jc,TubeGeometry:Xc,WireframeGeometry:Yc}),qc=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}},Zc=class extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},oa=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=ki,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 an,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}},Jc=class extends oa{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 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=ki,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 an,this.combine=fa,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}},Qc=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=ki,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}},eu=class extends Dt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ki,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}},tu=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=ki,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 an,this.combine=fa,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}},nu=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=ki,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}},iu=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}};RI={convertArray:dr,isTypedArray:dv,getKeyframeOrder:hv,sortedArray:lf,flattenJSON:pp,subclip:II,makeClipAdditive:CI},wr=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_(){}},ru=class extends wr{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:cr,endingEnd:cr}}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 ur:s=e,a=2*t-i;break;case Lo: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 ur:o=e,l=2*i-t;break;case Lo: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}},aa=class extends wr{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}},su=class extends wr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},un=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=dr(t,this.TimeBufferType),this.values=dr(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:dr(e.times,Array),values:dr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new aa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ru(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ro:t=this.InterpolantFactoryMethodDiscrete;break;case Po:t=this.InterpolantFactoryMethodLinear;break;case lc: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 Ro;case this.InterpolantFactoryMethodLinear:return Po;case this.InterpolantFactoryMethodSmooth:return lc}}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&&dv(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()===lc,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}};un.prototype.TimeBufferType=Float32Array;un.prototype.ValueBufferType=Float32Array;un.prototype.DefaultInterpolation=Po;di=class extends un{};di.prototype.ValueTypeName="bool";di.prototype.ValueBufferType=Array;di.prototype.DefaultInterpolation=Ro;di.prototype.InterpolantFactoryMethodLinear=void 0;di.prototype.InterpolantFactoryMethodSmooth=void 0;la=class extends un{};la.prototype.ValueTypeName="color";Mr=class extends un{};Mr.prototype.ValueTypeName="number";ou=class extends wr{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)Gt.slerpFlat(s,0,o,c-a,o,c,l);return s}},Fi=class extends un{InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}};Fi.prototype.ValueTypeName="quaternion";Fi.prototype.DefaultInterpolation=Po;Fi.prototype.InterpolantFactoryMethodSmooth=void 0;hi=class extends un{};hi.prototype.ValueTypeName="string";hi.prototype.ValueBufferType=Array;hi.prototype.DefaultInterpolation=Ro;hi.prototype.InterpolantFactoryMethodLinear=void 0;hi.prototype.InterpolantFactoryMethodSmooth=void 0;Sr=class extends un{};Sr.prototype.ValueTypeName="vector";Ar=class{constructor(e="",t=-1,i=[],r=Mu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=sn(),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(LI(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(un.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=hv(l);l=lf(l,1,u),c=lf(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Mr(".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=[];pp(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 Mr(".morphTargetInfluence["+y+"]",g,m))}l=f.length*o}else{let f=".bones["+t[d].name+"]";i(Sr,f+".position",h,"pos",r),i(Fi,f+".quaternion",h,"rot",r),i(Sr,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)}};ri={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={}}},ca=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}}},fv=new ca,$t=class{constructor(e){this.manager=e!==void 0?e:fv,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}};$t.DEFAULT_MATERIAL_NAME="__DEFAULT";Qn={},cf=class extends Error{constructor(e,t){super(e),this.response=t}},Rn=class extends $t{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=ri.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 cf(`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=>{ri.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}},uf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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=Ar.parse(e[i]);t.push(r)}return t}},df=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new As,l=new Rn(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 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=wt),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},Er=class extends $t{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=ri.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=ko("img");function l(){u(),ri.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}},hf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=new yr;s.colorSpace=yn;let o=new Er(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}},ff=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new kn,a=new Rn(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:vn,o.wrapT=c.wrapT!==void 0?c.wrapT:vn,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=Nn),c.mipmapCount===1&&(o.minFilter=wt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}},pf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=new Mt,o=new Er(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}},Hn=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}},au=class extends Hn{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}},Kd=new Ne,w0=new R,M0=new R,ua=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 vr,this._frameExtents=new te(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;w0.setFromMatrixPosition(e.matrixWorld),t.position.copy(w0),M0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(M0),t.updateMatrixWorld(),Kd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Kd),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Kd)}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}},mf=class extends ua{constructor(){super(new Et(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ys*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}},lu=class extends Hn{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 mf}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}},S0=new Ne,yo=new R,Qd=new R,gf=class extends ua{constructor(){super(new Et(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(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 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()),yo.setFromMatrixPosition(e.matrixWorld),i.position.copy(yo),Qd.copy(i.position),Qd.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Qd),i.updateMatrixWorld(),r.makeTranslation(-yo.x,-yo.y,-yo.z),S0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(S0)}},cu=class extends Hn{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 gf}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}},yf=class extends ua{constructor(){super(new Ms(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},uu=class extends Hn{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 yf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},du=class extends Hn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},hu=class extends Hn{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}},fu=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)}},pu=class extends Hn{constructor(e=new fu,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}},mu=class n extends $t{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Rn(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 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 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:qc,SpriteMaterial:jo,RawShaderMaterial:Zc,ShaderMaterial:ln,PointsMaterial:Yo,MeshPhysicalMaterial:Jc,MeshStandardMaterial:oa,MeshPhongMaterial:Kc,MeshToonMaterial:Qc,MeshNormalMaterial:eu,MeshLambertMaterial:tu,MeshDepthMaterial:$o,MeshDistanceMaterial:Wo,MeshBasicMaterial:zn,MeshMatcapMaterial:nu,LineDashedMaterial:iu,LineBasicMaterial:Ut,Material:Dt};return new t[e]}},da=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)}},gu=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}},yu=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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=ds(g.type,m),v=new Ss(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 gu:new Ye,a=e.data.index;if(a!==void 0){let f=ds(a.type,a.array);o.setIndex(new nt(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 xr(g,p.itemSize,p.offset,p.normalized)}else{let g=ds(p.type,p.array),m=p.isInstancedBufferAttribute?Ui:nt;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 xr(b,x.itemSize,x.offset,x.normalized)}else{let b=ds(x.type,x.array);v=new nt(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 Lt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},vf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Rn(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===""?da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Rn(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 ai().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 wc().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new yu;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 b0?a=b0[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 mu;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=Ar.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:ds(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){let l=new ca(t);s=new Er(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 kn(m.data,m.width,m.height)))}r[d.uuid]=new ni(f)}else{let f=a(d.url);r[d.uuid]=new ni(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:ds(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Er(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 kn(p.data,p.width,p.height)))}i[l.uuid]=new ni(u)}else{let u=await s(l.url);i[l.uuid]=new ni(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 yr,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new kn: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,DI)),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],A0),u.wrapT=i(a.wrap[1],A0)),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,E0)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,E0)),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 vc,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 yc(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new gc(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 du(e.color,e.intensity);break;case"DirectionalLight":o=new uu(e.color,e.intensity);break;case"PointLight":o=new cu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new hu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new lu(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new au(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new pu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new bc(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,p=e.instanceColor;o=new Mc(u,d,h),o.instanceMatrix=new Ui(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new Ui(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new Sc(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 m=new Lt;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 _c;break;case"Line":o=new Vn(a(e.geometry),l(e.material));break;case"LineLoop":o=new Tc(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 Ic(a(e.geometry),l(e.material));break;case"Sprite":o=new xc(l(e.material));break;case"Group":o=new Li;break;case"Bone":o=new Xo;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 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)}})}},DI={UVMapping:wu,CubeReflectionMapping:ci,CubeRefractionMapping:Di,EquirectangularReflectionMapping:Eo,EquirectangularRefractionMapping:To,CubeUVReflectionMapping:Is},A0={RepeatWrapping:Io,ClampToEdgeWrapping:vn,MirroredRepeatWrapping:Co},E0={NearestFilter:Pt,NearestMipmapNearestFilter:ep,NearestMipmapLinearFilter:us,LinearFilter:wt,LinearMipmapNearestFilter:_o,LinearMipmapLinearFilter:Nn},xf=class extends $t{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=ri.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 ri.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ri.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ri.add(e,l),s.manager.itemStart(e)}},ha=class{static getContext(){return Zl===void 0&&(Zl=new(window.AudioContext||window.webkitAudioContext)),Zl}static setContext(e){Zl=e}},_f=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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);ha.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)}}},T0=new Ne,I0=new Ne,tr=new Ne,bf=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,tr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(pr*t.fov*.5)/t.zoom,a,l;I0.elements[12]=-r,T0.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,tr.elements[0]=2*t.near/(l-a),tr.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(tr),a=-o*t.aspect-s,l=o*t.aspect-s,tr.elements[0]=2*t.near/(l-a),tr.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(tr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(I0),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(T0)}},vu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=C0(),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=C0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};nr=new R,R0=new Gt,OI=new R,ir=new R,wf=class extends rt{constructor(){super(),this.type="AudioListener",this.context=ha.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new vu}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(nr,R0,OI),ir.set(0,0,-1).applyQuaternion(R0),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(nr.x,r),t.positionY.linearRampToValueAtTime(nr.y,r),t.positionZ.linearRampToValueAtTime(nr.z,r),t.forwardX.linearRampToValueAtTime(ir.x,r),t.forwardY.linearRampToValueAtTime(ir.y,r),t.forwardZ.linearRampToValueAtTime(ir.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(nr.x,nr.y,nr.z),t.setOrientation(ir.x,ir.y,ir.z,i.x,i.y,i.z)}},xu=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}},rr=new R,P0=new Gt,UI=new R,sr=new R,Mf=class extends xu{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(rr,P0,UI),sr.set(0,0,1).applyQuaternion(P0);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(rr.x,i),t.positionY.linearRampToValueAtTime(rr.y,i),t.positionZ.linearRampToValueAtTime(rr.z,i),t.orientationX.linearRampToValueAtTime(sr.x,i),t.orientationY.linearRampToValueAtTime(sr.y,i),t.orientationZ.linearRampToValueAtTime(sr.z,i)}else t.setPosition(rr.x,rr.y,rr.z),t.setOrientation(sr.x,sr.y,sr.z)}},Sf=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}},_u=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){Gt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Gt.multiplyQuaternionsFlat(e,o,e,t,e,i),Gt.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}}},mp="\\[\\]\\.:\\/",NI=new RegExp("["+mp+"]","g"),gp="[^"+mp+"]",FI="[^"+mp.replace("\\.","")+"]",kI=/((?:WC+[\/:])*)/.source.replace("WC",gp),BI=/(WCOD+)?/.source.replace("WCOD",FI),zI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gp),VI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gp),HI=new RegExp("^"+kI+BI+zI+VI+"$"),GI=["material","materials","bones","map"],Af=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(NI,"")}static parseTrackName(e){let t=HI.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);GI.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=Af;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]];Ef=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=sn(),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 ot(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 ot(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 ot(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()}}},bu=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:cr,endingEnd:cr};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=Ny,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 cp:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mu: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===Fy;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Uy){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=ur,r.endingEnd=ur):(e?r.endingStart=this.zeroSlopeAtStart?ur:cr:r.endingStart=Lo,t?r.endingEnd=this.zeroSlopeAtEnd?ur:cr:r.endingEnd=Lo)}_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}},$I=new Float32Array(1),Tf=class extends Cn{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 _u(ot.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 aa(new Float32Array(2),new Float32Array(2),1,$I),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"?Ar.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=Mu),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 bu(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"?Ar.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))}},If=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},WI=0,Cf=class extends Cn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:WI++}),this.name="",this.usage=No,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)}},Rf=class extends Ss{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}},Pf=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}},L0=new Ne,Lf=class{constructor(e,t,i=0,r=1/0){this.ray=new Oi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new xs,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 L0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(L0),this}intersectObject(e,t=!0,i=[]){return Df(e,this,i,t),i.sort(D0),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Df(e[r],this,i,t);return i.sort(D0),i}};Of=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Uf=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)}},O0=new te,Nf=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=O0.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,O0).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)}},U0=new R,Jl=new R,Ff=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){U0.subVectors(e,this.start),Jl.subVectors(this.end,this.start);let i=Jl.dot(Jl),s=Jl.dot(U0)/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)}},N0=new R,kf=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),N0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(N0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Ri=new R,Kl=new Ne,eh=new Ne,Bf=class extends _n{constructor(e){let t=pv(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");eh.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(eh,a.matrixWorld),Ri.setFromMatrixPosition(Kl),r.setXYZ(o,Ri.x,Ri.y,Ri.z),Kl.multiplyMatrices(eh,a.parent.matrixWorld),Ri.setFromMatrixPosition(Kl),r.setXYZ(o+1,Ri.x,Ri.y,Ri.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};zf=class extends vt{constructor(e,t,i){let r=new sa(t,4,2),s=new zn({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)}},jI=new R,F0=new we,k0=new we,Vf=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 ra(t);r.rotateY(Math.PI*.5),this.material=new zn({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");F0.copy(this.light.color),k0.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?F0:k0;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(jI.setFromMatrixPosition(this.light.matrixWorld).negate())}},Hf=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,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 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,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 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()}},B0=new R,Ql=new R,z0=new R,$f=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 Vn(r,s),this.add(this.lightPlane),r=new Ye,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Vn(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),B0.setFromMatrixPosition(this.light.matrixWorld),Ql.setFromMatrixPosition(this.light.target.matrixWorld),z0.subVectors(Ql,B0),this.lightPlane.lookAt(Ql),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(Ql),this.targetLine.scale.z=z0.length()}},ec=new R,gt=new bs,Wf=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(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;gt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),xt("c",t,e,gt,0,0,-1),xt("t",t,e,gt,0,0,1),xt("n1",t,e,gt,-i,-r,-1),xt("n2",t,e,gt,i,-r,-1),xt("n3",t,e,gt,-i,r,-1),xt("n4",t,e,gt,i,r,-1),xt("f1",t,e,gt,-i,-r,1),xt("f2",t,e,gt,i,-r,1),xt("f3",t,e,gt,-i,r,1),xt("f4",t,e,gt,i,r,1),xt("u1",t,e,gt,i*.7,r*1.1,-1),xt("u2",t,e,gt,-i*.7,r*1.1,-1),xt("u3",t,e,gt,0,r*2,-1),xt("cf1",t,e,gt,-i,0,1),xt("cf2",t,e,gt,i,0,1),xt("cf3",t,e,gt,0,-r,1),xt("cf4",t,e,gt,0,r,1),xt("cn1",t,e,gt,-i,0,-1),xt("cn2",t,e,gt,i,0,-1),xt("cn3",t,e,gt,0,-r,-1),xt("cn4",t,e,gt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};tc=new Ot,jf=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&&tc.setFromObject(this.object),tc.isEmpty())return;let t=tc.min,i=tc.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()}},Yf=class extends Vn{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 zn({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()}},V0=new R,qf=class extends rt{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",nc===void 0&&(nc=new Ye,nc.setAttribute("position",new Te([0,0,0,0,1,0],3)),th=new Ts(0,.5,1,5,1),th.translate(0,-.5,0)),this.position.copy(t),this.line=new Vn(nc,new Ut({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new vt(th,new zn({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{V0.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(V0,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()}},Zf=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()}},Jf=class{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _r,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 ai;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=Bn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new ai,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 ai,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}},Kf=class extends on{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 IC={};Sp(IC,{DEFAULT_VIEWER_STATE:()=>mn,WORLDORBIT_FIELD_KEYS:()=>Ep,WORLDORBIT_FIELD_SCHEMAS:()=>Nu,WORLDORBIT_OBJECT_TYPES:()=>Bs,WORLD_LAYER_ID:()=>ul,WorldOrbit3DUnavailableError:()=>pn,WorldOrbitError:()=>Y,WorldOrbitViewerError:()=>to,clampScale:()=>io,cloneAtlasDocument:()=>Za,composeViewerTransform:()=>al,createAtlasViewer:()=>Ru,createDiagnostic:()=>Lp,createEmbedPayload:()=>Dv,createEmptyAtlasDocument:()=>sd,createInteractiveViewer:()=>Bi,createWorldOrbitEmbedMarkup:()=>Ov,defineWorldOrbitViewerElement:()=>kv,deserializeViewerAtlasState:()=>nl,deserializeWorldOrbitEmbedPayload:()=>_p,detectWorldOrbitSchemaVersion:()=>dd,diagnosticFromError:()=>Qt,evaluateSpatialSceneAtTime:()=>za,extractWorldOrbitBlocks:()=>qm,fitViewerState:()=>ji,focusViewerState:()=>ol,formatAtlasDocument:()=>Ha,formatDocument:()=>Ga,formatDraftDocument:()=>Yu,getAtlasDocumentNode:()=>od,getFieldSchema:()=>Zt,getSceneCenter:()=>Xi,getThemePreset:()=>Jm,getViewerVisibleBounds:()=>ll,invertViewerPoint:()=>Br,isKnownFieldKey:()=>Fu,listAtlasDocumentPaths:()=>km,load:()=>Iw,loadWorldOrbitSource:()=>wn,loadWorldOrbitSourceWithDiagnostics:()=>hd,materializeAtlasDocument:()=>Zs,materializeDraftDocument:()=>am,mountWorldOrbitEmbeds:()=>Uv,normalizeDocument:()=>Wn,normalizeRotation:()=>pd,normalizeViewerFilter:()=>en,normalizeWithDiagnostics:()=>Dp,panViewerState:()=>Wi,parse:()=>Zm,parseSafe:()=>Cw,parseWithDiagnostics:()=>Ta,parseWorldOrbit:()=>yi,parseWorldOrbitAtlas:()=>Ya,parseWorldOrbitDraft:()=>Im,removeAtlasDocumentNode:()=>zm,render:()=>Tw,renderDocumentToScene:()=>kt,renderDocumentToSpatialScene:()=>Ys,renderDocumentToSvg:()=>yd,renderSceneToSvg:()=>Mn,renderSourceToSvg:()=>sg,resolveAtlasDiagnosticPath:()=>cd,resolveAtlasDiagnostics:()=>ld,resolveLayers:()=>Ka,resolveTheme:()=>$i,rotatePoint:()=>Pn,rotateViewerState:()=>sl,sceneViewpointToLayerOptions:()=>il,searchSceneObjects:()=>el,serializeViewerAtlasState:()=>tl,serializeWorldOrbitEmbedPayload:()=>xp,stringify:()=>Rw,supportsObjectType:()=>ku,tokenizeLine:()=>Tp,tokenizeLineDetailed:()=>Vi,unitFamilyAllowsUnit:()=>zs,updateAtlasDocumentNode:()=>Bm,upgradeDocumentToDraftV2:()=>Va,upgradeDocumentToV2:()=>qs,upsertAtlasDocumentNode:()=>ad,validateAtlasDocumentWithDiagnostics:()=>Vm,validateDocument:()=>jn,validateDocumentWithDiagnostics:()=>Op,viewpointToViewerFilter:()=>rl,zoomViewerStateAt:()=>kr});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 ks=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],hn=ks.filter(n=>n!=="system"),jv=["star","planet","moon","asteroid","comet","structure","phenomenon"],Ap=["structure","phenomenon"],gi=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],Xv=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function et(n,e){return{key:n,...e}}var Bs=new Set(ks),Nu=new Map([et("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:gi}),et("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"distance"}),et("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"distance"}),et("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:gi}),et("period",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"duration"}),et("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("at",{kind:"string",placement:!0,arity:"single",objectTypes:Ap}),et("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Ap}),et("free",{kind:"string",placement:!0,arity:"single",objectTypes:Xv}),et("kind",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("class",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("culture",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:ks}),et("color",{kind:"string",placement:!1,arity:"single",objectTypes:ks}),et("image",{kind:"string",placement:!1,arity:"single",objectTypes:jv}),et("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:ks}),et("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"radius"}),et("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"mass"}),et("density",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:hn}),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:hn}),et("source",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"duration"})].map(n=>[n.key,n])),Ep=new Set(Nu.keys());function Zt(n){return Nu.get(n)}function Fu(n){return Ep.has(n)}function ku(n,e){return n.objectTypes.includes(e)}function zs(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 Tp(n){return Vi(n).map(e=>e.value)}function Vi(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 Sa(n){return n.match(/^\s*/)?.[0].length??0}function yi(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=Sa(h),y=Vi(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=Yv(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(Jv(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(Kv(y,f)):r.blockFields.push(Zv(y,f))}}return{type:"document",theme:i,objects:t}}function Yv(n,e){if(n.length<2)throw new Y("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Bs.has(t.value))throw new Y(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:qv(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function qv(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=Zt(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&&!Fu(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 Zv(n,e){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);if(!Zt(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 Jv(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 Kv(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 Ip=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Qv=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),ex=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Wn(n){let e=null,t=[],i=n.theme?tx(n.theme):null;for(let r of n.objects){let s=ix(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 tx(n){let e={};for(let t of n.blocks){let i=Cp(t.fields);e[t.target]=nx(i)}return{preset:n.preset,styles:e}}function nx(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 ix(n){let e=[...n.inlineFields,...n.blockFields];rx(n.objectType,e);let t=Cp(e),i=sx(n.objectType,t),r=ox(t),s=cx(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 rx(n,e){for(let t of e){let i=Zt(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(!ku(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 Cp(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 sx(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:Aa(e,"orbit"),distance:Pr(e,"distance"),semiMajor:Pr(e,"semiMajor"),eccentricity:hx(e,"eccentricity"),period:Pr(e,"period"),angle:Pr(e,"angle"),inclination:Pr(e,"inclination"),phase:Pr(e,"phase")};if(i){let a=Ea(e,"at"),l=Aa(e,"at");return{mode:"at",target:l,reference:ux(l,a.location)}}if(r)return{mode:"surface",target:Aa(e,"surface")};if(s){let a=Aa(e,"free"),l=dx(a);return{mode:"free",distance:l??void 0,descriptor:l?void 0:a}}return null}function ox(n){let e={};for(let[t,i]of n.entries()){let r=Zt(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=fx(i);break;case"number":e[t]=Pp(Lr(i),t,i.location);break;case"unit":e[t]=Rp(Lr(i),i.location,t);break;case"string":e[t]=ax(t,i);break}}return e}function ax(n,e){let t=e.values.join(" ").trim();return n==="image"&&lx(t,e.location),t}function lx(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(ex);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 cx(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 ux(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 Rp(n,e,t){let i=n.match(Ip);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Zt(t);if(s?.unitFamily&&!zs(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function dx(n){let e=n.match(Ip);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Pr(n,e){if(!n.has(e))return;let t=Ea(n,e);return Rp(Lr(t),t.location,e)}function hx(n,e){if(!n.has(e))return;let t=Ea(n,e);return Pp(Lr(t),e,t.location)}function Pp(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function fx(n){let e=Lr(n).toLowerCase(),t=Qv.get(e);if(t===void 0)throw Y.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Ea(n,e){let t=n.get(e);if(!t)throw new Y(`Missing value for key "${e}"`);return t}function Aa(n,e){return Lr(Ea(n,e))}function Lr(n){if(n.values.length!==1)throw Y.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var px=new Set(["star","planet","moon","asteroid","comet"]);function jn(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||!px.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"&&mx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&gx(i,i.placement.reference,e))}}function mx(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 gx(n,e,t){if(!t.has(e.objectId))throw new Y(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function Lp(n){return{...n}}function Qt(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)}}function Ta(n){let e;try{e=yi(n)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"parse")]}}let t;try{t=Wn(e)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"normalize")]}}try{jn(t)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"validate")]}}return{ok:!0,value:{ast:e,document:t},diagnostics:[]}}function Dp(n){try{return{ok:!0,value:Wn(n),diagnostics:[]}}catch(e){return{ok:!1,value:null,diagnostics:[Qt(e,"normalize")]}}}function Op(n){try{return jn(n),{ok:!0,value:n,diagnostics:[]}}catch(e){return{ok:!1,value:null,diagnostics:[Qt(e,"validate")]}}}var Vs=1495978707e-1,yx=6371,vx=71492,xx=695700,_x=63241.077,bx=206264.806,wx=206264806,Vp=.68,Mx=.2,Hp=28;function kt(n,e={}){let t=Ex(e),i=t.width,r=t.height,s=t.padding,o=Ax(n),a=Ix(n,e.projection),l=$u(e.camera??null),c=Gu(a,l),u=Px(o,e.scaleModel),d=Dx(o),h=n.system?.id??null,f=e.activeEventId??null,p=Sx(n.objects,n.events??[],f),y=new Map(p.map(q=>[q.id,q])),g=g_(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"){kp(D,pe.target,q);continue}if(pe.mode==="surface"){kp(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&&zu(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=js(ne,I.length,-Math.PI/2),_e=Xs(Fe,q,c,1);zu(pe,M+_e.x,w+_e.y,0,m,x,v,T)})}L.forEach((q,pe)=>{let ne=i-s-140-w_(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:La(q,0,u),sortKey:Oa(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"}),Ra(q,m,x,v,T,1)}),A.forEach((q,pe)=>{if(m.has(q.id)||!q.placement||q.placement.mode!=="at")return;let ne=p_(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:La(q,2,u),sortKey:Oa(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"}),Ra(q,m,x,v,T,2)});let B=[...m.values()].map(q=>Ox(q,u,g)),W=x.map(q=>Ux(q,g.groupIds.get(q.object.id)??null)),F=v.map(q=>Nx(q)),X=Fx(B,i,r,u.labelMultiplier),k=Wx(n,B),re=jx(n.events??[],B,f),se=Hx(W,k,re,F,B,X),ve=Gx(B,W,F,X,g,u.labelMultiplier),Le=$x(n,B),Ke=Xx(n,a,t.preset,g,y),Z=s_(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:Rx(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:Ke,events:re,activeEventId:f,objects:B,orbitVisuals:W,relations:k,leaders:F,labels:X}}function Pn(n,e,t){let i=Ua(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 Sx(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 Ax(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 Ex(n){let e=Tx(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function Tx(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 Ix(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return Wp(t)??"topdown"}function Gu(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 $u(n){if(!n)return null;let e={azimuth:Bu(n.azimuth),elevation:Bu(n.elevation),roll:Bu(n.roll),distance:Cx(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function Bu(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Cx(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Rx(n,e,t,i){let r=[`${Bp(n)} view`,`${Bp(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 Px(n,e){return{...Lx(n),...e}}function Lx(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 Dx(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function Ox(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:Dr(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:b_(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:S_(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function Ux(n,e){return{renderId:`${Dr(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 Nx(n){return{renderId:`${Dr(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 Fx(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(kx);for(let l of a){let c=Bx(l,o,s,e,t,i)??$p(l,Gp(l,o.get(l.parentId??"")??null,t),0,i);s.push(Zp(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 kx(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 Bx(n,e,t,i,r,s){for(let o of zx(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=Zp(n,c,s);if(!t.some(d=>x_(d,u)))return c}}return null}function zx(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=Gp(n,r,i),o=s==="below"?"above":"below",a=Vx(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 Gp(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 Vx(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 Hx(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 Gx(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:Ws(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=y_(l,n,e,t,i,s);return[...o.values()].sort((l,c)=>l.label.localeCompare(c.label))}function $x(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 Wx(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:`${Dr(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 jx(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:`${Dr(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 Xx(n,e,t,i,r){let s=Yx(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=n_(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};qx(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(c=>Zx(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 Yx(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=$u(null),o=Gu(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 qx(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=$s(l);return;case"projection":case"view":n.projection=Wp(l)??r;return;case"preset":n.preset=Kx(l)??s;return;case"rotation":case"angle":n.rotationDeg=Hs(l)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??Ca(),azimuth:Hs(l)};return;case"camera.elevation":n.camera={...n.camera??Ca(),elevation:Hs(l)};return;case"camera.roll":n.camera={...n.camera??Ca(),roll:Hs(l)};return;case"camera.distance":n.camera={...n.camera??Ca(),distance:Np(l)};return;case"zoom":case"scale":n.scale=Np(l);return;case"layers":n.layers=Qx(l);return;case"query":n.filter={...n.filter??Ia(),query:l||null};return;case"types":case"objecttypes":n.filter={...n.filter??Ia(),objectTypes:e_(l)};return;case"tags":n.filter={...n.filter??Ia(),tags:$s(l)};return;case"groups":n.filter={...n.filter??Ia(),groupIds:t_(l,i,o,a)};return}}function Zx(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=Jx(n.filter),a=n.label?.trim()||i_(n.id),l=n.projection??e,c=$u(n.camera??null),u=Gu(l,c);return{id:n.id,label:a,summary:n.summary?.trim()||r_(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 Ia(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Ca(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Jx(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 Wp(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Kx(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function Hs(n){let e=Number(n);return Number.isFinite(e)?e:null}function Np(n){let e=Hs(n);return e!==null&&e>0?e:null}function Qx(n){let e={};for(let t of $s(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 e_(n){return $s(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function t_(n,e,t,i){return $s(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)??Gs(r):(i.has(r),Gs(r)))}function $s(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function n_(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function i_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function r_(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 s_(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||jp(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||Xp(h,d);for(let h of s)h.hidden||Yp(h,d,o);return!Number.isFinite(a)||!Number.isFinite(l)?Ws(0,0,n,e):Ws(a,l,c,u)}function jp(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=Kp(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,Hp*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function Ws(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 Xp(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 Yp(n,e,t){let i=Jp(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 zu(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:La(n,i,a.scaleModel),sortKey:Oa(e,t,i)}),Ra(n,r,s,o,a,i+1))}function Ra(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(o_),l=a_(a,o.radius,r.spacingFactor,r.scaleModel),c=u_(a,l);a.forEach((d,h)=>{let f=l_(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}),zu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=js(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=Xs(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=Xs(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:La(d,s+1,r.scaleModel),sortKey:Oa(v,b,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?Gs(v_(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:b,mode:"surface"}),Ra(d,e,t,i,r,s+1)})}function o_(n,e){let t=Pa(n),i=Pa(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 a_(n,e,t,i){let r=n.map(d=>Pa(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 l_(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=At(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-c*c),u*.18),h=Hu(a.inclination)??0,f=o.projection==="isometric"?Math.max(Mx,Math.cos(Ua(h)))*Vp:1,p=Math.max(d*f,u*.14),y=Hu(a.angle)??0,g=u*c,m=em(-g,0,y),x=i.x+m.x,v=i.y+m.y,b=h_(a.phase,e,t),L=Qp(x,v,u,p,y,b),A=o.projection==="topdown"&&c<=1e-4&&Math.abs(y)<=1e-4,E=l?f_(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 c_(n,e){return e.innerPx+e.stepPx*d_(Math.max(n,0)+1)}function u_(n,e){let t=[];return n.forEach((i,r)=>{let s=Pa(i),o=e.innerPx+r*e.stepPx,a=s===null?o:c_(s,e),l=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,l))}),t}function Pa(n){return!n.placement||n.placement.mode!=="orbit"?null:Da(n.placement.semiMajor??n.placement.distance??null)}function d_(n){return Math.log(n)/Math.log(2)}function h_(n,e,t){let i=n?Hu(n):null;return i!==null?Ua(i-90):js(e,t,-Math.PI/2)}function f_(n,e,t,i){let r=Da(Vu(n.properties.inner)),s=Da(Vu(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 p_(n,e,t,i,r,s,o,a,l){if(n.kind==="lagrange")return m_(n,e,t,s,o);if(n.kind==="anchor"){let c=e.get(n.objectId);if(c){let u=js(i,r,Math.PI/5),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Xs(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=js(i,r,Math.PI/6),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Xs(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 m_(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,p=At(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 g_(n,e){let t=new Map,i=new Map;for(let c of n){let u=qp(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=Gs(u);s.set(c.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function qp(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 y_(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)&&Xp(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&jp(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)&&Yp(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?Ws(0,0,0,0):Ws(o,a,l,c)}function v_(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=qp(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function Zp(n,e,t){return Jp(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function Jp(n,e,t,i,r,s,o,a){let l=A_(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 x_(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 La(n,e,t){let i=M_(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 b_(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 Da(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/Vs;case"m":return n.value/1e3/Vs;case"ly":return n.value*_x;case"pc":return n.value*bx;case"kpc":return n.value*wx;case"re":return n.value*yx/Vs;case"rj":return n.value*vx/Vs;case"sol":return n.value*xx/Vs;default:return n.value}}function w_(n,e){let t=Da(n??null);return t===null||t<=0?0:At(t*96*e.freePlacementMultiplier,0,420)}function M_(n,e){let t=Vu(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 Vu(n){return!n||typeof n!="object"||!("value"in n)?null:n}function Hu(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function js(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function Fp(n,e,t,i,r,s,o){let a=Kp(n,e,t,i,r,s,o,Hp);return a.length===0?"":a.map((l,c)=>`${c===0?"M":"L"} ${zp(l.x)} ${zp(l.y)}`).join(" ")}function Kp(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(Qp(n,e,t,i,r,u))}return l}function Qp(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),l=em(o,a,r);return{x:n+l.x,y:e+l.y}}function em(n,e,t){let i=Ua(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function Xs(n,e,t,i){let r=t==="isometric"?Vp*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function Oa(n,e,t){return e*1e3+n+t*.01}function At(n,e,t){return Math.min(Math.max(n,e),t)}function kp(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Dr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function Gs(n){return`${Dr(n)}-group`}function S_(n){return typeof n=="string"&&n.trim()?n:void 0}function A_(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 Bp(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function Ua(n){return n*Math.PI/180}function zp(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var im=86400,Na=im*365.25,Fa=18,tm=180;function Ys(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=kt(n,t),r=C_(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,ju(g))}let c=Math.min(...[...l.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>E_(y,i,s,o,a,r,u,c)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>T_(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:P_(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function E_(n,e,t,i,r,s,o,a){let l=ka(n,e,t,i,r,o),c=Xu(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:Or(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Or(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 T_(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??Ba(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??Xu(n.object,n,t,i)}}function ka(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?ka(c,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=Xu(n.object,d,1,e.activeEventId!==null),f=h?rm(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};l=sm(u,f)}else if(a?.mode==="surface"&&n.parentId){let c=i.get(n.parentId),u=c?ka(c,e,t,i,r,s):{x:0,y:0,z:0},d=c?.visualRadius??16,h=L_(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?ka(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 za(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=rm(a.motion,n.timeFrozen?0:e);l=sm(c,u)}return i.set(s,l),l};for(let s of n.objects)r(s.objectId);return i}function rm(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=Wu(t),r=Wu(n.rotationDeg),s=Wu(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 Xu(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Or(ju(r)*48,24,1200),o=e?.radius??e?.ry??s,a=I_(r.period),l=ju(r),c=Or(l/Math.max(t,1e-4),1,20),u=Or(a?Fa*c:Fa*Math.pow(c,.75),Fa,tm);return{phase0Deg:Ba(r.phase)??0,rotationDeg:Ba(r.angle)??e?.rotationDeg??0,inclinationDeg:Ba(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 ju(n){let e=nm(n.semiMajor)??nm(n.distance)??1;return Math.max(e,.01)}function nm(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 I_(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*im;case"y":return n.value*Na;case"ky":return n.value*Na*1e3;case"my":return n.value*Na*1e6;case"gy":return n.value*Na*1e9;default:return null}}function Ba(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function C_(n,e){return{...R_(n),...e}}function R_(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 P_(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 sm(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function L_(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 Or(n,e,t){return Math.min(Math.max(n,e),t)}function Wu(n){return n*Math.PI/180}function qs(n,e={}){let t=kt(n,e),i=[],r=U_(n,i),s=N_(n,i),o=O_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?D_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(l=>!l.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(l=>!l.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.6.1",schemaVersion:"2.6.1",sourceVersion:n.version,theme:n.theme??null,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(lm),diagnostics:i}}function Va(n,e={}){return X_(qs(n,e))}function Zs(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:$_(n.system),info:W_(n.system)}:null,i=n.objects.map(lm);return z_(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(k_),objects:i}}function am(n){return Zs(n)}function D_(n,e,t,i,r,s){let o=kt(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(F_),annotations:i}}function O_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function U_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function N_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=om(s);if(!a)continue;let l=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":l.label=r;break;case"target":case"object":l.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":l.body=r;break;case"tags":l.tags=H_(r);break}t.set(a,l)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=om(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??G_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function F_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function lm(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:V_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function k_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(B_)}}function B_(n){return{objectId:n.objectId,placement:cm(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 cm(n){return n?structuredClone(n):null}function z_(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=cm(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 V_(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 H_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function om(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function G_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function $_(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 W_(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=j_(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 j_(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(" ")}function X_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var um=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function Ga(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6.1"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6.1"||n.version==="2.0-draft"){if(t==="2.0-draft"){let l=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6.1"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:Va(n);return Yu(l)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6.1"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:qs(n);return(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6.1")&&a.version!==t?Ha({...a,version:t,schemaVersion:t}):Ha(a)}let r=[],s=n;s.system&&r.push(...Y_(s.system));let o=[...s.objects].sort(Ju);for(let a of o)r.length>0&&r.push(""),r.push(...Z_(a));return r.join(`
|
|
3821
|
+
}`,qh=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 ln({vertexShader:$T,fragmentShader:WT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new vt(new ws(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},Zh=class extends Cn{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 qh,g=t.getContextAttributes(),m=null,x=null,v=[],b=[],L=new te,A=null,E=new Et;E.layers.enable(1),E.viewport=new lt;let D=new Et;D.layers.enable(2),D.viewport=new lt;let M=[E,D],w=new mc;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 wo,v[Z]=q),q.getTargetRaySpace()},this.getControllerGrip=function(Z){let q=v[Z];return q===void 0&&(q=new wo,v[Z]=q),q.getGripSpace()},this.getHand=function(Z){let q=v[Z];return q===void 0&&(q=new wo,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,Ke.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 on(f.framebufferWidth,f.framebufferHeight,{format:rn,type:ui,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?gs:fr,pe=g.stencil?Cs:mr);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 on(h.textureWidth,h.textureHeight,{format:rn,type:ui,depthTexture:new Go(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),Ke.setContext(r),Ke.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=ys*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 Et,J.layers.enable(_e),J.viewport=new lt,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 Ke=new ev;Ke.setAnimationLoop(Le),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}},Qi=new an,jT=new Ne;Jh=class{constructor(e={}){let{canvas:t=qy(),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=yn,this._useLegacyLights=!1,this.toneMapping=oi,this.toneMappingExposure=1;let v=this,b=!1,L=0,A=0,E=null,D=-1,M=null,w=new lt,T=new lt,U=null,I=new we(0),B=0,W=t.width,F=t.height,X=1,k=null,re=null,se=new lt(0,0,W,F),ve=new lt(0,0,W,F),Le=!1,Ke=new vr,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,je,Pe,Me,De,Ze;function ft(){J=new pE(H),J.init(),Me=new ov(H,J),ce=new lE(H,J,e,Me),K=new VT(H),de=new yE(H),le=new CT,he=new HT(H,J,K,le,ce,Me,de),Ae=new uE(v),P=new fE(v),S=new SS(H),De=new oE(H,S),j=new mE(H,S,de,De),ee=new xE(H,j,S,de),Re=new vE(H,ce,he),ge=new cE(le),oe=new IT(v,Ae,P,J,ce,De,ge),ie=new XT(v,le),Ce=new PT,me=new FT(J),fe=new sE(v,Ae,P,K,ee,h,l),ke=new zT(v,ee,ce),Ze=new YT(H,de,ce,K),je=new aE(H,J,de),Pe=new gE(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}ft();let $e=new Zh(v,H);this.xr=$e,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($e.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===lp||ue===ap||ue===op}if($){let ue=E.texture.type,Ee=ue===ui||ue===mr||ue===tp||ue===Cs||ue===ip||ue===rp,Ie=fe.getClearColor(),Oe=fe.getClearAlpha(),Be=Ie.r,Xe=Ie.g,qe=Ie.b;Ee?(f[0]=Be,f[1]=Xe,f[2]=qe,f[3]=Oe,H.clearBufferuiv(H.COLOR,0,f)):(p[0]=Be,p[1]=Xe,p[2]=qe,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(),Ze.dispose(),oe.dispose(),$e.dispose(),$e.removeEventListener("sessionstart",tt),$e.removeEventListener("sessionend",qt),St.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;ft(),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=Pu(_,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 Xe=V.drawRange,qe=V.attributes.position,_t=Xe.start*Be,Nt=(Xe.start+Xe.count)*Be;ue!==null&&(_t=Math.max(_t,ue.start*Be),Nt=Math.min(Nt,(ue.start+ue.count)*Be)),Oe!==null?(_t=Math.max(_t,0),Nt=Math.min(Nt,Oe.count)):qe!=null&&(_t=Math.max(_t,0),Nt=Math.min(Nt,qe.count));let Kt=Nt-_t;if(Kt<0||Kt===1/0)return;De.setup($,N,Ie,V,Oe);let $n,it=je;if(Oe!==null&&($n=S.get(Oe),it=Pe,it.setIndex($n)),$.isMesh)N.wireframe===!0?(K.setLineWidth(N.wireframeLinewidth*_e()),it.setMode(H.LINES)):it.setMode(H.TRIANGLES);else if($.isLine){let Ve=N.linewidth;Ve===void 0&&(Ve=1),K.setLineWidth(Ve*_e()),$.isLineSegments?it.setMode(H.LINES):$.isLineLoop?it.setMode(H.LINE_LOOP):it.setMode(H.LINE_STRIP)}else $.isPoints?it.setMode(H.POINTS):$.isSprite&&it.setMode(H.TRIANGLES);if($.isBatchedMesh)$._multiDrawInstances!==null?it.renderMultiDrawInstances($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount,$._multiDrawInstances):it.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else if($.isInstancedMesh)it.renderInstances(_t,Kt,$.count);else if(V.isInstancedBufferGeometry){let Ve=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Ns=Math.min(V.instanceCount,Ve);it.renderInstances(_t,Kt,Ns)}else it.render(_t,Kt)};function Qe(_,O,V){_.transparent===!0&&_.side===Un&&_.forceSinglePass===!1?(_.side=Yt,_.needsUpdate=!0,Rr(_,O,V),_.side=li,_.needsUpdate=!0,Rr(_,O,V),_.side=Un):Rr(_,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];Qe(Ie,V,$),N.add(Ie)}else Qe(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 ct=null;function pt(_){ct&&ct(_)}function tt(){St.stop()}function qt(){St.start()}let St=new ev;St.setAnimationLoop(pt),typeof self<"u"&&St.setContext(self),this.setAnimationLoop=function(_){ct=_,$e.setAnimationLoop(_),_===null?St.stop():St.start()},$e.addEventListener("sessionstart",tt),$e.addEventListener("sessionend",qt),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(),$e.enabled===!0&&$e.isPresenting===!0&&($e.cameraAutoUpdate===!0&&$e.updateCamera(O),O=$e.getCamera()),_.isScene===!0&&_.onBeforeRender(v,_,O,E),g=me.get(_,x.length),g.init(O),x.push(g),pe.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ke.setFromProjectionMatrix(pe),q=this.localClippingEnabled,Z=ge.init(this.clippingPlanes,q),y=Ce.get(_,m.length),y.init(),m.push(y),_a(_,O,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,re);let V=$e.enabled===!1||$e.isPresenting===!1||$e.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];ba($,ue,_,Be)}V&&fe.render(_);for(let Ie=0,Oe=Ee.length;Ie<Oe;Ie++){let Be=Ee[Ie];Os(y,_,Be,Be.viewport)}}else ue.length>0&&ba($,ue,_,O),V&&fe.render(_),Os(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 _a(_,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||Ke.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||Ke.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,Xe=Oe.length;Be<Xe;Be++){let qe=Oe[Be],_t=Ie[qe.materialIndex];_t&&_t.visible&&y.push(_,Ee,_t,V,ne.z,qe)}}else Ie.visible&&y.push(_,Ee,Ie,V,ne.z,null)}}let ue=_.children;for(let Ee=0,Ie=ue.length;Ee<Ie;Ee++)_a(ue[Ee],O,V,N)}function Os(_,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&&Cr($,O,V),ue.length>0&&Cr(ue,O,V),Ee.length>0&&Cr(Ee,O,V),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function ba(_,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 on(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?pa:ui,minFilter:Nn,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=oi;let Be=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),g.setupLightsView(N),Z===!0&&ge.setGlobalState(v.clippingPlanes,N),Cr(_,V,N),he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue),J.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let qe=0,_t=O.length;qe<_t;qe++){let Nt=O[qe],Kt=Nt.object,$n=Nt.geometry,it=Nt.material,Ve=Nt.group;if(it.side===Un&&Kt.layers.test(N.layers)){let Ns=it.side;it.side=Yt,it.needsUpdate=!0,wa(Kt,V,N,$n,it,Ve),it.side=Ns,it.needsUpdate=!0,Xe=!0}}Xe===!0&&(he.updateMultisampleRenderTarget(ue),he.updateRenderTargetMipmap(ue))}v.setRenderTarget(Ie),v.setClearColor(I,B),Be!==void 0&&(N.viewport=Be),v.toneMapping=Oe}function Cr(_,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,Xe=Ee.group;Ie.layers.test(V.layers)&&wa(Ie,O,V,Oe,Be,Xe)}}function wa(_,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===Un&&$.forceSinglePass===!1?($.side=Yt,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=li,$.needsUpdate=!0,v.renderBufferDirect(V,O,N,$,_,ue),$.side=Un):v.renderBufferDirect(V,O,N,$,_,ue),_.onAfterRender(v,O,V,N,$,ue)}function Rr(_,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 Xe=Be.get(Oe);if(Xe!==void 0){if(N.currentProgram===Xe&&N.lightsStateVersion===Ee)return Ma(_,Ie),Xe}else Ie.uniforms=oe.getUniforms(_),_.onBuild(V,Ie,v),_.onBeforeCompile(Ie,v),Xe=oe.acquireProgram(Ie,Oe),Be.set(Oe,Xe),N.uniforms=Ie.uniforms;let qe=N.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(qe.clippingPlanes=ge.uniform),Ma(_,Ie),N.needsLights=G(_),N.lightsStateVersion=Ee,N.needsLights&&(qe.ambientLightColor.value=$.state.ambient,qe.lightProbe.value=$.state.probe,qe.directionalLights.value=$.state.directional,qe.directionalLightShadows.value=$.state.directionalShadow,qe.spotLights.value=$.state.spot,qe.spotLightShadows.value=$.state.spotShadow,qe.rectAreaLights.value=$.state.rectArea,qe.ltc_1.value=$.state.rectAreaLTC1,qe.ltc_2.value=$.state.rectAreaLTC2,qe.pointLights.value=$.state.point,qe.pointLightShadows.value=$.state.pointShadow,qe.hemisphereLights.value=$.state.hemi,qe.directionalShadowMap.value=$.state.directionalShadowMap,qe.directionalShadowMatrix.value=$.state.directionalShadowMatrix,qe.spotShadowMap.value=$.state.spotShadowMap,qe.spotLightMatrix.value=$.state.spotLightMatrix,qe.spotLightMap.value=$.state.spotLightMap,qe.pointShadowMap.value=$.state.pointShadowMap,qe.pointShadowMatrix.value=$.state.pointShadowMatrix),N.currentProgram=Xe,N.uniformsList=null,Xe}function Us(_){if(_.uniformsList===null){let O=_.currentProgram.getUniforms();_.uniformsList=ms.seqWithValue(O.seq,_.uniforms)}return _.uniformsList}function Ma(_,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 Pu(_,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:fi,Oe=(N.isMeshStandardMaterial?P:Ae).get(N.envMap||Ee),Be=N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Xe=!!V.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),qe=!!V.morphAttributes.position,_t=!!V.morphAttributes.normal,Nt=!!V.morphAttributes.color,Kt=oi;N.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Kt=v.toneMapping);let $n=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,it=$n!==void 0?$n.length:0,Ve=le.get(N),Ns=g.state.lights;if(Z===!0&&(q===!0||_!==M)){let dn=_===M&&N.id===D;ge.setState(N,_,dn)}let ht=!1;N.version===Ve.__version?(Ve.needsLights&&Ve.lightsStateVersion!==Ns.state.version||Ve.outputColorSpace!==Ie||$.isBatchedMesh&&Ve.batching===!1||!$.isBatchedMesh&&Ve.batching===!0||$.isInstancedMesh&&Ve.instancing===!1||!$.isInstancedMesh&&Ve.instancing===!0||$.isSkinnedMesh&&Ve.skinning===!1||!$.isSkinnedMesh&&Ve.skinning===!0||$.isInstancedMesh&&Ve.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&Ve.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&Ve.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&Ve.instancingMorph===!1&&$.morphTexture!==null||Ve.envMap!==Oe||N.fog===!0&&Ve.fog!==ue||Ve.numClippingPlanes!==void 0&&(Ve.numClippingPlanes!==ge.numPlanes||Ve.numIntersection!==ge.numIntersection)||Ve.vertexAlphas!==Be||Ve.vertexTangents!==Xe||Ve.morphTargets!==qe||Ve.morphNormals!==_t||Ve.morphColors!==Nt||Ve.toneMapping!==Kt||Ve.morphTargetsCount!==it)&&(ht=!0):(ht=!0,Ve.__version=N.version);let zi=Ve.currentProgram;ht===!0&&(zi=Rr(N,O,$));let wp=!1,Fs=!1,Lu=!1,Ft=zi.getUniforms(),mi=Ve.uniforms;if(K.useProgram(zi.program)&&(wp=!0,Fs=!0,Lu=!0),N.id!==D&&(D=N.id,Fs=!0),wp||M!==_){Ft.setValue(H,"projectionMatrix",_.projectionMatrix),Ft.setValue(H,"viewMatrix",_.matrixWorldInverse);let dn=Ft.map.cameraPosition;dn!==void 0&&dn.setValue(H,ne.setFromMatrixPosition(_.matrixWorld)),ce.logarithmicDepthBuffer&&Ft.setValue(H,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&Ft.setValue(H,"isOrthographic",_.isOrthographicCamera===!0),M!==_&&(M=_,Fs=!0,Lu=!0)}if($.isSkinnedMesh){Ft.setOptional(H,$,"bindMatrix"),Ft.setOptional(H,$,"bindMatrixInverse");let dn=$.skeleton;dn&&(dn.boneTexture===null&&dn.computeBoneTexture(),Ft.setValue(H,"boneTexture",dn.boneTexture,he))}$.isBatchedMesh&&(Ft.setOptional(H,$,"batchingTexture"),Ft.setValue(H,"batchingTexture",$._matricesTexture,he));let Du=V.morphAttributes;if((Du.position!==void 0||Du.normal!==void 0||Du.color!==void 0)&&Re.update($,V,zi),(Fs||Ve.receiveShadow!==$.receiveShadow)&&(Ve.receiveShadow=$.receiveShadow,Ft.setValue(H,"receiveShadow",$.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(mi.envMap.value=Oe,mi.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&O.environment!==null&&(mi.envMapIntensity.value=O.environmentIntensity),Fs&&(Ft.setValue(H,"toneMappingExposure",v.toneMappingExposure),Ve.needsLights&&C(mi,Lu),ue&&N.fog===!0&&ie.refreshFogUniforms(mi,ue),ie.refreshMaterialUniforms(mi,N,X,F,g.state.transmissionRenderTarget[_.id]),ms.upload(H,Us(Ve),mi,he)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(ms.upload(H,Us(Ve),mi,he),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&Ft.setValue(H,"center",$.center),Ft.setValue(H,"modelViewMatrix",$.modelViewMatrix),Ft.setValue(H,"normalMatrix",$.normalMatrix),Ft.setValue(H,"modelMatrix",$.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){let dn=N.uniformsGroups;for(let Ou=0,Bv=dn.length;Ou<Bv;Ou++){let Mp=dn[Ou];Ze.update(Mp,zi),Ze.bind(Mp,zi)}}return zi}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 Xe=le.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(Xe[O])?$=Xe[O][V]:$=Xe[O],ue=!0):_.samples>0&&he.useMultisampledRTT(_)===!1?$=le.get(_).__webglMultisampledFramebuffer:Array.isArray(Xe)?$=Xe[V]:$=Xe,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,Xe=Oe.type;if(!ce.textureFormatReadable(Be)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ce.textureTypeReadable(Xe)){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(Xe),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),Xe;if(N.isData3DTexture)he.setTexture3D(N,0),Xe=H.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)he.setTexture2DArray(N,0),Xe=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 qe=H.getParameter(H.UNPACK_ROW_LENGTH),_t=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Nt=H.getParameter(H.UNPACK_SKIP_PIXELS),Kt=H.getParameter(H.UNPACK_SKIP_ROWS),$n=H.getParameter(H.UNPACK_SKIP_IMAGES),it=V.isCompressedTexture?V.mipmaps[$]:V.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,it.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,it.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(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,it.data):N.isCompressedArrayTexture?H.compressedTexSubImage3D(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,it.data):H.texSubImage3D(Xe,$,O.x,O.y,O.z,ue,Ee,Ie,Oe,Be,it),H.pixelStorei(H.UNPACK_ROW_LENGTH,qe),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,_t),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Nt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Kt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,$n),$===0&&N.generateMipmaps&&H.generateMipmap(Xe),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 Fn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Su?"display-p3":"srgb",t.unpackColorSpace=at.workingColorSpace===ma?"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}},gc=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}}},yc=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}}},vc=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 an,this.environmentIntensity=1,this.environmentRotation=new an,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}},Ss=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=No,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=sn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Zy("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=sn()),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=sn()),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}}},Wt=new R,xr=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++)Wt.fromBufferAttribute(this,t),Wt.applyMatrix4(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Wt.fromBufferAttribute(this,t),Wt.applyNormalMatrix(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Wt.fromBufferAttribute(this,t),Wt.transformDirection(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xt(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=Xt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xt(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}}},jo=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}},co=new R,ss=new R,os=new R,as=new te,uo=new te,av=new Ne,Ll=new R,ho=new R,Dl=new R,Jg=new te,Hd=new te,Kg=new te,xc=class extends rt{constructor(e=new jo){if(super(),this.isSprite=!0,this.type="Sprite",rs===void 0){rs=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 Ss(t,5);rs.setIndex([0,1,2,0,2,3]),rs.setAttribute("position",new xr(i,3,0,!1)),rs.setAttribute("uv",new xr(i,2,3,!1))}this.geometry=rs,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.'),ss.setFromMatrixScale(this.matrixWorld),av.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),os.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ss.multiplyScalar(-os.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Ol(Ll.set(-.5,-.5,0),os,o,ss,r,s),Ol(ho.set(.5,-.5,0),os,o,ss,r,s),Ol(Dl.set(.5,.5,0),os,o,ss,r,s),Jg.set(0,0),Hd.set(1,0),Kg.set(1,1);let a=e.ray.intersectTriangle(Ll,ho,Dl,!1,co);if(a===null&&(Ol(ho.set(-.5,.5,0),os,o,ss,r,s),Hd.set(0,1),a=e.ray.intersectTriangle(Ll,Dl,ho,!1,co),a===null))return;let l=e.ray.origin.distanceTo(co);l<e.near||l>e.far||t.push({distance:l,point:co.clone(),uv:ii.getInterpolation(co,Ll,ho,Dl,Jg,Hd,Kg,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}};Ul=new R,Qg=new R,_c=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){Ul.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Ul);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Ul.setFromMatrixPosition(e.matrixWorld),Qg.setFromMatrixPosition(this.matrixWorld);let i=Ul.distanceTo(Qg)/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}},e0=new R,t0=new lt,n0=new lt,qT=new R,i0=new Ne,Nl=new R,Gd=new Lt,r0=new Ne,$d=new Oi,bc=class extends vt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=oh,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,Nl),this.boundingBox.expandByPoint(Nl)}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,Nl),this.boundingSphere.expandByPoint(Nl)}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&&(r0.copy(r).invert(),$d.copy(e.ray).applyMatrix4(r0),!(this.boundingBox!==null&&$d.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,$d)))}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===oh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Ay?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;t0.fromBufferAttribute(r.attributes.skinIndex,e),n0.fromBufferAttribute(r.attributes.skinWeight,e),e0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=n0.getComponent(s);if(o!==0){let a=t0.getComponent(s);i0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(qT.copy(e0).applyMatrix4(i0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},Xo=class extends rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},kn=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}},s0=new Ne,ZT=new Ne,wc=class n{constructor(e=[],t=[]){this.uuid=sn(),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:ZT;s0.multiplyMatrices(a,t[s]),s0.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 kn(t,e,e,rn,xn);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 Xo),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}},Ui=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}},ls=new Ne,o0=new Ne,Fl=[],a0=new Ot,JT=new Ne,fo=new vt,po=new Lt,Mc=class extends vt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ui(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,JT)}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,ls),a0.copy(e.boundingBox).applyMatrix4(ls),this.boundingBox.union(a0)}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,ls),po.copy(e.boundingSphere).applyMatrix4(ls),this.boundingSphere.union(po)}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(fo.geometry=this.geometry,fo.material=this.material,fo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),po.copy(this.boundingSphere),po.applyMatrix4(i),e.ray.intersectsSphere(po)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,ls),o0.multiplyMatrices(i,ls),fo.matrixWorld=o0,fo.raycast(e,Fl);for(let o=0,a=Fl.length;o<a;o++){let l=Fl[o];l.instanceId=s,l.object=this,t.push(l)}Fl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ui(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 kn(new Float32Array(r*this.count),r,this.count,sp,xn));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}};Kh=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}},cs="batchId",Ci=new Ne,l0=new Ne,eI=new Ne,c0=new Ne,Wd=new vr,kl=new Ot,er=new Lt,mo=new R,jd=new Kh,Ht=new vt,Bl=[];Sc=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 kn(t,e,e,rn,xn);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(cs,new nt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(cs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${cs}"`);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===cs)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,Ci),this.getBoundingBoxAt(r,kl).applyMatrix4(Ci),t.union(kl))}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,Ci),this.getBoundingSphereAt(r,er).applyMatrix4(Ci),t.union(er))}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++,eI.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 Ot,sphereInitialized:!1,sphere:new Lt});let g=this.geometry.getAttribute(cs);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===cs)continue;let p=t.getAttribute(f),y=i.getAttribute(f);tI(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(mo.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,kl),kl.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)),mo.fromBufferAttribute(l,f),u=Math.max(u,s.center.distanceToSquared(mo))}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;Ht.material=this.material,Ht.geometry.index=l.index,Ht.geometry.attributes=l.attributes,Ht.geometry.boundingBox===null&&(Ht.geometry.boundingBox=new Ot),Ht.geometry.boundingSphere===null&&(Ht.geometry.boundingSphere=new Lt);for(let c=0;c<o;c++){if(!i[c]||!r[c])continue;let u=s[c];Ht.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Ht.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,Ht.geometry.boundingBox),this.getBoundingSphereAt(c,Ht.geometry.boundingSphere),Ht.raycast(e,Bl);for(let d=0,h=Bl.length;d<h;d++){let f=Bl[d];f.object=this,f.batchId=c,t.push(f)}Bl.length=0}Ht.material=null,Ht.geometry.index=null,Ht.geometry.attributes={},Ht.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&&(c0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Wd.setFromProjectionMatrix(c0,e.coordinateSystem));let p=0;if(this.sortObjects){l0.copy(this.matrixWorld).invert(),mo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(l0);for(let m=0,x=c.length;m<x;m++)if(c[m]&&l[m]){this.getMatrixAt(m,Ci),this.getBoundingSphereAt(m,er).applyMatrix4(Ci);let v=!1;if(f&&(v=!Wd.intersectsSphere(er)),!v){let b=mo.distanceTo(er.center);jd.push(h[m],b)}}let y=jd.list,g=this.customSort;g===null?y.sort(s.transparent?QT:KT):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++}jd.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,Ci),this.getBoundingSphereAt(y,er).applyMatrix4(Ci),m=!Wd.intersectsSphere(er)),!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)}},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}},Ac=new R,Ec=new R,u0=new Ne,go=new Oi,zl=new Lt,Xd=new R,d0=new R,Vn=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++)Ac.fromBufferAttribute(t,r-1),Ec.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Ac.distanceTo(Ec);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(),zl.copy(i.boundingSphere),zl.applyMatrix4(r),zl.radius+=s,e.ray.intersectsSphere(zl)===!1)return;u0.copy(r).invert(),go.copy(e.ray).applyMatrix4(u0);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=Vl(this,e,go,l,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=Vl(this,e,go,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=Vl(this,e,go,l,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=Vl(this,e,go,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}}}}};h0=new R,f0=new R,_n=class extends Vn{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)h0.fromBufferAttribute(t,r),f0.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+h0.distanceTo(f0);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Tc=class extends Vn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Yo=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}},p0=new Ne,Qh=new Oi,Hl=new Lt,Gl=new R,Ic=class extends rt{constructor(e=new Ye,t=new Yo){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(),Hl.copy(i.boundingSphere),Hl.applyMatrix4(r),Hl.radius+=s,e.ray.intersectsSphere(Hl)===!1)return;p0.copy(r).invert(),Qh.copy(e.ray).applyMatrix4(p0);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);Gl.fromBufferAttribute(d,g),m0(Gl,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++)Gl.fromBufferAttribute(d,p),m0(Gl,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}}}}};ef=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)}},tf=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}},As=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}},nf=class extends As{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=vn}},rf=class extends As{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ci),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},sf=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}},cn=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(yt(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(yt(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}},Es=class extends cn{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}},Cc=class extends Es{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};$l=new R,Yd=new fp,qd=new fp,Zd=new fp,Rc=class extends cn{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]:($l.subVectors(r[0],r[1]).add(r[0]),c=$l);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:($l.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=$l),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),Yd.initNonuniformCatmullRom(c.x,d.x,h.x,u.x,p,y,g),qd.initNonuniformCatmullRom(c.y,d.y,h.y,u.y,p,y,g),Zd.initNonuniformCatmullRom(c.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(Yd.initCatmullRom(c.x,d.x,h.x,u.x,this.tension),qd.initCatmullRom(c.y,d.y,h.y,u.y,this.tension),Zd.initCatmullRom(c.z,d.z,h.z,u.z,this.tension));return i.set(Yd.calc(l),qd.calc(l),Zd.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}};qo=class extends cn{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(So(e,r.x,s.x,o.x,a.x),So(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}},Pc=class extends cn{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(So(e,r.x,s.x,o.x,a.x),So(e,r.y,s.y,o.y,a.y),So(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}},Zo=class extends cn{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}},Lc=class extends cn{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}},Jo=class extends cn{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(Mo(e,r.x,s.x,o.x),Mo(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}},Ko=class extends cn{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(Mo(e,r.x,s.x,o.x),Mo(e,r.y,s.y,o.y),Mo(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}},Qo=class extends cn{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(g0(a,l.x,c.x,u.x,d.x),g0(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}},Dc=Object.freeze({__proto__:null,ArcCurve:Cc,CatmullRomCurve3:Rc,CubicBezierCurve:qo,CubicBezierCurve3:Pc,EllipseCurve:Es,LineCurve:Zo,LineCurve3:Lc,QuadraticBezierCurve:Jo,QuadraticBezierCurve3:Ko,SplineCurve:Qo}),Oc=class extends cn{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 Dc[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 Dc[r.type]().fromJSON(r))}return this}},_r=class extends Oc{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 Zo(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 Jo(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 qo(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 Qo(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 Es(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}},ea=class n extends Ye{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=yt(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)}},Uc=class n extends ea{constructor(e=1,t=1,i=4,r=8){let s=new _r;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)}},Nc=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 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)}},Ts=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=[],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)}},Fc=class n extends Ts{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)}},Ni=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(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)}},kc=class n extends Ni{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)}},Wl=new R,jl=new R,Jd=new R,Xl=new ii,Bc=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(pr*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}=Xl;if(y.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),Xl.getNormal(Jd),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=Xl[u[x]],E=Xl[u[v]],D=`${b}_${L}`,M=`${L}_${b}`;M in h&&h[M]?(Jd.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:Jd.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];Wl.fromBufferAttribute(a,y),jl.fromBufferAttribute(a,g),f.push(Wl.x,Wl.y,Wl.z),f.push(jl.x,jl.y,jl.z)}this.setAttribute("position",new Te(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ai=class extends _r{constructor(e){super(e),this.uuid=sn(),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 _r().fromJSON(r))}return this}},cI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=lv(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=pI(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 ta(s,o,t,a,l,f,0),o}};Bn=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=[];v0(e),x0(i,e);let o=e.length;t.forEach(v0);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,x0(i,t[l]);let a=cI.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};zc=class n extends Ye{constructor(e=new ai([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:EI,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(!Bn.isClockWise(w)){w=w.reverse();for(let J=0,ce=T.length;J<ce;J++){let K=T[J];Bn.isClockWise(K)&&(T[J]=K.reverse())}}let I=Bn.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 je=de*de+le*le;if(je<=2)return new te(de,le);he=Math.sqrt(je/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 Ke=p+y;for(let J=0;J<F;J++){let ce=h?W(w[J],Le[J],Ke):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],Ke):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 TI(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 Dc[r.type]().fromJSON(r)),new n(i,e.options)}},EI={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)]}};Vc=class n extends Ni{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)}},ra=class n extends Ni{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)}},Hc=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 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)}},Gc=class n extends Ye{constructor(e=new ai([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;Bn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Bn.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Bn.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 II(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)}};sa=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 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)}},$c=class n extends Ni{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)}},Wc=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 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)}},jc=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 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)}},Xc=class n extends Ye{constructor(e=new Ko(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 Dc[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},Yc=class extends Ye{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),_0(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),_0(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}};b0=Object.freeze({__proto__:null,BoxGeometry:gr,CapsuleGeometry:Uc,CircleGeometry:Nc,ConeGeometry:Fc,CylinderGeometry:Ts,DodecahedronGeometry:kc,EdgesGeometry:Bc,ExtrudeGeometry:zc,IcosahedronGeometry:Vc,LatheGeometry:ea,OctahedronGeometry:ra,PlaneGeometry:ws,PolyhedronGeometry:Ni,RingGeometry:Hc,ShapeGeometry:Gc,SphereGeometry:sa,TetrahedronGeometry:$c,TorusGeometry:Wc,TorusKnotGeometry:jc,TubeGeometry:Xc,WireframeGeometry:Yc}),qc=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}},Zc=class extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},oa=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=ki,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 an,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}},Jc=class extends oa{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 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=ki,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 an,this.combine=fa,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}},Qc=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=ki,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}},eu=class extends Dt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ki,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}},tu=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=ki,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 an,this.combine=fa,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}},nu=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=ki,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}},iu=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}};PI={convertArray:dr,isTypedArray:dv,getKeyframeOrder:hv,sortedArray:lf,flattenJSON:pp,subclip:CI,makeClipAdditive:RI},wr=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_(){}},ru=class extends wr{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:cr,endingEnd:cr}}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 ur:s=e,a=2*t-i;break;case Lo: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 ur:o=e,l=2*i-t;break;case Lo: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}},aa=class extends wr{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}},su=class extends wr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},un=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=dr(t,this.TimeBufferType),this.values=dr(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:dr(e.times,Array),values:dr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new aa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ru(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ro:t=this.InterpolantFactoryMethodDiscrete;break;case Po:t=this.InterpolantFactoryMethodLinear;break;case lc: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 Ro;case this.InterpolantFactoryMethodLinear:return Po;case this.InterpolantFactoryMethodSmooth:return lc}}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&&dv(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()===lc,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}};un.prototype.TimeBufferType=Float32Array;un.prototype.ValueBufferType=Float32Array;un.prototype.DefaultInterpolation=Po;di=class extends un{};di.prototype.ValueTypeName="bool";di.prototype.ValueBufferType=Array;di.prototype.DefaultInterpolation=Ro;di.prototype.InterpolantFactoryMethodLinear=void 0;di.prototype.InterpolantFactoryMethodSmooth=void 0;la=class extends un{};la.prototype.ValueTypeName="color";Mr=class extends un{};Mr.prototype.ValueTypeName="number";ou=class extends wr{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)Gt.slerpFlat(s,0,o,c-a,o,c,l);return s}},Fi=class extends un{InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}};Fi.prototype.ValueTypeName="quaternion";Fi.prototype.DefaultInterpolation=Po;Fi.prototype.InterpolantFactoryMethodSmooth=void 0;hi=class extends un{};hi.prototype.ValueTypeName="string";hi.prototype.ValueBufferType=Array;hi.prototype.DefaultInterpolation=Ro;hi.prototype.InterpolantFactoryMethodLinear=void 0;hi.prototype.InterpolantFactoryMethodSmooth=void 0;Sr=class extends un{};Sr.prototype.ValueTypeName="vector";Ar=class{constructor(e="",t=-1,i=[],r=Mu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=sn(),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(DI(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(un.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=hv(l);l=lf(l,1,u),c=lf(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Mr(".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=[];pp(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 Mr(".morphTargetInfluence["+y+"]",g,m))}l=f.length*o}else{let f=".bones["+t[d].name+"]";i(Sr,f+".position",h,"pos",r),i(Fi,f+".quaternion",h,"rot",r),i(Sr,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)}};ri={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={}}},ca=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}}},fv=new ca,$t=class{constructor(e){this.manager=e!==void 0?e:fv,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}};$t.DEFAULT_MATERIAL_NAME="__DEFAULT";Qn={},cf=class extends Error{constructor(e,t){super(e),this.response=t}},Rn=class extends $t{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=ri.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 cf(`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=>{ri.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}},uf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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=Ar.parse(e[i]);t.push(r)}return t}},df=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new As,l=new Rn(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 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=wt),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},Er=class extends $t{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=ri.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=ko("img");function l(){u(),ri.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}},hf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=new yr;s.colorSpace=yn;let o=new Er(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}},ff=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new kn,a=new Rn(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:vn,o.wrapT=c.wrapT!==void 0?c.wrapT:vn,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=Nn),c.mipmapCount===1&&(o.minFilter=wt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}},pf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=new Mt,o=new Er(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}},Hn=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}},au=class extends Hn{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}},Kd=new Ne,w0=new R,M0=new R,ua=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 vr,this._frameExtents=new te(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;w0.setFromMatrixPosition(e.matrixWorld),t.position.copy(w0),M0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(M0),t.updateMatrixWorld(),Kd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Kd),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Kd)}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}},mf=class extends ua{constructor(){super(new Et(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ys*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}},lu=class extends Hn{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 mf}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}},S0=new Ne,yo=new R,Qd=new R,gf=class extends ua{constructor(){super(new Et(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(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 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()),yo.setFromMatrixPosition(e.matrixWorld),i.position.copy(yo),Qd.copy(i.position),Qd.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Qd),i.updateMatrixWorld(),r.makeTranslation(-yo.x,-yo.y,-yo.z),S0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(S0)}},cu=class extends Hn{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 gf}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}},yf=class extends ua{constructor(){super(new Ms(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},uu=class extends Hn{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 yf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},du=class extends Hn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},hu=class extends Hn{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}},fu=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)}},pu=class extends Hn{constructor(e=new fu,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}},mu=class n extends $t{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Rn(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 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 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:qc,SpriteMaterial:jo,RawShaderMaterial:Zc,ShaderMaterial:ln,PointsMaterial:Yo,MeshPhysicalMaterial:Jc,MeshStandardMaterial:oa,MeshPhongMaterial:Kc,MeshToonMaterial:Qc,MeshNormalMaterial:eu,MeshLambertMaterial:tu,MeshDepthMaterial:$o,MeshDistanceMaterial:Wo,MeshBasicMaterial:zn,MeshMatcapMaterial:nu,LineDashedMaterial:iu,LineBasicMaterial:Ut,Material:Dt};return new t[e]}},da=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)}},gu=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}},yu=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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=ds(g.type,m),v=new Ss(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 gu:new Ye,a=e.data.index;if(a!==void 0){let f=ds(a.type,a.array);o.setIndex(new nt(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 xr(g,p.itemSize,p.offset,p.normalized)}else{let g=ds(p.type,p.array),m=p.isInstancedBufferAttribute?Ui:nt;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 xr(b,x.itemSize,x.offset,x.normalized)}else{let b=ds(x.type,x.array);v=new nt(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 Lt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},vf=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Rn(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===""?da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Rn(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 ai().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 wc().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new yu;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 b0?a=b0[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 mu;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=Ar.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:ds(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){let l=new ca(t);s=new Er(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 kn(m.data,m.width,m.height)))}r[d.uuid]=new ni(f)}else{let f=a(d.url);r[d.uuid]=new ni(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:ds(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Er(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 kn(p.data,p.width,p.height)))}i[l.uuid]=new ni(u)}else{let u=await s(l.url);i[l.uuid]=new ni(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 yr,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new kn: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,OI)),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],A0),u.wrapT=i(a.wrap[1],A0)),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,E0)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,E0)),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 vc,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 yc(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new gc(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 du(e.color,e.intensity);break;case"DirectionalLight":o=new uu(e.color,e.intensity);break;case"PointLight":o=new cu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new hu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new lu(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new au(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new pu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new bc(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,p=e.instanceColor;o=new Mc(u,d,h),o.instanceMatrix=new Ui(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new Ui(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new Sc(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 m=new Lt;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 _c;break;case"Line":o=new Vn(a(e.geometry),l(e.material));break;case"LineLoop":o=new Tc(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 Ic(a(e.geometry),l(e.material));break;case"Sprite":o=new xc(l(e.material));break;case"Group":o=new Li;break;case"Bone":o=new Xo;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 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)}})}},OI={UVMapping:wu,CubeReflectionMapping:ci,CubeRefractionMapping:Di,EquirectangularReflectionMapping:Eo,EquirectangularRefractionMapping:To,CubeUVReflectionMapping:Is},A0={RepeatWrapping:Io,ClampToEdgeWrapping:vn,MirroredRepeatWrapping:Co},E0={NearestFilter:Pt,NearestMipmapNearestFilter:ep,NearestMipmapLinearFilter:us,LinearFilter:wt,LinearMipmapNearestFilter:_o,LinearMipmapLinearFilter:Nn},xf=class extends $t{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=ri.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 ri.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ri.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ri.add(e,l),s.manager.itemStart(e)}},ha=class{static getContext(){return Zl===void 0&&(Zl=new(window.AudioContext||window.webkitAudioContext)),Zl}static setContext(e){Zl=e}},_f=class extends $t{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Rn(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);ha.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)}}},T0=new Ne,I0=new Ne,tr=new Ne,bf=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,tr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(pr*t.fov*.5)/t.zoom,a,l;I0.elements[12]=-r,T0.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,tr.elements[0]=2*t.near/(l-a),tr.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(tr),a=-o*t.aspect-s,l=o*t.aspect-s,tr.elements[0]=2*t.near/(l-a),tr.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(tr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(I0),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(T0)}},vu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=C0(),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=C0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};nr=new R,R0=new Gt,UI=new R,ir=new R,wf=class extends rt{constructor(){super(),this.type="AudioListener",this.context=ha.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new vu}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(nr,R0,UI),ir.set(0,0,-1).applyQuaternion(R0),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(nr.x,r),t.positionY.linearRampToValueAtTime(nr.y,r),t.positionZ.linearRampToValueAtTime(nr.z,r),t.forwardX.linearRampToValueAtTime(ir.x,r),t.forwardY.linearRampToValueAtTime(ir.y,r),t.forwardZ.linearRampToValueAtTime(ir.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(nr.x,nr.y,nr.z),t.setOrientation(ir.x,ir.y,ir.z,i.x,i.y,i.z)}},xu=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}},rr=new R,P0=new Gt,NI=new R,sr=new R,Mf=class extends xu{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(rr,P0,NI),sr.set(0,0,1).applyQuaternion(P0);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(rr.x,i),t.positionY.linearRampToValueAtTime(rr.y,i),t.positionZ.linearRampToValueAtTime(rr.z,i),t.orientationX.linearRampToValueAtTime(sr.x,i),t.orientationY.linearRampToValueAtTime(sr.y,i),t.orientationZ.linearRampToValueAtTime(sr.z,i)}else t.setPosition(rr.x,rr.y,rr.z),t.setOrientation(sr.x,sr.y,sr.z)}},Sf=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}},_u=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){Gt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Gt.multiplyQuaternionsFlat(e,o,e,t,e,i),Gt.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}}},mp="\\[\\]\\.:\\/",FI=new RegExp("["+mp+"]","g"),gp="[^"+mp+"]",kI="[^"+mp.replace("\\.","")+"]",BI=/((?:WC+[\/:])*)/.source.replace("WC",gp),zI=/(WCOD+)?/.source.replace("WCOD",kI),VI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gp),HI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gp),GI=new RegExp("^"+BI+zI+VI+HI+"$"),$I=["material","materials","bones","map"],Af=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(FI,"")}static parseTrackName(e){let t=GI.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);$I.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=Af;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]];Ef=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=sn(),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 ot(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 ot(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 ot(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()}}},bu=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:cr,endingEnd:cr};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=Ny,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 cp:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mu: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===Fy;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Uy){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=ur,r.endingEnd=ur):(e?r.endingStart=this.zeroSlopeAtStart?ur:cr:r.endingStart=Lo,t?r.endingEnd=this.zeroSlopeAtEnd?ur:cr:r.endingEnd=Lo)}_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}},WI=new Float32Array(1),Tf=class extends Cn{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 _u(ot.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 aa(new Float32Array(2),new Float32Array(2),1,WI),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"?Ar.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=Mu),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 bu(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"?Ar.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))}},If=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},jI=0,Cf=class extends Cn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:jI++}),this.name="",this.usage=No,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)}},Rf=class extends Ss{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}},Pf=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}},L0=new Ne,Lf=class{constructor(e,t,i=0,r=1/0){this.ray=new Oi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new xs,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 L0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(L0),this}intersectObject(e,t=!0,i=[]){return Df(e,this,i,t),i.sort(D0),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Df(e[r],this,i,t);return i.sort(D0),i}};Of=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Uf=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)}},O0=new te,Nf=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=O0.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,O0).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)}},U0=new R,Jl=new R,Ff=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){U0.subVectors(e,this.start),Jl.subVectors(this.end,this.start);let i=Jl.dot(Jl),s=Jl.dot(U0)/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)}},N0=new R,kf=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),N0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(N0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Ri=new R,Kl=new Ne,eh=new Ne,Bf=class extends _n{constructor(e){let t=pv(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");eh.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(eh,a.matrixWorld),Ri.setFromMatrixPosition(Kl),r.setXYZ(o,Ri.x,Ri.y,Ri.z),Kl.multiplyMatrices(eh,a.parent.matrixWorld),Ri.setFromMatrixPosition(Kl),r.setXYZ(o+1,Ri.x,Ri.y,Ri.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};zf=class extends vt{constructor(e,t,i){let r=new sa(t,4,2),s=new zn({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)}},XI=new R,F0=new we,k0=new we,Vf=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 ra(t);r.rotateY(Math.PI*.5),this.material=new zn({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");F0.copy(this.light.color),k0.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?F0:k0;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(XI.setFromMatrixPosition(this.light.matrixWorld).negate())}},Hf=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,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 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,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 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()}},B0=new R,Ql=new R,z0=new R,$f=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 Vn(r,s),this.add(this.lightPlane),r=new Ye,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Vn(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),B0.setFromMatrixPosition(this.light.matrixWorld),Ql.setFromMatrixPosition(this.light.target.matrixWorld),z0.subVectors(Ql,B0),this.lightPlane.lookAt(Ql),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(Ql),this.targetLine.scale.z=z0.length()}},ec=new R,gt=new bs,Wf=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(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;gt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),xt("c",t,e,gt,0,0,-1),xt("t",t,e,gt,0,0,1),xt("n1",t,e,gt,-i,-r,-1),xt("n2",t,e,gt,i,-r,-1),xt("n3",t,e,gt,-i,r,-1),xt("n4",t,e,gt,i,r,-1),xt("f1",t,e,gt,-i,-r,1),xt("f2",t,e,gt,i,-r,1),xt("f3",t,e,gt,-i,r,1),xt("f4",t,e,gt,i,r,1),xt("u1",t,e,gt,i*.7,r*1.1,-1),xt("u2",t,e,gt,-i*.7,r*1.1,-1),xt("u3",t,e,gt,0,r*2,-1),xt("cf1",t,e,gt,-i,0,1),xt("cf2",t,e,gt,i,0,1),xt("cf3",t,e,gt,0,-r,1),xt("cf4",t,e,gt,0,r,1),xt("cn1",t,e,gt,-i,0,-1),xt("cn2",t,e,gt,i,0,-1),xt("cn3",t,e,gt,0,-r,-1),xt("cn4",t,e,gt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};tc=new Ot,jf=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&&tc.setFromObject(this.object),tc.isEmpty())return;let t=tc.min,i=tc.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()}},Yf=class extends Vn{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 zn({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()}},V0=new R,qf=class extends rt{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",nc===void 0&&(nc=new Ye,nc.setAttribute("position",new Te([0,0,0,0,1,0],3)),th=new Ts(0,.5,1,5,1),th.translate(0,-.5,0)),this.position.copy(t),this.line=new Vn(nc,new Ut({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new vt(th,new zn({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{V0.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(V0,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()}},Zf=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()}},Jf=class{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _r,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 ai;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=Bn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new ai,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 ai,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}},Kf=class extends on{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 CC={};Sp(CC,{DEFAULT_VIEWER_STATE:()=>mn,WORLDORBIT_FIELD_KEYS:()=>Ep,WORLDORBIT_FIELD_SCHEMAS:()=>Nu,WORLDORBIT_OBJECT_TYPES:()=>Bs,WORLD_LAYER_ID:()=>ul,WorldOrbit3DUnavailableError:()=>pn,WorldOrbitError:()=>Y,WorldOrbitViewerError:()=>to,clampScale:()=>io,cloneAtlasDocument:()=>Za,composeViewerTransform:()=>al,createAtlasViewer:()=>Ru,createDiagnostic:()=>Lp,createEmbedPayload:()=>Dv,createEmptyAtlasDocument:()=>sd,createInteractiveViewer:()=>Bi,createWorldOrbitEmbedMarkup:()=>Ov,defineWorldOrbitViewerElement:()=>kv,deserializeViewerAtlasState:()=>nl,deserializeWorldOrbitEmbedPayload:()=>_p,detectWorldOrbitSchemaVersion:()=>dd,diagnosticFromError:()=>Qt,evaluateSpatialSceneAtTime:()=>za,extractWorldOrbitBlocks:()=>qm,fitViewerState:()=>ji,focusViewerState:()=>ol,formatAtlasDocument:()=>Ha,formatDocument:()=>Ga,formatDraftDocument:()=>Yu,getAtlasDocumentNode:()=>od,getFieldSchema:()=>Zt,getSceneCenter:()=>Xi,getThemePreset:()=>Jm,getViewerVisibleBounds:()=>ll,invertViewerPoint:()=>Br,isKnownFieldKey:()=>Fu,listAtlasDocumentPaths:()=>km,load:()=>Cw,loadWorldOrbitSource:()=>wn,loadWorldOrbitSourceWithDiagnostics:()=>hd,materializeAtlasDocument:()=>Zs,materializeDraftDocument:()=>am,mountWorldOrbitEmbeds:()=>Uv,normalizeDocument:()=>Wn,normalizeRotation:()=>pd,normalizeViewerFilter:()=>en,normalizeWithDiagnostics:()=>Dp,panViewerState:()=>Wi,parse:()=>Zm,parseSafe:()=>Rw,parseWithDiagnostics:()=>Ta,parseWorldOrbit:()=>yi,parseWorldOrbitAtlas:()=>Ya,parseWorldOrbitDraft:()=>Im,removeAtlasDocumentNode:()=>zm,render:()=>Iw,renderDocumentToScene:()=>kt,renderDocumentToSpatialScene:()=>Ys,renderDocumentToSvg:()=>yd,renderSceneToSvg:()=>Mn,renderSourceToSvg:()=>sg,resolveAtlasDiagnosticPath:()=>cd,resolveAtlasDiagnostics:()=>ld,resolveLayers:()=>Ka,resolveTheme:()=>$i,rotatePoint:()=>Pn,rotateViewerState:()=>sl,sceneViewpointToLayerOptions:()=>il,searchSceneObjects:()=>el,serializeViewerAtlasState:()=>tl,serializeWorldOrbitEmbedPayload:()=>xp,stringify:()=>Pw,supportsObjectType:()=>ku,tokenizeLine:()=>Tp,tokenizeLineDetailed:()=>Vi,unitFamilyAllowsUnit:()=>zs,updateAtlasDocumentNode:()=>Bm,upgradeDocumentToDraftV2:()=>Va,upgradeDocumentToV2:()=>qs,upsertAtlasDocumentNode:()=>ad,validateAtlasDocumentWithDiagnostics:()=>Vm,validateDocument:()=>jn,validateDocumentWithDiagnostics:()=>Op,viewpointToViewerFilter:()=>rl,zoomViewerStateAt:()=>kr});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 ks=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],hn=ks.filter(n=>n!=="system"),jv=["star","planet","moon","asteroid","comet","structure","phenomenon"],Ap=["structure","phenomenon"],gi=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],Xv=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function et(n,e){return{key:n,...e}}var Bs=new Set(ks),Nu=new Map([et("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:gi}),et("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"distance"}),et("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"distance"}),et("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:gi}),et("period",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"duration"}),et("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:gi,unitFamily:"angle"}),et("at",{kind:"string",placement:!0,arity:"single",objectTypes:Ap}),et("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Ap}),et("free",{kind:"string",placement:!0,arity:"single",objectTypes:Xv}),et("kind",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("class",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("culture",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:ks}),et("color",{kind:"string",placement:!1,arity:"single",objectTypes:ks}),et("image",{kind:"string",placement:!1,arity:"single",objectTypes:jv}),et("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:ks}),et("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"radius"}),et("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"mass"}),et("density",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"generic"}),et("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:hn}),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:hn}),et("source",{kind:"string",placement:!1,arity:"single",objectTypes:hn}),et("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:hn,unitFamily:"duration"})].map(n=>[n.key,n])),Ep=new Set(Nu.keys());function Zt(n){return Nu.get(n)}function Fu(n){return Ep.has(n)}function ku(n,e){return n.objectTypes.includes(e)}function zs(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 Tp(n){return Vi(n).map(e=>e.value)}function Vi(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 Sa(n){return n.match(/^\s*/)?.[0].length??0}function yi(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=Sa(h),y=Vi(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=Yv(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(Jv(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(Kv(y,f)):r.blockFields.push(Zv(y,f))}}return{type:"document",theme:i,objects:t}}function Yv(n,e){if(n.length<2)throw new Y("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Bs.has(t.value))throw new Y(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:qv(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function qv(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=Zt(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&&!Fu(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 Zv(n,e){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);if(!Zt(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 Jv(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 Kv(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 Ip=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Qv=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),ex=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Wn(n){let e=null,t=[],i=n.theme?tx(n.theme):null;for(let r of n.objects){let s=ix(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 tx(n){let e={};for(let t of n.blocks){let i=Cp(t.fields);e[t.target]=nx(i)}return{preset:n.preset,styles:e}}function nx(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 ix(n){let e=[...n.inlineFields,...n.blockFields];rx(n.objectType,e);let t=Cp(e),i=sx(n.objectType,t),r=ox(t),s=cx(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 rx(n,e){for(let t of e){let i=Zt(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(!ku(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 Cp(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 sx(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:Aa(e,"orbit"),distance:Pr(e,"distance"),semiMajor:Pr(e,"semiMajor"),eccentricity:hx(e,"eccentricity"),period:Pr(e,"period"),angle:Pr(e,"angle"),inclination:Pr(e,"inclination"),phase:Pr(e,"phase")};if(i){let a=Ea(e,"at"),l=Aa(e,"at");return{mode:"at",target:l,reference:ux(l,a.location)}}if(r)return{mode:"surface",target:Aa(e,"surface")};if(s){let a=Aa(e,"free"),l=dx(a);return{mode:"free",distance:l??void 0,descriptor:l?void 0:a}}return null}function ox(n){let e={};for(let[t,i]of n.entries()){let r=Zt(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=fx(i);break;case"number":e[t]=Pp(Lr(i),t,i.location);break;case"unit":e[t]=Rp(Lr(i),i.location,t);break;case"string":e[t]=ax(t,i);break}}return e}function ax(n,e){let t=e.values.join(" ").trim();return n==="image"&&lx(t,e.location),t}function lx(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(ex);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 cx(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 ux(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 Rp(n,e,t){let i=n.match(Ip);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Zt(t);if(s?.unitFamily&&!zs(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function dx(n){let e=n.match(Ip);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Pr(n,e){if(!n.has(e))return;let t=Ea(n,e);return Rp(Lr(t),t.location,e)}function hx(n,e){if(!n.has(e))return;let t=Ea(n,e);return Pp(Lr(t),e,t.location)}function Pp(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function fx(n){let e=Lr(n).toLowerCase(),t=Qv.get(e);if(t===void 0)throw Y.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Ea(n,e){let t=n.get(e);if(!t)throw new Y(`Missing value for key "${e}"`);return t}function Aa(n,e){return Lr(Ea(n,e))}function Lr(n){if(n.values.length!==1)throw Y.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var px=new Set(["star","planet","moon","asteroid","comet"]);function jn(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||!px.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"&&mx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&gx(i,i.placement.reference,e))}}function mx(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 gx(n,e,t){if(!t.has(e.objectId))throw new Y(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function Lp(n){return{...n}}function Qt(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)}}function Ta(n){let e;try{e=yi(n)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"parse")]}}let t;try{t=Wn(e)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"normalize")]}}try{jn(t)}catch(i){return{ok:!1,value:null,diagnostics:[Qt(i,"validate")]}}return{ok:!0,value:{ast:e,document:t},diagnostics:[]}}function Dp(n){try{return{ok:!0,value:Wn(n),diagnostics:[]}}catch(e){return{ok:!1,value:null,diagnostics:[Qt(e,"normalize")]}}}function Op(n){try{return jn(n),{ok:!0,value:n,diagnostics:[]}}catch(e){return{ok:!1,value:null,diagnostics:[Qt(e,"validate")]}}}var Vs=1495978707e-1,yx=6371,vx=71492,xx=695700,_x=63241.077,bx=206264.806,wx=206264806,Vp=.68,Mx=.2,Hp=28;function kt(n,e={}){let t=Ex(e),i=t.width,r=t.height,s=t.padding,o=Ax(n),a=Ix(n,e.projection),l=$u(e.camera??null),c=Gu(a,l),u=Px(o,e.scaleModel),d=Dx(o),h=n.system?.id??null,f=e.activeEventId??null,p=Sx(n.objects,n.events??[],f),y=new Map(p.map(q=>[q.id,q])),g=g_(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"){kp(D,pe.target,q);continue}if(pe.mode==="surface"){kp(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&&zu(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=js(ne,I.length,-Math.PI/2),_e=Xs(Fe,q,c,1);zu(pe,M+_e.x,w+_e.y,0,m,x,v,T)})}L.forEach((q,pe)=>{let ne=i-s-140-w_(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:La(q,0,u),sortKey:Oa(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"}),Ra(q,m,x,v,T,1)}),A.forEach((q,pe)=>{if(m.has(q.id)||!q.placement||q.placement.mode!=="at")return;let ne=p_(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:La(q,2,u),sortKey:Oa(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"}),Ra(q,m,x,v,T,2)});let B=[...m.values()].map(q=>Ox(q,u,g)),W=x.map(q=>Ux(q,g.groupIds.get(q.object.id)??null)),F=v.map(q=>Nx(q)),X=Fx(B,i,r,u.labelMultiplier),k=Wx(n,B),re=jx(n.events??[],B,f),se=Hx(W,k,re,F,B,X),ve=Gx(B,W,F,X,g,u.labelMultiplier),Le=$x(n,B),Ke=Xx(n,a,t.preset,g,y),Z=s_(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:Rx(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:Ke,events:re,activeEventId:f,objects:B,orbitVisuals:W,relations:k,leaders:F,labels:X}}function Pn(n,e,t){let i=Ua(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 Sx(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 Ax(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 Ex(n){let e=Tx(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function Tx(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 Ix(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return Wp(t)??"topdown"}function Gu(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 $u(n){if(!n)return null;let e={azimuth:Bu(n.azimuth),elevation:Bu(n.elevation),roll:Bu(n.roll),distance:Cx(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function Bu(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Cx(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Rx(n,e,t,i){let r=[`${Bp(n)} view`,`${Bp(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 Px(n,e){return{...Lx(n),...e}}function Lx(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 Dx(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function Ox(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:Dr(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:b_(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:S_(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function Ux(n,e){return{renderId:`${Dr(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 Nx(n){return{renderId:`${Dr(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 Fx(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(kx);for(let l of a){let c=Bx(l,o,s,e,t,i)??$p(l,Gp(l,o.get(l.parentId??"")??null,t),0,i);s.push(Zp(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 kx(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 Bx(n,e,t,i,r,s){for(let o of zx(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=Zp(n,c,s);if(!t.some(d=>x_(d,u)))return c}}return null}function zx(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=Gp(n,r,i),o=s==="below"?"above":"below",a=Vx(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 Gp(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 Vx(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 Hx(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 Gx(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:Ws(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=y_(l,n,e,t,i,s);return[...o.values()].sort((l,c)=>l.label.localeCompare(c.label))}function $x(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 Wx(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:`${Dr(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 jx(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:`${Dr(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 Xx(n,e,t,i,r){let s=Yx(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=n_(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};qx(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(c=>Zx(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 Yx(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=$u(null),o=Gu(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 qx(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=$s(l);return;case"projection":case"view":n.projection=Wp(l)??r;return;case"preset":n.preset=Kx(l)??s;return;case"rotation":case"angle":n.rotationDeg=Hs(l)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??Ca(),azimuth:Hs(l)};return;case"camera.elevation":n.camera={...n.camera??Ca(),elevation:Hs(l)};return;case"camera.roll":n.camera={...n.camera??Ca(),roll:Hs(l)};return;case"camera.distance":n.camera={...n.camera??Ca(),distance:Np(l)};return;case"zoom":case"scale":n.scale=Np(l);return;case"layers":n.layers=Qx(l);return;case"query":n.filter={...n.filter??Ia(),query:l||null};return;case"types":case"objecttypes":n.filter={...n.filter??Ia(),objectTypes:e_(l)};return;case"tags":n.filter={...n.filter??Ia(),tags:$s(l)};return;case"groups":n.filter={...n.filter??Ia(),groupIds:t_(l,i,o,a)};return}}function Zx(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=Jx(n.filter),a=n.label?.trim()||i_(n.id),l=n.projection??e,c=$u(n.camera??null),u=Gu(l,c);return{id:n.id,label:a,summary:n.summary?.trim()||r_(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 Ia(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Ca(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Jx(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 Wp(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Kx(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function Hs(n){let e=Number(n);return Number.isFinite(e)?e:null}function Np(n){let e=Hs(n);return e!==null&&e>0?e:null}function Qx(n){let e={};for(let t of $s(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 e_(n){return $s(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function t_(n,e,t,i){return $s(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.schemaVersion==="2.6"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??Gs(r):(i.has(r),Gs(r)))}function $s(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function n_(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function i_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function r_(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 s_(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||jp(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||Xp(h,d);for(let h of s)h.hidden||Yp(h,d,o);return!Number.isFinite(a)||!Number.isFinite(l)?Ws(0,0,n,e):Ws(a,l,c,u)}function jp(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=Kp(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,Hp*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function Ws(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 Xp(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 Yp(n,e,t){let i=Jp(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 zu(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:La(n,i,a.scaleModel),sortKey:Oa(e,t,i)}),Ra(n,r,s,o,a,i+1))}function Ra(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(o_),l=a_(a,o.radius,r.spacingFactor,r.scaleModel),c=u_(a,l);a.forEach((d,h)=>{let f=l_(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}),zu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=js(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=Xs(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=Xs(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:La(d,s+1,r.scaleModel),sortKey:Oa(v,b,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?Gs(v_(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:b,mode:"surface"}),Ra(d,e,t,i,r,s+1)})}function o_(n,e){let t=Pa(n),i=Pa(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 a_(n,e,t,i){let r=n.map(d=>Pa(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 l_(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=At(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-c*c),u*.18),h=Hu(a.inclination)??0,f=o.projection==="isometric"?Math.max(Mx,Math.cos(Ua(h)))*Vp:1,p=Math.max(d*f,u*.14),y=Hu(a.angle)??0,g=u*c,m=em(-g,0,y),x=i.x+m.x,v=i.y+m.y,b=h_(a.phase,e,t),L=Qp(x,v,u,p,y,b),A=o.projection==="topdown"&&c<=1e-4&&Math.abs(y)<=1e-4,E=l?f_(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 c_(n,e){return e.innerPx+e.stepPx*d_(Math.max(n,0)+1)}function u_(n,e){let t=[];return n.forEach((i,r)=>{let s=Pa(i),o=e.innerPx+r*e.stepPx,a=s===null?o:c_(s,e),l=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,l))}),t}function Pa(n){return!n.placement||n.placement.mode!=="orbit"?null:Da(n.placement.semiMajor??n.placement.distance??null)}function d_(n){return Math.log(n)/Math.log(2)}function h_(n,e,t){let i=n?Hu(n):null;return i!==null?Ua(i-90):js(e,t,-Math.PI/2)}function f_(n,e,t,i){let r=Da(Vu(n.properties.inner)),s=Da(Vu(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 p_(n,e,t,i,r,s,o,a,l){if(n.kind==="lagrange")return m_(n,e,t,s,o);if(n.kind==="anchor"){let c=e.get(n.objectId);if(c){let u=js(i,r,Math.PI/5),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Xs(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=js(i,r,Math.PI/6),d=(c.radius+36)*l.scaleModel.labelMultiplier,h=Xs(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 m_(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,p=At(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 g_(n,e){let t=new Map,i=new Map;for(let c of n){let u=qp(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=Gs(u);s.set(c.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function qp(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 y_(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)&&Xp(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&jp(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)&&Yp(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?Ws(0,0,0,0):Ws(o,a,l,c)}function v_(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=qp(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function Zp(n,e,t){return Jp(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function Jp(n,e,t,i,r,s,o,a){let l=A_(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 x_(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 La(n,e,t){let i=M_(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 b_(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 Da(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/Vs;case"m":return n.value/1e3/Vs;case"ly":return n.value*_x;case"pc":return n.value*bx;case"kpc":return n.value*wx;case"re":return n.value*yx/Vs;case"rj":return n.value*vx/Vs;case"sol":return n.value*xx/Vs;default:return n.value}}function w_(n,e){let t=Da(n??null);return t===null||t<=0?0:At(t*96*e.freePlacementMultiplier,0,420)}function M_(n,e){let t=Vu(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 Vu(n){return!n||typeof n!="object"||!("value"in n)?null:n}function Hu(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function js(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function Fp(n,e,t,i,r,s,o){let a=Kp(n,e,t,i,r,s,o,Hp);return a.length===0?"":a.map((l,c)=>`${c===0?"M":"L"} ${zp(l.x)} ${zp(l.y)}`).join(" ")}function Kp(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(Qp(n,e,t,i,r,u))}return l}function Qp(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),l=em(o,a,r);return{x:n+l.x,y:e+l.y}}function em(n,e,t){let i=Ua(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function Xs(n,e,t,i){let r=t==="isometric"?Vp*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function Oa(n,e,t){return e*1e3+n+t*.01}function At(n,e,t){return Math.min(Math.max(n,e),t)}function kp(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Dr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function Gs(n){return`${Dr(n)}-group`}function S_(n){return typeof n=="string"&&n.trim()?n:void 0}function A_(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 Bp(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function Ua(n){return n*Math.PI/180}function zp(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var im=86400,Na=im*365.25,Fa=18,tm=180;function Ys(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=kt(n,t),r=C_(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,ju(g))}let c=Math.min(...[...l.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>E_(y,i,s,o,a,r,u,c)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>T_(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:P_(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function E_(n,e,t,i,r,s,o,a){let l=ka(n,e,t,i,r,o),c=Xu(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:Or(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Or(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 T_(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??Ba(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??Xu(n.object,n,t,i)}}function ka(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?ka(c,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=Xu(n.object,d,1,e.activeEventId!==null),f=h?rm(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};l=sm(u,f)}else if(a?.mode==="surface"&&n.parentId){let c=i.get(n.parentId),u=c?ka(c,e,t,i,r,s):{x:0,y:0,z:0},d=c?.visualRadius??16,h=L_(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?ka(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 za(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=rm(a.motion,n.timeFrozen?0:e);l=sm(c,u)}return i.set(s,l),l};for(let s of n.objects)r(s.objectId);return i}function rm(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=Wu(t),r=Wu(n.rotationDeg),s=Wu(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 Xu(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Or(ju(r)*48,24,1200),o=e?.radius??e?.ry??s,a=I_(r.period),l=ju(r),c=Or(l/Math.max(t,1e-4),1,20),u=Or(a?Fa*c:Fa*Math.pow(c,.75),Fa,tm);return{phase0Deg:Ba(r.phase)??0,rotationDeg:Ba(r.angle)??e?.rotationDeg??0,inclinationDeg:Ba(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 ju(n){let e=nm(n.semiMajor)??nm(n.distance)??1;return Math.max(e,.01)}function nm(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 I_(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*im;case"y":return n.value*Na;case"ky":return n.value*Na*1e3;case"my":return n.value*Na*1e6;case"gy":return n.value*Na*1e9;default:return null}}function Ba(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function C_(n,e){return{...R_(n),...e}}function R_(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 P_(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 sm(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function L_(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 Or(n,e,t){return Math.min(Math.max(n,e),t)}function Wu(n){return n*Math.PI/180}function qs(n,e={}){let t=kt(n,e),i=[],r=U_(n,i),s=N_(n,i),o=O_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?D_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(l=>!l.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(l=>!l.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.6",schemaVersion:"2.6",sourceVersion:n.version,theme:n.theme??null,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(lm),diagnostics:i}}function Va(n,e={}){return X_(qs(n,e))}function Zs(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:$_(n.system),info:W_(n.system)}:null,i=n.objects.map(lm);return z_(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(k_),objects:i}}function am(n){return Zs(n)}function D_(n,e,t,i,r,s){let o=kt(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(F_),annotations:i}}function O_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function U_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function N_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=om(s);if(!a)continue;let l=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":l.label=r;break;case"target":case"object":l.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":l.body=r;break;case"tags":l.tags=H_(r);break}t.set(a,l)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=om(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??G_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function F_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function lm(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:V_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function k_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(B_)}}function B_(n){return{objectId:n.objectId,placement:cm(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 cm(n){return n?structuredClone(n):null}function z_(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=cm(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 V_(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 H_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function om(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function G_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function $_(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 W_(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=j_(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 j_(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(" ")}function X_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var um=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function Ga(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"||n.version==="2.0-draft"){if(t==="2.0-draft"){let l=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:Va(n);return Yu(l)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:qs(n);return(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6")&&a.version!==t?Ha({...a,version:t,schemaVersion:t}):Ha(a)}let r=[],s=n;s.system&&r.push(...Y_(s.system));let o=[...s.objects].sort(Ju);for(let a of o)r.length>0&&r.push(""),r.push(...Z_(a));return r.join(`
|
|
3822
3822
|
`)}function Ha(n){let e=[`schema ${n.version}`,""];n.system&&e.push(...hm(n.system));for(let i of[...n.groups].sort(Ur))e.push(""),e.push(...gm(i));for(let i of[...n.relations].sort(Ur))e.push(""),e.push(...ym(i));for(let i of[...n.events].sort(Ur))e.push(""),e.push(...vm(i));let t=[...n.objects].sort(Ju);return t.length>0&&e.at(-1)!==""&&e.push(""),t.forEach((i,r)=>{r>0&&e.push(""),e.push(...fm(i))}),e.join(`
|
|
3823
3823
|
`)}function Yu(n){let e=n.version==="2.0-draft"?n:{...n,version:"2.0-draft",schemaVersion:"2.0-draft"},t=["schema 2.0-draft",""];e.system&&t.push(...hm(e.system));for(let r of[...e.groups].sort(Ur))t.push(""),t.push(...gm(r));for(let r of[...e.relations].sort(Ur))t.push(""),t.push(...ym(r));for(let r of[...e.events].sort(Ur))t.push(""),t.push(...vm(r));let i=[...e.objects].sort(Ju);return i.length>0&&t.at(-1)!==""&&t.push(""),i.forEach((r,s)=>{s>0&&t.push(""),t.push(...fm(r))}),t.join(`
|
|
3824
|
-
`)}function Y_(n){return q_("system",n.id,n.properties,null,n.info)}function q_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...qu(i),...mm(t)];for(let l of o)s.push(` ${l}`);let a=Object.entries(r).sort(([l],[c])=>l.localeCompare(c));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[l,c]of a)s.push(` ${l} ${ze(c)}`)}return s}function hm(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${ze(n.title)}`),n.description&&e.push(` description ${ze(n.description)}`),n.epoch&&e.push(` epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${ze(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${ze(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${ze(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${ze(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${ze(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...K_(t));for(let t of n.annotations)e.push(""),e.push(...Q_(t));return e}function Z_(n){return pm(n.type,n.id,n)}function fm(n){return pm(`object ${n.type}`,n.id,n)}function pm(n,e,t){let i=[`${n} ${e}`],r=[...qu(t.placement),...mm(t.properties),...J_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${ze(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([l],[c])=>l.localeCompare(c));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[l,c]of a)i.push(` ${l} ${ze(c)}`)}}return i}function qu(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...vi("distance",n.distance),...vi("semiMajor",n.semiMajor),...nb("eccentricity",n.eccentricity),...vi("period",n.period),...vi("angle",n.angle),...vi("inclination",n.inclination),...vi("phase",n.phase)];case"at":return[`at ${ib(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?Zu(n.distance):n.descriptor??""}`.trim()]}}function mm(n){return Object.keys(n).sort(sb).map(e=>`${e} ${xm(n[e])}`)}function J_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${ze(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${xm(t.value)}`);return e}function K_(n){let e=[`viewpoint ${n.id}`,` label ${ze(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&tb(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=rb(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${ze(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(ze).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function Q_(n){let e=[`annotation ${n.id}`,` label ${ze(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${ze(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),e}function gm(n){let e=[`group ${n.id}`,` label ${ze(n.label)}`];return n.summary&&e.push(` summary ${ze(n.summary)}`),n.color&&e.push(` color ${ze(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function ym(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${ze(n.from)}`),n.to&&e.push(` to ${ze(n.to)}`),n.kind&&e.push(` kind ${ze(n.kind)}`),n.label&&e.push(` label ${ze(n.label)}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.color&&e.push(` color ${ze(n.color)}`),n.hidden&&e.push(" hidden true"),e}function vm(n){let e=[`event ${n.id}`,` kind ${ze(n.kind)}`];if(n.label&&e.push(` label ${ze(n.label)}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${ze(n.timing)}`),n.visibility&&e.push(` visibility ${ze(n.visibility)}`),n.epoch&&e.push(` epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${ze(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.color&&e.push(` color ${ze(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(ob)){e.push(` pose ${t.objectId}`);for(let i of eb(t))e.push(` ${i}`)}}return e}function eb(n){return[...qu(n.placement),...n.epoch?[`epoch ${ze(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${ze(n.referencePlane)}`]:[],...vi("inner",n.inner),...vi("outer",n.outer)]}function tb(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function xm(n){return Array.isArray(n)?n.map(e=>ze(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?ze(n):Zu(n)}function Zu(n){return`${n.value}${n.unit??""}`}function vi(n,e){return e?[`${n} ${Zu(e)}`]:[]}function nb(n,e){return e===void 0?[]:[`${n} ${e}`]}function ib(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function rb(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}function sb(n,e){let t=um.indexOf(n),i=um.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function Ju(n,e){let t=dm(n.type),i=dm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function Ur(n,e){return n.id.localeCompare(e.id)}function ob(n,e){return n.objectId.localeCompare(e.objectId)}function dm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function ze(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var _m=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,ab=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),lb=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Nr(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ks(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Ku(n,e,t){let i=n.match(_m);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Zt(t);if(s?.unitFamily&&!zs(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Qu(n){let e=n.match(_m);return e?{value:Number(e[1]),unit:e[2]??null}:null}function $a(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function xi(n,e,t){let i=ab.get(n.toLowerCase());if(i===void 0)throw Y.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function bm(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 cb(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(lb);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 wm(n,e,t){let i=Zt(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 xi(Js(e,n,t),n,t);case"number":return $a(Js(e,n,t),n,t);case"unit":return Ku(Js(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&cb(r,t),r}}}function ed(n,e,t){let i=Zt(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 Js(n,e,t){if(n.length!==1)throw Y.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Sm=new Set(["star","planet","moon","asteroid","comet"]),ub=332946.0487,db=1047.3486,Wa=1495978707e-1,hb=6371,fb=695700,pb=63241.077,mb=206264.806,gb=206264806;function Qs(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)yb(a,i,t);for(let a of n.system?.viewpoints??[])vb(a,r,s,e,t,i);for(let a of n.objects)xb(a,n.system,i,r,t);for(let a of n.events)_b(a,n.system,i,t);return t}function yb(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 vb(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(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`))}Sb(n.projection,r,`viewpoint.${n.id}.projection`,n.id),Ab(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function xb(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&&!nd(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?Sm.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")),wb(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=Mm(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(td("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${Cb(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=Am(o?.period),u=Mm(n,a);if(c===null||u===null)continue;let d=Ib(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 _b(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)),bb(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 bb(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&&!Eb(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&&!Tb(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&&!nd(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?Sm.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 wb(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 Mm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=Mb(t.semiMajor??t.distance),r=nd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function Mb(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/Wa;case"m":return n.value/(Wa*1e3);case"ly":return n.value*pb;case"pc":return n.value*mb;case"kpc":return n.value*gb;case"re":return n.value*hb/Wa;case"sol":return n.value*fb/Wa;default:return null}}function nd(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/ub;case"mj":return e.value/db;default:return null}}function Am(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 Sb(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 Ab(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(td("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(td("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,c))}function Eb(n,e,t,i){return _i(i?.epoch)??_i(t?.epoch)??_i(e.epoch)??_i(n?.epoch)??null}function Tb(n,e,t,i){return _i(i?.referencePlane)??_i(t?.referencePlane)??_i(e.referencePlane)??_i(n?.referencePlane)??null}function _i(n){return typeof n=="string"&&n.trim()?n.trim():null}function Ib(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Am(t)??0:0}function Cb(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 td(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var Rb=new Set(["climate","habitability","settlement"]),Xa=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=Zt(n);e&&Xa.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}])Xa.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var Pb=new Set(Xa.keys()),Tm=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function Ya(n){return Cm(n)}function Im(n){return Cm(n,"2.0-draft")}function Cm(n,e){let t=yw(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=Sa(T),B=Vi(T.slice(I),{line:U,columnOffset:I});if(B.length!==0){if(!s){o=Lb(B,U),s=!0,t.comments.length>0&&qa(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=Db(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);Vb(l,I,B,U)}}if(!s)throw new Y('Missing required atlas schema header "schema 2.0"');let L=c.map(w=>ow(w,o,r)),A=h.map(w=>aw(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(...Qs(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(...Qs(M,o)),M}function Lb(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 Db(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 Ob(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 Ub(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 Nb(n,e,r,d);case"group":return fn(t,i,"group",{line:e,column:n[0].column}),Fb(n,e,o,h);case"relation":return fn(t,i,"relation",{line:e,column:n[0].column}),kb(n,e,a,f);case"event":return fn(t,i,"event",{line:e,column:n[0].column}),Bb(n,e,l,c,p,t,i);case"object":return zb(n,e,t,i,s);default:throw new Y(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function Ob(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 Ub(n,e,t,i,r,s){if(n.length!==2)throw new Y("Invalid viewpoint declaration",e,n[0]?.column??1);let o=Nr(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:Ks(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 Nb(n,e,t,i){if(n.length!==2)throw new Y("Invalid annotation declaration",e,n[0]?.column??1);let r=Nr(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:Ks(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function Fb(n,e,t,i){if(n.length!==2)throw new Y("Invalid group declaration",e,n[0]?.column??1);let r=Nr(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:Ks(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function kb(n,e,t,i){if(n.length!==2)throw new Y("Invalid relation declaration",e,n[0]?.column??1);let r=Nr(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 Bb(n,e,t,i,r,s,o){if(n.length!==2)throw new Y("Invalid event declaration",e,n[0]?.column??1);let a=Nr(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:Ks(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 zb(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(!Bs.has(a)||a==="system")throw new Y(`Unknown object type "${s.value}"`,e,s.column);let l={objectType:a,id:o.value,fields:rw(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 Vb(n,e,t,i){switch(n.kind){case"system":Hb(n,t,i);return;case"defaults":Gb(n,t,i);return;case"atlas":$b(n,e,t,i);return;case"viewpoint":Wb(n,e,t,i);return;case"annotation":Yb(n,t,i);return;case"group":qb(n,t,i);return;case"relation":Zb(n,t,i);return;case"event":Jb(n,e,t,i);return;case"object":Qb(n,e,t,i);return}}function Hb(n,e,t){let i=Xn(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 Y(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function Gb(n,e,t){let i=Xn(e,n.seenFields,t),r=st(e,t);switch(i){case"view":Pm(r)&&Hi(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Rm(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=Lm(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 $b(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Dm(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 Wb(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){jb(n,t,i);return}if(n.inFilter){Xb(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(Hi(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??rd();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=Xn(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":Pm(s)&&Hi(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Rm(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Lm(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=id(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=wi(s,i,t[0].column,"rotation");return;case"camera":Hi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=iw(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=tw(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=Ln(t.slice(1),i,"events");return;default:throw new Y(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function jb(n,e,t){let i=Xn(e,n.seenCameraFields,t),r=st(e,t),s=n.viewpoint.camera??rd();switch(i){case"azimuth":s.azimuth=wi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=wi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=wi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=id(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 Xb(n,e,t){let i=Xn(e,n.seenFilterFields,t),r=n.viewpoint.filter??nw();switch(i){case"query":r.query=st(e,t);break;case"objecttypes":r.objectTypes=ew(e.slice(1),t);break;case"tags":r.tags=Ln(e.slice(1),t,"tags");break;case"groups":r.groupIds=Ln(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 Yb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;default:throw new Y(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function qb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=xi(st(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 Zb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;case"color":n.relation.color=st(e,t);return;case"hidden":n.relation.hidden=xi(st(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 Jb(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")&&Hi(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(Kb(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(Xn(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=Ln(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":Hi(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=st(t,i);return;case"referenceplane":Hi(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=st(t,i);return;case"tags":n.event.tags=Ln(t.slice(1),i,"tags");return;case"color":n.event.color=st(t,i);return;case"hidden":n.event.hidden=xi(st(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 Kb(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(!Tm.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 Qb(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"||Rb.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=Dm(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(sw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function Xn(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 st(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 ew(n,e){return Ln(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function tw(n,e,t,i){let r={};for(let s of Ln(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 Ln(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 Rm(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 Pm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Lm(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 id(n,e,t,i){let r=wi(n,e,t,i);if(r<=0)throw new Y(`Field "${i}" must be greater than zero`,e,t);return r}function wi(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 nw(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function rd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function iw(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}:rd(),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=wi(c,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=wi(c,e,o.column,"camera.elevation");break;case"roll":i.roll=wi(c,e,o.column,"camera.roll");break;case"distance":i.distance=id(c,e,o.column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function rw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],l=eo(a.value);if(!l)throw new Y(`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&&!Pb.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 Fm(s,t),s}function sw(n,e,t,i,r){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);let s=eo(n[0].value);if(!s)throw new Y(`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 Fm([o],t),o}function Dm(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 ow(n,e,t){let i=Om(n.fields),r=Um(i),s=cw(n.objectType,i),o=mw(i.get("groups")?.[0]),a=ja(i.get("epoch")?.[0]),l=ja(i.get("referencePlane")?.[0]),c=i.has("tidalLock")?xi(bn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?hw(i.get("resonance")[0]):void 0,d=dw(i),h=i.get("derive")?.map(v=>fw(v)),f=i.get("validate")?.map(v=>({rule:bn(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>pw(v)),g=uw(n.typedBlockEntries),m=Nm(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),qa(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)&&fn(e,t,n.id,n.location),x}function aw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>lw(t))}}function lw(n){let e=Om(n.fields,"event-pose"),t=Um(e);return{objectId:n.objectId,placement:t,inner:bi(e.get("inner")?.[0],"inner"),outer:bi(e.get("outer")?.[0],"outer"),epoch:ja(e.get("epoch")?.[0]),referencePlane:ja(e.get("referencePlane")?.[0])}}function Om(n,e="object"){let t=new Map;for(let i of n){let r=eo(i.key);if(!r&&!Tm.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 Um(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:bn(e),distance:bi(n.get("distance")?.[0],"distance"),semiMajor:bi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:gw(n.get("eccentricity")?.[0],"eccentricity"),period:bi(n.get("period")?.[0],"period"),angle:bi(n.get("angle")?.[0],"angle"),inclination:bi(n.get("inclination")?.[0],"inclination"),phase:bi(n.get("phase")?.[0],"phase")};if(t){let o=bn(t);return{mode:"at",target:o,reference:bm(o,t.location)}}if(i)return{mode:"surface",target:bn(i)};if(r){let o=bn(r),a=Qu(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function cw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=eo(i);!s||!o?.legacySchema||o.legacySchema.placement||(ed(i,n,s.location),t[i]=wm(i,s.values,s.location))}return t}function Nm(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 uw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=Nm(i,t))}return e}function dw(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=xi(bn(t),"renderLabel",t.location)),i&&(e.renderOrbit=xi(bn(i),"renderOrbit",i.location)),r&&(e.renderPriority=$a(bn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function hw(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 fw(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 pw(n){if(n.values.length!==2)throw Y.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=Qu(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function mw(n){return n?[...new Set(n.values)]:[]}function ja(n){return n&&n.values.join(" ").trim()||null}function bi(n,e){return n?Ku(bn(n),n.location,e):void 0}function gw(n,e){return n?$a(bn(n),e,n.location):void 0}function bn(n){return Js(n.values,n.key,n.location)}function eo(n){return Xa.get(n)}function Fm(n,e){for(let t of n){let i=eo(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){ed(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 fn(n,e,t,i){qa(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 Hi(n,e,t,i){qa(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 qa(n,e){return Em(n)<Em(e)}function Em(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 yw(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!==`
|
|
3824
|
+
`)}function Y_(n){return q_("system",n.id,n.properties,null,n.info)}function q_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...qu(i),...mm(t)];for(let l of o)s.push(` ${l}`);let a=Object.entries(r).sort(([l],[c])=>l.localeCompare(c));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[l,c]of a)s.push(` ${l} ${ze(c)}`)}return s}function hm(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${ze(n.title)}`),n.description&&e.push(` description ${ze(n.description)}`),n.epoch&&e.push(` epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${ze(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${ze(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${ze(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${ze(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${ze(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...K_(t));for(let t of n.annotations)e.push(""),e.push(...Q_(t));return e}function Z_(n){return pm(n.type,n.id,n)}function fm(n){return pm(`object ${n.type}`,n.id,n)}function pm(n,e,t){let i=[`${n} ${e}`],r=[...qu(t.placement),...mm(t.properties),...J_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${ze(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([l],[c])=>l.localeCompare(c));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[l,c]of a)i.push(` ${l} ${ze(c)}`)}}return i}function qu(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...vi("distance",n.distance),...vi("semiMajor",n.semiMajor),...nb("eccentricity",n.eccentricity),...vi("period",n.period),...vi("angle",n.angle),...vi("inclination",n.inclination),...vi("phase",n.phase)];case"at":return[`at ${ib(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?Zu(n.distance):n.descriptor??""}`.trim()]}}function mm(n){return Object.keys(n).sort(sb).map(e=>`${e} ${xm(n[e])}`)}function J_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${ze(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${xm(t.value)}`);return e}function K_(n){let e=[`viewpoint ${n.id}`,` label ${ze(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&tb(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=rb(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${ze(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(ze).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function Q_(n){let e=[`annotation ${n.id}`,` label ${ze(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${ze(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),e}function gm(n){let e=[`group ${n.id}`,` label ${ze(n.label)}`];return n.summary&&e.push(` summary ${ze(n.summary)}`),n.color&&e.push(` color ${ze(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function ym(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${ze(n.from)}`),n.to&&e.push(` to ${ze(n.to)}`),n.kind&&e.push(` kind ${ze(n.kind)}`),n.label&&e.push(` label ${ze(n.label)}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.color&&e.push(` color ${ze(n.color)}`),n.hidden&&e.push(" hidden true"),e}function vm(n){let e=[`event ${n.id}`,` kind ${ze(n.kind)}`];if(n.label&&e.push(` label ${ze(n.label)}`),n.summary&&e.push(` summary ${ze(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${ze(n.timing)}`),n.visibility&&e.push(` visibility ${ze(n.visibility)}`),n.epoch&&e.push(` epoch ${ze(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${ze(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(ze).join(" ")}`),n.color&&e.push(` color ${ze(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(ob)){e.push(` pose ${t.objectId}`);for(let i of eb(t))e.push(` ${i}`)}}return e}function eb(n){return[...qu(n.placement),...n.epoch?[`epoch ${ze(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${ze(n.referencePlane)}`]:[],...vi("inner",n.inner),...vi("outer",n.outer)]}function tb(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function xm(n){return Array.isArray(n)?n.map(e=>ze(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?ze(n):Zu(n)}function Zu(n){return`${n.value}${n.unit??""}`}function vi(n,e){return e?[`${n} ${Zu(e)}`]:[]}function nb(n,e){return e===void 0?[]:[`${n} ${e}`]}function ib(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function rb(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}function sb(n,e){let t=um.indexOf(n),i=um.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function Ju(n,e){let t=dm(n.type),i=dm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function Ur(n,e){return n.id.localeCompare(e.id)}function ob(n,e){return n.objectId.localeCompare(e.objectId)}function dm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function ze(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var _m=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,ab=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),lb=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Nr(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ks(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Ku(n,e,t){let i=n.match(_m);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=Zt(t);if(s?.unitFamily&&!zs(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Qu(n){let e=n.match(_m);return e?{value:Number(e[1]),unit:e[2]??null}:null}function $a(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function xi(n,e,t){let i=ab.get(n.toLowerCase());if(i===void 0)throw Y.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function bm(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 cb(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(lb);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 wm(n,e,t){let i=Zt(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 xi(Js(e,n,t),n,t);case"number":return $a(Js(e,n,t),n,t);case"unit":return Ku(Js(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&cb(r,t),r}}}function ed(n,e,t){let i=Zt(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 Js(n,e,t){if(n.length!==1)throw Y.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Sm=new Set(["star","planet","moon","asteroid","comet"]),ub=332946.0487,db=1047.3486,Wa=1495978707e-1,hb=6371,fb=695700,pb=63241.077,mb=206264.806,gb=206264806;function Qs(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)yb(a,i,t);for(let a of n.system?.viewpoints??[])vb(a,r,s,e,t,i);for(let a of n.objects)xb(a,n.system,i,r,t);for(let a of n.events)_b(a,n.system,i,t);return t}function yb(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 vb(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"||i==="2.6"){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`))}Sb(n.projection,r,`viewpoint.${n.id}.projection`,n.id),Ab(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function xb(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&&!nd(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?Sm.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")),wb(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=Mm(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(td("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${Cb(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=Am(o?.period),u=Mm(n,a);if(c===null||u===null)continue;let d=Ib(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 _b(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)),bb(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 bb(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&&!Eb(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&&!Tb(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&&!nd(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?Sm.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 wb(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 Mm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=Mb(t.semiMajor??t.distance),r=nd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function Mb(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/Wa;case"m":return n.value/(Wa*1e3);case"ly":return n.value*pb;case"pc":return n.value*mb;case"kpc":return n.value*gb;case"re":return n.value*hb/Wa;case"sol":return n.value*fb/Wa;default:return null}}function nd(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/ub;case"mj":return e.value/db;default:return null}}function Am(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 Sb(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 Ab(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(td("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(td("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,c))}function Eb(n,e,t,i){return _i(i?.epoch)??_i(t?.epoch)??_i(e.epoch)??_i(n?.epoch)??null}function Tb(n,e,t,i){return _i(i?.referencePlane)??_i(t?.referencePlane)??_i(e.referencePlane)??_i(n?.referencePlane)??null}function _i(n){return typeof n=="string"&&n.trim()?n.trim():null}function Ib(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Am(t)??0:0}function Cb(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 td(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var Rb=new Set(["climate","habitability","settlement"]),Xa=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=Zt(n);e&&Xa.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}])Xa.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var Pb=new Set(Xa.keys()),Tm=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function Ya(n){return Cm(n)}function Im(n){return Cm(n,"2.0-draft")}function Cm(n,e){let t=yw(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=Sa(T),B=Vi(T.slice(I),{line:U,columnOffset:I});if(B.length!==0){if(!s){o=Lb(B,U),s=!0,t.comments.length>0&&qa(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=Db(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);Vb(l,I,B,U)}}if(!s)throw new Y('Missing required atlas schema header "schema 2.0"');let L=c.map(w=>ow(w,o,r)),A=h.map(w=>aw(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(...Qs(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(...Qs(M,o)),M}function Lb(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5","2.6"].includes(n[1].value.toLowerCase()))throw new Y('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", "schema 2.6", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.6"?"2.6":t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function Db(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 Ob(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 Ub(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 Nb(n,e,r,d);case"group":return fn(t,i,"group",{line:e,column:n[0].column}),Fb(n,e,o,h);case"relation":return fn(t,i,"relation",{line:e,column:n[0].column}),kb(n,e,a,f);case"event":return fn(t,i,"event",{line:e,column:n[0].column}),Bb(n,e,l,c,p,t,i);case"object":return zb(n,e,t,i,s);default:throw new Y(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function Ob(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 Ub(n,e,t,i,r,s){if(n.length!==2)throw new Y("Invalid viewpoint declaration",e,n[0]?.column??1);let o=Nr(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:Ks(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 Nb(n,e,t,i){if(n.length!==2)throw new Y("Invalid annotation declaration",e,n[0]?.column??1);let r=Nr(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:Ks(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function Fb(n,e,t,i){if(n.length!==2)throw new Y("Invalid group declaration",e,n[0]?.column??1);let r=Nr(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:Ks(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function kb(n,e,t,i){if(n.length!==2)throw new Y("Invalid relation declaration",e,n[0]?.column??1);let r=Nr(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 Bb(n,e,t,i,r,s,o){if(n.length!==2)throw new Y("Invalid event declaration",e,n[0]?.column??1);let a=Nr(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:Ks(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 zb(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(!Bs.has(a)||a==="system")throw new Y(`Unknown object type "${s.value}"`,e,s.column);let l={objectType:a,id:o.value,fields:rw(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 Vb(n,e,t,i){switch(n.kind){case"system":Hb(n,t,i);return;case"defaults":Gb(n,t,i);return;case"atlas":$b(n,e,t,i);return;case"viewpoint":Wb(n,e,t,i);return;case"annotation":Yb(n,t,i);return;case"group":qb(n,t,i);return;case"relation":Zb(n,t,i);return;case"event":Jb(n,e,t,i);return;case"object":Qb(n,e,t,i);return}}function Hb(n,e,t){let i=Xn(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 Y(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function Gb(n,e,t){let i=Xn(e,n.seenFields,t),r=st(e,t);switch(i){case"view":Pm(r)&&Hi(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Rm(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=Lm(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 $b(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Dm(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 Wb(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){jb(n,t,i);return}if(n.inFilter){Xb(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(Hi(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??rd();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=Xn(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":Pm(s)&&Hi(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Rm(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Lm(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=id(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=wi(s,i,t[0].column,"rotation");return;case"camera":Hi(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=iw(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=tw(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=Ln(t.slice(1),i,"events");return;default:throw new Y(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function jb(n,e,t){let i=Xn(e,n.seenCameraFields,t),r=st(e,t),s=n.viewpoint.camera??rd();switch(i){case"azimuth":s.azimuth=wi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=wi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=wi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=id(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 Xb(n,e,t){let i=Xn(e,n.seenFilterFields,t),r=n.viewpoint.filter??nw();switch(i){case"query":r.query=st(e,t);break;case"objecttypes":r.objectTypes=ew(e.slice(1),t);break;case"tags":r.tags=Ln(e.slice(1),t,"tags");break;case"groups":r.groupIds=Ln(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 Yb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;default:throw new Y(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function qb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=xi(st(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 Zb(n,e,t){switch(Xn(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=Ln(e.slice(1),t,"tags");return;case"color":n.relation.color=st(e,t);return;case"hidden":n.relation.hidden=xi(st(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 Jb(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")&&Hi(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(Kb(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(Xn(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=Ln(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":Hi(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=st(t,i);return;case"referenceplane":Hi(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=st(t,i);return;case"tags":n.event.tags=Ln(t.slice(1),i,"tags");return;case"color":n.event.color=st(t,i);return;case"hidden":n.event.hidden=xi(st(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 Kb(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(!Tm.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 Qb(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"||Rb.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=Dm(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(sw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function Xn(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 st(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 ew(n,e){return Ln(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function tw(n,e,t,i){let r={};for(let s of Ln(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 Ln(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 Rm(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 Pm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Lm(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 id(n,e,t,i){let r=wi(n,e,t,i);if(r<=0)throw new Y(`Field "${i}" must be greater than zero`,e,t);return r}function wi(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 nw(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function rd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function iw(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}:rd(),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=wi(c,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=wi(c,e,o.column,"camera.elevation");break;case"roll":i.roll=wi(c,e,o.column,"camera.roll");break;case"distance":i.distance=id(c,e,o.column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function rw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],l=eo(a.value);if(!l)throw new Y(`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&&!Pb.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 Fm(s,t),s}function sw(n,e,t,i,r){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);let s=eo(n[0].value);if(!s)throw new Y(`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 Fm([o],t),o}function Dm(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 ow(n,e,t){let i=Om(n.fields),r=Um(i),s=cw(n.objectType,i),o=mw(i.get("groups")?.[0]),a=ja(i.get("epoch")?.[0]),l=ja(i.get("referencePlane")?.[0]),c=i.has("tidalLock")?xi(bn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?hw(i.get("resonance")[0]):void 0,d=dw(i),h=i.get("derive")?.map(v=>fw(v)),f=i.get("validate")?.map(v=>({rule:bn(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>pw(v)),g=uw(n.typedBlockEntries),m=Nm(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),qa(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)&&fn(e,t,n.id,n.location),x}function aw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>lw(t))}}function lw(n){let e=Om(n.fields,"event-pose"),t=Um(e);return{objectId:n.objectId,placement:t,inner:bi(e.get("inner")?.[0],"inner"),outer:bi(e.get("outer")?.[0],"outer"),epoch:ja(e.get("epoch")?.[0]),referencePlane:ja(e.get("referencePlane")?.[0])}}function Om(n,e="object"){let t=new Map;for(let i of n){let r=eo(i.key);if(!r&&!Tm.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 Um(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:bn(e),distance:bi(n.get("distance")?.[0],"distance"),semiMajor:bi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:gw(n.get("eccentricity")?.[0],"eccentricity"),period:bi(n.get("period")?.[0],"period"),angle:bi(n.get("angle")?.[0],"angle"),inclination:bi(n.get("inclination")?.[0],"inclination"),phase:bi(n.get("phase")?.[0],"phase")};if(t){let o=bn(t);return{mode:"at",target:o,reference:bm(o,t.location)}}if(i)return{mode:"surface",target:bn(i)};if(r){let o=bn(r),a=Qu(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function cw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=eo(i);!s||!o?.legacySchema||o.legacySchema.placement||(ed(i,n,s.location),t[i]=wm(i,s.values,s.location))}return t}function Nm(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 uw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=Nm(i,t))}return e}function dw(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=xi(bn(t),"renderLabel",t.location)),i&&(e.renderOrbit=xi(bn(i),"renderOrbit",i.location)),r&&(e.renderPriority=$a(bn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function hw(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 fw(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 pw(n){if(n.values.length!==2)throw Y.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=Qu(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function mw(n){return n?[...new Set(n.values)]:[]}function ja(n){return n&&n.values.join(" ").trim()||null}function bi(n,e){return n?Ku(bn(n),n.location,e):void 0}function gw(n,e){return n?$a(bn(n),e,n.location):void 0}function bn(n){return Js(n.values,n.key,n.location)}function eo(n){return Xa.get(n)}function Fm(n,e){for(let t of n){let i=eo(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){ed(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 fn(n,e,t,i){qa(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 Hi(n,e,t,i){qa(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 qa(n,e){return Em(n)<Em(e)}function Em(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":return 4;default:return 5}}function yw(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!==`
|
|
3825
3825
|
`&&c!=="\r"&&(e[l]=" "),c===`
|
|
3826
3826
|
`?(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==="#"&&!vw(e,l)){t.push({kind:"line",line:o,column:a}),e[l]=" ";let d=l+1;for(;d<e.length&&e[d]!==`
|
|
3827
3827
|
`&&e[d]!=="\r";)e[d]=" ",d++;a+=d-l,l=d-1;continue}c==='"'&&e[l-1]!=="\\"&&(i=!i),c===`
|
|
3828
3828
|
`?(o++,a=1):a++}if(r)throw Y.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function vw(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===`
|
|
3829
|
-
`}function sd(n="WorldOrbit",e="2.6
|
|
3829
|
+
`}function sd(n="WorldOrbit",e="2.6"){return{format:"worldorbit",version:e,schemaVersion:e,sourceVersion:"1.0",theme:{preset:"blueprint",styles:{}},system:{type:"system",id:n,title:n,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},groups:[],relations:[],events:[],objects:[],diagnostics:[]}}function Za(n){return structuredClone(n)}function km(n){let e=[{kind:"system"},{kind:"defaults"}];if(n.system){for(let t of Object.keys(n.system.atlasMetadata).sort())e.push({kind:"metadata",key:t});for(let t of[...n.system.viewpoints].sort(Gi))e.push({kind:"viewpoint",id:t.id});for(let t of[...n.system.annotations].sort(Gi))e.push({kind:"annotation",id:t.id})}for(let t of[...n.groups].sort(Gi))e.push({kind:"group",id:t.id});for(let t of[...n.relations].sort(Gi))e.push({kind:"relation",id:t.id});for(let t of[...n.events].sort(Gi)){e.push({kind:"event",id:t.id});for(let i of[...t.positions].sort(Ym))e.push({kind:"event-pose",id:t.id,key:i.objectId})}for(let t of[...n.objects].sort(Gi))e.push({kind:"object",id:t.id});return e}function od(n,e){switch(e.kind){case"system":return n.system;case"defaults":return n.system?.defaults??null;case"metadata":return e.key?n.system?.atlasMetadata[e.key]??null:null;case"group":return e.id?Gm(n,e.id):null;case"event":return e.id?Ja(n,e.id):null;case"event-pose":return e.id&&e.key?Wm(n,e.id,e.key):null;case"object":return e.id?Hm(n,e.id):null;case"viewpoint":return e.id?jm(n.system,e.id):null;case"annotation":return e.id?Xm(n.system,e.id):null;case"relation":return e.id?$m(n,e.id):null}}function ad(n,e,t){let i=Za(n),r=ud(i);switch(e.kind){case"system":return i.system=t,i;case"defaults":return r.defaults={...r.defaults,...t},i;case"metadata":if(!e.key)throw new Error('Metadata updates require a "key" value.');return t==null||t===""?delete r.atlasMetadata[e.key]:r.atlasMetadata[e.key]=String(t),i;case"group":if(!e.id)throw new Error('Group updates require an "id" value.');return Fr(i.groups,t),i;case"event":if(!e.id)throw new Error('Event updates require an "id" value.');return Fr(i.events,t),i;case"event-pose":if(!e.id||!e.key)throw new Error('Event pose updates require an event "id" and pose "key" value.');return xw(i.events,e.id,t),i;case"object":if(!e.id)throw new Error('Object updates require an "id" value.');return Fr(i.objects,t),i;case"viewpoint":if(!e.id)throw new Error('Viewpoint updates require an "id" value.');return Fr(r.viewpoints,t),i;case"annotation":if(!e.id)throw new Error('Annotation updates require an "id" value.');return Fr(r.annotations,t),i;case"relation":if(!e.id)throw new Error('Relation updates require an "id" value.');return Fr(i.relations,t),i}}function Bm(n,e,t){return ad(n,e,t(od(n,e)))}function zm(n,e){let t=Za(n),i=ud(t);switch(e.kind){case"metadata":return e.key&&delete i.atlasMetadata[e.key],t;case"object":return e.id&&(t.objects=t.objects.filter(r=>r.id!==e.id)),t;case"group":return e.id&&(t.groups=t.groups.filter(r=>r.id!==e.id)),t;case"event":return e.id&&(t.events=t.events.filter(r=>r.id!==e.id)),t;case"event-pose":if(e.id&&e.key){let r=Ja(t,e.id);r&&(r.positions=r.positions.filter(s=>s.objectId!==e.key))}return t;case"viewpoint":return e.id&&(i.viewpoints=i.viewpoints.filter(r=>r.id!==e.id)),t;case"annotation":return e.id&&(i.annotations=i.annotations.filter(r=>r.id!==e.id)),t;case"relation":return e.id&&(t.relations=t.relations.filter(r=>r.id!==e.id)),t;default:return t}}function ld(n,e){return e.map(t=>({diagnostic:t,path:cd(n,t)}))}function cd(n,e){if(e.objectId&&Hm(n,e.objectId))return{kind:"object",id:e.objectId};if(e.field?.startsWith("group.")){let t=e.field.split(".");if(t[1]&&Gm(n,t[1]))return{kind:"group",id:t[1]}}if(e.field?.startsWith("viewpoint.")){let t=e.field.split(".");if(t[1]&&jm(n.system,t[1]))return{kind:"viewpoint",id:t[1]}}if(e.field?.startsWith("annotation.")){let t=e.field.split(".");if(t[1]&&Xm(n.system,t[1]))return{kind:"annotation",id:t[1]}}if(e.field?.startsWith("relation.")){let t=e.field.split(".");if(t[1]&&$m(n,t[1]))return{kind:"relation",id:t[1]}}if(e.field?.startsWith("event.")){let t=e.field.split(".");if(t[1]&&Ja(n,t[1]))return t[2]==="pose"&&t[3]&&Wm(n,t[1],t[3])?{kind:"event-pose",id:t[1],key:t[3]}:{kind:"event",id:t[1]}}return e.field&&e.field in ud(n).atlasMetadata?{kind:"metadata",key:e.field}:null}function Vm(n){let e=[...n.diagnostics,...Qs(n,n.version)];return ld(n,e)}function ud(n){return n.system||(n.system=sd().system),n.system}function Hm(n,e){return n.objects.find(t=>t.id===e)??null}function Gm(n,e){return n.groups.find(t=>t.id===e)??null}function $m(n,e){return n.relations.find(t=>t.id===e)??null}function Ja(n,e){return n.events.find(t=>t.id===e)??null}function Wm(n,e,t){return Ja(n,e)?.positions.find(i=>i.objectId===t)??null}function jm(n,e){return n?.viewpoints.find(t=>t.id===e)??null}function Xm(n,e){return n?.annotations.find(t=>t.id===e)??null}function Fr(n,e){let t=n.findIndex(i=>i.id===e.id);if(t===-1){n.push(e),n.sort(Gi);return}n[t]=e}function xw(n,e,t){let i=n.find(s=>s.id===e);if(!i)throw new Error(`Unknown event "${e}" for pose update.`);let r=i.positions.findIndex(s=>s.objectId===t.objectId);if(r===-1){i.positions.push(t),i.positions.sort(Ym);return}i.positions[r]=t}function Gi(n,e){return n.id.localeCompare(e.id)}function Ym(n,e){return n.objectId.localeCompare(e.objectId)}var _w=/^schema\s+2(?:\.0|\.1|\.5|\.6)?$/i,bw=/^schema\s+2\.1$/i,ww=/^schema\s+2\.5$/i,Mw=/^schema\s+2\.6$/i,Sw=/^schema\s+2\.0-draft$/i;function dd(n){for(let e of Aw(n).split(/\r?\n/)){let t=e.trim();if(t)return Sw.test(t)?"2.0-draft":bw.test(t)?"2.1":ww.test(t)?"2.5":Mw.test(t)?"2.6":_w.test(t)?"2.0":"1.0"}return"1.0"}function Aw(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!==`
|
|
3830
3830
|
`&&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]!==`
|
|
3831
|
-
`&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function wn(n){let e=hd(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 hd(n){let e=dd(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5"||e==="2.6
|
|
3832
|
-
`),info:r,startLine:s,endLine:c}),i=!1,r=null,s=0,o=[];return}o.push(a)}),t}function Zm(n){let e=yi(n),t=Wn(e);return jn(t),{ast:e,document:t}}function Tw(n){let e=Zm(n);return{...e,scene:kt(e.document)}}function Iw(n){return wn(n)}function Cw(n){return Ta(n)}function Rw(n,e={}){return Ga(n,e)}var to=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},pn=class extends to{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var Pw={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},no={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 $i(n){return n?typeof n=="string"?no[n]??no.atlas:{...no.atlas,...n}:no.atlas}function Ka(n){return{...Pw,...n}}function Jm(n){return no[n]}function en(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:fd(n.objectTypes??[]),tags:fd((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:fd((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return Lw(e)?e:null}function Lw(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function Qa(n,e){let t=en(e),i=new Set;for(let r of n.objects)if(!r.hidden&&Dw(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 el(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Ow(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=>Km(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>Km(r,1))}function Qm(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:en(t)}}function tl(n){return encodeURIComponent(JSON.stringify(n))}function nl(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:en(e.filter??null)}}function eg(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 il(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 rl(n){return n?.filter?en({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function Km(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 Dw(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=tg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Ow(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=tg(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 tg(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 fd(n){return[...new Set(n)]}var mn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function pd(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function io(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function Wi(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function sl(n,e){return{...n,rotationDeg:pd(n.rotationDeg+e)}}function kr(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=Xi(n),o=io(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 ji(n,e,t){let i=Xi(n),r=Uw(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=io(Math.min(s/a,o/l),t),u=Pn({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 ol(n,e,t,i){let r=n.objects.find(l=>l.objectId===t&&!l.hidden);if(!r)return e;let s=Xi(n),o=io(Math.max(e.scale,1.8),i),a=Pn({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 al(n,e){let t=Xi(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function Br(n,e,t){let i=Xi(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=Pn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function ll(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=>Br(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 Xi(n){return{x:n.width/2,y:n.height/2}}function Uw(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=>Pn(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 ul="worldorbit-camera-root";function Mn(n,e={}){let t=$i(e.theme),i=Kw(e.preset??n.renderPreset??void 0),r=Ka({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=Qa(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!cl(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||!cl(x.object)),c=Bw(a),u=r.orbits?kw(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||!cl(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="${Ct(x.renderId)}" data-group-id="${Bt(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="${Ct(x.renderId)}" data-relation-id="${Bt(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>Nw(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>zw(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?l.map(x=>Vw(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Ct(n.title)}</text>
|
|
3831
|
+
`&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function wn(n){let e=hd(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 hd(n){let e=dd(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5"||e==="2.6")return Ew(n,e);let t;try{t=yi(n)}catch(r){return{ok:!1,value:null,diagnostics:[Qt(r,"parse")]}}let i;try{i=Wn(t)}catch(r){return{ok:!1,value:null,diagnostics:[Qt(r,"normalize")]}}try{jn(i)}catch(r){return{ok:!1,value:null,diagnostics:[Qt(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function Ew(n,e){let t;try{t=Ya(n)}catch(o){return{ok:!1,value:null,diagnostics:[Qt(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=Zs(t)}catch(o){return{ok:!1,value:null,diagnostics:[Qt(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 Tw=/^```worldorbit(?:\s+(.*))?\s*$/;function qm(n){let e=n.split(/\r?\n/),t=[],i=!1,r=null,s=0,o=[];return e.forEach((a,l)=>{let c=l+1;if(!i){let u=a.match(Tw);u&&(i=!0,r=u[1]??null,s=c,o=[]);return}if(a.trim()==="```"){t.push({source:o.join(`
|
|
3832
|
+
`),info:r,startLine:s,endLine:c}),i=!1,r=null,s=0,o=[];return}o.push(a)}),t}function Zm(n){let e=yi(n),t=Wn(e);return jn(t),{ast:e,document:t}}function Iw(n){let e=Zm(n);return{...e,scene:kt(e.document)}}function Cw(n){return wn(n)}function Rw(n){return Ta(n)}function Pw(n,e={}){return Ga(n,e)}var to=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},pn=class extends to{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var Lw={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},no={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 $i(n){return n?typeof n=="string"?no[n]??no.atlas:{...no.atlas,...n}:no.atlas}function Ka(n){return{...Lw,...n}}function Jm(n){return no[n]}function en(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:fd(n.objectTypes??[]),tags:fd((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:fd((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return Dw(e)?e:null}function Dw(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function Qa(n,e){let t=en(e),i=new Set;for(let r of n.objects)if(!r.hidden&&Ow(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 el(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Uw(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=>Km(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>Km(r,1))}function Qm(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:en(t)}}function tl(n){return encodeURIComponent(JSON.stringify(n))}function nl(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:en(e.filter??null)}}function eg(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 il(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 rl(n){return n?.filter?en({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function Km(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 Ow(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=tg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Uw(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=tg(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 tg(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 fd(n){return[...new Set(n)]}var mn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function pd(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function io(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function Wi(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function sl(n,e){return{...n,rotationDeg:pd(n.rotationDeg+e)}}function kr(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=Xi(n),o=io(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 ji(n,e,t){let i=Xi(n),r=Nw(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=io(Math.min(s/a,o/l),t),u=Pn({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 ol(n,e,t,i){let r=n.objects.find(l=>l.objectId===t&&!l.hidden);if(!r)return e;let s=Xi(n),o=io(Math.max(e.scale,1.8),i),a=Pn({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 al(n,e){let t=Xi(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function Br(n,e,t){let i=Xi(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=Pn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function ll(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=>Br(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 Xi(n){return{x:n.width/2,y:n.height/2}}function Nw(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=>Pn(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 ul="worldorbit-camera-root";function Mn(n,e={}){let t=$i(e.theme),i=Qw(e.preset??n.renderPreset??void 0),r=Ka({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=Qa(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!cl(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||!cl(x.object)),c=zw(a),u=r.orbits?Bw(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||!cl(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="${Ct(x.renderId)}" data-group-id="${Bt(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="${Ct(x.renderId)}" data-relation-id="${Bt(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>Fw(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>Vw(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?l.map(x=>Hw(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Ct(n.title)}</text>
|
|
3833
3833
|
<text class="wo-subtitle" x="56" y="88">${Ct(s)}</text>
|
|
3834
|
-
<text class="wo-meta" x="56" y="${n.height-42}">${Ct(
|
|
3834
|
+
<text class="wo-meta" x="56" y="${n.height-42}">${Ct(tM(n))}</text>`:"",m=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
|
|
3835
3835
|
<rect class="wo-bg-glow" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
|
|
3836
|
-
${r.guides?
|
|
3836
|
+
${r.guides?eM(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">
|
|
3837
3837
|
<title id="worldorbit-title">${Ct(n.title)}</title>
|
|
3838
3838
|
<desc id="worldorbit-desc">A ${Ct(n.viewMode)} WorldOrbit render with ${a.length} visible objects.</desc>
|
|
3839
3839
|
<defs>
|
|
@@ -3904,17 +3904,17 @@ void main() {
|
|
|
3904
3904
|
</g>
|
|
3905
3905
|
</g>
|
|
3906
3906
|
</g>
|
|
3907
|
-
</svg>`}function
|
|
3907
|
+
</svg>`}function Fw(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="${Bt(s)}" data-event-id="${Bt(e.eventId)}" data-object-id="${Bt(l.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${Ct(e.renderId)}" data-event-id="${Bt(e.eventId)}">
|
|
3908
3908
|
${a}
|
|
3909
3909
|
<circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${Bt(s)}" />
|
|
3910
3910
|
<text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${Ct(o)}</text>
|
|
3911
|
-
</g>`}function yd(n,e={}){return Mn(kt(n,e),e)}function sg(n,e={}){let t=wn(n);return yd(t.document,
|
|
3911
|
+
</g>`}function yd(n,e={}){return Mn(kt(n,e),e)}function sg(n,e={}){let t=wn(n);return yd(t.document,kw(t,e))}function kw(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function Bw(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!cl(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="${Bt(s.objectId)}" data-parent-id="${Bt(s.parentId)}" data-group-id="${Bt(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 zw(n){return n.filter(e=>!!e.imageHref).map(e=>Ww(e)).join("")}function Vw(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=Xw(n,t),d=$w(n),h=d?ng(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="${Bt(n.parentId??"")}" data-group-id="${Bt(n.groupId??"")}" data-render-id="${Ct(n.renderId)}" tabindex="0" role="button" aria-label="${Ct(`${i.type} ${n.objectId}`)}">
|
|
3912
3912
|
<circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${a+8}" />
|
|
3913
|
-
${
|
|
3913
|
+
${Gw(n,u)}
|
|
3914
3914
|
${ng(i,r,s,o,u)}
|
|
3915
3915
|
${d}
|
|
3916
3916
|
${h}
|
|
3917
|
-
</g>`}function
|
|
3917
|
+
</g>`}function Hw(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="${Bt(e.groupId??"")}" data-render-id="${Ct(e.renderId)}">
|
|
3918
3918
|
<text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${Ct(e.label)}</text>
|
|
3919
3919
|
<text class="wo-label-secondary" x="${e.x}" y="${e.secondaryY}" text-anchor="${e.textAnchor}" font-size="${11*r}">${Ct(e.secondaryLabel)}</text>
|
|
3920
3920
|
</g>`}function ng(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" />
|
|
@@ -3924,16 +3924,16 @@ void main() {
|
|
|
3924
3924
|
<ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${o}" stroke="${r.stroke}" stroke-width="1.2" />
|
|
3925
3925
|
<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" />
|
|
3926
3926
|
<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" />
|
|
3927
|
-
<circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${md(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function
|
|
3927
|
+
<circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${md(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function Gw(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 $w(n){if(!n.imageHref)return"";let e=jw(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Bt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Bt(og(n))})" />`}function Ww(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="${ag(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${md(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Bt(og(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function jw(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 Xw(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=Yw(n.object.type,t,e),r=n.fillColor&&iM(n.fillColor)?n.fillColor:i.fill,s=ig(n.object.properties.albedo),o=ig(n.object.properties.temperature),a=Zw(r,o,s,n.object.type),l=ro(a,"#ffffff",.4)??i.stroke,c=Kw(n.object.properties.atmosphere),u=n.object.type==="star"?rg(ro(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:l,glow:u,atmosphere:c,tail:n.object.type==="comet"?rg(ro(a,"#ffffff",.5)??a,.72):void 0}}function Yw(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 qw(e)}}function qw(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 Zw(n,e,t,i){let r=n;if(e!==null){let s=Jw(e,i);r=ro(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=ro(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function Jw(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function Kw(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 Qw(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 ig(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function og(n){return`${n.renderId}-clip`}function ag(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function md(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 eM(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 tM(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function cl(n){return n.type==="structure"||n.type==="phenomenon"}function ro(n,e,t){let i=gd(n),r=gd(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return nM({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 rg(n,e){let t=gd(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function gd(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 nM(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function iM(n){return!!n.trim()}function Ct(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Bt(n){return Ct(n)}var zr=180,Vr=120,lg=10;function cg(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((zr-lg*2)/Math.max(i.width,1),(Vr-lg*2)/Math.max(i.height,1)),s=(zr-i.width*r)/2-i.minX*r,o=(Vr-i.height*r)/2-i.minY*r,a=ll(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??rM(c.object.type);return`<circle cx="${Sn(u)}" cy="${Sn(d)}" r="${Sn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${zr}px;height:${Vr}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;">
|
|
3928
3928
|
<svg width="${zr}" height="${Vr}" viewBox="0 0 ${zr} ${Vr}" role="presentation" aria-hidden="true">
|
|
3929
3929
|
<rect x="0.5" y="0.5" width="${zr-1}" height="${Vr-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
|
|
3930
3930
|
<rect x="${Sn(i.minX*r+s)}" y="${Sn(i.minY*r+o)}" width="${Sn(i.width*r)}" height="${Sn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
|
|
3931
3931
|
${l}
|
|
3932
3932
|
<rect x="${Sn(a.minX*r+s)}" y="${Sn(a.minY*r+o)}" width="${Sn(a.width*r)}" height="${Sn(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" />
|
|
3933
3933
|
</svg>
|
|
3934
|
-
</div>`}function iM(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 Sn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var XI="wo-viewer-3d-root",yp=null;function bv(n){sC();let e=document.createElement("div");e.className=XI,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 lC().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=nC(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},yv(B,T,"balanced"),u&&x(u)}).catch(T=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${aC(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=oC(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,yv(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&&(iC(t,r),p=I),U&&v(T.spatialScene),w(T.spatialScene),c=za(T.spatialScene,T.timeSeconds),b(),L(),A(),E(),D(),M(),t.renderer.render(t.scene3d,t.camera)}function v(T){if(!t)return;_v(t.orbitLayer),_v(t.objectLayer),y.clear(),g.clear(),m.length=0,h=null,f=null;let U=$i(r?.theme);for(let I of T.orbits){let B=qI(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=YI(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;vv(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())vv(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=ga((T?.azimuth??30)+s.rotationDeg),W=ga(Tu(T?.elevation??22,-75,75)),F=Tu(2.2/Math.max(s.scale,.1),.35,7.2),X=Tu(T?.distance??5.4,2,24),k=Tu(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=ga(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 YI(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??rC(e),s=[],o=ZI(n,e,r,t),a=new n.Mesh(JI(n,e),o.material);if(a.userData.objectId=e.objectId,i.add(a),s.push(o),eC(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=QI(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 qI(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=ga(e.rotationDeg),i.rotation.x=ga(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(tC(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(wv(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 ZI(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:xv(n,t,.08),selectedColor:xv(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function JI(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 KI(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 KI(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 QI(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 eC(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function tC(n,e){let t=Math.max(e.bandThickness??8,3),i=wv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function wv(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 nC(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 yv(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 iC(n,e){let t=$i(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 vv(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 rC(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 xv(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function _v(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 sC(){if(typeof document>"u")throw new pn;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new pn("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 pn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function oC(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function Tu(n,e,t){return Math.min(Math.max(n,e),t)}function ga(n){return n*Math.PI/180}function aC(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function lC(){return yp||(yp=Promise.resolve().then(()=>(gv(),mv))),yp}var cC=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Sv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:pC(n.object.type),imageHref:n.renderObject.imageHref??null,description:hC(n),tags:dC(n.object.properties.tags),fields:uC(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function Av(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Gn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Gn(s.label)}</dt><dd>${Gn(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="${Gn(n.objectId)}">
|
|
3934
|
+
</div>`}function rM(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 Sn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var YI="wo-viewer-3d-root",yp=null;function bv(n){oC();let e=document.createElement("div");e.className=YI,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 cC().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=iC(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},yv(B,T,"balanced"),u&&x(u)}).catch(T=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${lC(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=aC(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,yv(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&&(rC(t,r),p=I),U&&v(T.spatialScene),w(T.spatialScene),c=za(T.spatialScene,T.timeSeconds),b(),L(),A(),E(),D(),M(),t.renderer.render(t.scene3d,t.camera)}function v(T){if(!t)return;_v(t.orbitLayer),_v(t.objectLayer),y.clear(),g.clear(),m.length=0,h=null,f=null;let U=$i(r?.theme);for(let I of T.orbits){let B=ZI(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=qI(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;vv(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())vv(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=ga((T?.azimuth??30)+s.rotationDeg),W=ga(Tu(T?.elevation??22,-75,75)),F=Tu(2.2/Math.max(s.scale,.1),.35,7.2),X=Tu(T?.distance??5.4,2,24),k=Tu(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=ga(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 qI(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??sC(e),s=[],o=JI(n,e,r,t),a=new n.Mesh(KI(n,e),o.material);if(a.userData.objectId=e.objectId,i.add(a),s.push(o),tC(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=eC(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 ZI(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=ga(e.rotationDeg),i.rotation.x=ga(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(nC(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(wv(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 JI(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:xv(n,t,.08),selectedColor:xv(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function KI(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 QI(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 QI(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 eC(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 tC(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function nC(n,e){let t=Math.max(e.bandThickness??8,3),i=wv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function wv(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 iC(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 yv(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 rC(n,e){let t=$i(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 vv(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 sC(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 xv(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function _v(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 oC(){if(typeof document>"u")throw new pn;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new pn("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 pn("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function aC(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function Tu(n,e,t){return Math.min(Math.max(n,e),t)}function ga(n){return n*Math.PI/180}function lC(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function cC(){return yp||(yp=Promise.resolve().then(()=>(gv(),mv))),yp}var uC=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Sv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:mC(n.object.type),imageHref:n.renderObject.imageHref??null,description:fC(n),tags:hC(n.object.properties.tags),fields:dC(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function Av(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Gn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Gn(s.label)}</dt><dd>${Gn(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="${Gn(n.objectId)}">
|
|
3935
3935
|
<div class="wo-tooltip-head">
|
|
3936
|
-
${n.imageHref?`<img class="wo-tooltip-image" src="${
|
|
3936
|
+
${n.imageHref?`<img class="wo-tooltip-image" src="${yC(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Gn(n.typeLabel.slice(0,1))}</div>`}
|
|
3937
3937
|
<div class="wo-tooltip-heading">
|
|
3938
3938
|
<strong>${Gn(n.title)}</strong>
|
|
3939
3939
|
<span>${Gn(n.typeLabel)}</span>
|
|
@@ -3943,7 +3943,7 @@ void main() {
|
|
|
3943
3943
|
${t}
|
|
3944
3944
|
${i}
|
|
3945
3945
|
${r.length?`<p class="wo-tooltip-relations">${Gn(r.join(" - "))}</p>`:""}
|
|
3946
|
-
</article>`}function uC(n){let e=new Map;for(let i of cC){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:mC(i),value:Mv(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 ${Mv(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function dC(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function hC(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 Mv(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):fC(n)}function fC(n){return`${n.value}${n.unit??""}`}function pC(n){return n.charAt(0).toUpperCase()+n.slice(1)}function mC(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Gn(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function gC(n){return Gn(n)}var Ps={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Ev="worldorbit-viewer-tooltip-style";function Bi(n,e){if(_C(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??Ps.minScale,maxScale:e.maxScale??Ps.maxScale,fitPadding:e.fitPadding??Ps.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??Ps.panStep,zoomStep:e.zoomStep??Ps.zoomStep,rotationStep:e.rotationStep??Ps.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:en(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,l=n.style.position,c=yC(e),u=ya(c,s),d=e.spatialScene??null,h=s.viewMode==="3d"?Tr(c,s,d):null,f={...mn},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),bC(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),Qe();let re=C=>{if(!r.pointer||D)return;if(C.preventDefault(),n.focus(),Se()){let O=Ir(Math.exp(-C.deltaY*.002),.6,1.6);_e.zoomBy(O);return}let G=ee(C.clientX,C.clientY),_=Ir(Math.exp(-C.deltaY*.002),.6,1.6);Ue(kr(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=Iv(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=Iv(u,f,M));let ue=Pv(M),Ee=ue.distance/Math.max(w.startDistance,1),Ie=kr(u,w.startState,Ee,w.startCenter,i),Oe=ue.center.x-w.startViewportCenter.x,Be=ue.center.y-w.startViewportCenter.y;Ue(Wi(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(Wi(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(Wi(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)},Ke=C=>{if(!r.selection||D)return;if(b){b=!1;return}let G=Se()?g?.hitTest(C.clientX,C.clientY)??null:Iu(C.target);K(G),r.tooltipMode==="pinned"&&(U=G,De())},Z=C=>{if(Se())return;let G=Iu(C.target);de(G)},q=()=>{de(null)},pe=C=>{if(Se())return;let G=Iu(C.target);G&&de(G)},ne=()=>{de(null)},Fe=C=>{if(!r.keyboard||D)return;let G=Se()?f.selectedObjectId:Iu(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",Ke),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=ya(c,s),d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},setDocument(C){c={kind:"document",value:C},u=ya(c,s),d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},setScene(C){c={kind:"scene",value:C},u=C,d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},getScene(){return u},getRenderOptions(){return vC(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(C){let G=s,_=h,O=vp(s,{viewMode:C}),V=C==="3d"?Tr(c,O,d):null;s=O,h=V,Qe();try{H(!1)}catch(N){throw s=G,h=_,Qe(),H(!1),N}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return me(W)},goToViewpoint(C){let G=me(C);if(!G)return!1;let _={},O=il(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=Tv(_);s=vp(s,_),c.kind!=="scene"&&N&&(u=ya(c,s)),H(N)}fe(rl(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)),je(),Pe(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(C){_e.setRenderOptions({activeEventId:C})},playAnimation(){if(!Se()){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(),qt()},setAnimationSpeed(C){k={...k,speed:Ir(C,.1,64)}},getAnimationState(){return{...k}},search(C,G=12){return el(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 Qm(f,s,s.filter??null,W)},setAtlasState(C){let G=typeof C=="string"?nl(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),je(),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),Pe()},serializeAtlasState(){return tl(_e.getAtlasState())},captureBookmark(C,G){return eg(C,G,_e.getAtlasState())},applyBookmark(C){return typeof C=="string"?(_e.setAtlasState(C),!0):(_e.setAtlasState(C.atlasState),!0)},setRenderOptions(C){let G=Tv(C),_=s,O=u,V=h,N=vp(s,C),$=u;c.kind!=="scene"&&G&&($=ya(c,N));let ue=N.viewMode==="3d"?Tr(c,N,d):null;s=N,u=$,h=ue,Qe();try{H(G)}catch(Ee){throw s=_,u=O,h=V,Qe(),H(G),Ee}},getState(){return{...f}},setState(C){Ue(J({...f,...C}))},zoomBy(C,G){Ue(kr(u,f,C,G??{x:u.width/2,y:u.height/2},i))},panBy(C,G){Ue(Wi(f,C,G))},rotateBy(C){Ue(sl(f,C))},fitToSystem(){Ue(Se()?{...mn,selectedObjectId:f.selectedObjectId}:ji(u,f,i))},focusObject(C){W=null,Ue(Se()?Pu(C):ol(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()?{...mn}:ji(u,{...mn},i);W=null,Ue(C),K(null),U=null,De()},exportSvg(){return Mn(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",Ke),n.removeEventListener("mouseover",Z),n.removeEventListener("mouseleave",q),n.removeEventListener("focusin",pe),n.removeEventListener("focusout",ne),n.removeEventListener("keydown",Fe),pt(),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??Tr(c,s,d),g=bv(n)):(n.innerHTML=Mn(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.");_a(),f=C?Se()?{...mn}:ji(u,{...mn},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,qt(),Re(),je(),e.onViewChange?.({...f}),Pe()}function Ue(C){f=J(C),qt(),e.onViewChange?.({...f}),Pe()}function J(C){return{scale:Ir(C.scale,i.minScale,i.maxScale),rotationDeg:Cv(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()){St();return}y&&(y.setAttribute("transform",al(u,f)),Os(),Me(),De())}function K(C,G=!0){if(!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${va(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="${va(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()){St();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="${va(V)}"]`))N.classList.add(G.objectClass);for(let V of _.ancestors)for(let N of n.querySelectorAll(`[data-object-id="${va(V.objectId)}"]`))N.classList.add(G.ancestorClass);for(let V of _.relatedOrbits)for(let N of n.querySelectorAll(`[data-orbit-object-id="${va(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 Br(u,f,j(C,G))}function oe(){return Qa(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=Cv(C.rotationDeg),_=C.scale!==null&&C.scale!==void 0?Ir(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,mn.scale),G,C.selectedObjectId??O.objectId);let V=ji(u,{...mn,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=Pn(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:en(C)},_&&(W=null),H(!1)}function Re(){e.onFilterChange?.(s.filter??null,ie())}function je(){e.onViewpointChange?.(me(W))}function Pe(){e.onAtlasStateChange?.(_e.getAtlasState())}function Me(){!r.minimap||!m||(m.innerHTML=cg(u,f,ie()))}function De(){if(r.tooltipMode==="disabled"||!v){be(null);return}let C=Ze();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 _=Sv(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",ft(v,_,C.mode),$e(v,G.renderObject),v.style.visibility="visible",be(_)}function Ze(){return U&&he(U)?{objectId:U,mode:"pinned"}:T&&he(T)?{objectId:T,mode:"hover"}:null}function ft(C,G,_){let O=e.tooltipRenderer?.(G,_);C.innerHTML="",typeof O=="string"?C.innerHTML=O:O instanceof HTMLElement?C.append(O):C.innerHTML=Av(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 $e(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,$=Ir(_.x+18,12,O),ue=Ir(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},_=Pn(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 Qe(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},pt())}function ct(){F!==null||!k.playing||D||(F=window.requestAnimationFrame(tt))}function pt(){F!==null&&(window.cancelAnimationFrame(F),F=null),X=null}function tt(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},St(),ct()}function qt(){ce(),Se()&&k.playing?ct():(!k.playing||!Se())&&pt()}function St(){!Se()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:oe(),selectedObjectId:f.selectedObjectId,hoveredObjectId:T,state:f,timeSeconds:k.timeSeconds}),Os(),Me(),De())}function _a(){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 Os(){if(!x)return;let C=ba();x.replaceChildren(...C.map(G=>Rr(G))),x.hidden=C.length===0}function ba(){let C=[],G=oe();if(Us("labels"))for(let _ of u.labels){if(_.hidden||!G.has(_.objectId)||Se()&&!wa(_.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()&&Us("events"))for(let _ of u.events){if(_.hidden||!Cr(_,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 Cr(C,G){return C.objectIds.some(_=>G.has(_))}function wa(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 Rr(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 Ma(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 Us(C){return s.layers?.[C]!==!1}function Ma(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 Pu(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}:{...mn,selectedObjectId:C}}}function yC(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 ya(n,e){switch(n.kind){case"scene":return n.value;case"document":return kt(n.value,e);case"source":{let t=wn(n.value);return kt(t.document,Rv(t,e))}}}function Tr(n,e,t){if(t)return t;switch(n.kind){case"scene":return xC(n.value);case"document":return Ys(n.value,e);case"source":{let i=wn(n.value);return Ys(i.document,Rv(i,e))}}}function vC(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 vp(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?en(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 Tv(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 Rv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function xC(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 Iv(n,e,t){let{center:i,distance:r}=Pv(t);return{startState:{...e},startCenter:Br(n,e,i),startViewportCenter:i,startDistance:r}}function Pv(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 Iu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function _C(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 Ir(n,e,t){return Math.min(Math.max(n,e),t)}function Cv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function va(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function bC(){if(typeof document>"u"||document.getElementById(Ev))return;let n=document.createElement("style");n.id=Ev,n.textContent=`
|
|
3946
|
+
</article>`}function dC(n){let e=new Map;for(let i of uC){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:gC(i),value:Mv(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 ${Mv(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function hC(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function fC(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 Mv(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):pC(n)}function pC(n){return`${n.value}${n.unit??""}`}function mC(n){return n.charAt(0).toUpperCase()+n.slice(1)}function gC(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Gn(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function yC(n){return Gn(n)}var Ps={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Ev="worldorbit-viewer-tooltip-style";function Bi(n,e){if(bC(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??Ps.minScale,maxScale:e.maxScale??Ps.maxScale,fitPadding:e.fitPadding??Ps.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??Ps.panStep,zoomStep:e.zoomStep??Ps.zoomStep,rotationStep:e.rotationStep??Ps.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:en(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,l=n.style.position,c=vC(e),u=ya(c,s),d=e.spatialScene??null,h=s.viewMode==="3d"?Tr(c,s,d):null,f={...mn},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),wC(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),Qe();let re=C=>{if(!r.pointer||D)return;if(C.preventDefault(),n.focus(),Se()){let O=Ir(Math.exp(-C.deltaY*.002),.6,1.6);_e.zoomBy(O);return}let G=ee(C.clientX,C.clientY),_=Ir(Math.exp(-C.deltaY*.002),.6,1.6);Ue(kr(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=Iv(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=Iv(u,f,M));let ue=Pv(M),Ee=ue.distance/Math.max(w.startDistance,1),Ie=kr(u,w.startState,Ee,w.startCenter,i),Oe=ue.center.x-w.startViewportCenter.x,Be=ue.center.y-w.startViewportCenter.y;Ue(Wi(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(Wi(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(Wi(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)},Ke=C=>{if(!r.selection||D)return;if(b){b=!1;return}let G=Se()?g?.hitTest(C.clientX,C.clientY)??null:Iu(C.target);K(G),r.tooltipMode==="pinned"&&(U=G,De())},Z=C=>{if(Se())return;let G=Iu(C.target);de(G)},q=()=>{de(null)},pe=C=>{if(Se())return;let G=Iu(C.target);G&&de(G)},ne=()=>{de(null)},Fe=C=>{if(!r.keyboard||D)return;let G=Se()?f.selectedObjectId:Iu(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",Ke),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=ya(c,s),d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},setDocument(C){c={kind:"document",value:C},u=ya(c,s),d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},setScene(C){c={kind:"scene",value:C},u=C,d=null,h=s.viewMode==="3d"?Tr(c,s,null):null,Qe(),W=null,H(!0)},getScene(){return u},getRenderOptions(){return xC(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(C){let G=s,_=h,O=vp(s,{viewMode:C}),V=C==="3d"?Tr(c,O,d):null;s=O,h=V,Qe();try{H(!1)}catch(N){throw s=G,h=_,Qe(),H(!1),N}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return me(W)},goToViewpoint(C){let G=me(C);if(!G)return!1;let _={},O=il(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=Tv(_);s=vp(s,_),c.kind!=="scene"&&N&&(u=ya(c,s)),H(N)}fe(rl(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)),je(),Pe(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(C){_e.setRenderOptions({activeEventId:C})},playAnimation(){if(!Se()){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(),qt()},setAnimationSpeed(C){k={...k,speed:Ir(C,.1,64)}},getAnimationState(){return{...k}},search(C,G=12){return el(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 Qm(f,s,s.filter??null,W)},setAtlasState(C){let G=typeof C=="string"?nl(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),je(),e.onSelectionChange?.(le()),e.onSelectionDetailsChange?.(Ae(f.selectedObjectId)),Pe()},serializeAtlasState(){return tl(_e.getAtlasState())},captureBookmark(C,G){return eg(C,G,_e.getAtlasState())},applyBookmark(C){return typeof C=="string"?(_e.setAtlasState(C),!0):(_e.setAtlasState(C.atlasState),!0)},setRenderOptions(C){let G=Tv(C),_=s,O=u,V=h,N=vp(s,C),$=u;c.kind!=="scene"&&G&&($=ya(c,N));let ue=N.viewMode==="3d"?Tr(c,N,d):null;s=N,u=$,h=ue,Qe();try{H(G)}catch(Ee){throw s=_,u=O,h=V,Qe(),H(G),Ee}},getState(){return{...f}},setState(C){Ue(J({...f,...C}))},zoomBy(C,G){Ue(kr(u,f,C,G??{x:u.width/2,y:u.height/2},i))},panBy(C,G){Ue(Wi(f,C,G))},rotateBy(C){Ue(sl(f,C))},fitToSystem(){Ue(Se()?{...mn,selectedObjectId:f.selectedObjectId}:ji(u,f,i))},focusObject(C){W=null,Ue(Se()?Pu(C):ol(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()?{...mn}:ji(u,{...mn},i);W=null,Ue(C),K(null),U=null,De()},exportSvg(){return Mn(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",Ke),n.removeEventListener("mouseover",Z),n.removeEventListener("mouseleave",q),n.removeEventListener("focusin",pe),n.removeEventListener("focusout",ne),n.removeEventListener("keydown",Fe),pt(),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??Tr(c,s,d),g=bv(n)):(n.innerHTML=Mn(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.");_a(),f=C?Se()?{...mn}:ji(u,{...mn},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,qt(),Re(),je(),e.onViewChange?.({...f}),Pe()}function Ue(C){f=J(C),qt(),e.onViewChange?.({...f}),Pe()}function J(C){return{scale:Ir(C.scale,i.minScale,i.maxScale),rotationDeg:Cv(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()){St();return}y&&(y.setAttribute("transform",al(u,f)),Os(),Me(),De())}function K(C,G=!0){if(!Se()&&f.selectedObjectId)for(let _ of n.querySelectorAll(`[data-object-id="${va(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="${va(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()){St();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="${va(V)}"]`))N.classList.add(G.objectClass);for(let V of _.ancestors)for(let N of n.querySelectorAll(`[data-object-id="${va(V.objectId)}"]`))N.classList.add(G.ancestorClass);for(let V of _.relatedOrbits)for(let N of n.querySelectorAll(`[data-orbit-object-id="${va(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 Br(u,f,j(C,G))}function oe(){return Qa(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=Cv(C.rotationDeg),_=C.scale!==null&&C.scale!==void 0?Ir(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,mn.scale),G,C.selectedObjectId??O.objectId);let V=ji(u,{...mn,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=Pn(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:en(C)},_&&(W=null),H(!1)}function Re(){e.onFilterChange?.(s.filter??null,ie())}function je(){e.onViewpointChange?.(me(W))}function Pe(){e.onAtlasStateChange?.(_e.getAtlasState())}function Me(){!r.minimap||!m||(m.innerHTML=cg(u,f,ie()))}function De(){if(r.tooltipMode==="disabled"||!v){be(null);return}let C=Ze();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 _=Sv(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",ft(v,_,C.mode),$e(v,G.renderObject),v.style.visibility="visible",be(_)}function Ze(){return U&&he(U)?{objectId:U,mode:"pinned"}:T&&he(T)?{objectId:T,mode:"hover"}:null}function ft(C,G,_){let O=e.tooltipRenderer?.(G,_);C.innerHTML="",typeof O=="string"?C.innerHTML=O:O instanceof HTMLElement?C.append(O):C.innerHTML=Av(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 $e(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,$=Ir(_.x+18,12,O),ue=Ir(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},_=Pn(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 Qe(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},pt())}function ct(){F!==null||!k.playing||D||(F=window.requestAnimationFrame(tt))}function pt(){F!==null&&(window.cancelAnimationFrame(F),F=null),X=null}function tt(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},St(),ct()}function qt(){ce(),Se()&&k.playing?ct():(!k.playing||!Se())&&pt()}function St(){!Se()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:oe(),selectedObjectId:f.selectedObjectId,hoveredObjectId:T,state:f,timeSeconds:k.timeSeconds}),Os(),Me(),De())}function _a(){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 Os(){if(!x)return;let C=ba();x.replaceChildren(...C.map(G=>Rr(G))),x.hidden=C.length===0}function ba(){let C=[],G=oe();if(Us("labels"))for(let _ of u.labels){if(_.hidden||!G.has(_.objectId)||Se()&&!wa(_.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()&&Us("events"))for(let _ of u.events){if(_.hidden||!Cr(_,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 Cr(C,G){return C.objectIds.some(_=>G.has(_))}function wa(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 Rr(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 Ma(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 Us(C){return s.layers?.[C]!==!1}function Ma(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 Pu(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}:{...mn,selectedObjectId:C}}}function vC(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 ya(n,e){switch(n.kind){case"scene":return n.value;case"document":return kt(n.value,e);case"source":{let t=wn(n.value);return kt(t.document,Rv(t,e))}}}function Tr(n,e,t){if(t)return t;switch(n.kind){case"scene":return _C(n.value);case"document":return Ys(n.value,e);case"source":{let i=wn(n.value);return Ys(i.document,Rv(i,e))}}}function xC(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 vp(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?en(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 Tv(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 Rv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function _C(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 Iv(n,e,t){let{center:i,distance:r}=Pv(t);return{startState:{...e},startCenter:Br(n,e,i),startViewportCenter:i,startDistance:r}}function Pv(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 Iu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function bC(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 Ir(n,e,t){return Math.min(Math.max(n,e),t)}function Cv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function va(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function wC(){if(typeof document>"u"||document.getElementById(Ev))return;let n=document.createElement("style");n.id=Ev,n.textContent=`
|
|
3947
3947
|
.wo-viewer-3d-root {
|
|
3948
3948
|
position: relative;
|
|
3949
3949
|
min-height: 320px;
|
|
@@ -4091,7 +4091,7 @@ void main() {
|
|
|
4091
4091
|
padding: 6px 12px;
|
|
4092
4092
|
font: 600 12px/1.3 "Segoe UI Variable", "Segoe UI", sans-serif;
|
|
4093
4093
|
}
|
|
4094
|
-
`,document.head.append(n)}var wC="[data-worldorbit-embed]";function xp(n){return encodeURIComponent(JSON.stringify(n))}function _p(n){let e=JSON.parse(decodeURIComponent(n));return{version:"2.0",mode:Ds(e.mode),scene:e.scene,spatialScene:e.spatialScene??void 0,options:e.options?{...e.options,viewMode:e.options.viewMode??Cu(Ds(e.mode)),initialFilter:e.options.initialFilter??null,atlasState:e.options.atlasState??null}:void 0}}function Dv(n,e,t={}){return{version:"2.0",mode:Ds(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??Cu(Ds(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function Ov(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??Cu(Ds(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=Mn(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="${xa(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${xa(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${xa(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${xa(xp(t))}">${i}</div>`}function Uv(n=document,e={}){let t=new Map,i=[],r=[...n.querySelectorAll(wC)];for(let s of r){let o=SC(s),a=Ds(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??Cu(a),m=()=>MC(s,o.scene,e);if(a==="interactive-2d"||a==="interactive-3d")try{let x=m(),v=Bi(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(Lv(s,()=>{let b=m();v.setRenderOptions({width:b.width,height:b.height})})),e.onMount?.(v,s)}catch(x){if(x instanceof pn&&a==="interactive-3d")s.innerHTML=bp(x.message),e.onMount?.(null,s);else throw x}else{let x=()=>{let v=m();s.innerHTML=Mn(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(Lv(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 MC(n,e,t){let i=n.getBoundingClientRect(),r=Ls(t.width)??Ls(n.clientWidth)??Ls(i.width)??e.width,s=Ls(t.height)??Ls(n.clientHeight)??Ls(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 Ls(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?Math.round(n):null}function Lv(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 SC(n){let e=n.dataset.worldorbitPayload;if(!e)throw new Error("WorldOrbit embed is missing data-worldorbit-payload.");return _p(e)}function xa(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function Ds(n){return!n||n==="interactive"?"interactive-2d":n}function Cu(n){return n==="interactive-3d"?"3d":"2d"}function bp(n){return`<div class="worldorbit-embed-unavailable" data-worldorbit-3d-unavailable="true"><strong>3D unavailable</strong><span>${xa(n)}</span></div>`}var Nv="worldorbit-atlas-viewer-style";function Ru(n,e){if(typeof document>"u")throw new Error("Atlas viewer requires a browser environment.");EC();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=AC(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=en(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=Bi(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(Fv)},captureBookmark(F,X){let k=v().captureBookmark(F,X);return m=[...m,k],W(),I(),Fv(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 en({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="${pi(k.id)}">${pi(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="${pi(X.id)}">${pi(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="${pi(X.objectId)}">${pi(X.objectId)} - ${pi(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="${pi(F.id)}">${pi(F.label)}</button>`).join(""))}}function AC(n){let e=[n.search?`<label class="wo-atlas-field">
|
|
4094
|
+
`,document.head.append(n)}var MC="[data-worldorbit-embed]";function xp(n){return encodeURIComponent(JSON.stringify(n))}function _p(n){let e=JSON.parse(decodeURIComponent(n));return{version:"2.0",mode:Ds(e.mode),scene:e.scene,spatialScene:e.spatialScene??void 0,options:e.options?{...e.options,viewMode:e.options.viewMode??Cu(Ds(e.mode)),initialFilter:e.options.initialFilter??null,atlasState:e.options.atlasState??null}:void 0}}function Dv(n,e,t={}){return{version:"2.0",mode:Ds(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??Cu(Ds(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function Ov(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??Cu(Ds(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=Mn(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="${xa(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${xa(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${xa(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${xa(xp(t))}">${i}</div>`}function Uv(n=document,e={}){let t=new Map,i=[],r=[...n.querySelectorAll(MC)];for(let s of r){let o=AC(s),a=Ds(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??Cu(a),m=()=>SC(s,o.scene,e);if(a==="interactive-2d"||a==="interactive-3d")try{let x=m(),v=Bi(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(Lv(s,()=>{let b=m();v.setRenderOptions({width:b.width,height:b.height})})),e.onMount?.(v,s)}catch(x){if(x instanceof pn&&a==="interactive-3d")s.innerHTML=bp(x.message),e.onMount?.(null,s);else throw x}else{let x=()=>{let v=m();s.innerHTML=Mn(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(Lv(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 SC(n,e,t){let i=n.getBoundingClientRect(),r=Ls(t.width)??Ls(n.clientWidth)??Ls(i.width)??e.width,s=Ls(t.height)??Ls(n.clientHeight)??Ls(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 Ls(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?Math.round(n):null}function Lv(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 AC(n){let e=n.dataset.worldorbitPayload;if(!e)throw new Error("WorldOrbit embed is missing data-worldorbit-payload.");return _p(e)}function xa(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function Ds(n){return!n||n==="interactive"?"interactive-2d":n}function Cu(n){return n==="interactive-3d"?"3d":"2d"}function bp(n){return`<div class="worldorbit-embed-unavailable" data-worldorbit-3d-unavailable="true"><strong>3D unavailable</strong><span>${xa(n)}</span></div>`}var Nv="worldorbit-atlas-viewer-style";function Ru(n,e){if(typeof document>"u")throw new Error("Atlas viewer requires a browser environment.");TC();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=EC(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=en(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=Bi(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(Fv)},captureBookmark(F,X){let k=v().captureBookmark(F,X);return m=[...m,k],W(),I(),Fv(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 en({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="${pi(k.id)}">${pi(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="${pi(X.id)}">${pi(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="${pi(X.objectId)}">${pi(X.objectId)} - ${pi(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="${pi(F.id)}">${pi(F.label)}</button>`).join(""))}}function EC(n){let e=[n.search?`<label class="wo-atlas-field">
|
|
4095
4095
|
<span>Search</span>
|
|
4096
4096
|
<input data-atlas-search type="text" placeholder="Search objects, tags, or types" />
|
|
4097
4097
|
</label>`:"",n.typeFilter?`<label class="wo-atlas-field">
|
|
@@ -4128,7 +4128,7 @@ void main() {
|
|
|
4128
4128
|
<div class="wo-atlas-results" data-atlas-results></div>
|
|
4129
4129
|
${n.bookmarks?'<div class="wo-atlas-bookmarks" data-atlas-bookmarks></div>':""}
|
|
4130
4130
|
</div>
|
|
4131
|
-
</section>`}function
|
|
4131
|
+
</section>`}function TC(){if(document.getElementById(Nv))return;let n=document.createElement("style");n.id=Nv,n.textContent=`
|
|
4132
4132
|
.wo-atlas-shell { display: grid; gap: 16px; min-width: 0; }
|
|
4133
4133
|
.wo-atlas-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
|
|
4134
4134
|
.wo-atlas-workspace { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
|
|
@@ -4162,7 +4162,7 @@ void main() {
|
|
|
4162
4162
|
.wo-atlas-workspace { grid-template-columns: 1fr; }
|
|
4163
4163
|
.wo-atlas-inspector { min-height: 220px; }
|
|
4164
4164
|
}
|
|
4165
|
-
`,document.head.append(n)}function Fv(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 pi(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function kv(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=
|
|
4165
|
+
`,document.head.append(n)}function Fv(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 pi(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function kv(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=IC(i),o=kt(s),a=this.getAttribute("theme")??void 0;if(r==="static"){this.innerHTML=Mn(o,{theme:a});return}if(r==="atlas"){this.viewer=Ru(this,{scene:o,theme:a});return}try{this.viewer=Bi(this,{source:i,theme:a,viewMode:r==="interactive-3d"?"3d":"2d"})}catch(l){if(l instanceof pn&&r==="interactive-3d"){this.innerHTML=bp(l.message);return}throw l}}}customElements.define(n,e)}function IC(n){return wn(n).document}return Wv(CC);})();
|
|
4166
4166
|
/**
|
|
4167
4167
|
* @license
|
|
4168
4168
|
* Copyright 2010-2024 Three.js Authors
|