PROCEDURAL  /  WOODLAND Nº 01

林间小屋

暮色森林里,有一盏灯还亮着

第一视角垂钓 成功上鱼后退出
0 条 · 30天

溪畔垂钓 · FISHING

点击「抛竿」,静候鱼儿咬钩

CATCH 虹鳟 · 32 cm

BUILDING THE CABIN & POND

正在搭建木屋与码头…

&!!b.sheenColorMap,Pt= &!!b.sheenRoughnessMap,ue=!!b.specularMap,re=!!b.specularColorMap,Re=!!b.specularIntensityMap,D=Dt&&!!b.transmissionMap,_t=Dt&&!!b.thicknessMap,q=!!b.gradientMap,Q=!!b.alphaMap,Mt=b.alphaTest>0,xt=!!b.alphaHash,ee=!!b.extensions,Fe=Fi;b.toneMapped&&(ct===null||ct.isXRRenderTarget===!0)&&(Fe=s.toneMapping);let an={shaderID:ft,shaderType:b.type,shaderName:b.name,vertexShader:ge,fragmentShader:K,defines:b.defines,customVertexShaderID:at,customFragmentShaderID:Lt,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:qt,batchingColor:qt&&O._colorsTexture!==null,instancing:Jt,instancingColor:Jt&&O.instanceColor!==null,instancingMorph:Jt&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:ct===null?s.outputColorSpace:ct.isXRRenderTarget===!0?ct.texture.colorSpace:rr,alphaToCoverage:!!b.alphaToCoverage,map:fe,matcap:tt,envMap:rt,envMapMode:rt&&st.mapping,envMapCubeUVHeight:X,aoMap:P,lightMap:Bt,bumpMap:nt,normalMap:At,displacementMap:d&&dt,emissiveMap:Gt,normalMapObjectSpace:At&&b.normalMapType===C0,normalMapTangentSpace:At&&b.normalMapType===ds,metalnessMap:Et,roughnessMap:A,anisotropy:S,anisotropyMap:gt,clearcoat:F,clearcoatMap:wt,clearcoatNormalMap:ae,clearcoatRoughnessMap:it,dispersion:J,iridescence:et,iridescenceMap:Ct,iridescenceThicknessMap:Wt,sheen:$,sheenColorMap:Zt,sheenRoughnessMap:Pt,specularMap:ue,specularColorMap:re,specularIntensityMap:Re,transmission:Dt,transmissionMap:D,thicknessMap:_t,gradientMap:q,opaque:b.transparent===!1&&b.blending===Ni&&b.alphaToCoverage===!1,alphaMap:Q,alphaTest:Mt,alphaHash:xt,combine:b.combine,mapUv:fe&&_(b.map.channel),aoMapUv:P&&_(b.aoMap.channel),lightMapUv:Bt&&_(b.lightMap.channel),bumpMapUv:nt&&_(b.bumpMap.channel),normalMapUv:At&&_(b.normalMap.channel),displacementMapUv:dt&&_(b.displacementMap.channel),emissiveMapUv:Gt&&_(b.emissiveMap.channel),metalnessMapUv:Et&&_(b.metalnessMap.channel),roughnessMapUv:A&&_(b.roughnessMap.channel),anisotropyMapUv:gt&&_(b.anisotropyMap.channel),clearcoatMapUv:wt&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:ae&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:Ct&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:Wt&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:Zt&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:Pt&&_(b.sheenRoughnessMap.channel),specularMapUv:ue&&_(b.specularMap.channel),specularColorMapUv:re&&_(b.specularColorMap.channel),specularIntensityMapUv:Re&&_(b.specularIntensityMap.channel),transmissionMapUv:D&&_(b.transmissionMap.channel),thicknessMapUv:_t&&_(b.thicknessMap.channel),alphaMapUv:Q&&_(b.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(At||S),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!j.attributes.uv&&(fe||Q),fog:!!G,useFog:b.fog===!0,fogExp2:!!G&&G.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:zt,skinning:O.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:It,morphTextureStride:jt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:s.shadowMap.enabled&&L.length>0,shadowMapType:s.shadowMap.type,toneMapping:Fe,decodeVideoTexture:fe&&b.map.isVideoTexture===!0&&ce.getTransfer(b.map.colorSpace)===Se,decodeVideoTextureEmissive:Gt&&b.emissiveMap.isVideoTexture===!0&&ce.getTransfer(b.emissiveMap.colorSpace)===Se,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===un,flipSided:b.side===sn,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:ee&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ee&&b.extensions.multiDraw===!0||qt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return an.vertexUv1s=c.has(1),an.vertexUv2s=c.has(2),an.vertexUv3s=c.has(3),c.clear(),an}function p(b){let M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(let L in b.defines)M.push(L),M.push(b.defines[L]);return b.isRawShaderMaterial===!1&&(v(M,b),x(M,b),M.push(s.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function v(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function x(b,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),M.dispersion&&a.enable(20),M.batchingColor&&a.enable(21),b.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reverseDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),b.push(a.mask)}function y(b){let M=m[b.type],L;if(M){let V=ii[M];L=H0.clone(V.uniforms)}else L=b.uniforms;return L}function I(b,M){let L;for(let V=0,O=h.length;V0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function l(u,d,f,m,_,g){let p=o(u,d,f,m,_,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||DS),n.length>1&&n.sort(d||nm),i.length>1&&i.sort(d||nm)}function h(){for(let u=t,d=s.length;u=r.length?(o=new im,r.push(o)):o=r[i],o}function e(){s=new WeakMap}return{get:t,dispose:e}}function NS(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new w,color:new Z};break;case"SpotLight":e={position:new w,direction:new w,color:new Z,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new w,color:new Z,distance:0,decay:0};break;case"HemisphereLight":e={direction:new w,skyColor:new Z,groundColor:new Z};break;case"RectAreaLight":e={color:new Z,position:new w,halfWidth:new w,halfHeight:new w};break}return s[t.id]=e,e}}}function FS(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var OS=0;function BS(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function kS(s){let t=new NS,e=FS(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new w);let i=new w,r=new Yt,o=new Yt;function a(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,v=0,x=0,y=0,I=0,T=0,R=0;c.sort(BS);for(let b=0,M=c.length;b0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pt.LTC_FLOAT_1,n.rectAreaLTC2=pt.LTC_FLOAT_2):(n.rectAreaLTC1=pt.LTC_HALF_1,n.rectAreaLTC2=pt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;let C=n.hash;(C.directionalLength!==f||C.pointLength!==m||C.spotLength!==_||C.rectAreaLength!==g||C.hemiLength!==p||C.numDirectionalShadows!==v||C.numPointShadows!==x||C.numSpotShadows!==y||C.numSpotMaps!==I||C.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=y+I-T,n.spotLightMap.length=I,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=R,C.directionalLength=f,C.pointLength=m,C.spotLength=_,C.rectAreaLength=g,C.hemiLength=p,C.numDirectionalShadows=v,C.numPointShadows=x,C.numSpotShadows=y,C.numSpotMaps=I,C.numLightProbes=R,n.version=OS++)}function l(c,h){let u=0,d=0,f=0,m=0,_=0,g=h.matrixWorldInverse;for(let p=0,v=c.length;p=o.length?(a=new sm(s),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var oa=class extends je{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},aa=class extends je{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},HS=`void main() { gl_Position = vec4( position, 1.0 ); }`,VS=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function GS(s,t,e){let n=new qs,i=new Y,r=new Y,o=new pe,a=new oa({depthPacking:R0}),l=new aa,c={},h=e.maxTextureSize,u={[Bi]:sn,[sn]:Bi,[un]:un},d=new Qe({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Y},radius:{value:4}},vertexShader:HS,fragmentShader:VS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Xt;m.setAttribute("position",new se(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new ht(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mf;let p=this.type;this.render=function(T,R,C){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;let b=s.getRenderTarget(),M=s.getActiveCubeFace(),L=s.getActiveMipmapLevel(),V=s.state;V.setBlending(Ui),V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let O=p!==hi&&this.type===hi,G=p===hi&&this.type!==hi;for(let j=0,W=T.length;jh||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/ft.x),i.x=r.x*ft.x,X.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/ft.y),i.y=r.y*ft.y,X.mapSize.y=r.y)),X.map===null||O===!0||G===!0){let It=this.type!==hi?{minFilter:rn,magFilter:rn}:{};X.map!==null&&X.map.dispose(),X.map=new Fn(i.x,i.y,It),X.map.texture.name=st.name+".shadowMap",X.camera.updateProjectionMatrix()}s.setRenderTarget(X.map),s.clear();let St=X.getViewportCount();for(let It=0;It0||R.map&&R.alphaTest>0){let V=M.uuid,O=R.uuid,G=c[V];G===void 0&&(G={},c[V]=G);let j=G[O];j===void 0&&(j=M.clone(),G[O]=j,R.addEventListener("dispose",I)),M=j}if(M.visible=R.visible,M.wireframe=R.wireframe,b===hi?M.side=R.shadowSide!==null?R.shadowSide:R.side:M.side=R.shadowSide!==null?R.shadowSide:u[R.side],M.alphaMap=R.alphaMap,M.alphaTest=R.alphaTest,M.map=R.map,M.clipShadows=R.clipShadows,M.clippingPlanes=R.clippingPlanes,M.clipIntersection=R.clipIntersection,M.displacementMap=R.displacementMap,M.displacementScale=R.displacementScale,M.displacementBias=R.displacementBias,M.wireframeLinewidth=R.wireframeLinewidth,M.linewidth=R.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let V=s.properties.get(M);V.light=C}return M}function y(T,R,C,b,M){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===hi)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);let O=t.update(T),G=T.material;if(Array.isArray(G)){let j=O.groups;for(let W=0,st=j.length;W=1):X.indexOf("OpenGL ES")!==-1&&(st=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),W=st>=2);let ft=null,St={},It=s.getParameter(s.SCISSOR_BOX),jt=s.getParameter(s.VIEWPORT),ge=new pe().fromArray(It),K=new pe().fromArray(jt);function at(D,_t,q,Q){let Mt=new Uint8Array(4),xt=s.createTexture();s.bindTexture(D,xt),s.texParameteri(D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(D,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ee=0;eet?(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function YS(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function ZS(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function dd(s,t,e,n){let i=JS(n);switch(e){case vf:return s*t;case Sf:return s*t;case bf:return s*t*2;case Th:return s*t/i.components*i.byteLength;case Ca:return s*t/i.components*i.byteLength;case Ef:return s*t*2/i.components*i.byteLength;case Ah:return s*t*2/i.components*i.byteLength;case Mf:return s*t*3/i.components*i.byteLength;case yn:return s*t*4/i.components*i.byteLength;case Rh:return s*t*4/i.components*i.byteLength;case Bo:case ko:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case zo:case Ho:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Kl:case Ql:return Math.max(s,16)*Math.max(t,8)/4;case $l:case jl:return Math.max(s,8)*Math.max(t,8)/2;case tc:case ec:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case nc:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case ic:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case sc:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case rc:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case oc:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case ac:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case lc:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case cc:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case hc:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case uc:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case dc:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case fc:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case pc:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case mc:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case gc:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case Vo:case _c:case yc:return Math.ceil(s/4)*Math.ceil(t/4)*16;case wf:case xc:return Math.ceil(s/4)*Math.ceil(t/4)*8;case vc:case Mc:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function JS(s){switch(s){case gi:case _f:return{byteLength:1,components:1};case zr:case yf:case ro:return{byteLength:2,components:1};case Eh:case wh:return{byteLength:2,components:4};case zi:case bh:case An:return{byteLength:4,components:1};case xf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}var $S={contain:qS,cover:YS,fill:ZS,getByteLength:dd};function KS(s,t,e,n,i,r,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Y,h=new WeakMap,u,d=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(A,S){return f?new OffscreenCanvas(A,S):ta("canvas")}function _(A,S,F){let J=1,et=Et(A);if((et.width>F||et.height>F)&&(J=F/Math.max(et.width,et.height)),J<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let $=Math.floor(J*et.width),Dt=Math.floor(J*et.height);u===void 0&&(u=m($,Dt));let gt=S?m($,Dt):u;return gt.width=$,gt.height=Dt,gt.getContext("2d").drawImage(A,0,0,$,Dt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+et.width+"x"+et.height+") to ("+$+"x"+Dt+")."),gt}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+et.width+"x"+et.height+")."),A;return A}function g(A){return A.generateMipmaps}function p(A){s.generateMipmap(A)}function v(A){return A.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?s.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function x(A,S,F,J,et=!1){if(A!==null){if(s[A]!==void 0)return s[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let $=S;if(S===s.RED&&(F===s.FLOAT&&($=s.R32F),F===s.HALF_FLOAT&&($=s.R16F),F===s.UNSIGNED_BYTE&&($=s.R8)),S===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.R8UI),F===s.UNSIGNED_SHORT&&($=s.R16UI),F===s.UNSIGNED_INT&&($=s.R32UI),F===s.BYTE&&($=s.R8I),F===s.SHORT&&($=s.R16I),F===s.INT&&($=s.R32I)),S===s.RG&&(F===s.FLOAT&&($=s.RG32F),F===s.HALF_FLOAT&&($=s.RG16F),F===s.UNSIGNED_BYTE&&($=s.RG8)),S===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RG8UI),F===s.UNSIGNED_SHORT&&($=s.RG16UI),F===s.UNSIGNED_INT&&($=s.RG32UI),F===s.BYTE&&($=s.RG8I),F===s.SHORT&&($=s.RG16I),F===s.INT&&($=s.RG32I)),S===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGB8UI),F===s.UNSIGNED_SHORT&&($=s.RGB16UI),F===s.UNSIGNED_INT&&($=s.RGB32UI),F===s.BYTE&&($=s.RGB8I),F===s.SHORT&&($=s.RGB16I),F===s.INT&&($=s.RGB32I)),S===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGBA8UI),F===s.UNSIGNED_SHORT&&($=s.RGBA16UI),F===s.UNSIGNED_INT&&($=s.RGBA32UI),F===s.BYTE&&($=s.RGBA8I),F===s.SHORT&&($=s.RGBA16I),F===s.INT&&($=s.RGBA32I)),S===s.RGB&&F===s.UNSIGNED_INT_5_9_9_9_REV&&($=s.RGB9_E5),S===s.RGBA){let Dt=et?Pa:ce.getTransfer(J);F===s.FLOAT&&($=s.RGBA32F),F===s.HALF_FLOAT&&($=s.RGBA16F),F===s.UNSIGNED_BYTE&&($=Dt===Se?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT_4_4_4_4&&($=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&($=s.RGB5_A1)}return($===s.R16F||$===s.R32F||$===s.RG16F||$===s.RG32F||$===s.RGBA16F||$===s.RGBA32F)&&t.get("EXT_color_buffer_float"),$}function y(A,S){let F;return A?S===null||S===zi||S===Gs?F=s.DEPTH24_STENCIL8:S===An?F=s.DEPTH32F_STENCIL8:S===zr&&(F=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===zi||S===Gs?F=s.DEPTH_COMPONENT24:S===An?F=s.DEPTH_COMPONENT32F:S===zr&&(F=s.DEPTH_COMPONENT16),F}function I(A,S){return g(A)===!0||A.isFramebufferTexture&&A.minFilter!==rn&&A.minFilter!==We?Math.log2(Math.max(S.width,S.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?S.mipmaps.length:1}function T(A){let S=A.target;S.removeEventListener("dispose",T),C(S),S.isVideoTexture&&h.delete(S)}function R(A){let S=A.target;S.removeEventListener("dispose",R),M(S)}function C(A){let S=n.get(A);if(S.__webglInit===void 0)return;let F=A.source,J=d.get(F);if(J){let et=J[S.__cacheKey];et.usedTimes--,et.usedTimes===0&&b(A),Object.keys(J).length===0&&d.delete(F)}n.remove(A)}function b(A){let S=n.get(A);s.deleteTexture(S.__webglTexture);let F=A.source,J=d.get(F);delete J[S.__cacheKey],o.memory.textures--}function M(A){let S=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let J=0;J<6;J++){if(Array.isArray(S.__webglFramebuffer[J]))for(let et=0;et=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+i.maxTextures),L+=1,A}function G(A){let S=[];return S.push(A.wrapS),S.push(A.wrapT),S.push(A.wrapR||0),S.push(A.magFilter),S.push(A.minFilter),S.push(A.anisotropy),S.push(A.internalFormat),S.push(A.format),S.push(A.type),S.push(A.generateMipmaps),S.push(A.premultiplyAlpha),S.push(A.flipY),S.push(A.unpackAlignment),S.push(A.colorSpace),S.join()}function j(A,S){let F=n.get(A);if(A.isVideoTexture&&dt(A),A.isRenderTargetTexture===!1&&A.version>0&&F.__version!==A.version){let J=A.image;if(J===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(J.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(F,A,S);return}}e.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+S)}function W(A,S){let F=n.get(A);if(A.version>0&&F.__version!==A.version){K(F,A,S);return}e.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+S)}function st(A,S){let F=n.get(A);if(A.version>0&&F.__version!==A.version){K(F,A,S);return}e.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+S)}function X(A,S){let F=n.get(A);if(A.version>0&&F.__version!==A.version){at(F,A,S);return}e.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+S)}let ft={[ss]:s.REPEAT,[_n]:s.CLAMP_TO_EDGE,[Jo]:s.MIRRORED_REPEAT},St={[rn]:s.NEAREST,[gf]:s.NEAREST_MIPMAP_NEAREST,[Ur]:s.NEAREST_MIPMAP_LINEAR,[We]:s.LINEAR,[Oo]:s.LINEAR_MIPMAP_NEAREST,[di]:s.LINEAR_MIPMAP_LINEAR},It={[P0]:s.NEVER,[F0]:s.ALWAYS,[I0]:s.LESS,[Af]:s.LEQUAL,[L0]:s.EQUAL,[N0]:s.GEQUAL,[D0]:s.GREATER,[U0]:s.NOTEQUAL};function jt(A,S){if(S.type===An&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===We||S.magFilter===Oo||S.magFilter===Ur||S.magFilter===di||S.minFilter===We||S.minFilter===Oo||S.minFilter===Ur||S.minFilter===di)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(A,s.TEXTURE_WRAP_S,ft[S.wrapS]),s.texParameteri(A,s.TEXTURE_WRAP_T,ft[S.wrapT]),(A===s.TEXTURE_3D||A===s.TEXTURE_2D_ARRAY)&&s.texParameteri(A,s.TEXTURE_WRAP_R,ft[S.wrapR]),s.texParameteri(A,s.TEXTURE_MAG_FILTER,St[S.magFilter]),s.texParameteri(A,s.TEXTURE_MIN_FILTER,St[S.minFilter]),S.compareFunction&&(s.texParameteri(A,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(A,s.TEXTURE_COMPARE_FUNC,It[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===rn||S.minFilter!==Ur&&S.minFilter!==di||S.type===An&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");s.texParameterf(A,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function ge(A,S){let F=!1;A.__webglInit===void 0&&(A.__webglInit=!0,S.addEventListener("dispose",T));let J=S.source,et=d.get(J);et===void 0&&(et={},d.set(J,et));let $=G(S);if($!==A.__cacheKey){et[$]===void 0&&(et[$]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,F=!0),et[$].usedTimes++;let Dt=et[A.__cacheKey];Dt!==void 0&&(et[A.__cacheKey].usedTimes--,Dt.usedTimes===0&&b(S)),A.__cacheKey=$,A.__webglTexture=et[$].texture}return F}function K(A,S,F){let J=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(J=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(J=s.TEXTURE_3D);let et=ge(A,S),$=S.source;e.bindTexture(J,A.__webglTexture,s.TEXTURE0+F);let Dt=n.get($);if($.version!==Dt.__version||et===!0){e.activeTexture(s.TEXTURE0+F);let gt=ce.getPrimaries(ce.workingColorSpace),wt=S.colorSpace===si?null:ce.getPrimaries(S.colorSpace),ae=S.colorSpace===si||gt===wt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ae);let it=_(S.image,!1,i.maxTextureSize);it=Gt(S,it);let Ct=r.convert(S.format,S.colorSpace),Wt=r.convert(S.type),Zt=x(S.internalFormat,Ct,Wt,S.colorSpace,S.isVideoTexture);jt(J,S);let Pt,ue=S.mipmaps,re=S.isVideoTexture!==!0,Re=Dt.__version===void 0||et===!0,D=$.dataReady,_t=I(S,it);if(S.isDepthTexture)Zt=y(S.format===Ws,S.type),Re&&(re?e.texStorage2D(s.TEXTURE_2D,1,Zt,it.width,it.height):e.texImage2D(s.TEXTURE_2D,0,Zt,it.width,it.height,0,Ct,Wt,null));else if(S.isDataTexture)if(ue.length>0){re&&Re&&e.texStorage2D(s.TEXTURE_2D,_t,Zt,ue[0].width,ue[0].height);for(let q=0,Q=ue.length;q0){let Mt=dd(Pt.width,Pt.height,S.format,S.type);for(let xt of S.layerUpdates){let ee=Pt.data.subarray(xt*Mt/Pt.data.BYTES_PER_ELEMENT,(xt+1)*Mt/Pt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,q,0,0,xt,Pt.width,Pt.height,1,Ct,ee)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,q,0,0,0,Pt.width,Pt.height,it.depth,Ct,Pt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,q,Zt,Pt.width,Pt.height,it.depth,0,Pt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else re?D&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,q,0,0,0,Pt.width,Pt.height,it.depth,Ct,Wt,Pt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,q,Zt,Pt.width,Pt.height,it.depth,0,Ct,Wt,Pt.data)}else{re&&Re&&e.texStorage2D(s.TEXTURE_2D,_t,Zt,ue[0].width,ue[0].height);for(let q=0,Q=ue.length;q0){let q=dd(it.width,it.height,S.format,S.type);for(let Q of S.layerUpdates){let Mt=it.data.subarray(Q*q/it.data.BYTES_PER_ELEMENT,(Q+1)*q/it.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Q,it.width,it.height,1,Ct,Wt,Mt)}S.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,it.width,it.height,it.depth,Ct,Wt,it.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,Zt,it.width,it.height,it.depth,0,Ct,Wt,it.data);else if(S.isData3DTexture)re?(Re&&e.texStorage3D(s.TEXTURE_3D,_t,Zt,it.width,it.height,it.depth),D&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,it.width,it.height,it.depth,Ct,Wt,it.data)):e.texImage3D(s.TEXTURE_3D,0,Zt,it.width,it.height,it.depth,0,Ct,Wt,it.data);else if(S.isFramebufferTexture){if(Re)if(re)e.texStorage2D(s.TEXTURE_2D,_t,Zt,it.width,it.height);else{let q=it.width,Q=it.height;for(let Mt=0;Mt<_t;Mt++)e.texImage2D(s.TEXTURE_2D,Mt,Zt,q,Q,0,Ct,Wt,null),q>>=1,Q>>=1}}else if(ue.length>0){if(re&&Re){let q=Et(ue[0]);e.texStorage2D(s.TEXTURE_2D,_t,Zt,q.width,q.height)}for(let q=0,Q=ue.length;q0&&_t++;let Q=Et(Ct[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,_t,ue,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(it){re?D&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Ct[Q].width,Ct[Q].height,Zt,Pt,Ct[Q].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,ue,Ct[Q].width,Ct[Q].height,0,Zt,Pt,Ct[Q].data);for(let Mt=0;Mt>$),Wt=Math.max(1,S.height>>$);et===s.TEXTURE_3D||et===s.TEXTURE_2D_ARRAY?e.texImage3D(et,$,wt,Ct,Wt,S.depth,0,Dt,gt,null):e.texImage2D(et,$,wt,Ct,Wt,0,Dt,gt,null)}e.bindFramebuffer(s.FRAMEBUFFER,A),At(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,J,et,it.__webglTexture,0,nt(S)):(et===s.TEXTURE_2D||et>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&et<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,J,et,it.__webglTexture,$),e.bindFramebuffer(s.FRAMEBUFFER,null)}function ct(A,S,F){if(s.bindRenderbuffer(s.RENDERBUFFER,A),S.depthBuffer){let J=S.depthTexture,et=J&&J.isDepthTexture?J.type:null,$=y(S.stencilBuffer,et),Dt=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,gt=nt(S);At(S)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,gt,$,S.width,S.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,gt,$,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,$,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Dt,s.RENDERBUFFER,A)}else{let J=S.textures;for(let et=0;et{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,J.removeEventListener("dispose",et)};J.addEventListener("dispose",et),S.__depthDisposeCallback=et}S.__boundDepthTexture=J}if(A.depthTexture&&!S.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");zt(S.__webglFramebuffer,A)}else if(F){S.__webglDepthbuffer=[];for(let J=0;J<6;J++)if(e.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[J]),S.__webglDepthbuffer[J]===void 0)S.__webglDepthbuffer[J]=s.createRenderbuffer(),ct(S.__webglDepthbuffer[J],A,!1);else{let et=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,$=S.__webglDepthbuffer[J];s.bindRenderbuffer(s.RENDERBUFFER,$),s.framebufferRenderbuffer(s.FRAMEBUFFER,et,s.RENDERBUFFER,$)}}else if(e.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),ct(S.__webglDepthbuffer,A,!1);else{let J=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,et=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,et),s.framebufferRenderbuffer(s.FRAMEBUFFER,J,s.RENDERBUFFER,et)}e.bindFramebuffer(s.FRAMEBUFFER,null)}function qt(A,S,F){let J=n.get(A);S!==void 0&&Lt(J.__webglFramebuffer,A,A.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Jt(A)}function fe(A){let S=A.texture,F=n.get(A),J=n.get(S);A.addEventListener("dispose",R);let et=A.textures,$=A.isWebGLCubeRenderTarget===!0,Dt=et.length>1;if(Dt||(J.__webglTexture===void 0&&(J.__webglTexture=s.createTexture()),J.__version=S.version,o.memory.textures++),$){F.__webglFramebuffer=[];for(let gt=0;gt<6;gt++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[gt]=[];for(let wt=0;wt0){F.__webglFramebuffer=[];for(let gt=0;gt0&&At(A)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let gt=0;gt0)for(let wt=0;wt0)for(let wt=0;wt0){if(At(A)===!1){let S=A.textures,F=A.width,J=A.height,et=s.COLOR_BUFFER_BIT,$=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Dt=n.get(A),gt=S.length>1;if(gt)for(let wt=0;wt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function dt(A){let S=o.render.frame;h.get(A)!==S&&(h.set(A,S),A.update())}function Gt(A,S){let F=A.colorSpace,J=A.format,et=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||F!==rr&&F!==si&&(ce.getTransfer(F)===Se?(J!==yn||et!==gi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),S}function Et(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=O,this.resetTextureUnits=V,this.setTexture2D=j,this.setTexture2DArray=W,this.setTexture3D=st,this.setTextureCube=X,this.rebindTextures=qt,this.setupRenderTarget=fe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=Bt,this.setupDepthRenderbuffer=Jt,this.setupFrameBufferTexture=Lt,this.useMultisampledRTT=At}function Y0(s,t){function e(n,i=si){let r,o=ce.getTransfer(i);if(n===gi)return s.UNSIGNED_BYTE;if(n===Eh)return s.UNSIGNED_SHORT_4_4_4_4;if(n===wh)return s.UNSIGNED_SHORT_5_5_5_1;if(n===xf)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===_f)return s.BYTE;if(n===yf)return s.SHORT;if(n===zr)return s.UNSIGNED_SHORT;if(n===bh)return s.INT;if(n===zi)return s.UNSIGNED_INT;if(n===An)return s.FLOAT;if(n===ro)return s.HALF_FLOAT;if(n===vf)return s.ALPHA;if(n===Mf)return s.RGB;if(n===yn)return s.RGBA;if(n===Sf)return s.LUMINANCE;if(n===bf)return s.LUMINANCE_ALPHA;if(n===zs)return s.DEPTH_COMPONENT;if(n===Ws)return s.DEPTH_STENCIL;if(n===Th)return s.RED;if(n===Ca)return s.RED_INTEGER;if(n===Ef)return s.RG;if(n===Ah)return s.RG_INTEGER;if(n===Rh)return s.RGBA_INTEGER;if(n===Bo||n===ko||n===zo||n===Ho)if(o===Se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Bo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ko)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===zo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ho)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Bo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ko)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===zo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ho)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===$l||n===Kl||n===jl||n===Ql)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===$l)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Kl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===jl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ql)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===tc||n===ec||n===nc)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===tc||n===ec)return o===Se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===nc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ic||n===sc||n===rc||n===oc||n===ac||n===lc||n===cc||n===hc||n===uc||n===dc||n===fc||n===pc||n===mc||n===gc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===ic)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===sc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===rc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===oc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ac)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===lc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===cc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===hc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===uc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===dc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===fc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===pc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===mc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===gc)return o===Se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Vo||n===_c||n===yc)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Vo)return o===Se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===_c)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===yc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===wf||n===xc||n===vc||n===Mc)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Vo)return r.COMPRESSED_RED_RGTC1_EXT;if(n===xc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===vc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Mc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Gs?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}var Ac=class extends ke{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Te=class extends de{constructor(){super(),this.isGroup=!0,this.type="Group"}},jS={type:"move"},Wo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Te,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 Te,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Te,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let _ of t.hand.values()){let g=e.getJointPose(_,n),p=this._getHandJoint(c,_);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(jS)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Te;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},QS=` void main() { gl_Position = vec4( position, 1.0 ); }`,tb=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`,fd=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let i=new Ge,r=t.properties.get(i);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new Qe({vertexShader:QS,fragmentShader:tb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ht(new Yn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pd=class extends qn{constructor(t,e){super();let n=this,i=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,m=null,_=new fd,g=e.getContextAttributes(),p=null,v=null,x=[],y=[],I=new Y,T=null,R=new ke;R.viewport=new pe;let C=new ke;C.viewport=new pe;let b=[R,C],M=new Ac,L=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let at=x[K];return at===void 0&&(at=new Wo,x[K]=at),at.getTargetRaySpace()},this.getControllerGrip=function(K){let at=x[K];return at===void 0&&(at=new Wo,x[K]=at),at.getGripSpace()},this.getHand=function(K){let at=x[K];return at===void 0&&(at=new Wo,x[K]=at),at.getHandSpace()};function O(K){let at=y.indexOf(K.inputSource);if(at===-1)return;let Lt=x[at];Lt!==void 0&&(Lt.update(K.inputSource,K.frame,c||o),Lt.dispatchEvent({type:K.type,data:K.inputSource}))}function G(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",j);for(let K=0;K=0&&(y[ct]=null,x[ct].disconnect(Lt))}for(let at=0;at=y.length){y.push(Lt),ct=Jt;break}else if(y[Jt]===null){y[Jt]=Lt,ct=Jt;break}if(ct===-1)break}let zt=x[ct];zt&&zt.connect(Lt)}}let W=new w,st=new w;function X(K,at,Lt){W.setFromMatrixPosition(at.matrixWorld),st.setFromMatrixPosition(Lt.matrixWorld);let ct=W.distanceTo(st),zt=at.projectionMatrix.elements,Jt=Lt.projectionMatrix.elements,qt=zt[14]/(zt[10]-1),fe=zt[14]/(zt[10]+1),tt=(zt[9]+1)/zt[5],rt=(zt[9]-1)/zt[5],P=(zt[8]-1)/zt[0],Bt=(Jt[8]+1)/Jt[0],nt=qt*P,At=qt*Bt,dt=ct/(-P+Bt),Gt=dt*-P;if(at.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Gt),K.translateZ(dt),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),zt[10]===-1)K.projectionMatrix.copy(at.projectionMatrix),K.projectionMatrixInverse.copy(at.projectionMatrixInverse);else{let Et=qt+dt,A=fe+dt,S=nt-Gt,F=At+(ct-Gt),J=tt*fe/A*Et,et=rt*fe/A*Et;K.projectionMatrix.makePerspective(S,F,J,et,Et,A),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function ft(K,at){at===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(at.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let at=K.near,Lt=K.far;_.texture!==null&&(_.depthNear>0&&(at=_.depthNear),_.depthFar>0&&(Lt=_.depthFar)),M.near=C.near=R.near=at,M.far=C.far=R.far=Lt,(L!==M.near||V!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,V=M.far),R.layers.mask=K.layers.mask|2,C.layers.mask=K.layers.mask|4,M.layers.mask=R.layers.mask|C.layers.mask;let ct=K.parent,zt=M.cameras;ft(M,ct);for(let Jt=0;Jt0&&(g.alphaTest.value=p.alphaTest);let v=t.get(p),x=v.envMap,y=v.envMapRotation;x&&(g.envMap.value=x,Ts.copy(y),Ts.x*=-1,Ts.y*=-1,Ts.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Ts.y*=-1,Ts.z*=-1),g.envMapRotation.value.setFromMatrix4(eb.makeRotationFromEuler(Ts)),g.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,v,x){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=x*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,v){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===sn&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){let v=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function ib(s,t,e,n){let i={},r={},o=[],a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,x){let y=x.program;n.uniformBlockBinding(v,y)}function c(v,x){let y=i[v.id];y===void 0&&(m(v),y=h(v),i[v.id]=y,v.addEventListener("dispose",g));let I=x.program;n.updateUBOMapping(v,I);let T=t.render.frame;r[v.id]!==T&&(d(v),r[v.id]=T)}function h(v){let x=u();v.__bindingPointIndex=x;let y=s.createBuffer(),I=v.__size,T=v.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,I,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,x,y),y}function u(){for(let v=0;v0&&(y+=I-T),v.__size=y,v.__cache={},this}function _(v){let x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let y=o.indexOf(x.__bindingPointIndex);o.splice(y,1),s.deleteBuffer(i[x.id]),delete i[x.id],delete r[x.id]}function p(){for(let v in i)s.deleteBuffer(i[v]);o=[],i={},r={}}return{bind:l,update:c,dispose:p}}var la=class{constructor(t={}){let{canvas:e=B0(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=o;let m=new Uint32Array(4),_=new Int32Array(4),g=null,p=null,v=[],x=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=nn,this.toneMapping=Fi,this.toneMappingExposure=1;let y=this,I=!1,T=0,R=0,C=null,b=-1,M=null,L=new pe,V=new pe,O=null,G=new Z(0),j=0,W=e.width,st=e.height,X=1,ft=null,St=null,It=new pe(0,0,W,st),jt=new pe(0,0,W,st),ge=!1,K=new qs,at=!1,Lt=!1,ct=new Yt,zt=new Yt,Jt=new w,qt=new pe,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},tt=!1;function rt(){return C===null?X:1}let P=n;function Bt(E,U){return e.getContext(E,U)}try{let E={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${xh}`),e.addEventListener("webglcontextlost",Q,!1),e.addEventListener("webglcontextrestored",Mt,!1),e.addEventListener("webglcontextcreationerror",xt,!1),P===null){let U="webgl2";if(P=Bt(U,E),P===null)throw Bt(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let nt,At,dt,Gt,Et,A,S,F,J,et,$,Dt,gt,wt,ae,it,Ct,Wt,Zt,Pt,ue,re,Re,D;function _t(){nt=new gM(P),nt.init(),re=new Y0(P,nt),At=new hM(P,nt,t,re),dt=new XS(P,nt),At.reverseDepthBuffer&&d&&dt.buffers.depth.setReversed(!0),Gt=new xM(P),Et=new LS,A=new KS(P,nt,dt,Et,At,re,Gt),S=new dM(y),F=new mM(y),J=new Ty(P),Re=new lM(P,J),et=new _M(P,J,Gt,Re),$=new MM(P,et,J,Gt),Zt=new vM(P,At,A),it=new uM(Et),Dt=new IS(y,S,F,nt,At,Re,it),gt=new nb(y,Et),wt=new US,ae=new zS(nt),Wt=new aM(y,S,F,dt,$,f,l),Ct=new GS(y,$,At),D=new ib(P,Gt,At,dt),Pt=new cM(P,nt,Gt),ue=new yM(P,nt,Gt),Gt.programs=Dt.programs,y.capabilities=At,y.extensions=nt,y.properties=Et,y.renderLists=wt,y.shadowMap=Ct,y.state=dt,y.info=Gt}_t();let q=new pd(y,P);this.xr=q,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let E=nt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=nt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(E){E!==void 0&&(X=E,this.setSize(W,st,!1))},this.getSize=function(E){return E.set(W,st)},this.setSize=function(E,U,k=!0){if(q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=E,st=U,e.width=Math.floor(E*X),e.height=Math.floor(U*X),k===!0&&(e.style.width=E+"px",e.style.height=U+"px"),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(W*X,st*X).floor()},this.setDrawingBufferSize=function(E,U,k){W=E,st=U,X=k,e.width=Math.floor(E*k),e.height=Math.floor(U*k),this.setViewport(0,0,E,U)},this.getCurrentViewport=function(E){return E.copy(L)},this.getViewport=function(E){return E.copy(It)},this.setViewport=function(E,U,k,z){E.isVector4?It.set(E.x,E.y,E.z,E.w):It.set(E,U,k,z),dt.viewport(L.copy(It).multiplyScalar(X).round())},this.getScissor=function(E){return E.copy(jt)},this.setScissor=function(E,U,k,z){E.isVector4?jt.set(E.x,E.y,E.z,E.w):jt.set(E,U,k,z),dt.scissor(V.copy(jt).multiplyScalar(X).round())},this.getScissorTest=function(){return ge},this.setScissorTest=function(E){dt.setScissorTest(ge=E)},this.setOpaqueSort=function(E){ft=E},this.setTransparentSort=function(E){St=E},this.getClearColor=function(E){return E.copy(Wt.getClearColor())},this.setClearColor=function(){Wt.setClearColor.apply(Wt,arguments)},this.getClearAlpha=function(){return Wt.getClearAlpha()},this.setClearAlpha=function(){Wt.setClearAlpha.apply(Wt,arguments)},this.clear=function(E=!0,U=!0,k=!0){let z=0;if(E){let N=!1;if(C!==null){let lt=C.texture.format;N=lt===Rh||lt===Ah||lt===Ca}if(N){let lt=C.texture.type,vt=lt===gi||lt===zi||lt===zr||lt===Gs||lt===Eh||lt===wh,Ut=Wt.getClearColor(),Nt=Wt.getClearAlpha(),$t=Ut.r,ne=Ut.g,Ft=Ut.b;vt?(m[0]=$t,m[1]=ne,m[2]=Ft,m[3]=Nt,P.clearBufferuiv(P.COLOR,0,m)):(_[0]=$t,_[1]=ne,_[2]=Ft,_[3]=Nt,P.clearBufferiv(P.COLOR,0,_))}else z|=P.COLOR_BUFFER_BIT}U&&(z|=P.DEPTH_BUFFER_BIT),k&&(z|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Q,!1),e.removeEventListener("webglcontextrestored",Mt,!1),e.removeEventListener("webglcontextcreationerror",xt,!1),wt.dispose(),ae.dispose(),Et.dispose(),S.dispose(),F.dispose(),$.dispose(),Re.dispose(),D.dispose(),Dt.dispose(),q.dispose(),q.removeEventListener("sessionstart",ap),q.removeEventListener("sessionend",lp),vs.stop()};function Q(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),I=!0}function Mt(){console.log("THREE.WebGLRenderer: Context Restored."),I=!1;let E=Gt.autoReset,U=Ct.enabled,k=Ct.autoUpdate,z=Ct.needsUpdate,N=Ct.type;_t(),Gt.autoReset=E,Ct.enabled=U,Ct.autoUpdate=k,Ct.needsUpdate=z,Ct.type=N}function xt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function ee(E){let U=E.target;U.removeEventListener("dispose",ee),Fe(U)}function Fe(E){an(E),Et.remove(E)}function an(E){let U=Et.get(E).programs;U!==void 0&&(U.forEach(function(k){Dt.releaseProgram(k)}),E.isShaderMaterial&&Dt.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,k,z,N,lt){U===null&&(U=fe);let vt=N.isMesh&&N.matrixWorld.determinant()<0,Ut=e_(E,U,k,z,N);dt.setMaterial(z,vt);let Nt=k.index,$t=1;if(z.wireframe===!0){if(Nt=et.getWireframeAttribute(k),Nt===void 0)return;$t=2}let ne=k.drawRange,Ft=k.attributes.position,me=ne.start*$t,Ce=(ne.start+ne.count)*$t;lt!==null&&(me=Math.max(me,lt.start*$t),Ce=Math.min(Ce,(lt.start+lt.count)*$t)),Nt!==null?(me=Math.max(me,0),Ce=Math.min(Ce,Nt.count)):Ft!=null&&(me=Math.max(me,0),Ce=Math.min(Ce,Ft.count));let Pe=Ce-me;if(Pe<0||Pe===1/0)return;Re.setup(N,z,Ut,k,Nt);let En,_e=Pt;if(Nt!==null&&(En=J.get(Nt),_e=ue,_e.setIndex(En)),N.isMesh)z.wireframe===!0?(dt.setLineWidth(z.wireframeLinewidth*rt()),_e.setMode(P.LINES)):_e.setMode(P.TRIANGLES);else if(N.isLine){let kt=z.linewidth;kt===void 0&&(kt=1),dt.setLineWidth(kt*rt()),N.isLineSegments?_e.setMode(P.LINES):N.isLineLoop?_e.setMode(P.LINE_LOOP):_e.setMode(P.LINE_STRIP)}else N.isPoints?_e.setMode(P.POINTS):N.isSprite&&_e.setMode(P.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)_e.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(nt.get("WEBGL_multi_draw"))_e.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{let kt=N._multiDrawStarts,Ei=N._multiDrawCounts,ye=N._multiDrawCount,Qn=Nt?J.get(Nt).bytesPerElement:1,mr=Et.get(z).currentProgram.getUniforms();for(let In=0;In{function lt(){if(z.forEach(function(vt){Et.get(vt).currentProgram.isReady()&&z.delete(vt)}),z.size===0){N(E);return}setTimeout(lt,10)}nt.get("KHR_parallel_shader_compile")!==null?lt():setTimeout(lt,10)})};let jn=null;function bi(E){jn&&jn(E)}function ap(){vs.stop()}function lp(){vs.start()}let vs=new V0;vs.setAnimationLoop(bi),typeof self<"u"&&vs.setContext(self),this.setAnimationLoop=function(E){jn=E,q.setAnimationLoop(E),E===null?vs.stop():vs.start()},q.addEventListener("sessionstart",ap),q.addEventListener("sessionend",lp),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),q.enabled===!0&&q.isPresenting===!0&&(q.cameraAutoUpdate===!0&&q.updateCamera(U),U=q.getCamera()),E.isScene===!0&&E.onBeforeRender(y,E,U,C),p=ae.get(E,x.length),p.init(U),x.push(p),zt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),K.setFromProjectionMatrix(zt),Lt=this.localClippingEnabled,at=it.init(this.clippingPlanes,Lt),g=wt.get(E,v.length),g.init(),v.push(g),q.enabled===!0&&q.isPresenting===!0){let lt=y.xr.getDepthSensingMesh();lt!==null&&su(lt,U,-1/0,y.sortObjects)}su(E,U,0,y.sortObjects),g.finish(),y.sortObjects===!0&&g.sort(ft,St),tt=q.enabled===!1||q.isPresenting===!1||q.hasDepthSensing()===!1,tt&&Wt.addToRenderList(g,E),this.info.render.frame++,at===!0&&it.beginShadows();let k=p.state.shadowsArray;Ct.render(k,E,U),at===!0&&it.endShadows(),this.info.autoReset===!0&&this.info.reset();let z=g.opaque,N=g.transmissive;if(p.setupLights(),U.isArrayCamera){let lt=U.cameras;if(N.length>0)for(let vt=0,Ut=lt.length;vt0&&hp(z,N,E,U),tt&&Wt.render(E),cp(g,E,U);C!==null&&(A.updateMultisampleRenderTarget(C),A.updateRenderTargetMipmap(C)),E.isScene===!0&&E.onAfterRender(y,E,U),Re.resetDefaultState(),b=-1,M=null,x.pop(),x.length>0?(p=x[x.length-1],at===!0&&it.setGlobalState(y.clippingPlanes,p.state.camera)):p=null,v.pop(),v.length>0?g=v[v.length-1]:g=null};function su(E,U,k,z){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)k=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||K.intersectsSprite(E)){z&&qt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(zt);let vt=$.update(E),Ut=E.material;Ut.visible&&g.push(E,vt,Ut,k,qt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||K.intersectsObject(E))){let vt=$.update(E),Ut=E.material;if(z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),qt.copy(E.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),qt.copy(vt.boundingSphere.center)),qt.applyMatrix4(E.matrixWorld).applyMatrix4(zt)),Array.isArray(Ut)){let Nt=vt.groups;for(let $t=0,ne=Nt.length;$t0&&Ya(N,U,k),lt.length>0&&Ya(lt,U,k),vt.length>0&&Ya(vt,U,k),dt.buffers.depth.setTest(!0),dt.buffers.depth.setMask(!0),dt.buffers.color.setMask(!0),dt.setPolygonOffset(!1)}function hp(E,U,k,z){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new Fn(1,1,{generateMipmaps:!0,type:nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float")?ro:gi,minFilter:di,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ce.workingColorSpace}));let lt=p.state.transmissionRenderTarget[z.id],vt=z.viewport||L;lt.setSize(vt.z,vt.w);let Ut=y.getRenderTarget();y.setRenderTarget(lt),y.getClearColor(G),j=y.getClearAlpha(),j<1&&y.setClearColor(16777215,.5),y.clear(),tt&&Wt.render(k);let Nt=y.toneMapping;y.toneMapping=Fi;let $t=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),at===!0&&it.setGlobalState(y.clippingPlanes,z),Ya(E,k,z),A.updateMultisampleRenderTarget(lt),A.updateRenderTargetMipmap(lt),nt.has("WEBGL_multisampled_render_to_texture")===!1){let ne=!1;for(let Ft=0,me=U.length;Ft0),Ft=!!k.morphAttributes.position,me=!!k.morphAttributes.normal,Ce=!!k.morphAttributes.color,Pe=Fi;z.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(Pe=y.toneMapping);let En=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,_e=En!==void 0?En.length:0,kt=Et.get(z),Ei=p.state.lights;if(at===!0&&(Lt===!0||E!==M)){let Vn=E===M&&z.id===b;it.setState(z,E,Vn)}let ye=!1;z.version===kt.__version?(kt.needsLights&&kt.lightsStateVersion!==Ei.state.version||kt.outputColorSpace!==Ut||N.isBatchedMesh&&kt.batching===!1||!N.isBatchedMesh&&kt.batching===!0||N.isBatchedMesh&&kt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&kt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&kt.instancing===!1||!N.isInstancedMesh&&kt.instancing===!0||N.isSkinnedMesh&&kt.skinning===!1||!N.isSkinnedMesh&&kt.skinning===!0||N.isInstancedMesh&&kt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&kt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&kt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&kt.instancingMorph===!1&&N.morphTexture!==null||kt.envMap!==Nt||z.fog===!0&&kt.fog!==lt||kt.numClippingPlanes!==void 0&&(kt.numClippingPlanes!==it.numPlanes||kt.numIntersection!==it.numIntersection)||kt.vertexAlphas!==$t||kt.vertexTangents!==ne||kt.morphTargets!==Ft||kt.morphNormals!==me||kt.morphColors!==Ce||kt.toneMapping!==Pe||kt.morphTargetsCount!==_e)&&(ye=!0):(ye=!0,kt.__version=z.version);let Qn=kt.currentProgram;ye===!0&&(Qn=Za(z,U,N));let mr=!1,In=!1,vo=!1,Ie=Qn.getUniforms(),ci=kt.uniforms;if(dt.useProgram(Qn.program)&&(mr=!0,In=!0,vo=!0),z.id!==b&&(b=z.id,In=!0),mr||M!==E){dt.buffers.depth.getReversed()?(ct.copy(E.projectionMatrix),ry(ct),oy(ct),Ie.setValue(P,"projectionMatrix",ct)):Ie.setValue(P,"projectionMatrix",E.projectionMatrix),Ie.setValue(P,"viewMatrix",E.matrixWorldInverse);let Yi=Ie.map.cameraPosition;Yi!==void 0&&Yi.setValue(P,Jt.setFromMatrixPosition(E.matrixWorld)),At.logarithmicDepthBuffer&&Ie.setValue(P,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&Ie.setValue(P,"isOrthographic",E.isOrthographicCamera===!0),M!==E&&(M=E,In=!0,vo=!0)}if(N.isSkinnedMesh){Ie.setOptional(P,N,"bindMatrix"),Ie.setOptional(P,N,"bindMatrixInverse");let Vn=N.skeleton;Vn&&(Vn.boneTexture===null&&Vn.computeBoneTexture(),Ie.setValue(P,"boneTexture",Vn.boneTexture,A))}N.isBatchedMesh&&(Ie.setOptional(P,N,"batchingTexture"),Ie.setValue(P,"batchingTexture",N._matricesTexture,A),Ie.setOptional(P,N,"batchingIdTexture"),Ie.setValue(P,"batchingIdTexture",N._indirectTexture,A),Ie.setOptional(P,N,"batchingColorTexture"),N._colorsTexture!==null&&Ie.setValue(P,"batchingColorTexture",N._colorsTexture,A));let Mo=k.morphAttributes;if((Mo.position!==void 0||Mo.normal!==void 0||Mo.color!==void 0)&&Zt.update(N,k,Qn),(In||kt.receiveShadow!==N.receiveShadow)&&(kt.receiveShadow=N.receiveShadow,Ie.setValue(P,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(ci.envMap.value=Nt,ci.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&U.environment!==null&&(ci.envMapIntensity.value=U.environmentIntensity),In&&(Ie.setValue(P,"toneMappingExposure",y.toneMappingExposure),kt.needsLights&&n_(ci,vo),lt&&z.fog===!0&>.refreshFogUniforms(ci,lt),gt.refreshMaterialUniforms(ci,z,X,st,p.state.transmissionRenderTarget[E.id]),kr.upload(P,dp(kt),ci,A)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(kr.upload(P,dp(kt),ci,A),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&Ie.setValue(P,"center",N.center),Ie.setValue(P,"modelViewMatrix",N.modelViewMatrix),Ie.setValue(P,"normalMatrix",N.normalMatrix),Ie.setValue(P,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let Vn=z.uniformsGroups;for(let Yi=0,Zi=Vn.length;Yi0&&A.useMultisampledRTT(E)===!1?N=Et.get(E).__webglMultisampledFramebuffer:Array.isArray(ne)?N=ne[k]:N=ne,L.copy(E.viewport),V.copy(E.scissor),O=E.scissorTest}else L.copy(It).multiplyScalar(X).floor(),V.copy(jt).multiplyScalar(X).floor(),O=ge;if(dt.bindFramebuffer(P.FRAMEBUFFER,N)&&z&&dt.drawBuffers(E,N),dt.viewport(L),dt.scissor(V),dt.setScissorTest(O),lt){let Nt=Et.get(E.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+U,Nt.__webglTexture,k)}else if(vt){let Nt=Et.get(E.texture),$t=U||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Nt.__webglTexture,k||0,$t)}b=-1},this.readRenderTargetPixels=function(E,U,k,z,N,lt,vt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=Et.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&vt!==void 0&&(Ut=Ut[vt]),Ut){dt.bindFramebuffer(P.FRAMEBUFFER,Ut);try{let Nt=E.texture,$t=Nt.format,ne=Nt.type;if(!At.textureFormatReadable($t)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!At.textureTypeReadable(ne)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-z&&k>=0&&k<=E.height-N&&P.readPixels(U,k,z,N,re.convert($t),re.convert(ne),lt)}finally{let Nt=C!==null?Et.get(C).__webglFramebuffer:null;dt.bindFramebuffer(P.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(E,U,k,z,N,lt,vt){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=Et.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&vt!==void 0&&(Ut=Ut[vt]),Ut){let Nt=E.texture,$t=Nt.format,ne=Nt.type;if(!At.textureFormatReadable($t))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!At.textureTypeReadable(ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(U>=0&&U<=E.width-z&&k>=0&&k<=E.height-N){dt.bindFramebuffer(P.FRAMEBUFFER,Ut);let Ft=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,Ft),P.bufferData(P.PIXEL_PACK_BUFFER,lt.byteLength,P.STREAM_READ),P.readPixels(U,k,z,N,re.convert($t),re.convert(ne),0);let me=C!==null?Et.get(C).__webglFramebuffer:null;dt.bindFramebuffer(P.FRAMEBUFFER,me);let Ce=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await sy(P,Ce,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,Ft),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,lt),P.deleteBuffer(Ft),P.deleteSync(Ce),lt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,U=null,k=0){E.isTexture!==!0&&(Uo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),U=arguments[0]||null,E=arguments[1]);let z=Math.pow(2,-k),N=Math.floor(E.image.width*z),lt=Math.floor(E.image.height*z),vt=U!==null?U.x:0,Ut=U!==null?U.y:0;A.setTexture2D(E,0),P.copyTexSubImage2D(P.TEXTURE_2D,k,0,0,vt,Ut,N,lt),dt.unbindTexture()},this.copyTextureToTexture=function(E,U,k=null,z=null,N=0){E.isTexture!==!0&&(Uo("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,E=arguments[1],U=arguments[2],N=arguments[3]||0,k=null);let lt,vt,Ut,Nt,$t,ne,Ft,me,Ce,Pe=E.isCompressedTexture?E.mipmaps[N]:E.image;k!==null?(lt=k.max.x-k.min.x,vt=k.max.y-k.min.y,Ut=k.isBox3?k.max.z-k.min.z:1,Nt=k.min.x,$t=k.min.y,ne=k.isBox3?k.min.z:0):(lt=Pe.width,vt=Pe.height,Ut=Pe.depth||1,Nt=0,$t=0,ne=0),z!==null?(Ft=z.x,me=z.y,Ce=z.z):(Ft=0,me=0,Ce=0);let En=re.convert(U.format),_e=re.convert(U.type),kt;U.isData3DTexture?(A.setTexture3D(U,0),kt=P.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(A.setTexture2DArray(U,0),kt=P.TEXTURE_2D_ARRAY):(A.setTexture2D(U,0),kt=P.TEXTURE_2D),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);let Ei=P.getParameter(P.UNPACK_ROW_LENGTH),ye=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Qn=P.getParameter(P.UNPACK_SKIP_PIXELS),mr=P.getParameter(P.UNPACK_SKIP_ROWS),In=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,Pe.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Pe.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Nt),P.pixelStorei(P.UNPACK_SKIP_ROWS,$t),P.pixelStorei(P.UNPACK_SKIP_IMAGES,ne);let vo=E.isDataArrayTexture||E.isData3DTexture,Ie=U.isDataArrayTexture||U.isData3DTexture;if(E.isRenderTargetTexture||E.isDepthTexture){let ci=Et.get(E),Mo=Et.get(U),Vn=Et.get(ci.__renderTarget),Yi=Et.get(Mo.__renderTarget);dt.bindFramebuffer(P.READ_FRAMEBUFFER,Vn.__webglFramebuffer),dt.bindFramebuffer(P.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let Zi=0;Zi0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},Jr=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=jo,this.updateRanges=[],this.version=0,this.uuid=Un()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:l,point:To.clone(),uv:ui.getInterpolation(To,ml,Ro,gl,rm,Iu,om,new Y),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};function _l(s,t,e,n,i,r){Lr.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(Ao.x=r*Lr.x-i*Lr.y,Ao.y=i*Lr.x+r*Lr.y):Ao.copy(Lr),s.copy(t),s.x+=Ao.x,s.y+=Ao.y,s.applyMatrix4(Z0)}var yl=new w,am=new w,Cc=class extends de{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let n=0,i=e.length;n0){let n,i;for(n=1,i=e.length;n0){yl.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(yl);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){yl.setFromMatrixPosition(t.matrixWorld),am.setFromMatrixPosition(this.matrixWorld);let n=yl.distanceTo(am)/t.zoom;e[0].object.visible=!0;let i,r;for(i=1,r=e.length;i=o)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];o.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}},wn=new Yt,cb=new Z(1,1,1),Nu=new qs,Ml=new on,As=new Ke,Io=new w,gm=new w,hb=new w,Fu=new md,hn=new ht,Sl=[];function ub(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new se(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new on);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Uu),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let r=this._matricesTexture;wn.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;let o=this._colorsTexture;return o&&(cb.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);let i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;let o=t.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Uu),l=this._availableGeometryIds.shift(),r[l]=i):(l=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(l,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=e.getIndex(),a=this._geometryInfo[t];if(i&&o.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let l=a.vertexStart,c=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(let h in n.attributes){let u=e.getAttribute(h),d=n.getAttribute(h);ub(u,d,l);let f=u.itemSize;for(let m=u.count,_=c;m<_;m++){let g=l+m;for(let p=0;p=e.length||e[t].active===!1)return this;let n=this._instanceInfo;for(let i=0,r=n.length;i=e.length||e[t].active===!1?this:(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this)}optimize(){let t=0,e=0,n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),r=this.geometry;for(let o=0,a=n.length;o=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){let r=new on,o=n.index,a=n.attributes.position;for(let l=i.start,c=i.start+i.count;l=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){let r=new Ke;this.getBoundingBoxAt(t,Ml),Ml.getCenter(r.center);let o=n.index,a=n.attributes.position,l=0;for(let c=i.start,h=i.start+i.count;c=n.length||n[t].active===!1?this:(e.toArray(r,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){let n=this._instanceInfo,i=this._matricesTexture.image.data;return t>=n.length||n[t].active===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();let n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._instanceInfo;return t>=r.length||r[t].active===!1?this:(e.toArray(i,t*4),n.needsUpdate=!0,this)}getColorAt(t,e){let n=this._colorsTexture.image.data,i=this._instanceInfo;return t>=i.length||i[t].active===!1?null:e.fromArray(n,t*4)}setVisibleAt(t,e){let n=this._instanceInfo;return t>=n.length||n[t].active===!1||n[t].visible===e?this:(n[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){let e=this._instanceInfo;return t>=e.length||e[t].active===!1?!1:e[t].visible}setGeometryIdAt(t,e){let n=this._instanceInfo,i=this._geometryInfo;return t>=n.length||n[t].active===!1||e>=i.length||i[e].active===!1?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){let e=this._instanceInfo;return t>=e.length||e[t].active===!1?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;let n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){let e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(Uu);e[e.length-1]===n.length;)n.pop(),e.pop();if(ta.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xt,this._initializeGeometry(r));let o=this.geometry;r.index&&Rs(r.index.array,o.index.array);for(let a in r.attributes)Rs(r.attributes[a].array,o.attributes[a].array)}raycast(t,e){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;hn.material=this.material,hn.geometry.index=o.index,hn.geometry.attributes=o.attributes,hn.geometry.boundingBox===null&&(hn.geometry.boundingBox=new on),hn.geometry.boundingSphere===null&&(hn.geometry.boundingSphere=new Ke);for(let a=0,l=n.length;a({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data;d&&(wn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Nu.setFromProjectionMatrix(wn,t.coordinateSystem));let _=0;if(this.sortObjects){wn.copy(this.matrixWorld).invert(),Io.setFromMatrixPosition(n.matrixWorld).applyMatrix4(wn),gm.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(wn);for(let v=0,x=l.length;v0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;rn)return;Ou.applyMatrix4(s.matrixWorld);let l=t.ray.origin.distanceTo(Ou);if(!(lt.far))return{distance:l,point:ym.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:s}}var xm=new w,vm=new w,Jn=class extends Zn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;ri.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var _d=class extends Ge{constructor(t,e,n,i,r,o,a,l,c){super(t,e,n,i,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:We,this.magFilter=r!==void 0?r:We,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},yd=class extends Ge{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=rn,this.minFilter=rn,this.generateMipmaps=!1,this.needsUpdate=!0}},Kr=class extends Ge{constructor(t,e,n,i,r,o,a,l,c,h,u,d){super(null,o,a,l,c,h,i,r,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}},xd=class extends Kr{constructor(t,e,n,i,r,o){super(t,e,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=_n,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},vd=class extends Kr{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,ki),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},ha=class extends Ge{constructor(t,e,n,i,r,o,a,l,c){super(t,e,n,i,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Bn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,r=n.length,o;e?o=e:o=t*n[r-1];let a=0,l=r-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(r-1);let h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let o=this.getPoint(i),a=this.getPoint(r),l=e||(o.isVector2?new Y:new w);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new w,i=[],r=[],o=[],a=new w,l=new Yt;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new w)}r[0]=new w,o[0]=new w;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let f=1;f<=t;f++){if(r[f]=r[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Be(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],r[f])}if(e===!0){let f=Math.acos(Be(r[0].dot(r[t]),-1,1));f/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(f=-f);for(let m=1;m<=t;m++)r[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],r[m])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},jr=class extends Bn{constructor(t=0,e=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new Y){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%r]:(Al.subVectors(i[0],i[1]).add(i[0]),c=Al);let u=i[a%r],d=i[(a+1)%r];if(this.closed||a+2i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(bm(a,l.x,c.x,h.x,u.x),bm(a,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){let o=i[r]-n,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},ga=class s extends Xt{constructor(t=[new Y(0,-.5),new Y(.5,0),new Y(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Be(i,0,Math.PI*2);let r=[],o=[],a=[],l=[],c=[],h=1/e,u=new w,d=new Y,f=new w,m=new w,_=new w,g=0,p=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(m)}for(let v=0;v<=e;v++){let x=n+v*h*i,y=Math.sin(x),I=Math.cos(x);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*y,u.y=t[T].y,u.z=t[T].x*I,o.push(u.x,u.y,u.z),d.x=v/e,d.y=T/(t.length-1),a.push(d.x,d.y);let R=l[3*T+0]*y,C=l[3*T+1],b=l[3*T+0]*I;c.push(R,C,b)}}for(let v=0;v0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new Tt(u,3)),this.setAttribute("normal",new Tt(d,3)),this.setAttribute("uv",new Tt(f,2));function v(){let y=new w,I=new w,T=0,R=(e-t)/n;for(let C=0;C<=r;C++){let b=[],M=C/r,L=M*(e-t)+t;for(let V=0;V<=i;V++){let O=V/i,G=O*l+a,j=Math.sin(G),W=Math.cos(G);I.x=L*j,I.y=-M*n+g,I.z=L*W,u.push(I.x,I.y,I.z),y.set(j,R,W).normalize(),d.push(y.x,y.y,y.z),f.push(O,1-M),b.push(m++)}_.push(b)}for(let C=0;C0||b!==0)&&(h.push(M,L,O),T+=3),(e>0||b!==r-1)&&(h.push(L,V,O),T+=3)}c.addGroup(p,T,0),p+=T}function x(y){let I=m,T=new Y,R=new w,C=0,b=y===!0?t:e,M=y===!0?1:-1;for(let V=1;V<=i;V++)u.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),m++;let L=m;for(let V=0;V<=i;V++){let G=V/i*l+a,j=Math.cos(G),W=Math.sin(G);R.x=b*W,R.y=g*M,R.z=b*j,u.push(R.x,R.y,R.z),d.push(0,M,0),T.x=j*.5+.5,T.y=W*.5*M+.5,f.push(T.x,T.y),m++}for(let V=0;V.9&&R<.1&&(x<.2&&(o[v+0]+=1),y<.2&&(o[v+2]+=1),I<.2&&(o[v+4]+=1))}}function d(v){r.push(v.x,v.y,v.z)}function f(v,x){let y=v*3;x.x=t[y+0],x.y=t[y+1],x.z=t[y+2]}function m(){let v=new w,x=new w,y=new w,I=new w,T=new Y,R=new Y,C=new Y;for(let b=0,M=0;b80*e){a=c=s[0],l=h=s[1];for(let m=e;mc&&(c=u),d>h&&(h=d);f=Math.max(c-a,h-l),f=f!==0?32767/f:0}return _a(r,o,e,a,l,f,0),o}};function J0(s,t,e,n,i){let r,o;if(i===Nb(s,t,e,n)>0)for(r=t;r=t;r-=n)o=Em(r,s[r],s[r+1],o);return o&&Ih(o,o.next)&&(xa(o),o=o.next),o}function $s(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Ih(e,e.next)||De(e.prev,e,e.next)===0)){if(xa(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function _a(s,t,e,n,i,r,o){if(!s)return;!o&&r&&Cb(s,n,i,r);let a=s,l,c;for(;s.prev!==s.next;){if(l=s.prev,c=s.next,r?Mb(s,n,i,r):vb(s)){t.push(l.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),xa(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=Sb($s(s),t,e),_a(s,t,e,n,i,r,2)):o===2&&bb(s,t,e,n,i,r):_a($s(s),t,e,n,i,r,1);break}}}function vb(s){let t=s.prev,e=s,n=s.next;if(De(t,e,n)>=0)return!1;let i=t.x,r=e.x,o=n.x,a=t.y,l=e.y,c=n.y,h=ir?i>o?i:o:r>o?r:o,f=a>l?a>c?a:c:l>c?l:c,m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&Or(i,a,r,l,o,c,m.x,m.y)&&De(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Mb(s,t,e,n){let i=s.prev,r=s,o=s.next;if(De(i,r,o)>=0)return!1;let a=i.x,l=r.x,c=o.x,h=i.y,u=r.y,d=o.y,f=al?a>c?a:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,p=Md(f,m,t,e,n),v=Md(_,g,t,e,n),x=s.prevZ,y=s.nextZ;for(;x&&x.z>=p&&y&&y.z<=v;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&Or(a,h,l,u,c,d,x.x,x.y)&&De(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Or(a,h,l,u,c,d,y.x,y.y)&&De(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=p;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&Or(a,h,l,u,c,d,x.x,x.y)&&De(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Or(a,h,l,u,c,d,y.x,y.y)&&De(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Sb(s,t,e){let n=s;do{let i=n.prev,r=n.next.next;!Ih(i,r)&&$0(i,n,n.next,r)&&ya(i,r)&&ya(r,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(r.i/e|0),xa(n),xa(n.next),n=s=r),n=n.next}while(n!==s);return $s(n)}function bb(s,t,e,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Lb(o,a)){let l=K0(o,a);o=$s(o,o.next),l=$s(l,l.next),_a(o,t,e,n,i,r,0),_a(l,t,e,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function Eb(s,t,e,n){let i=[],r,o,a,l,c;for(r=0,o=t.length;r=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=r&&d>n&&(n=d,i=e.x=e.x&&e.x>=l&&r!==e.x&&Or(oi.x||e.x===i.x&&Rb(i,e)))&&(i=e,h=u)),e=e.next;while(e!==a);return i}function Rb(s,t){return De(s.prev,s,t.prev)<0&&De(t.next,s,s.next)<0}function Cb(s,t,e,n){let i=s;do i.z===0&&(i.z=Md(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Pb(i)}function Pb(s){let t,e,n,i,r,o,a,l,c=1;do{for(e=s,s=null,r=null,o=0;e;){for(o++,n=e,a=0,t=0;t0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;e=n}r.nextZ=null,c*=2}while(o>1);return s}function Md(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Ib(s){let t=s,e=s;do(t.x=(s-o)*(r-a)&&(s-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(i-o)*(n-a)}function Lb(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Db(s,t)&&(ya(s,t)&&ya(t,s)&&Ub(s,t)&&(De(s.prev,s,t.prev)||De(s,t.prev,t))||Ih(s,t)&&De(s.prev,s,s.next)>0&&De(t.prev,t,t.next)>0)}function De(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Ih(s,t){return s.x===t.x&&s.y===t.y}function $0(s,t,e,n){let i=Ll(De(s,t,e)),r=Ll(De(s,t,n)),o=Ll(De(e,n,s)),a=Ll(De(e,n,t));return!!(i!==r&&o!==a||i===0&&Il(s,e,t)||r===0&&Il(s,n,t)||o===0&&Il(e,s,n)||a===0&&Il(e,t,n))}function Il(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Ll(s){return s>0?1:s<0?-1:0}function Db(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&$0(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function ya(s,t){return De(s.prev,s,s.next)<0?De(s,t,s.next)>=0&&De(s,s.prev,t)>=0:De(s,t,s.prev)<0||De(s,s.next,t)<0}function Ub(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function K0(s,t){let e=new Sd(s.i,s.x,s.y),n=new Sd(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function Em(s,t,e,n){let i=new Sd(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function xa(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Sd(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Nb(s,t,e,n){let i=0;for(let r=t,o=e-n;r2&&s[t-1].equals(s[0])&&s.pop()}function Tm(s,t){for(let e=0;eNumber.EPSILON){let J=Math.sqrt(S),et=Math.sqrt(Et*Et+A*A),$=rt.x-Gt/J,Dt=rt.y+dt/J,gt=P.x-A/et,wt=P.y+Et/et,ae=((gt-$)*A-(wt-Dt)*Et)/(dt*A-Gt*Et);Bt=$+dt*ae-tt.x,nt=Dt+Gt*ae-tt.y;let it=Bt*Bt+nt*nt;if(it<=2)return new Y(Bt,nt);At=Math.sqrt(it/2)}else{let J=!1;dt>Number.EPSILON?Et>Number.EPSILON&&(J=!0):dt<-Number.EPSILON?Et<-Number.EPSILON&&(J=!0):Math.sign(Gt)===Math.sign(A)&&(J=!0),J?(Bt=-Gt,nt=dt,At=Math.sqrt(S)):(Bt=dt,nt=Gt,At=Math.sqrt(S/2))}return new Y(Bt/At,nt/At)}let ft=[];for(let tt=0,rt=G.length,P=rt-1,Bt=tt+1;tt=0;tt--){let rt=tt/g,P=f*Math.cos(rt*Math.PI/2),Bt=m*Math.sin(rt*Math.PI/2)+_;for(let nt=0,At=G.length;nt=0;){let Bt=P,nt=P-1;nt<0&&(nt=tt.length-1);for(let At=0,dt=h+g*2;At0)&&f.push(x,y,T),(p!==n-1||l0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}},Qc=class extends je{static get type(){return"MeshPhongMaterial"}constructor(t){super(),this.isMeshPhongMaterial=!0,this.color=new Z(16777215),this.specular=new Z(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Ra,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},th=class extends je{static get type(){return"MeshToonMaterial"}constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.color=new Z(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},eh=class extends je{static get type(){return"MeshNormalMaterial"}constructor(t){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}},nh=class extends je{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new Z(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Ra,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},ih=class extends je{static get type(){return"MeshMatcapMaterial"}constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.color=new Z(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}},sh=class extends Ye{static get type(){return"LineDashedMaterial"}constructor(t){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}};function ks(s,t,e){return!s||!e&&s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function j0(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Q0(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function bd(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){let a=e[r]*t;for(let l=0;l!==t;++l)i[o++]=s[a+l]}return i}function If(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(t.push(r.time),e.push.apply(e,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(t.push(r.time),o.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(t.push(r.time),e.push(o)),r=s[i++];while(r!==void 0)}function kb(s,t,e,n,i=30){let r=s.clone();r.name=t;let o=[];for(let l=0;l=n)){u.push(c.times[f]);for(let _=0;_r.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l=a.times[m]){let p=m*u+h,v=p+u-h;_=a.values.slice(p,v)}else{let p=a.createInterpolant(),v=h,x=u-h;p.evaluate(r),_=p.resultBuffer.slice(v,x)}l==="quaternion"&&new Ue().fromArray(_).normalize().conjugate().toArray(_);let g=c.times.length;for(let p=0;p=r)){let a=e[1];t=r)break e}o=n,n=0;break n}break t}for(;n>>1;te;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&j0(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===zl,r=t.length-1,o=1;for(let a=1;a0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Hn.prototype.TimeBufferType=Float32Array;Hn.prototype.ValueBufferType=Float32Array;Hn.prototype.DefaultInterpolation=Sc;var Gi=class extends Hn{constructor(t,e,n){super(t,e,n)}};Gi.prototype.ValueTypeName="bool";Gi.prototype.ValueBufferType=Array;Gi.prototype.DefaultInterpolation=$o;Gi.prototype.InterpolantFactoryMethodLinear=void 0;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;var Sa=class extends Hn{};Sa.prototype.ValueTypeName="color";var Qs=class extends Hn{};Qs.prototype.ValueTypeName="number";var ah=class extends js{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),c=t*a;for(let h=c+a;c!==h;c+=4)Ue.slerpFlat(r,0,o,c-a,o,c,l);return r}},tr=class extends Hn{InterpolantFactoryMethodLinear(t){return new ah(this.times,this.values,this.getValueSize(),t)}};tr.prototype.ValueTypeName="quaternion";tr.prototype.InterpolantFactoryMethodSmooth=void 0;var Wi=class extends Hn{constructor(t,e,n){super(t,e,n)}};Wi.prototype.ValueTypeName="string";Wi.prototype.ValueBufferType=Array;Wi.prototype.DefaultInterpolation=$o;Wi.prototype.InterpolantFactoryMethodLinear=void 0;Wi.prototype.InterpolantFactoryMethodSmooth=void 0;var er=class extends Hn{};er.prototype.ValueTypeName="vector";var nr=class{constructor(t="",e=-1,n=[],i=Ch){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Un(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(Gb(n[o]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,o=n.length;r!==o;++r)e.push(Hn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,o=[];for(let a=0;a1){let u=h[1],d=i[u];d||(i[u]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,d,f,m,_){if(f.length!==0){let g=[],p=[];If(f,g,p,m),g.length!==0&&_.push(new u(d,g,p))}},i=[],r=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let u=0;u{e&&e(r),this.manager.itemEnd(t)},0),r;if(Pi[t]!==void 0){Pi[t].push({onLoad:e,onProgress:n,onError:i});return}Pi[t]=[],Pi[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{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 h=Pi[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,_=0,g=new ReadableStream({start(p){v();function v(){u.read().then(({done:x,value:y})=>{if(x)p.close();else{_+=y.byteLength;let I=new ProgressEvent("progress",{lengthComputable:m,loaded:_,total:f});for(let T=0,R=h.length;T{p.error(x)})}}});return new Response(g)}else throw new Ed(`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(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Di.add(t,c);let h=Pi[t];delete Pi[t];for(let u=0,d=h.length;u{let h=Pi[t];if(h===void 0)throw this.manager.itemError(t),c;delete Pi[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}},wd=class extends dn{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new oi(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(t)}},n,i)}parse(t){let e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let r in t.uniforms){let o=t.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new Z().setHex(o.value);break;case"v2":i.uniforms[r].value=new Y().fromArray(o.value);break;case"v3":i.uniforms[r].value=new w().fromArray(o.value);break;case"v4":i.uniforms[r].value=new pe().fromArray(o.value);break;case"m3":i.uniforms[r].value=new Kt().fromArray(o.value);break;case"m4":i.uniforms[r].value=new Yt().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let r in t.extensions)i.extensions[r]=t.extensions[r];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let r=t.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new Y().fromArray(r)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new Y().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return s.createMaterialFromType(t)}static createMaterialFromType(t){let e={ShadowMaterial:$c,SpriteMaterial:rs,RawShaderMaterial:Kc,ShaderMaterial:Qe,PointsMaterial:as,MeshPhysicalMaterial:jc,MeshStandardMaterial:Rt,MeshPhongMaterial:Qc,MeshToonMaterial:th,MeshNormalMaterial:eh,MeshLambertMaterial:nh,MeshDepthMaterial:oa,MeshDistanceMaterial:aa,MeshBasicMaterial:xn,MeshMatcapMaterial:ih,LineDashedMaterial:sh,LineBasicMaterial:Ye,Material:je};return new e[t]}},wa=class{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n0){let l=new ba(e);r=new ir(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c0){i=new ir(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=t.length;o{let g=new on;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);let p=new Ke;return p.radius=_.sphereRadius,p.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:p}}),o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._geometryCount=t.geometryCount,o._matricesTexture=c(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(o._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":o=new Cc;break;case"Line":o=new Zn(a(t.geometry),l(t.material));break;case"LineLoop":o=new Nc(a(t.geometry),l(t.material));break;case"LineSegments":o=new Jn(a(t.geometry),l(t.material));break;case"PointCloud":case"Points":o=new Hi(a(t.geometry),l(t.material));break;case"Sprite":o=new ri(l(t.material));break;case"Group":o=new Te;break;case"Bone":o=new ca;break;default:o=new de}if(o.uuid=t.uuid,t.name!==void 0&&(o.name=t.name),t.matrix!==void 0?(o.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(t.position!==void 0&&o.position.fromArray(t.position),t.rotation!==void 0&&o.rotation.fromArray(t.rotation),t.quaternion!==void 0&&o.quaternion.fromArray(t.quaternion),t.scale!==void 0&&o.scale.fromArray(t.scale)),t.up!==void 0&&o.up.fromArray(t.up),t.castShadow!==void 0&&(o.castShadow=t.castShadow),t.receiveShadow!==void 0&&(o.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(o.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(o.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(o.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(o.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(o.visible=t.visible),t.frustumCulled!==void 0&&(o.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(o.renderOrder=t.renderOrder),t.userData!==void 0&&(o.userData=t.userData),t.layers!==void 0&&(o.layers.mask=t.layers),t.children!==void 0){let d=t.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=Di.get(t);if(o!==void 0){if(r.manager.itemStart(t),o.then){o.then(c=>{e&&e(c),r.manager.itemEnd(t)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let l=fetch(t,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Di.add(t,c),e&&e(c),r.manager.itemEnd(t),c}).catch(function(c){i&&i(c),Di.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)});Di.add(t,l),r.manager.itemStart(t)}},Dl,Ta=class{static getContext(){return Dl===void 0&&(Dl=new(window.AudioContext||window.webkitAudioContext)),Dl}static setContext(t){Dl=t}},Nd=class extends dn{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new oi(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(l){try{let c=l.slice(0);Ta.getContext().decodeAudioData(c,function(u){e(u)}).catch(a)}catch(c){a(c)}},n,i);function a(l){i?i(l):console.error(l),r.manager.itemError(t)}}},Um=new Yt,Nm=new Yt,Cs=new Yt,Fd=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ke,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ke,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Cs.copy(t.projectionMatrix);let i=e.eyeSep/2,r=i*e.near/e.focus,o=e.near*Math.tan(Hs*e.fov*.5)/e.zoom,a,l;Nm.elements[12]=-i,Um.elements[12]=i,a=-o*e.aspect+r,l=o*e.aspect+r,Cs.elements[0]=2*e.near/(l-a),Cs.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Cs),a=-o*e.aspect-r,l=o*e.aspect-r,Cs.elements[0]=2*e.near/(l-a),Cs.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Cs)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Nm),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Um)}},no=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Fm(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=Fm();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function Fm(){return performance.now()}var Ps=new w,Om=new Ue,Xb=new w,Is=new w,Od=class extends de{constructor(){super(),this.type="AudioListener",this.context=Ta.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new no}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ps,Om,Xb),Is.set(0,0,-1).applyQuaternion(Om),e.positionX){let i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Ps.x,i),e.positionY.linearRampToValueAtTime(Ps.y,i),e.positionZ.linearRampToValueAtTime(Ps.z,i),e.forwardX.linearRampToValueAtTime(Is.x,i),e.forwardY.linearRampToValueAtTime(Is.y,i),e.forwardZ.linearRampToValueAtTime(Is.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(Ps.x,Ps.y,Ps.z),e.setOrientation(Is.x,Is.y,Is.z,n.x,n.y,n.z)}},gh=class extends de{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){a.setValue(n,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,o=i;r!==o;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let o=0;o!==r;++o)t[e+o]=t[n+o]}_slerp(t,e,n,i){Ue.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){let o=this._workIndex*r;Ue.multiplyQuaternionsFlat(t,o,t,e,t,n),Ue.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,r){let o=1-i;for(let a=0;a!==r;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let o=0;o!==r;++o){let a=e+o;t[a]=t[a]+t[n+o]*i}}},Lf="\\[\\]\\.:\\/",Yb=new RegExp("["+Lf+"]","g"),Df="[^"+Lf+"]",Zb="[^"+Lf.replace("\\.","")+"]",Jb=/((?:WC+[\/:])*)/.source.replace("WC",Df),$b=/(WCOD+)?/.source.replace("WCOD",Zb),Kb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Df),jb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Df),Qb=new RegExp("^"+Jb+$b+Kb+jb+"$"),tE=["material","materials","bones","map"],zd=class{constructor(t,e,n){let i=n||be.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},be=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Yb,"")}static parseTrackName(t){let e=Qb.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);tE.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let o=0;o=r){let u=r++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,m=i;f!==m;++f){let _=n[f],g=_[u],p=_[h];_[h]=g,_[u]=p}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,o=t.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,_=i;m!==_;++m){let g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(i!==void 0)return r[i];let o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=r.length,n[t]=i,o.push(t),a.push(e),r.push(u);for(let d=h,f=l.length;d!==f;++d){let m=l[d];u[d]=new be(m,t,e)}return u}unsubscribe_(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=t[a];e[c]=n,o[n]=l,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},yh=class{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;let r=e.tracks,o=r.length,a=new Array(o),l={endingStart:Os,endingEnd:Os};for(let c=0;c!==o;++c){let h=r[c].createInterpolant(null);a[c]=h,h.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=w0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let i=this._clip.duration,r=t._clip.duration,o=r/i,a=i/r;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let i=this._mixer,r=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+n,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}let r=this._startTime;if(r!==null){let l=(t-r)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Tf:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulateAdditive(a);break;case Ch:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,i=this.time+t,r=this._loopCount,o=n===T0;if(t===0)return r===-1?i:o&&(r&1)===1?e-i:i;if(n===E0){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,r+=Math.abs(a);let l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){let i=this._interpolantSettings;n?(i.endingStart=Bs,i.endingEnd=Bs):(t?i.endingStart=this.zeroSlopeAtStart?Bs:Os:i.endingStart=Ko,e?i.endingEnd=this.zeroSlopeAtEnd?Bs:Os:i.endingEnd=Ko)}_scheduleFading(t,e,n){let i=this._mixer,r=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=e,a[1]=r+t,l[1]=n,this}},eE=new Float32Array(1),Vd=class extends qn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName,h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==r;++u){let d=i[u],f=d.name,m=h[f];if(m!==void 0)++m.referenceCount,o[u]=m;else{if(m=o[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let _=e&&e._propertyBindings[u].binding.parsedPath;m=new _h(be.create(n,f,_),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[u]=m}a[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,r,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Hm).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Vm=new w,Ul=new w,jd=class{constructor(t=new w,e=new w){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Vm.subVectors(t,this.start),Ul.subVectors(this.end,this.start);let n=Ul.dot(Ul),r=Ul.dot(Vm)/n;return e&&(r=Be(r,0,1)),r}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Gm=new w,Qd=class extends de{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Xt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Zm.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Zm,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},df=class extends Jn{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Xt;i.setAttribute("position",new Tt(e,3)),i.setAttribute("color",new Tt(n,3));let r=new Ye({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new Z,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},ff=class{constructor(){this.type="ShapePath",this.color=new Z,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Zs,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,o){return this.currentPath.bezierCurveTo(t,e,n,i,r,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){let v=[];for(let x=0,y=p.length;xNumber.EPSILON){if(M<0&&(R=v[T],b=-b,C=v[I],M=-M),p.yC.y)continue;if(p.y===R.y){if(p.x===R.x)return!0}else{let L=M*(p.x-R.x)-b*(p.y-R.y);if(L===0)return!0;if(L<0)continue;y=!y}}else{if(p.y!==R.y)continue;if(C.x<=p.x&&p.x<=R.x||R.x<=p.x&&p.x<=C.x)return!0}}return y}let i=pi.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l,c=[];if(r.length===1)return a=r[0],l=new Nn,l.curves=a.curves,c.push(l),c;let h=!i(r[0].getPoints());h=t?!h:h;let u=[],d=[],f=[],m=0,_;d[m]=void 0,f[m]=[];for(let p=0,v=r.length;p1){let p=!1,v=0;for(let x=0,y=d.length;x0&&p===!1&&(f=u)}let g;for(let p=0,v=d.length;pMath.PI&&(n-=Rn),i<-Math.PI?i+=Rn:i>Math.PI&&(i-=Rn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Ze.setFromSpherical(this._spherical),Ze.applyQuaternion(this._quatInverse),e.copy(this.target).add(Ze),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=Ze.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new w(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new w(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Ze.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Lh.origin.copy(this.object.position),Lh.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Lh.direction))Nf||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Nf||this._lastTargetPosition.distanceToSquared(this.target)>Nf?(this.dispatchEvent(ng),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?Rn/60*this.autoRotateSpeed*t:Rn/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Ze.setFromMatrixColumn(e,0),Ze.multiplyScalar(-t),this._panOffset.add(Ze)}_panUp(t,e){this.screenSpacePanning===!0?Ze.setFromMatrixColumn(e,1):(Ze.setFromMatrixColumn(e,0),Ze.crossVectors(this.object.up,Ze)),Ze.multiplyScalar(t),this._panOffset.add(Ze)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Ze.copy(i).sub(this.target);let r=Ze.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Rn*this._rotateDelta.x/e.clientHeight),this._rotateUp(Rn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(Rn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-Rn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(Rn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-Rn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(n,i)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),i=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Rn*this._rotateDelta.x/e.clientHeight),this._rotateUp(Rn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(t.pageX+e.x)*.5,a=(t.pageY+e.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e>>0;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}var _g=Ae(20261018),rg=(s,t)=>s+(t-s)*_g();function Uh(s,t){let e=Math.sin(s*127.1+t*311.7)*43758.5453123;return e-Math.floor(e)}function _E(s,t){let e=Math.floor(s),n=Math.floor(t),i=s-e,r=t-n,o=i*i*(3-2*i),a=r*r*(3-2*r),l=Uh(e,n),c=Uh(e+1,n),h=Uh(e,n+1),u=Uh(e+1,n+1);return Ne(Ne(l,c,o),Ne(h,u,o),a)}function Na(s,t,e=4){let n=0,i=.5,r=1;for(let o=0;o.001){let l=Ot.waterY-.62-.12*(1-Mn(0,2.7,r));i=Ne(i,l,o)}let a=Mn(3.55,4.25,r)*(1-Mn(4.8,5.9,r));return a>.001&&(i=Math.max(i,Ot.waterY+.03+.16*a)),i}var yE=document.querySelector("#scene"),xE=!!(window.matchMedia&&window.matchMedia("(max-width: 760px)").matches),yg=xE?1.5:2,Je;try{Je=new la({canvas:yE,antialias:!0,alpha:!1,powerPreference:"high-performance"})}catch(s){throw document.querySelector(".loader-text").textContent="\u5F53\u524D\u6D4F\u89C8\u5668\u65E0\u6CD5\u542F\u52A8 WebGL",s}Je.setPixelRatio(Math.min(window.devicePixelRatio||1,yg));Je.setSize(window.innerWidth,window.innerHeight);Je.outputColorSpace=nn;Je.toneMapping=Mh;Je.toneMappingExposure=1.18;Je.shadowMap.enabled=!0;Je.shadowMap.type=vh;var Vt=new Zr;Vt.background=new Z(528656);Vt.fog=new Yr(726806,.0175);var oe=new ke(42,window.innerWidth/window.innerHeight,.1,180);function xg(){let s=window.innerWidth/window.innerHeight;oe.fov=s<.8?68:s<1.05?52:42,oe.updateProjectionMatrix()}xg();var po=new w(-2.6,3.1,2),Wh=new w(13.8,8,22);window.innerWidth/window.innerHeight<.8&&Wh.sub(po).multiplyScalar(1.22).add(po);oe.position.set(17.5,10.5,29);var he=new Dh(oe,Je.domElement);he.target.copy(po);he.enableDamping=!0;he.dampingFactor=.055;he.enablePan=!0;he.screenSpacePanning=!0;he.minDistance=7.4;he.maxDistance=36;he.minPolarAngle=.42;he.maxPolarAngle=Math.PI*.495;he.autoRotate=!1;he.autoRotateSpeed=.34;he.update();var vE=Math.min(8,Je.capabilities.getMaxAnisotropy());function dr(s,t,e,n={}){let i=document.createElement("canvas");i.width=s,i.height=t;let r=i.getContext("2d");e(r,s,t);let o=new ha(i);return o.colorSpace=n.srgb===!1?si:nn,o.wrapS=n.clamp?_n:ss,o.wrapT=n.clamp?_n:ss,o.anisotropy=vE,o.needsUpdate=!0,o}function La(s,t=1,e=1){let n=s.clone();return n.repeat.set(t,e),n.needsUpdate=!0,n}function vg(s=!1){let t=Ae(s?1933:9177);return dr(s?256:512,s?512:256,(i,r,o)=>{i.fillStyle=s?"#6f462a":"#70482d",i.fillRect(0,0,r,o);let a=s?i.createLinearGradient(0,0,r,0):i.createLinearGradient(0,0,0,o);a.addColorStop(0,"rgba(255,220,173,0.13)"),a.addColorStop(.45,"rgba(255,218,170,0.02)"),a.addColorStop(1,"rgba(40,20,10,0.24)"),i.fillStyle=a,i.fillRect(0,0,r,o);for(let l=0;l<145;l++){let c=.05+t()*.24;if(i.strokeStyle=t()>.48?"rgba(43,22,11,"+c.toFixed(3)+")":"rgba(220,167,111,"+(c*.56).toFixed(3)+")",i.lineWidth=.45+t()*1.45,i.beginPath(),s){let h=t()*r,u=-20+t()*o,d=80+t()*(o*.7);i.moveTo(h,u),i.bezierCurveTo(h+t()*11-5.5,u+d*.36,h+t()*13-6.5,u+d*.7,h+t()*7-3.5,u+d)}else{let h=-30+t()*r,u=t()*o,d=100+t()*(r*.65);i.moveTo(h,u),i.bezierCurveTo(h+d*.34,u+t()*9-4.5,h+d*.7,u+t()*11-5.5,h+d,u+t()*6-3)}i.stroke()}for(let l=0;l<7;l++){let c=t()*r,h=t()*o,u=4+t()*9,d=2+t()*5;i.save(),i.translate(c,h),i.rotate(t()*Math.PI);for(let f=0;f<4;f++)i.strokeStyle="rgba(48,25,13,"+(.28-f*.045).toFixed(3)+")",i.lineWidth=1,i.beginPath(),i.ellipse(0,0,u+f*3.2,d+f*2.1,0,0,te),i.stroke();i.fillStyle="rgba(36,18,9,0.34)",i.beginPath(),i.ellipse(0,0,u*.55,d*.5,0,0,te),i.fill(),i.restore()}for(let l=0;l<95;l++)i.fillStyle="rgba(255,229,188,"+(.018+t()*.04).toFixed(3)+")",i.fillRect(t()*r,t()*o,1+t()*12,1)})}function ME(){let s=Ae(4421);return dr(512,512,(t,e,n)=>{t.fillStyle="#2b1f17",t.fillRect(0,0,e,n);let i=9,r=n/i,o=72;for(let a=0;a{t.fillStyle="#77746b",t.fillRect(0,0,e,n);for(let i=0;i<120;i++){let r=s()*e,o=s()*n,a=8+s()*52,l=92+Math.floor(s()*58),c=s()>.5?6:-2,h=t.createRadialGradient(r,o,0,r,o,a);h.addColorStop(0,"rgba("+(l+c)+","+(l+2)+","+(l-7)+",0.32)"),h.addColorStop(1,"rgba("+(l+c)+","+(l+2)+","+(l-7)+",0)"),t.fillStyle=h,t.beginPath(),t.arc(r,o,a,0,te),t.fill()}for(let i=0;i<48;i++){t.strokeStyle="rgba(38,36,32,"+(.08+s()*.18).toFixed(3)+")",t.lineWidth=.6+s()*1.4,t.beginPath();let r=s()*e,o=s()*n;t.moveTo(r,o);for(let a=0;a<4;a++)r+=s()*40-20,o+=s()*34-17,t.lineTo(r,o);t.stroke()}for(let i=0;i<18;i++){let r=s()*e,o=s()*n,a=8+s()*24,l=t.createRadialGradient(r,o,0,r,o,a);l.addColorStop(0,"rgba(88,104,59,0.24)"),l.addColorStop(1,"rgba(88,104,59,0)"),t.fillStyle=l,t.beginPath(),t.arc(r,o,a,0,te),t.fill()}for(let i=0;i<1900;i++)t.fillStyle="rgba(236,230,213,"+(.015+s()*.05).toFixed(3)+")",t.fillRect(s()*e,s()*n,1,1)})}function bE(){let s=Ae(7781);return dr(256,256,(t,e,n)=>{let i=t.createImageData(e,n);for(let r=0;r{let n=s.createRadialGradient(t/2,e/2,0,t/2,e/2,t/2);n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.18,"rgba(255,247,225,0.92)"),n.addColorStop(.43,"rgba(255,202,139,0.3)"),n.addColorStop(.72,"rgba(255,174,91,0.05)"),n.addColorStop(1,"rgba(255,150,60,0)"),s.fillStyle=n,s.fillRect(0,0,t,e)},{clamp:!0}),EE=dr(512,208,(s,t,e)=>{s.clearRect(0,0,t,e),s.textAlign="center",s.textBaseline="middle",s.fillStyle="rgba(30,20,12,0.72)",s.font='600 82px "Songti SC","STSong","Microsoft YaHei",serif',s.fillText("\u6797\u95F4\u5C0F\u5C4B",t/2+2,e/2-12),s.fillStyle="#efd7ad",s.fillText("\u6797\u95F4\u5C0F\u5C4B",t/2,e/2-14),s.font='500 17px "Georgia",serif',s.fillStyle="rgba(235,210,171,0.76)",s.fillText("W O O D L A N D C A B I N",t/2,e-42),s.strokeStyle="rgba(235,210,171,0.36)",s.lineWidth=2,s.beginPath(),s.moveTo(90,e-22),s.lineTo(t-90,e-22),s.stroke()},{clamp:!0}),ao=vg(!1),or=vg(!0),Mg=ME(),kf=SE(),Sg=bE();Mg.repeat.set(4.6,2.1);kf.repeat.set(2.2,1.3);Sg.repeat.set(22,22);function ai(s,t,e,n=16777215,i={}){let r=La(s,t,e);return new Rt({map:r,color:n,roughness:.9,metalness:0,...i})}var B={logSides:[ai(or,1,1.35,16777215),ai(or,1,1.15,15255978),ai(or,1,1.6,14201748)],logEnd:new Rt({map:La(or,.8,.8),color:14267782,roughness:.86}),beam:ai(ao,1.3,1,7162416,{roughness:.94}),darkBeam:ai(or,1,1,6177840,{roughness:.94}),plank:ai(ao,2.1,1,15783608),doorPlank:ai(or,.9,1,13211752),deck:ai(ao,2.4,1,12884592),trim:ai(ao,1.5,1,5979430,{roughness:.92}),shutter:ai(ao,1,1.2,3492408,{roughness:.92}),roofSide:ai(ao,1.2,1,3942942,{roughness:.96}),roofTop:new Rt({map:Mg,color:16777215,roughness:.97,metalness:0}),roofUnder:new Rt({color:2168593,roughness:1}),stone:new Rt({map:La(kf,1.4,1),color:16777215,roughness:1,flatShading:!0}),stoneDark:new Rt({map:La(kf,1,1),color:10262410,roughness:1,flatShading:!0}),stoneLight:new Rt({color:10328461,roughness:.98,flatShading:!0}),bark:new Rt({map:La(or,1.2,2.7),color:8416082,roughness:1,flatShading:!0}),birch:new Rt({color:12037012,roughness:.94,flatShading:!0}),moss:new Rt({color:5070133,roughness:1,flatShading:!0}),mossLight:new Rt({color:6518856,roughness:1,flatShading:!0}),foliage:[new Rt({color:2836021,roughness:.94,flatShading:!0}),new Rt({color:3494972,roughness:.94,flatShading:!0}),new Rt({color:2441524,roughness:.95,flatShading:!0}),new Rt({color:4021314,roughness:.93,flatShading:!0})],gold:[new Rt({color:11106865,roughness:.9,flatShading:!0}),new Rt({color:12619325,roughness:.9,flatShading:!0}),new Rt({color:9265959,roughness:.92,flatShading:!0}),new Rt({color:11894575,roughness:.9,flatShading:!0})],glass:new Rt({color:16761976,emissive:16744745,emissiveIntensity:2.25,roughness:.26,metalness:0}),doorGlow:new xn({color:16753227,transparent:!0,opacity:.88,toneMapped:!1}),iron:new Rt({color:2170137,roughness:.48,metalness:.7}),brass:new Rt({color:11569742,roughness:.28,metalness:.82}),fabric:new Rt({color:7224883,roughness:1}),mushroomCap:new Rt({color:11947058,roughness:.8}),mushroomStem:new Rt({color:14207144,roughness:.95}),mushroomSpot:new Rt({color:15785915,roughness:.8}),flowerWhite:new Rt({color:15853775,roughness:.72,emissive:4208160,emissiveIntensity:.25}),flowerGold:new Rt({color:15188844,roughness:.72,emissive:4862988,emissiveIntensity:.25}),grass:new Rt({color:16777215,roughness:1,side:un}),fern:new Rt({color:3692594,roughness:.95,side:un,flatShading:!0}),fernLight:new Rt({color:4548669,roughness:.95,side:un,flatShading:!0}),rock:[new Rt({color:7106663,roughness:1,flatShading:!0}),new Rt({color:5988698,roughness:1,flatShading:!0}),new Rt({color:8092270,roughness:1,flatShading:!0})],hill:new Rt({color:1516831,roughness:1,flatShading:!0})},Oa=new rs({map:Xf,color:16752982,transparent:!0,opacity:.33,blending:mi,depthWrite:!1,toneMapped:!1}),og=new xn({map:Xf,color:16751436,transparent:!0,opacity:.2,blending:mi,depthWrite:!1,toneMapped:!1,side:un}),le={box:new yi(1,1,1),cylinder8:new kn(1,1,1,8,1,!1),cylinder6:new kn(1,1,1,6,1,!1),cylinder12:new kn(1,1,1,12,1,!1),rock:new to(1,0),ico:new Ks(1,1),icoLow:new Ks(1,0),cone7:new Js(1,1,7,1),cone4:new Js(1,1,4,1),sphere:new zn(1,12,8),leaf:null};function ot(s,t,e,n,i,r=0,o=0,a=0,l=!0,c=!0){let h=new ht(le.box,t);return h.scale.set(e,n,i),h.position.set(r,o,a),h.castShadow=l,h.receiveShadow=c,s.add(h),h}function xe(s,t,e,n,i=0,r=0,o=0,a=8,l=!0,c=!0){let h=a===6?le.cylinder6:a===12?le.cylinder12:le.cylinder8,u=new ht(h,t);return u.scale.set(e,n,e),u.position.set(i,r,o),u.castShadow=l,u.receiveShadow=c,s.add(u),u}var bg=new w(-50,18,-48),wE=bg.clone().normalize(),co={uTopColor:{value:new Z(397344)},uHorizonColor:{value:new Z(10184535)},uBottomColor:{value:new Z(528655)},uGlowColor:{value:new Z(16760451)},uGlowStrength:{value:.42},uMoonDir:{value:wE.clone()}},Eg=new ht(new zn(100,48,28),new Qe({uniforms:co,side:sn,depthWrite:!1,fog:!1,toneMapped:!1,vertexShader:["varying vec3 vWorldPosition;","void main() {"," vec4 worldPosition = modelMatrix * vec4(position, 1.0);"," vWorldPosition = worldPosition.xyz;"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join(` `),fragmentShader:["uniform vec3 uTopColor;","uniform vec3 uHorizonColor;","uniform vec3 uBottomColor;","uniform vec3 uGlowColor;","uniform float uGlowStrength;","uniform vec3 uMoonDir;","varying vec3 vWorldPosition;","void main() {"," vec3 dir = normalize(vWorldPosition);"," float upper = smoothstep(-0.015, 0.58, dir.y);"," vec3 color = mix(uHorizonColor, uTopColor, upper);"," color = mix(uBottomColor, color, smoothstep(-0.28, 0.015, dir.y));"," float glow = pow(max(dot(dir, uMoonDir), 0.0), 22.0);"," color += uGlowColor * glow * uGlowStrength;"," float dither = (fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) / 255.0;"," color += dither;"," gl_FragColor = vec4(color, 1.0);"," #include "," #include ","}"].join(` `)}));Eg.renderOrder=-20;Vt.add(Eg);var wg=bg.clone(),Tg=new xn({color:15986395,fog:!1,toneMapped:!1}),Xh=new ht(new zn(2.25,24,16),Tg);Xh.position.copy(wg);Xh.renderOrder=-10;Vt.add(Xh);var Fa=new rs({map:Xf,color:16768426,transparent:!0,opacity:.32,blending:mi,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1}),qh=new ri(Fa);qh.position.copy(wg);qh.scale.set(18,18,1);qh.renderOrder=-9;Vt.add(qh);function ag(s,t,e,n,i){let r=new Float32Array(s*3);for(let c=0;c2.5&&f<16.2?Math.abs(d-_o(f)):99,v=(1-Mn(.55,1.35,p))*Mn(2.4,3.4,f)*(1-Mn(14.6,16.2,f));h.lerp(r,v*.9);let x=1-Mn(3.1,5.4,Math.hypot(d,f*.92));h.lerp(o,x*.45);let y=Math.hypot(d-Ot.x,f-Ot.z),I=1-Mn(Ot.r*.82,Ot.r*1.5,y);h.lerp(l,I*.58);let T=1-Mn(Ot.r*.45,Ot.r*.98,y);h.lerp(c,T*.72),t[u*3]=h.r,t[u*3+1]=h.g,t[u*3+2]=h.b}Da.setAttribute("color",new se(t,3)),Da.computeVertexNormals()}var AE=new Rt({map:Sg,vertexColors:!0,color:16777215,roughness:1,metalness:0}),Ag=new ht(Da,AE);Ag.receiveShadow=!0;Vt.add(Ag);var lo=Ae(1289),Rg=new Te;Vt.add(Rg);for(let s=0;s<14;s++){let t=4.05+s*.78+lo()*.22,e=_o(t)+(lo()-.5)*.34,n=new ht(le.rock,B.rock[s%3]),i=.28+lo()*.17;n.scale.set(i*1.35,i*.16,i*.92),n.position.set(e,en(e,t)+.045,t),n.rotation.set(lo()*.1,lo()*te,lo()*.08),n.castShadow=!0,n.receiveShadow=!0,Rg.add(n)}var S1=Ae(551),Cn=new Te;{let s=_o(7.6)+2.15,t=7.55,e=en(s,t);Cn.position.set(s,e,t),Cn.rotation.y=Math.atan2(12.5-s,18.5-t),Vt.add(Cn),xe(Cn,B.darkBeam,.065,2.35,0,1.17,0,6);let n=ot(Cn,B.beam,.98,.49,.075,.36,1.57,.02);n.castShadow=!0;let i=new ht(new Yn(.92,.375),new xn({map:EE,transparent:!0,depthWrite:!1,toneMapped:!1}));i.position.set(.36,1.57,.064),Cn.add(i),ot(Cn,B.iron,.05,.05,.42,.06,2.15,.19),xe(Cn,B.iron,.012,.15,.06,2.06,.39,6,!1,!1);let r=ot(Cn,B.glass,.15,.21,.15,.06,1.91,.39,!1,!1);ot(Cn,B.iron,.21,.035,.21,.06,2.02,.39),ot(Cn,B.iron,.2,.03,.2,.06,1.8,.39);let o=new ht(le.cone4,B.iron);o.scale.set(.14,.12,.14),o.position.set(.06,2.09,.39),Cn.add(o);let a=new ri(Oa.clone());a.material.opacity=.22,a.material.userData.baseOpacity=.22,fr.push(a.material),a.position.set(.06,1.91,.47),a.scale.set(1.15,1.15,1),Cn.add(a);let l=new vi(16753756,3.2,4.6,2);l.position.set(.06,1.95,.45),l.userData.baseIntensity=3.2,Cn.add(l),ys.push(l),r.castShadow=!1}var yt=new Te;yt.name="cabin";Vt.add(yt);var bt={halfW:3.1,halfD:2.5,wallBottom:.84,wallTop:4.16,ridgeY:6.58,eaveY:4.14,run:3.32};function RE(s,t,e){let n=[];for(let[i,r]of s)e<=i||t>=r?n.push([i,r]):(t>i&&n.push([i,t]),er-i>.075)}function Zh(s,t,e,n,i,r=.12){for(let l=0;l<11;l++){let c=bt.wallBottom+.07+l*.304,h=[[e,n]];for(let u of i)c>u.y0-.13&&c{let m=d-u+r,_=(u+d)/2,g=[B.logSides[(l+f)%3],B.logEnd,B.logEnd],p=new ht(le.cylinder8,g);p.scale.set(.155,m,.155),s==="x"?(p.rotation.z=Math.PI/2,p.position.set(_,c,t)):(p.rotation.x=Math.PI/2,p.position.set(t,c,_)),p.castShadow=!0,p.receiveShadow=!0,yt.add(p)})}}ot(yt,B.stone,6.48,.74,5.28,0,.36,0);ot(yt,B.stoneDark,6.6,.12,5.4,0,.06,0);{let s=Ae(332);for(let t=0;t<46;t++){let e=s()>.5?1:-1,n=s()>.5,i,r;n?(i=(s()>.5?1:-1)*3.2,r=(s()-.5)*5):(i=(s()-.5)*6.2,r=e*2.56);let o=new ht(le.rock,B.rock[t%3]),a=.16+s()*.2;o.scale.set(a*1.4,a*.85,a),o.position.set(i,.2+s()*.38,r),o.rotation.set(s()*.4,s()*te,s()*.3),o.castShadow=!0,o.receiveShadow=!0,yt.add(o)}}var CE=[{a:0,b:1.16,y0:.72,y1:3.1},{a:-2.3,b:-1.16,y0:2.16,y1:3.4}],PE=[{a:-1.96,b:-1.04,y0:2.18,y1:3.28}],IE=[{a:.02,b:1.1,y0:2.16,y1:3.4}],LE=[{a:-1.5,b:-.5,y0:2.2,y1:3.32}];Zh("x",bt.halfD,-bt.halfW,bt.halfW,CE);Zh("x",-bt.halfD,-bt.halfW,bt.halfW,PE);Zh("z",bt.halfW,-bt.halfD,bt.halfD,IE);Zh("z",-bt.halfW,-bt.halfD,bt.halfD,LE);ot(yt,B.beam,6.6,.24,.22,0,bt.wallTop,bt.halfD+.01);ot(yt,B.beam,6.6,.24,.22,0,bt.wallTop,-bt.halfD-.01);ot(yt,B.beam,.22,.24,5.35,bt.halfW+.01,bt.wallTop,0);ot(yt,B.beam,.22,.24,5.35,-bt.halfW-.01,bt.wallTop,0);{let s=Ae(983),t=bt.ridgeY-bt.wallTop,e=.235;for(let l of[-1,1]){let c=l*(bt.halfW+.07);for(let h=-10;h<=10;h++){let u=h*.236,f=bt.wallTop+(1-Math.abs(u)/bt.halfD)*t-bt.wallTop;if(f<.11)continue;let m=B.plank.clone();m.color.offsetHSL(0,0,(s()-.5)*.1),ot(yt,m,.17,f,e,c,bt.wallTop+f/2,u)}}let i=bt.ridgeY-bt.halfD/bt.run*(bt.ridgeY-bt.eaveY)-.19,r=i-bt.wallTop;for(let l of[bt.halfD-.015,-bt.halfD+.015]){for(let c=-13;c<=13;c++){let h=B.plank.clone();h.color.offsetHSL(0,0,(s()-.5)*.09),ot(yt,h,.235,r,.17,c*.236,bt.wallTop+r/2,l)}ot(yt,B.darkBeam,6.55,.09,.18,0,i,l)}let o=Math.hypot(bt.run,t),a=Math.atan2(t,bt.run);for(let l of[-1,1])for(let c of[-1,1]){let h=ot(yt,B.darkBeam,.14,.16,o+.2,l*3.83,(bt.eaveY+bt.ridgeY)/2+.03,c*(bt.run/2));h.rotation.x=c*a}}for(let s of[-1,1]){let t=new Te;t.position.set(s*(bt.halfW+.17),5.02,0),t.rotation.y=s>0?Math.PI/2:-Math.PI/2,yt.add(t);let e=new ht(new Vi(.34,.046,7,22),B.trim);t.add(e);let n=new ht(new Qr(.305,24),B.glass);n.position.z=-.012,t.add(n),ot(t,B.trim,.035,.61,.04,0,0,.019),ot(t,B.trim,.61,.035,.04,0,0,.019);let i=new ri(Oa.clone());i.material.opacity=.2,i.material.userData.baseOpacity=.2,fr.push(i.material),i.scale.set(1.8,1.8,1),i.position.z=.27,t.add(i)}{let s=Math.hypot(bt.run,bt.ridgeY-bt.eaveY),t=Math.atan2(bt.ridgeY-bt.eaveY,bt.run),e=new yi(7.72,.18,s+.18),n=[B.roofSide,B.roofSide,B.roofTop,B.roofUnder,B.roofSide,B.roofSide];for(let r of[1,-1]){let o=new ht(e,n);o.position.set(0,(bt.eaveY+bt.ridgeY)/2+.04,r*(bt.run/2)),o.rotation.x=r*t,o.castShadow=!0,o.receiveShadow=!0,yt.add(o)}ot(yt,B.darkBeam,7.85,.2,.34,0,bt.ridgeY+.12,0),ot(yt,B.darkBeam,7.86,.17,.18,0,bt.eaveY-.015,bt.run+.06),ot(yt,B.darkBeam,7.86,.17,.18,0,bt.eaveY-.015,-bt.run-.06);for(let r=-3;r<=3;r++)for(let o of[1,-1]){let a=ot(yt,B.darkBeam,.11,.13,.56,r*1.02,bt.eaveY-.15,o*(bt.halfD+.45));a.rotation.x=o*t*.52}let i=Ae(2291);for(let r=0;r<22;r++){let a=(i()>.5?1:-1)*(.45+i()*(bt.run-.7)),l=(i()-.5)*6.9,c=bt.ridgeY-Math.abs(a)/bt.run*(bt.ridgeY-bt.eaveY)+.075,h=new ht(le.icoLow,i()>.7?B.mossLight:B.moss),u=.12+i()*.28;h.scale.set(u*1.7,u*.22,u),h.position.set(l,c,a),h.rotation.y=i()*te,h.receiveShadow=!0,yt.add(h)}}var vn=new w(-2.02,7.32,-.82);{ot(yt,B.stone,.84,3.15,.76,vn.x,5.35,vn.z,!0,!0);let s=Ae(771);for(let t=0;t<16;t++){let e=3.93+t*.195;for(let n=0;n<3;n++){let i=new ht(le.box,B.rock[Math.floor(s()*3)]);i.material=s()>.5?B.stone:B.stoneDark;let r=.16+s()*.2,o=.13+s()*.1,a=.08+s()*.12,l=n===0?-1:n===1?1:0;i.scale.set(r,o,a),l===0?(i.position.set(vn.x+(s()-.5)*.45,e,vn.z+.4),i.rotation.y=(s()-.5)*.18):(i.position.set(vn.x+l*.39,e,vn.z+(s()-.5)*.5),i.rotation.y=(s()-.5)*.18),i.castShadow=!0,i.receiveShadow=!0,yt.add(i)}}ot(yt,B.stoneLight,1.02,.12,.94,vn.x,7.02,vn.z),ot(yt,B.stoneDark,.9,.1,.82,vn.x,7.13,vn.z),ot(yt,B.roofUnder,.38,.08,.32,vn.x,7.2,vn.z)}{ot(yt,new Rt({color:1840144,roughness:1}),1.3,2.42,.12,.58,1.89,2.38);let t=new ht(new Yn(1.16,2.25),B.doorGlow);t.position.set(.58,1.88,2.397),yt.add(t);let e=B.doorPlank;for(let r=0;r<5;r++){let o=ot(yt,e,.2,2.14,.055,.58+(r-2)*.207,1.87,2.44);o.material=e.clone(),o.material.color.offsetHSL(0,0,(r-2)*.012)}ot(yt,B.darkBeam,1.01,.085,.045,.58,1.28,2.475),ot(yt,B.darkBeam,1.01,.08,.045,.58,2.25,2.475),ot(yt,B.glass,.44,.34,.025,.58,2.57,2.476,!1,!1),ot(yt,B.trim,.05,.52,.055,.58,2.57,2.49),ot(yt,B.trim,.52,.05,.055,.58,2.57,2.49);let n=new ht(new Vi(.057,.012,6,13),B.brass);n.position.set(.58+.43,1.7,2.505),yt.add(n),xe(yt,B.iron,.015,.055,.58+.43,1.7,2.49,6,!1,!1).rotation.x=Math.PI/2;for(let r of[1.23,2.24])ot(yt,B.iron,.1,.055,.024,.58-.48,r,2.48);ot(yt,B.trim,.13,2.42,.17,.58-.63,1.9,2.55),ot(yt,B.trim,.13,2.42,.17,.58+.63,1.9,2.55),ot(yt,B.trim,1.38,.16,.17,.58,3.11,2.55),ot(yt,B.stoneLight,1.38,.11,.46,.58,.79,2.68);let i=new vi(16751442,3.1,5.5,2);i.position.set(.58,2.25,3.12),i.userData.baseIntensity=3.1,Vt.add(i),Kn=i}function Jh(s,t,e,n,i,r,o=!0,a=!0){let l=new Te;l.position.set(s,t,e),l.rotation.y=n,yt.add(l),ot(l,B.glass,i-.12,r-.1,.032,0,0,-.055,!1,!1);let c=B.trim;if(ot(l,c,i+.16,.105,.11,0,r/2+.015,.035),ot(l,c,i+.16,.105,.11,0,-r/2-.015,.035),ot(l,c,.105,r+.16,.11,-i/2,0,.035),ot(l,c,.105,r+.16,.11,i/2,0,.035),ot(l,c,.045,r-.08,.075,0,0,.065),ot(l,c,i-.08,.045,.075,0,0,.065),ot(l,B.trim,i+.34,.08,.25,0,-r/2-.1,.15),o)for(let u of[-1,1]){let d=u*(i/2+.22);ot(l,B.shutter,.33,r*.94,.055,d,0,.02);for(let f=0;f<5;f++)ot(l,B.darkBeam,.27,.022,.022,d,-r*.36+f*r*.18,.055)}let h=new ri(Oa.clone());if(h.material.userData.baseOpacity=h.material.opacity,fr.push(h.material),h.position.set(0,.02,.2),h.scale.set(i*2.05,r*1.75,1),l.add(h),a){let u=Math.sin(n),d=Math.cos(n),f=new vi(16752984,7.5,7.2,2);f.position.set(s+u*.55,t+.05,e+d*.55),f.userData.baseIntensity=7.5,Vt.add(f),mo.push(f)}return l}Jh(-1.73,2.8,bt.halfD+.05,0,1.1,1.18,!0,!0);Jh(bt.halfW+.05,2.82,.56,Math.PI/2,1.04,1.16,!0,!0);Jh(-bt.halfW-.05,2.86,-1,-Math.PI/2,.96,1.12,!1,!0);Jh(-1.5,2.76,-bt.halfD-.05,Math.PI,.9,1.04,!0,!0);{ot(yt,B.darkBeam,4.65,.16,.16,0,.65,2.6),ot(yt,B.darkBeam,4.65,.16,.16,0,.65,4.02),ot(yt,B.darkBeam,.14,.18,1.48,-2.22,.64,3.32),ot(yt,B.darkBeam,.14,.18,1.48,2.22,.64,3.32);for(let i=0;i<11;i++){let r=2.6+i*.14,o=ot(yt,B.deck,4.55,.075,.127,0,.765,r,!0,!0);o.material=B.deck.clone(),o.material.color.offsetHSL(0,0,(i%3-1)*.012)}ot(yt,B.deck,1.92,.14,.34,.58,.57,4.22),ot(yt,B.deck,1.92,.14,.34,.58,.34,4.52),ot(yt,B.stoneLight,1.45,.11,.5,.58,.08,4.7);for(let i of[-1,1]){let r=i*2.24;ot(yt,B.darkBeam,.065,.98,.065,r,1.24,3.94),ot(yt,B.darkBeam,.065,.36,.065,r,1.06,2.68),ot(yt,B.darkBeam,.06,.06,1.31,r,1.63,3.3);for(let o=0;o<3;o++)ot(yt,B.darkBeam,.035,.57,.035,r,1.32,2.9+o*.36)}ot(yt,B.darkBeam,1.17,.075,.42,-1.55,1.05,2.95),ot(yt,B.darkBeam,1.17,.48,.06,-1.55,1.31,3.12),ot(yt,B.fabric,1.07,.065,.33,-1.55,1.102,2.93);for(let i of[-2.02,-1.08])for(let r of[2.82,3.06])ot(yt,B.darkBeam,.06,.34,.06,i,.9,r);ot(yt,B.darkBeam,1.12,.06,1.3,-.75,.69,2.95),ot(yt,B.fabric,.84,.018,.47,.58,.812,2.83,!1,!0);let e=new ht(new Yn(4.3,3.2),og);e.rotation.x=-Math.PI/2,e.position.set(.55,.815,3.32),e.renderOrder=2,e.userData.baseOpacity=.2,yt.add(e),zh.push(e);let n=new ht(new Yn(3.1,2.1),og.clone());n.material.opacity=.12,n.rotation.x=-Math.PI/2,n.position.set(.58,.045,4.8),n.renderOrder=2,n.userData.baseOpacity=.12,yt.add(n),zh.push(n)}{let s=new Te;s.position.set(1.5,2.9,2.97),yt.add(s),zf.push(s),ot(s,B.iron,.045,.045,.48,0,0,-.19),xe(s,B.iron,.012,.22,0,-.12,0,6,!1,!1);let t=new Te;t.position.set(0,-.38,0),s.add(t),ot(t,B.glass,.17,.25,.17,0,0,0,!1,!1);for(let r of[-.105,.105])for(let o of[-.105,.105])ot(t,B.iron,.022,.31,.022,r,.01,o,!1,!1);ot(t,B.iron,.235,.035,.235,0,.17,0,!1,!1),ot(t,B.iron,.235,.035,.235,0,-.17,0,!1,!1);let e=new ht(le.cone4,B.iron);e.scale.set(.19,.14,.19),e.position.y=.24,t.add(e),xe(t,B.iron,.009,.1,0,.33,0,6,!1,!1);let n=new ri(Oa.clone());n.material.opacity=.33,n.material.userData.baseOpacity=.33,fr.push(n.material),n.scale.set(1.65,1.65,1),t.add(n);let i=new vi(16753240,4.4,5.2,2);i.position.set(0,0,0),i.userData.baseIntensity=4.4,t.add(i),ys.push(i)}{let s=Ae(995);for(let o=0;o<3;o++){let a=5-o;for(let l=0;l3.3&&Math.abs(r)<5.3||Math.hypot(r-7.85,o-6.25)<2.2||Math.hypot(r-Ot.x,o-Ot.z)3&&Math.abs(f-_o(m))<1.05||Math.hypot(f,m*.85)<3.35||Math.hypot(f-Ot.x,m-Ot.z)3&&Math.abs(i-_o(r))<.9||Math.hypot(i-Ot.x,r-Ot.z).5?B.flowerWhite:B.flowerGold),l=.023+s()*.013;a.scale.set(l,l*.8,l),a.position.set(i,o+.18,r),Vt.add(a)}}{let s=Ae(2877);for(let t=0;t<31;t++){let e=s()*te,n=4.6+s()*16,i=Math.cos(e)*n,r=Math.sin(e)*n;if(r>3&&Math.abs(i-_o(r))<1.2||Math.hypot(i-Ot.x,r-Ot.z)"," #include ","}"].join(` `)}),ka=new ht(Cg,DE);ka.position.set(Ot.x,Ot.waterY,Ot.z);ka.renderOrder=-2;ka.receiveShadow=!1;Vt.add(ka);var tn=Ae(4609),fo={reed:new Rt({color:6714687,roughness:.95,flatShading:!0}),cattail:new Rt({color:6701354,roughness:.98,flatShading:!0}),lily:new Rt({color:4156748,roughness:.84,flatShading:!0}),lilyLight:new Rt({color:5471314,roughness:.84,flatShading:!0}),lilyFlower:new Rt({color:14923697,roughness:.75,emissive:4924960,emissiveIntensity:.18}),line:new Ye({color:15064516,transparent:!0,opacity:.62,depthWrite:!1})};for(let s=0;s<19;s++){let t=s/19*te+tn()*.18;if(Math.min(Math.abs(t),Math.abs(t-te))<.5)continue;let e=Ot.r*(.91+tn()*.17),n=Ot.x+Math.cos(t)*e,i=Ot.z+Math.sin(t)*e,r=en(n,i),o=new ht(le.rock,B.rock[s%3]),a=.22+tn()*.32;o.scale.set(a*1.3,a*.55,a),o.position.set(n,r+a*.12,i),o.rotation.set(tn()*.25,tn()*te,tn()*.22),o.castShadow=!0,o.receiveShadow=!0,Vt.add(o)}for(let s=0;s<8;s++){let t=2.05+tn()*3.15,e=Ot.r*(.89+tn()*.12),n=Ot.x+Math.cos(t)*e,i=Ot.z+Math.sin(t)*e,r=en(n,i);for(let o=0;o<4;o++){let a=n+(tn()-.5)*.42,l=i+(tn()-.5)*.42,c=.55+tn()*.55,h=xe(Vt,fo.reed,.009,c,a,r+c/2,l,6,!1,!1);h.rotation.z=(tn()-.5)*.08,o<2&&xe(Vt,fo.cattail,.025,.11,a,r+c+.02,l,6,!1,!1)}}{let s=new Nn;s.moveTo(0,0),s.absarc(0,0,1,.18,te-.18,!1),s.lineTo(0,0);let t=new cs(s,18);t.rotateX(-Math.PI/2);for(let e=0;e<9;e++){let n=tn()*te,i=1.2+tn()*1.85,r=Ot.x+Math.cos(n)*i,o=Ot.z+Math.sin(n)*i;if(Math.abs(Math.atan2(o-Ot.z,r-Ot.x))<.25)continue;let a=new ht(t,e%3===0?fo.lilyLight:fo.lily),l=.17+tn()*.16;if(a.scale.set(l,1,l),a.position.set(r,Ot.waterY+.023,o),a.rotation.y=tn()*te,a.receiveShadow=!0,Vt.add(a),e===2||e===6){let c=new ht(le.icoLow,fo.lilyFlower);c.scale.set(.055,.045,.055),c.position.set(r,Ot.waterY+.075,o),Vt.add(c)}}}for(let s=0;s<6;s++){let t=.88-s*.67,e=9.02+Math.sin(s*1.35)*.22,n=new ht(le.rock,B.rock[s%3]),i=.27+tn()*.09;n.scale.set(i*1.15,i*.16,i*.82),n.position.set(t,en(t,e)+.04,e),n.rotation.y=tn()*te,n.castShadow=!0,n.receiveShadow=!0,Vt.add(n)}var Le=new Te,lg={x:-3.02,z:9};Le.position.set(lg.x,0,lg.z);Le.rotation.y=-Math.PI/2;Vt.add(Le);for(let s=0;s<14;s++)ot(Le,B.deck,1.18,.065,.148,0,.18,.2+s*.157,!0,!0);ot(Le,B.darkBeam,.12,.11,2.34,-.51,.12,1.25);ot(Le,B.darkBeam,.12,.11,2.34,.51,.12,1.25);for(let s of[.42,1.35,2.28])for(let t of[-.51,.51])xe(Le,B.darkBeam,.052,1.35,t,-.45,s,6);ot(Le,B.deck,1.05,.1,.34,0,.15,.02,!0,!0);var UE=ot(Le,B.deck,1.03,.055,.72,0,.1,0,!0,!0);UE.rotation.x=-.3;{xe(Le,B.stoneLight,.13,.3,.72,.05,.35,8),xe(Le,B.darkBeam,.045,1.54,.72,.95,.35,6),ot(Le,B.iron,.34,.05,.05,.6,1.66,.35),xe(Le,B.iron,.011,.13,.54,1.56,.35,6,!1,!1),ot(Le,B.glass,.15,.2,.15,.54,1.42,.35,!1,!1),ot(Le,B.iron,.2,.032,.2,.54,1.53,.35),ot(Le,B.iron,.19,.03,.19,.54,1.31,.35);let s=new ht(le.cone4,B.iron);s.scale.set(.14,.12,.14),s.position.set(.54,1.59,.35),Le.add(s);let t=new ri(Oa.clone());t.material.opacity=.3,t.material.userData.baseOpacity=.3,fr.push(t.material),t.scale.set(1.55,1.55,1),t.position.set(.54,1.42,.35),Le.add(t);let e=new vi(16752982,4.2,5.6,2);e.position.set(.54,1.43,.35),e.userData.baseIntensity=4.2,Le.add(e),ys.push(e)}{xe(Le,B.bark,.17,.27,-.41,.33,2.08,8).scale.set(.17,.27,.15);let t=new ht(new Vi(.13,.012,6,14,Math.PI),B.darkBeam);t.position.set(-.41,.48,2.08),t.rotation.x=Math.PI/2,Le.add(t),ot(Le,B.darkBeam,.3,.22,.3,.4,.29,2.13),ot(Le,B.deck,.34,.04,.34,.4,.42,2.13)}var we={coat:new Rt({color:12089650,roughness:.84,flatShading:!0}),coatDark:new Rt({color:9328422,roughness:.9,flatShading:!0}),pants:new Rt({color:3753270,roughness:.95,flatShading:!0}),boot:new Rt({color:2366230,roughness:.86,flatShading:!0}),skin:new Rt({color:13867635,roughness:.78,flatShading:!0}),beanie:new Rt({color:9387825,roughness:.92,flatShading:!0}),beanieLight:new Rt({color:11819843,roughness:.92,flatShading:!0}),scarf:new Rt({color:13616296,roughness:.94,flatShading:!0}),dark:new Rt({color:2760987,roughness:.82,flatShading:!0}),rod:new Rt({color:7292201,roughness:.72,flatShading:!0}),reel:new Rt({color:9338466,roughness:.35,metalness:.65}),eye:new Rt({color:2168595,roughness:.55}),fish:new Rt({color:9280655,roughness:.48,metalness:.15,flatShading:!0}),fishBelly:new Rt({color:14207140,roughness:.55,flatShading:!0}),fishFin:new Rt({color:7166518,roughness:.62,flatShading:!0})};function Pg(s,t,e,n,i,r=6){let o=e.clone?e.clone():new w(e[0],e[1],e[2]),a=n.clone?n.clone():new w(n[0],n[1],n[2]),l=a.clone().sub(o),c=l.length(),h=xe(s,t,i,c,0,0,0,r);return h.position.copy(o).add(a).multiplyScalar(.5),h.quaternion.setFromUnitVectors(new w(0,1,0),l.normalize()),h}var ve=new Te;ve.position.set(0,.21,2.22);ve.rotation.y=.28;ve.scale.setScalar(1.08);Le.add(ve);for(let s of[-1,1])ot(ve,we.boot,.13,.16,.22,s*.095,.08,.035),xe(ve,we.pants,.052,.37,s*.09,.35,0,6);xe(ve,we.coat,.15,.5,0,.76,0,8);xe(ve,we.coatDark,.225,.12,0,.53,0,8);xe(ve,we.dark,.16,.055,0,.59,0,8);var Hf=new w(-.215,.95,0),Vf=new w(.215,.95,0),Ig=new w(-.3,.73,.12),qf=new w(.28,1.03,.19);xe(ve,we.coat,.06,.08,Hf.x,Hf.y,0,6);xe(ve,we.coat,.06,.08,Vf.x,Vf.y,0,6);Pg(ve,we.coat,Hf,Ig,.052);Pg(ve,we.coat,Vf,qf,.052);var Yf=new ht(le.sphere,we.skin);Yf.scale.setScalar(.043);Yf.position.copy(Ig);ve.add(Yf);var Zf=new ht(le.sphere,we.skin);Zf.scale.setScalar(.045);Zf.position.copy(qf);ve.add(Zf);var pr=[],za=new ht(le.sphere,we.skin);za.scale.set(.148,.17,.145);za.position.set(0,1.2,0);za.castShadow=!0;ve.add(za);pr.push(za);for(let s of[-1,1]){let t=new ht(le.sphere,we.eye);t.scale.setScalar(.012),t.position.set(s*.047,1.22,.132),ve.add(t),pr.push(t)}var $h=new ht(le.sphere,we.skin);$h.scale.set(.025,.022,.022);$h.position.set(0,1.18,.151);ve.add($h);pr.push($h);var Kh=new ht(new kn(.158,.166,.055,10),we.beanie);Kh.position.set(0,1.31,-.008);Kh.castShadow=!0;ve.add(Kh);pr.push(Kh);var Ha=new ht(new zn(.158,10,6,0,te,0,Math.PI/2),we.beanie);Ha.position.set(0,1.325,-.008);Ha.scale.y=1.05;Ha.castShadow=!0;ve.add(Ha);pr.push(Ha);var Va=new ht(le.sphere,we.beanieLight);Va.scale.setScalar(.045);Va.position.set(0,1.515,-.008);Va.castShadow=!0;ve.add(Va);pr.push(Va);var Jf=new ht(new Vi(.135,.027,6,14),we.scarf);Jf.rotation.x=Math.PI/2;Jf.position.set(0,1.09,0);ve.add(Jf);var Vh=ot(ve,we.scarf,.085,.3,.03,-.09,.98,-.15);Vh.rotation.x=.16;Vh.rotation.z=-.12;ot(ve,B.bark,.19,.23,.1,-.25,.69,-.02);ot(ve,B.darkBeam,.2,.035,.11,-.25,.81,-.02);var Xi=new Te;Xi.position.copy(qf);ve.add(Xi);var $f=new ht(new kn(.011,.022,1.72,6),we.rod);$f.position.y=.86;$f.castShadow=!0;Xi.add($f);var Kf=new de;Kf.position.y=1.72;Xi.add(Kf);var jf=new ht(new kn(.055,.055,.035,10),we.reel);jf.rotation.z=Math.PI/2;jf.position.set(.07,.11,.01);Xi.add(jf);var NE=xe(Xi,we.dark,.009,.09,.1,.11,.01,6,!1,!1);NE.rotation.z=Math.PI/2;Xi.rotation.x=.9;var Pn=new Te,FE=new Rt({color:13126451,roughness:.44,emissive:2755333,emissiveIntensity:.3}),OE=new Rt({color:15326913,roughness:.48}),Lg=new ht(new zn(.064,10,6,0,te,0,Math.PI/2),FE);Lg.position.y=.002;Pn.add(Lg);var BE=new ht(new zn(.061,10,6,0,te,Math.PI/2,Math.PI/2),OE);Pn.add(BE);var kE=xe(Pn,we.dark,.006,.11,0,.09,0,6,!1,!1);kE.castShadow=!1;Vt.add(Pn);var Gf=24,Oh=new Float32Array(Gf*3),Qf=new Xt;Qf.setAttribute("position",new se(Oh,3));var Dg=new Zn(Qf,fo.line);Dg.frustumCulled=!1;Vt.add(Dg);var jh=30,cr=new Float32Array(jh*3),lr=new Float32Array(jh*3),Qh=new Xt;Qh.setAttribute("position",new se(cr,3));var zE=dr(64,64,(s,t,e)=>{let n=s.createRadialGradient(t/2,e/2,0,t/2,e/2,t/2);n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.3,"rgba(235,252,247,0.7)"),n.addColorStop(1,"rgba(210,240,235,0)"),s.fillStyle=n,s.fillRect(0,0,t,e)},{clamp:!0}),Gh=new as({map:zE,color:13232351,size:.17,sizeAttenuation:!0,transparent:!0,opacity:0,depthWrite:!1,blending:mi,toneMapped:!1}),Ug=new Hi(Qh,Gh);Ug.frustumCulled=!1;Vt.add(Ug);var uo={active:!1,life:0},Of=new w;function Wf(s=1){Of.copy(Pn.position);for(let t=0;t=1&&(uo.active=!1,Gh.opacity=0)}var bn=new Te,Ng=new ht(le.sphere,we.fish);Ng.scale.set(.07,.1,.22);bn.add(Ng);var tp=new ht(le.sphere,we.fishBelly);tp.scale.set(.058,.06,.18);tp.position.y=-.035;bn.add(tp);var tu=new ht(le.cone4,we.fishFin);tu.scale.set(.11,.14,.022);tu.position.z=-.26;tu.rotation.x=Math.PI/2;bn.add(tu);var eu=new ht(le.box,we.fishFin);eu.scale.set(.015,.1,.14);eu.position.set(0,.1,.02);eu.rotation.x=-.16;bn.add(eu);for(let s of[-1,1]){let t=new ht(le.sphere,we.eye);t.scale.setScalar(.012),t.position.set(s*.06,.04,.165),bn.add(t)}bn.visible=!1;Vt.add(bn);var VE=new w(Ot.x-.15,Ot.waterY+.06,Ot.z+.28),mt={state:"idle",count:0,castElapsed:0,waitElapsed:0,waitDuration:4,biteElapsed:0,failedElapsed:0,caughtElapsed:0,fishJumpElapsed:0,castFrom:new w,target:VE.clone(),castSwing:0,fish:null};Pn.position.copy(mt.target);var ut={mode:"off",t:0,enterDuration:.9,exitDuration:1,savedPosition:new w,savedTarget:new w,savedFov:42,savedQuaternion:new Ue,startPosition:new w,startQuaternion:new Ue,startFov:42,eye:new w,look:new w,targetQuaternion:new Ue,exitTimer:0,headHidden:!1},gs=new ke,GE=new w(.035,1.225,.085);function Ia(s){ut.headHidden=!s;for(let t of pr)t.visible=s}function Fg(s){H.fpBadge&&H.fpBadge.classList.toggle("is-visible",s)}function cg(s){return ve.updateWorldMatrix(!0,!1),s.copy(GE).applyMatrix4(ve.matrixWorld)}function hg(s){let t=Pn.position.x-ut.eye.x,e=Pn.position.z-ut.eye.z,n=Math.hypot(t,e)||1;return s.set(Pn.position.x+t/n*1.65,Ot.waterY+.52,Pn.position.z+e/n*1.65)}function WE(s){return gs.position.copy(ut.eye),gs.up.set(0,1,0),gs.lookAt(ut.look),s.copy(gs.quaternion)}function XE(){ut.mode==="off"&&(ut.exitTimer&&(window.clearTimeout(ut.exitTimer),ut.exitTimer=0),ut.savedPosition.copy(oe.position),ut.savedTarget.copy(he.target),ut.savedFov=oe.fov,ut.startPosition.copy(oe.position),ut.startQuaternion.copy(oe.quaternion),ut.startFov=oe.fov,ut.t=0,ut.mode="entering",Mi.active=!1,Sn=null,he.enabled=!1,he.autoRotate=!1,Fg(!0))}function Og(){ut.mode==="off"||ut.mode==="exiting"||(ut.exitTimer&&(window.clearTimeout(ut.exitTimer),ut.exitTimer=0),ut.startPosition.copy(oe.position),ut.startQuaternion.copy(oe.quaternion),ut.startFov=oe.fov,ut.t=0,ut.mode="exiting",gs.position.copy(ut.savedPosition),gs.up.set(0,1,0),gs.lookAt(ut.savedTarget),ut.savedQuaternion.copy(gs.quaternion))}function qE(s=1200){ut.mode!=="off"&&(ut.exitTimer&&window.clearTimeout(ut.exitTimer),ut.exitTimer=window.setTimeout(()=>{ut.exitTimer=0,Og()},s))}function Bg(s,t){if(ut.mode!=="off"){if(ut.mode==="entering"){ut.t+=s/ut.enterDuration;let e=Math.min(1,ut.t),n=1-Math.pow(1-e,3);cg(ut.eye),hg(ut.look),WE(ut.targetQuaternion),oe.position.lerpVectors(ut.startPosition,ut.eye,n),oe.quaternion.slerpQuaternions(ut.startQuaternion,ut.targetQuaternion,n),oe.fov=Ne(ut.startFov,55,n),oe.updateProjectionMatrix(),n>.82&&!ut.headHidden&&Ia(!1),e>=1&&(ut.mode="active",Ia(!1));return}if(ut.mode==="active"){cg(ut.eye),ut.eye.y+=Math.sin(t*1.25)*.004,oe.position.copy(ut.eye),hg(ut.look),oe.lookAt(ut.look),Math.abs(oe.fov-55)>.01&&(oe.fov=55,oe.updateProjectionMatrix()),ut.headHidden||Ia(!1);return}if(ut.mode==="exiting"){ut.t+=s/ut.exitDuration;let e=Math.min(1,ut.t),n=1-Math.pow(1-e,3);oe.position.lerpVectors(ut.startPosition,ut.savedPosition,n),oe.quaternion.slerpQuaternions(ut.startQuaternion,ut.savedQuaternion,n),oe.fov=Ne(ut.startFov,ut.savedFov,n),oe.updateProjectionMatrix(),n>.55&&ut.headHidden&&Ia(!0),e>=1&&(ut.mode="off",oe.position.copy(ut.savedPosition),oe.quaternion.copy(ut.savedQuaternion),oe.fov=ut.savedFov,oe.updateProjectionMatrix(),he.target.copy(ut.savedTarget),he.enabled=go===null,he.autoRotate=ze.autoRotate,Ia(!0),Fg(!1))}}}var ug=[{name:"\u8679\u9CDF",min:24,max:42},{name:"\u9CAB\u9C7C",min:13,max:24},{name:"\u6EAA\u54E5",min:9,max:16},{name:"\u9CA4\u9C7C",min:32,max:56},{name:"\u5C71\u5973\u9CDF",min:18,max:30}];function YE(){let s=Math.PI+(Math.random()-.5)*1.15,t=.5+Math.random()*2.15;return new w(Ot.x+Math.cos(s)*t,Ot.waterY+.06,Ot.z+Math.sin(s)*t)}function kg(){["idle","caught","missed"].includes(mt.state)&&(XE(),mt.state="casting",mt.castElapsed=0,mt.castFrom.copy(Pn.position),mt.target.copy(YE()),mt.waitDuration=3.1+Math.random()*3.2,mt.castSwing=0,bn.visible=!1,ms("casting"))}function zg(){if(mt.state!=="bite")return;let s=ug[Math.floor(Math.random()*ug.length)],t=Math.floor(s.min+Math.random()*(s.max-s.min+1));mt.state="caught",mt.caughtElapsed=0,mt.fish={...s,length:t},mt.count+=1,Wf(1.15),bn.visible=!0,bn.position.copy(Pn.position),mt.fishJumpElapsed=0,ms("caught",mt.fish),o1(mt.fish),qE(1200)}function ep(s,t){let e=mt.state,n=Pn.position;if(go!==null){li.uTime.value=t;return}if(e==="casting"){mt.castElapsed+=s;let h=Ua(mt.castElapsed/.92,0,1),u=h*h*(3-2*h);n.lerpVectors(mt.castFrom,mt.target,u),n.y+=Math.sin(Math.PI*h)*.95,mt.castSwing=Math.sin(Math.PI*Math.min(1,h*1.3)),h>=1&&(mt.state="waiting",mt.waitElapsed=0,n.copy(mt.target),Wf(.32),ms("waiting"))}else e==="waiting"?(mt.waitElapsed+=s,n.copy(mt.target),n.y=Ot.waterY+.055+Math.sin(t*2.1)*.012+Math.sin(t*.9)*.008,mt.castSwing=Math.max(0,mt.castSwing-s*5),mt.waitElapsed>=mt.waitDuration&&(mt.state="bite",mt.biteElapsed=0,Wf(.52),ms("bite"))):e==="bite"?(mt.biteElapsed+=s,n.copy(mt.target),n.y=Ot.waterY+.01+Math.sin(t*19)*.026,mt.castSwing=0,mt.biteElapsed>=1.85&&(mt.state="missed",mt.failedElapsed=0,mt.fish=null,ms("missed"))):e==="caught"?(mt.caughtElapsed+=s,n.copy(mt.target),n.y=Ot.waterY+.05+Math.sin(t*2.4)*.01,mt.castSwing=-.22,mt.caughtElapsed>2.6&&(mt.state="idle",mt.fish=null,ms("idle"))):e==="missed"?(mt.failedElapsed+=s,n.copy(mt.target),n.y=Ot.waterY+.055+Math.sin(t*2.1)*.01,mt.castSwing=0,mt.failedElapsed>1.5&&(mt.state="idle",ms("idle"))):(n.copy(mt.target),n.y=Ot.waterY+.055+Math.sin(t*1.8)*.01,mt.castSwing=0);let i=.9;mt.state==="casting"?i=.9+mt.castSwing*.55:mt.state==="bite"?i=.98+Math.sin(t*16)*.028:mt.state==="caught"?i=.72:mt.state==="waiting"&&(i=.9+Math.sin(t*1.1)*.012),Xi.rotation.x=fs.damp(Xi.rotation.x,i,9,s),ve.position.y=.21+Math.sin(t*1.35)*.004,Vh.rotation.x=.16+Math.sin(t*1.8)*.13,Vh.rotation.z=-.12+Math.sin(t*1.1+1.2)*.05;let r=new w;Kf.getWorldPosition(r);let o=mt.state==="casting"?.06:mt.state==="caught"?.28:.11,a=new w(n.x,n.y+.08,n.z),l=new w;for(let h=0;h=1&&(bn.visible=!1)}HE(s)}var Ga=52,np=[],Bh=new Float32Array(Ga*3),Hg=new Float32Array(Ga),Vg=new Float32Array(Ga),hr=new Xt,Si=Ae(7129);for(let s=0;s","}"].join(` `)});hr.setAttribute("position",new se(Bh,3));hr.setAttribute("aSize",new se(Hg,1));hr.setAttribute("aAlpha",new se(Vg,1));var Gg=new Hi(hr,JE);Gg.frustumCulled=!1;Vt.add(Gg);var Wa=92,Wg=[],ur=new Float32Array(Wa*3),Xg=new Float32Array(Wa),qg=new Float32Array(Wa),Xa=new Xt,ps=Ae(9241);for(let s=0;s","}"].join(` `)}),Yg=new Hi(Xa,$E);Yg.frustumCulled=!1;Vt.add(Yg);function Zg(s){for(let t=0;t1&&ZE(t);let n=e.life,i=vn.y+.08+n*3.7,r=.08+n*.75,o=vn.x+Math.sin(n*5.5+e.phase)*r+e.drift*n,a=vn.z+Math.cos(n*4.2+e.phase*1.7)*r*.65-n*.32;Bh[t*3]=o,Bh[t*3+1]=i,Bh[t*3+2]=a,Hg[t]=.26+n*.95,Vg[t]=Math.sin(Math.PI*n)*.36*(1-n*.22)}hr.attributes.position.needsUpdate=!0,hr.attributes.aSize.needsUpdate=!0,hr.attributes.aAlpha.needsUpdate=!0}function Jg(s){for(let t=0;t{H.catchToast.classList.remove("is-visible")},2800))}function ms(s,t=null,e=mt.count){!H.fishingHud||!H.castButton||(H.fishingHud.classList.remove("is-bite","is-catch"),H.catchCount.textContent=String(e),H.castButton.disabled=!1,s==="casting"?(H.castLabel.textContent="\u629B\u7AFF\u4E2D\u2026",H.fishingStatus.textContent="\u9C7C\u7EBF\u5212\u8FC7\u6C34\u9762\uFF0C\u6D6E\u6807\u98DE\u5411\u6C60\u5858\u2026",H.castButton.disabled=!0):s==="waiting"?(H.castLabel.textContent="\u7B49\u5F85\u4E2D",H.fishingStatus.textContent="\u6D6E\u6807\u5DF2\u5165\u6C34 \xB7 \u9759\u5019\u9C7C\u513F\u54AC\u94A9",H.castButton.disabled=!0):s==="bite"?(H.fishingHud.classList.add("is-bite"),H.castLabel.textContent="\u6536\u7EBF\uFF01",H.fishingStatus.textContent="\u6709\u9C7C\u54AC\u94A9\uFF01\u70B9\u51FB\u300C\u6536\u7EBF\u300D\u628A\u5B83\u62C9\u4E0A\u6765"):s==="caught"?(H.fishingHud.classList.add("is-catch"),H.castLabel.textContent="\u518D\u629B\u4E00\u7AFF",H.fishingStatus.textContent=t?"\u9493\u5230"+t.name+" \xB7 "+t.length+" cm\uFF0C\u4ECA\u665A\u52A0\u9910":"\u6536\u83B7\u4E00\u6761\u9C7C\uFF0C\u4ECA\u665A\u52A0\u9910",H.castButton.disabled=!0,window.setTimeout(()=>{(mt.state==="caught"||mt.state==="idle")&&(H.castButton.disabled=!1)},2200),t&&KE(t)):s==="missed"?(H.castLabel.textContent="\u6536\u7EBF\u4E2D",H.fishingStatus.textContent="\u9C7C\u513F\u8DD1\u6389\u4E86\u2026 \u518D\u8BD5\u4E00\u6B21\u5427",H.castButton.disabled=!0):(H.castLabel.textContent="\u629B\u7AFF",H.fishingStatus.textContent="\u70B9\u51FB\u300C\u629B\u7AFF\u300D\uFF0C\u9759\u5019\u9C7C\u513F\u54AC\u94A9"))}var jE="/api/fishing",$g="forest-cabin-memory-v1",Ht={user:null,name:"",backpack:[],species:[],leaderboard:[],online:!1,loading:!1,windowDays:30,legacyUid:null,nameError:""};function QE(){try{let s=window.localStorage?window.localStorage.getItem($g):null;if(!s)return null;let t=JSON.parse(s);return t&&typeof t.uid=="string"&&/^[A-Za-z0-9_-]{8,64}$/.test(t.uid)?t.uid:null}catch{return null}}function ip(){if(Ht.legacyUid){Ht.legacyUid=null;try{window.localStorage&&window.localStorage.removeItem($g)}catch{}}}function sp(){return Ht.legacyUid?"?legacy_uid="+encodeURIComponent(Ht.legacyUid):""}Ht.legacyUid=QE();function t1(){try{if(window.crypto&&typeof window.crypto.randomUUID=="function")return window.crypto.randomUUID()}catch{}return"v-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,12)}async function rp(s,t={}){if(typeof fetch!="function")throw new Error("fetch-unavailable");let e=typeof AbortController=="function"?new AbortController:null,n=e?window.setTimeout(()=>e.abort(),4500):0;try{let i={Accept:"application/json",...t.body?{"Content-Type":"application/json"}:{}},r=await fetch(jE+s,{cache:"no-store",credentials:"same-origin",...t,headers:i,...e?{signal:e.signal}:{}}),o=await r.json().catch(()=>null);if(!r.ok){let a=new Error(o&&o.error||"HTTP "+r.status);throw a.status=r.status,a}return o}finally{n&&window.clearTimeout(n)}}function _s(){H.memorySync&&(H.memorySync.classList.remove("is-online","is-offline","is-syncing"),Ht.loading?(H.memorySync.classList.add("is-syncing"),H.memorySync.textContent="\u6B63\u5728\u540C\u6B65\u80CC\u5305\u2026"):Ht.online?(H.memorySync.classList.add("is-online"),H.memorySync.textContent="\u5DF2\u8FDE\u63A5 \xB7 \u6570\u636E\u4FDD\u5B58\u5728\u670D\u52A1\u5668"):(H.memorySync.classList.add("is-offline"),H.memorySync.textContent="\u672A\u8FDE\u63A5 \xB7 \u80CC\u5305\u6570\u636E\u5728\u670D\u52A1\u5668"))}function e1(s){let t=Math.max(0,Number(s)||0);mt.count=t,H.catchCount&&(H.catchCount.textContent=String(t)),H.memoryCount&&(H.memoryCount.textContent=String(t)),H.memoryToggle&&(H.memoryToggle.title="\u9493\u9C7C\u80CC\u5305 \xB7 \u8FD1 30 \u5929 "+t+" \u6761")}function n1(s){let t=new Date(Number(s)*1e3);if(Number.isNaN(t.getTime()))return"";let e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return e+"-"+n+" "+i+":"+r}function i1(){if(!H.backpackList||typeof H.backpackList.appendChild!="function")return;let s=H.backpackList;if(s.textContent="",!Ht.backpack.length){let t=document.createElement("li");t.className="memory-empty",t.textContent=Ht.online?"\u80CC\u5305\u8FD8\u662F\u7A7A\u7684\uFF0C\u53BB\u9493\u4E00\u6761\u9C7C\u5427":"\u8FDE\u63A5\u670D\u52A1\u5668\u540E\u624D\u80FD\u6253\u5F00\u80CC\u5305",s.appendChild(t);return}Ht.backpack.slice(0,40).forEach(t=>{let e=document.createElement("li");e.className="backpack-item";let n=document.createElement("span");n.className="backpack-dot";let i=document.createElement("div");i.className="backpack-item-main";let r=document.createElement("strong");r.textContent=t.species||"\u9C7C";let o=document.createElement("span");o.textContent=(Number(t.length)||0)+" cm \xB7 "+n1(t.caughtAt),i.append(r,o);let a=document.createElement("span");a.className="backpack-item-badge",a.textContent="\u5DF2\u5165\u5305",e.append(n,i,a),s.appendChild(e)})}function s1(){if(!H.backpackSpecies||typeof H.backpackSpecies.appendChild!="function")return;let s=H.backpackSpecies;s.textContent="";for(let t of Ht.species){let e=document.createElement("span");e.className="backpack-chip",e.textContent=t.name+" \xD7"+t.count,s.appendChild(e)}}function r1(){if(!H.memoryLeaderboard||typeof H.memoryLeaderboard.appendChild!="function")return;let s=H.memoryLeaderboard;if(s.textContent="",!Ht.leaderboard.length){let t=document.createElement("li");t.className="memory-empty",t.textContent=Ht.online?"\u8FD8\u6CA1\u6709\u4EBA\u7559\u4E0B\u6E14\u83B7\uFF0C\u6765\u5F53\u7B2C\u4E00\u4E2A":"\u8FDE\u63A5\u670D\u52A1\u5668\u540E\u663E\u793A\u5168\u7AD9\u6E14\u83B7\u699C",s.appendChild(t);return}Ht.leaderboard.slice(0,5).forEach((t,e)=>{let n=document.createElement("li");t.isMe&&(n.className="is-me");let i=document.createElement("span");i.className="memory-rank",i.textContent=String(e+1).padStart(2,"0");let r=document.createElement("span");r.className="memory-name",r.textContent=t.name||"\u65E0\u540D\u9493\u5BA2";let o=document.createElement("span");o.className="memory-score",o.textContent=String(t.count||0);let a=document.createElement("small");a.textContent="\u6761",o.appendChild(a),n.append(i,r,o),s.appendChild(n)})}function xs(){H.memoryName&&document.activeElement!==H.memoryName&&(H.memoryName.value=Ht.name),H.memoryError&&(H.memoryError.textContent=Ht.nameError||"",H.memoryError.classList.toggle("is-visible",!!Ht.nameError)),H.memoryCount&&(H.memoryCount.textContent=String(mt.count)),H.backpackTotal&&(H.backpackTotal.textContent=String(mt.count)+" \u6761"),_s(),i1(),s1(),r1()}function Kg(s){Ht.online=!0,Ht.windowDays=Number(s.windowDays)||30,s.user&&typeof s.user=="object"&&(Ht.user=s.user,Ht.name=typeof s.user.name=="string"?s.user.name:"",typeof s.user.count=="number"&&e1(s.user.count)),Ht.backpack=Array.isArray(s.backpack)?s.backpack:[],Ht.species=Array.isArray(s.species)?s.species:[],Ht.leaderboard=Array.isArray(s.leaderboard)?s.leaderboard:[],xs()}async function iu(){if(!Ht.loading){Ht.loading=!0,_s();try{let s=await rp("/me"+sp());Kg(s),ip()}catch{Ht.online=!1}finally{Ht.loading=!1,_s(),xs()}}}function o1(s){let t=t1();if(Ht.loading=!0,_s(),typeof fetch!="function"){Ht.loading=!1,Ht.online=!1,_s(),xs();return}rp("/catch"+sp(),{method:"POST",body:JSON.stringify({event_id:t,species:String(s.name||"\u9C7C"),length:Number(s.length)||0})}).then(e=>{Ht.online=!0,Kg(e),ip()}).catch(()=>{Ht.online=!1}).finally(()=>{Ht.loading=!1,_s(),xs()})}async function a1(s){if(s.preventDefault(),!H.memoryName)return;let t=Ht.name,e=Array.from(H.memoryName.value.trim()).slice(0,12).join("");Ht.name=e,Ht.nameError="",Ht.loading=!0,_s(),xs();try{let n=await rp("/profile"+sp(),{method:"POST",body:JSON.stringify({name:e})});Ht.online=!0,ip(),typeof n.name=="string"&&(Ht.name=n.name),Ht.nameError=""}catch(n){Ht.name=t,n&&n.status===409?Ht.nameError=n.message||"\u8FD9\u4E2A\u79F0\u547C\u5DF2\u7ECF\u6709\u4EBA\u7528\u4E86":(Ht.online=!1,Ht.nameError="\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5")}finally{Ht.loading=!1,H.memoryName&&(H.memoryName.value=Ht.name),_s(),xs(),Ht.online&&iu()}}var go=null,pg=0,Bf=!1,op={backpack:{panel:H.memoryPanel,toggle:H.memoryToggle},leaderboard:{panel:H.leaderboardPanel,toggle:H.leaderboardToggle},contact:{panel:H.contactPanel,toggle:H.contactToggle},feedback:{panel:H.feedbackPanel,toggle:H.feedbackToggle}};function jg(s,t){let e=op[s];e&&(e.panel&&(e.panel.classList.toggle("is-open",t),e.panel.setAttribute("aria-hidden",String(!t))),e.toggle&&(e.toggle.classList.toggle("is-active",t),e.toggle.setAttribute("aria-expanded",String(t))))}function qi(){for(let s of Object.keys(op))jg(s,!1);go=null,H.memoryBackdrop&&H.memoryBackdrop.classList.remove("is-open"),he.enabled=ut.mode==="off"}function xo(s){let t=op[s];if(!(!t||!t.panel)){if(go===s){qi();return}qi(),go=s,jg(s,!0),H.memoryBackdrop&&H.memoryBackdrop.classList.add("is-open"),he.enabled=!1,(s==="backpack"||s==="leaderboard")&&(xs(),iu()),s==="feedback"&&ho("","")}}function l1(){xo("backpack")}function c1(){qi()}function ho(s,t){H.feedbackStatus&&(H.feedbackStatus.textContent=s||"",H.feedbackStatus.className="feedback-status"+(t?" is-"+t:""))}async function h1(s){if(s.preventDefault(),!H.feedbackForm||Bf)return;let t=H.feedbackMessage?H.feedbackMessage.value.trim():"",e=H.feedbackContact?H.feedbackContact.value.trim():"",n=H.feedbackWebsite?H.feedbackWebsite.value:"";if(Array.from(t).length<2){ho("\u5199\u70B9\u4EC0\u4E48\u518D\u53D1\u9001\u5427\u3002","error"),H.feedbackMessage&&H.feedbackMessage.focus();return}if(typeof fetch!="function"){ho("\u5F53\u524D\u6D4F\u89C8\u5668\u65E0\u6CD5\u63D0\u4EA4\uFF0C\u8BF7\u76F4\u63A5\u53D1\u90AE\u4EF6\u3002","error");return}Bf=!0,H.feedbackSubmit&&(H.feedbackSubmit.disabled=!0,H.feedbackSubmit.textContent="\u53D1\u9001\u4E2D\u2026"),ho("\u6B63\u5728\u63D0\u4EA4\u2026","");try{let i=await fetch("/api/fishing/feedback",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({message:t,contact:e,page:window.location.pathname,website:n})}),r=await i.json().catch(()=>null);if(!i.ok){let o=new Error(r&&r.error||"\u63D0\u4EA4\u5931\u8D25");throw o.status=i.status,o}H.feedbackForm&&H.feedbackForm.reset(),ho("\u5DF2\u6536\u5230\uFF0C\u4F1A\u53D1\u9001\u5230\u7AD9\u957F\u90AE\u7BB1\u3002\u8C22\u8C22\u3002","success")}catch(i){ho(i&&i.message?i.message:"\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002","error")}finally{Bf=!1,H.feedbackSubmit&&(H.feedbackSubmit.disabled=!1,H.feedbackSubmit.textContent="\u53D1\u9001\u53CD\u9988")}}function u1(s){if(!s)return;let t=()=>{let n=document.createElement("textarea");n.value=s,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{return document.execCommand("copy"),!0}catch{return!1}finally{n.remove()}},e=n=>{H.contactStatus&&(H.contactStatus.textContent=n?"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F":"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9",window.clearTimeout(pg),pg=window.setTimeout(()=>{H.contactStatus.textContent="GitHub / \u90AE\u7BB1\u70B9\u51FB\u6253\u5F00\uFF0CQQ / \u5FAE\u4FE1\u70B9\u51FB\u590D\u5236\u3002"},1800))};navigator.clipboard&&typeof navigator.clipboard.writeText=="function"?navigator.clipboard.writeText(s).then(()=>e(!0)).catch(()=>e(t())):e(t())}H.memoryToggle&&H.memoryToggle.addEventListener("click",()=>xo("backpack"));H.leaderboardToggle&&H.leaderboardToggle.addEventListener("click",()=>xo("leaderboard"));H.contactToggle&&H.contactToggle.addEventListener("click",()=>xo("contact"));H.feedbackToggle&&H.feedbackToggle.addEventListener("click",()=>xo("feedback"));H.memoryClose&&H.memoryClose.addEventListener("click",qi);H.leaderboardClose&&H.leaderboardClose.addEventListener("click",qi);H.contactClose&&H.contactClose.addEventListener("click",qi);H.feedbackClose&&H.feedbackClose.addEventListener("click",qi);H.memoryBackdrop&&H.memoryBackdrop.addEventListener("click",qi);H.memoryForm&&H.memoryForm.addEventListener("submit",a1);H.feedbackForm&&H.feedbackForm.addEventListener("submit",h1);H.memoryName&&H.memoryName.addEventListener("input",()=>{Ht.nameError&&(Ht.nameError="",xs())});H.contactList&&H.contactList.addEventListener("click",s=>{let t=s.target.closest("[data-copy]");t&&u1(t.getAttribute("data-copy"))});document.addEventListener("keydown",s=>{s.key==="Escape"&&go!==null&&qi()});iu();H.castButton.addEventListener("click",()=>{mt.state==="bite"?zg():(mt.state==="idle"||mt.state==="caught"||mt.state==="missed")&&kg()});ms("idle",null,mt.count);H.lightToggle.addEventListener("click",()=>{ze.day=!ze.day,H.lightToggle.setAttribute("aria-pressed",String(ze.day)),H.lightLabel.textContent=ze.day?"\u767D\u663C":"\u9EC4\u660F"});H.rotateToggle.addEventListener("click",()=>{ut.mode==="off"&&(ze.autoRotate=!ze.autoRotate,H.rotateToggle.classList.toggle("is-active",ze.autoRotate),H.rotateToggle.setAttribute("aria-pressed",String(ze.autoRotate)))});var Sn=null;function d1(s,t,e=1.45){Sn={t:0,duration:e,fromPosition:oe.position.clone(),fromTarget:he.target.clone(),toPosition:s.clone(),toTarget:t.clone()},he.autoRotate=!1}H.reset.addEventListener("click",()=>{ut.mode==="off"&&d1(Wh,po,1.35)});he.addEventListener("start",()=>{Sn&&(Sn=null,he.autoRotate=ze.autoRotate)});function Qg(s){ze.mix=fs.damp(ze.mix,ze.day?1:0,2.35,s);let t=ze.mix,e=dg.dusk,n=dg.day;co.uTopColor.value.copy(e.top).lerp(n.top,t),co.uHorizonColor.value.copy(e.horizon).lerp(n.horizon,t),co.uBottomColor.value.copy(e.bottom).lerp(n.bottom,t),co.uGlowColor.value.copy(e.glowing).lerp(n.glowing,t),co.uGlowStrength.value=Ne(.42,.18,t),Vt.fog.color.copy(e.fog).lerp(n.fog,t),Vt.fog.density=Ne(.0175,.0092,t),li.uDeep.value.copy($n.dusk.deep).lerp($n.day.deep,t),li.uShallow.value.copy($n.dusk.shallow).lerp($n.day.shallow,t),li.uSky.value.copy($n.dusk.sky).lerp($n.day.sky,t),li.uGlow.value.copy($n.dusk.glow).lerp($n.day.glow,t),li.uNight.value=1-t,Nh.color.copy(e.hemiSky).lerp(n.hemiSky,t),Nh.groundColor.copy(e.hemiGround).lerp(n.hemiGround,t),Nh.intensity=Ne(.75,1.35,t),fn.color.copy(e.key).lerp(n.key,t),fn.intensity=Ne(2.25,2.7,t),kh.color.copy(e.rim).lerp(n.rim,t),kh.intensity=Ne(.62,.45,t),Je.toneMappingExposure=Ne(1.12,1.04,t),Tg.color.copy(new Z(15986395)).lerp(new Z(16769702),t),Fa.color.copy(new Z(16768426)).lerp(new Z(16771519),t),Fa.opacity=Ne(.32,.18,t);for(let i of mo)i.intensity=i.userData.baseIntensity*Ne(1,.36,t)*i.userData.flicker;for(let i of ys)i.intensity=i.userData.baseIntensity*Ne(1,.42,t)*i.userData.flicker;Kn&&(Kn.intensity=Kn.userData.baseIntensity*Ne(1,.34,t)*Kn.userData.flicker),B.glass.emissiveIntensity=Ne(2.25,1.05,t);for(let i of fr)i.opacity=(i.userData.baseOpacity??.3)*Ne(1,.34,t);for(let i of zh){let r=i.userData.baseOpacity??.2;i.material.opacity=r*Ne(1,.15,t)}qa.uOpacity.value=Ne(1,0,t),nu.uOpacity.value=Ne(.58,.3,t);for(let i of Yh)i.opacity=(i.userData?.baseOpacity??.82)*(1-t)}Yh[0].userData.baseOpacity=.82;Yh[1].userData.baseOpacity=.9;for(let s of mo)s.userData.flicker=1;for(let s of ys)s.userData.flicker=1;Kn&&(Kn.userData.flicker=1);var Mi={active:!0,t:0,duration:2.6,fromPosition:oe.position.clone(),fromTarget:he.target.clone()};function f1(s){if(!Mi.active)return;Mi.t+=s/Mi.duration;let t=Math.min(1,Mi.t),e=1-Math.pow(1-t,3);oe.position.lerpVectors(Mi.fromPosition,Wh,e),he.target.lerpVectors(Mi.fromTarget,po,e),t>=1&&(Mi.active=!1,he.autoRotate=ze.autoRotate)}function p1(s){if(!Sn)return;Sn.t+=s/Sn.duration;let t=Math.min(1,Sn.t),e=1-Math.pow(1-t,3);oe.position.lerpVectors(Sn.fromPosition,Sn.toPosition,e),he.target.lerpVectors(Sn.fromTarget,Sn.toTarget,e),t>=1&&(Sn=null,he.autoRotate=ze.autoRotate)}window.addEventListener("resize",()=>{oe.aspect=window.innerWidth/window.innerHeight,ut.mode==="off"?xg():(oe.fov=55,oe.updateProjectionMatrix()),Je.setPixelRatio(Math.min(window.devicePixelRatio||1,yg)),Je.setSize(window.innerWidth,window.innerHeight),nu.uPixelRatio.value=Je.getPixelRatio(),qa.uPixelRatio.value=Je.getPixelRatio()});function m1(){let s=0;return Vt.traverse(t=>{if(!t.isMesh||!t.geometry)return;let e=t.geometry,n=e.index?e.index.count:e.attributes.position.count;s+=n/3*(t.isInstancedMesh?t.count:1)}),Math.round(s)}var g1=m1();H.triCount.textContent=(g1/1e3).toFixed(1).replace(".0","")+"k \u4E09\u89D2\u9762";var mg=new no,gg=!0,_1=new URLSearchParams(window.location.search).has("shot");function t_(){requestAnimationFrame(t_);let s=Math.min(mg.getDelta(),.05),t=mg.elapsedTime;ze.time=t,Qg(s),ut.mode==="off"&&(f1(s),p1(s));for(let e=0;e{document.querySelector("#loader").classList.add("is-hidden")},420))}window.__CABIN__={THREE:Uf,scene:Vt,camera:oe,controls:he,cabin:yt,moon:Xh,state:ze,water:ka,angler:ve,fishing:mt,bobber:Pn,firstPerson:ut,startFishingCast:kg,landFishingCatch:zg,updateFishing:ep,updateFirstPerson:Bg,exitFirstPerson:Og,terrainHeight:en,POND:Ot,memory:Ht,syncMemory:iu,openMemoryPanel:l1,closeMemoryPanel:c1,openPanel:xo};if(_1){Mi.active=!1,Sn=null,ze.autoRotate=!1,he.autoRotate=!1,oe.position.copy(Wh),he.target.copy(po),he.update(),Qg(0),Zg(.55),Jg(0),ep(0,0),Fa.opacity=.32,nu.uOpacity.value=.58,qa.uOpacity.value=1;for(let t of fr)t.opacity=t.userData.baseOpacity??.3;for(let t of zh)t.material.opacity=t.userData.baseOpacity??.2;for(let t of mo)t.intensity=t.userData.baseIntensity;for(let t of ys)t.intensity=t.userData.baseIntensity;Kn&&(Kn.intensity=Kn.userData.baseIntensity),Je.render(Vt,oe),window.__SCENE_READY__=!0;let s=document.querySelector("#loader");s&&s.remove()}else t_();window.addEventListener("error",s=>{let t=document.querySelector(".loader-text");t&&(t.textContent="\u573A\u666F\u52A0\u8F7D\u5931\u8D25\uFF1A"+(s.message||"\u672A\u77E5\u9519\u8BEF")),console.error(s.error||s.message)});})();