/*! For license information please see main.d4fb0a3c.js.LICENSE.txt */ (()=>{var e={1947(e,t,n){"use strict";n.d(t,{A:()=>r});var a=n(5544),i=n(5043),s=n(9265),o=n(579);const r=function(e){var t,n,r,l;let c=e.mapData,h=e.levelKey,d=e.buildLevel,u=e.buildEntities,p=e.isFloor,m=e.bannerFor,f=e.actionsFor,g=e.lighting,v=e.weather,b=e.hidden,y=e.overlay,w=e.flash,x=e.onMove,S=e.onDispose,k=e.disabled;const _=(0,i.useRef)(null),T=(0,i.useRef)(null),R=(0,i.useRef)(0),A=(0,i.useRef)([0,0]),C=(0,i.useRef)(!1),N=(0,i.useRef)(""),E=(0,i.useRef)(c),M=(0,i.useRef)(k),L=(0,i.useRef)(x),I=(0,i.useRef)(p),X=(0,i.useRef)(m);E.current=c,M.current=k,L.current=x,I.current=p,X.current=m;const P=(0,i.useState)(0),W=(0,a.A)(P,2),G=W[0],j=W[1],V=(0,i.useState)(null),Z=(0,a.A)(V,2),F=Z[0],D=Z[1],B=(0,i.useState)(null),H=(0,a.A)(B,2),U=H[0],Y=H[1],O=e=>D({key:Date.now(),text:e});(0,i.useEffect)((()=>{null!==w&&void 0!==w&&w.key&&Y({key:w.key,text:w.text})}),[w]),(0,i.useEffect)((()=>{const e=_.current,t=new s.Ay({container:e,onDisposeTextures:S});T.current=t;const n=new ResizeObserver((()=>t.setSize(e.clientWidth,e.clientHeight)));return n.observe(e),()=>{n.disconnect(),t.dispose(),T.current=null}}),[]),(0,i.useEffect)((()=>{var e;const t=T.current,n=E.current;if(!t||null===n||void 0===n||null===(e=n.grid)||void 0===e||!e.length)return;t.buildLevel(d(n,t));const i=n.currentPos||[0,0],o=(0,a.A)(i,2),r=o[0],l=o[1];A.current=[r,l];const c=s.I_[R.current];if(!I.current(n,r+c[0],l+c[1]))for(let a=0;a<4;a++)if(I.current(n,r+s.I_[a][0],l+s.I_[a][1])){R.current=a,j(a);break}t.setPose(r,l,R.current),N.current="",n.name&&O(n.name)}),[h]),(0,i.useEffect)((()=>{T.current&&c&&u&&T.current.setEntities(u(c))}),[c]);const z=(0,i.useRef)(!1);(0,i.useEffect)((()=>{var e;g&&(z.current?null===(e=T.current)||void 0===e||e.setLighting(g):z.current=!0)}),[g]),(0,i.useEffect)((()=>{var e;null===(e=T.current)||void 0===e||e.setWeather(v)}),[v]),(0,i.useEffect)((()=>{var e;null===(e=T.current)||void 0===e||e.setPaused(!!b)}),[b]);const J=null!==(t=null===c||void 0===c||null===(n=c.currentPos)||void 0===n?void 0:n[0])&&void 0!==t?t:0,K=null!==(r=null===c||void 0===c||null===(l=c.currentPos)||void 0===l?void 0:l[1])&&void 0!==r?r:0,Q=f&&c&&f(c,J,K)||[];(0,i.useEffect)((()=>{var e;A.current=[J,K];const t=T.current;!t||t.gridPos[0]===J&&t.gridPos[1]===K||t.glideTo(J,K);const n=(null===(e=X.current)||void 0===e?void 0:e.call(X,E.current,J,K))||"";n&&n!==N.current&&O(n),n&&(N.current=n)}),[c]);const q=e=>(e=>{var t;const n=T.current,i=E.current;if(!n||!i||M.current||C.current)return;const o=(0,a.A)(A.current,2),r=o[0],l=o[1],c=(0,a.A)(s.I_[e],2),h=r+c[0],d=l+c[1];I.current(i,h,d)?(C.current=!0,n.glideTo(h,d),Promise.resolve(null===(t=L.current)||void 0===t?void 0:t.call(L,s.fF[e])).finally((()=>{C.current=!1}))):n.bump(e)})((R.current+e)%4),$=e=>{var t;M.current||(R.current=(R.current+e+4)%4,j(R.current),null===(t=T.current)||void 0===t||t.turnTo(R.current))};return(0,i.useEffect)((()=>{const e=e=>{const t=document.activeElement;if(!t||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable){switch(e.code){case"KeyW":case"ArrowUp":q(0);break;case"KeyS":case"ArrowDown":q(2);break;case"KeyA":q(3);break;case"KeyD":q(1);break;case"KeyQ":case"ArrowLeft":$(-1);break;case"KeyE":case"ArrowRight":$(1);break;default:return}e.preventDefault()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[]),(0,o.jsxs)("div",{className:"c3v-root".concat(b?" c3v-root--hidden":""),children:[(0,o.jsx)("div",{className:"c3v-canvas",ref:_}),F&&(0,o.jsx)("div",{className:"c3v-banner",children:F.text},F.key),y,(0,o.jsx)("div",{className:"c3v-compass",title:"Facing",children:s.fF[G]}),U&&(0,o.jsx)("div",{className:"c3v-result",children:U.text},U.key),Q.length>0&&(0,o.jsx)("div",{className:"c3v-actions",children:Q.map((e=>(0,o.jsx)("button",{type:"button",onClick:e.onClick,disabled:k,children:e.label},e.id)))}),(0,o.jsxs)("div",{className:"c3v-pad".concat(k?" c3v-pad-disabled":""),children:[(0,o.jsx)("button",{type:"button",onClick:()=>$(-1),disabled:k,title:"Turn left (Q)",children:"\u21ba"}),(0,o.jsx)("button",{type:"button",onClick:()=>q(0),disabled:k,title:"Forward (W)",children:"\u2191"}),(0,o.jsx)("button",{type:"button",onClick:()=>$(1),disabled:k,title:"Turn right (E)",children:"\u21bb"}),(0,o.jsx)("button",{type:"button",onClick:()=>q(3),disabled:k,title:"Strafe left (A)",children:"\u2190"}),(0,o.jsx)("button",{type:"button",onClick:()=>q(2),disabled:k,title:"Back (S)",children:"\u2193"}),(0,o.jsx)("button",{type:"button",onClick:()=>q(1),disabled:k,title:"Strafe right (D)",children:"\u2192"})]}),(0,o.jsx)("div",{className:"c3v-hint",children:"WASD move \xb7 Q/E turn"})]})}},9265(e,t,n){"use strict";n.d(t,{JA:()=>vn,fF:()=>bn,I_:()=>yn,Ay:()=>An});var a=n(5544),i=n(9435);function s(){let e=null,t=!1,n=null,a=null;function i(t,s){n(t,s),a=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&null!==e&&(a=e.requestAnimationFrame(i),t=!0)},stop:function(){null!==e&&e.cancelAnimationFrame(a),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function o(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const a=t.get(n);a&&(e.deleteBuffer(a.buffer),t.delete(n))},update:function(n,a){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.versione.start-t.start));let t=0;for(let e=1;e 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include ",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t\t#ifdef FLIP_SIDED\n\t\t\tvBitangent = - vBitangent;\n\t\t#endif\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},l={common:{diffuse:{value:new i.Q1f(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new i.dwI},alphaMap:{value:null},alphaMapTransform:{value:new i.dwI},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new i.dwI}},envmap:{envMap:{value:null},envMapRotation:{value:new i.dwI},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new i.dwI}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new i.dwI}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new i.dwI},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new i.dwI},normalScale:{value:new i.I9Y(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new i.dwI},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new i.dwI}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new i.dwI}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new i.dwI}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new i.Q1f(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new i.Pq0},probesMax:{value:new i.Pq0},probesResolution:{value:new i.Pq0}},points:{diffuse:{value:new i.Q1f(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new i.dwI},alphaTest:{value:0},uvTransform:{value:new i.dwI}},sprite:{diffuse:{value:new i.Q1f(16777215)},opacity:{value:1},center:{value:new i.I9Y(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new i.dwI},alphaMap:{value:null},alphaMapTransform:{value:new i.dwI},alphaTest:{value:0}}},c={basic:{uniforms:(0,i.Iit)([l.common,l.specularmap,l.envmap,l.aomap,l.lightmap,l.fog]),vertexShader:r.meshbasic_vert,fragmentShader:r.meshbasic_frag},lambert:{uniforms:(0,i.Iit)([l.common,l.specularmap,l.envmap,l.aomap,l.lightmap,l.emissivemap,l.bumpmap,l.normalmap,l.displacementmap,l.fog,l.lights,{emissive:{value:new i.Q1f(0)},envMapIntensity:{value:1}}]),vertexShader:r.meshlambert_vert,fragmentShader:r.meshlambert_frag},phong:{uniforms:(0,i.Iit)([l.common,l.specularmap,l.envmap,l.aomap,l.lightmap,l.emissivemap,l.bumpmap,l.normalmap,l.displacementmap,l.fog,l.lights,{emissive:{value:new i.Q1f(0)},specular:{value:new i.Q1f(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:r.meshphong_vert,fragmentShader:r.meshphong_frag},standard:{uniforms:(0,i.Iit)([l.common,l.envmap,l.aomap,l.lightmap,l.emissivemap,l.bumpmap,l.normalmap,l.displacementmap,l.roughnessmap,l.metalnessmap,l.fog,l.lights,{emissive:{value:new i.Q1f(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:r.meshphysical_vert,fragmentShader:r.meshphysical_frag},toon:{uniforms:(0,i.Iit)([l.common,l.aomap,l.lightmap,l.emissivemap,l.bumpmap,l.normalmap,l.displacementmap,l.gradientmap,l.fog,l.lights,{emissive:{value:new i.Q1f(0)}}]),vertexShader:r.meshtoon_vert,fragmentShader:r.meshtoon_frag},matcap:{uniforms:(0,i.Iit)([l.common,l.bumpmap,l.normalmap,l.displacementmap,l.fog,{matcap:{value:null}}]),vertexShader:r.meshmatcap_vert,fragmentShader:r.meshmatcap_frag},points:{uniforms:(0,i.Iit)([l.points,l.fog]),vertexShader:r.points_vert,fragmentShader:r.points_frag},dashed:{uniforms:(0,i.Iit)([l.common,l.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:r.linedashed_vert,fragmentShader:r.linedashed_frag},depth:{uniforms:(0,i.Iit)([l.common,l.displacementmap]),vertexShader:r.depth_vert,fragmentShader:r.depth_frag},normal:{uniforms:(0,i.Iit)([l.common,l.bumpmap,l.normalmap,l.displacementmap,{opacity:{value:1}}]),vertexShader:r.meshnormal_vert,fragmentShader:r.meshnormal_frag},sprite:{uniforms:(0,i.Iit)([l.sprite,l.fog]),vertexShader:r.sprite_vert,fragmentShader:r.sprite_frag},background:{uniforms:{uvTransform:{value:new i.dwI},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:r.background_vert,fragmentShader:r.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new i.dwI}},vertexShader:r.backgroundCube_vert,fragmentShader:r.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:r.cube_vert,fragmentShader:r.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:r.equirect_vert,fragmentShader:r.equirect_frag},distance:{uniforms:(0,i.Iit)([l.common,l.displacementmap,{referencePosition:{value:new i.Pq0},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:r.distance_vert,fragmentShader:r.distance_frag},shadow:{uniforms:(0,i.Iit)([l.lights,l.fog,{color:{value:new i.Q1f(0)},opacity:{value:1}}]),vertexShader:r.shadow_vert,fragmentShader:r.shadow_frag}};c.physical={uniforms:(0,i.Iit)([c.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new i.dwI},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new i.dwI},clearcoatNormalScale:{value:new i.I9Y(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new i.dwI},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new i.dwI},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new i.dwI},sheen:{value:0},sheenColor:{value:new i.Q1f(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new i.dwI},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new i.dwI},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new i.dwI},transmissionSamplerSize:{value:new i.I9Y},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new i.dwI},attenuationDistance:{value:0},attenuationColor:{value:new i.Q1f(0)},specularColor:{value:new i.Q1f(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new i.dwI},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new i.dwI},anisotropyVector:{value:new i.I9Y},anisotropyMap:{value:null},anisotropyMapTransform:{value:new i.dwI}}]),vertexShader:r.meshphysical_vert,fragmentShader:r.meshphysical_frag};const h={r:0,b:0,g:0},d=new i.kn4,u=new i.dwI;function p(e,t,n,a,s,o){const r=new i.Q1f(0);let l,p,m=!0===s?0:1,f=null,g=0,v=null;function b(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){const a=e.backgroundBlurriness>0;n=t.get(n,a)}return n}function y(t,a){t.getRGB(h,(0,i._Ut)(e)),n.buffers.color.setClear(h.r,h.g,h.b,a,o)}return{getClearColor:function(){return r},setClearColor:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;r.set(e),m=t,y(r,m)},getClearAlpha:function(){return m},setClearAlpha:function(e){m=e,y(r,m)},render:function(t){let a=!1;const i=b(t);null===i?y(r,m):i&&i.isColor&&(y(i,1),a=!0);const s=e.xr.getEnvironmentBlendMode();"additive"===s?n.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===s&&n.buffers.color.setClear(0,0,0,0,o),(e.autoClear||a)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const s=b(n);s&&(s.isCubeTexture||s.mapping===i.Om)?(void 0===p&&(p=new i.eaF(new i.iNn(1,1,1),new i.BKk({name:"BackgroundCubeMaterial",uniforms:(0,i.lxW)(c.backgroundCube.uniforms),vertexShader:c.backgroundCube.vertexShader,fragmentShader:c.backgroundCube.fragmentShader,side:i.hsX,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(p)),p.material.uniforms.envMap.value=s,p.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(d.makeRotationFromEuler(n.backgroundRotation)).transpose(),s.isCubeTexture&&!1===s.isRenderTargetTexture&&p.material.uniforms.backgroundRotation.value.premultiply(u),p.material.toneMapped=i.ppV.getTransfer(s.colorSpace)!==i.KLL,f===s&&g===s.version&&v===e.toneMapping||(p.material.needsUpdate=!0,f=s,g=s.version,v=e.toneMapping),p.layers.enableAll(),t.unshift(p,p.geometry,p.material,0,0,null)):s&&s.isTexture&&(void 0===l&&(l=new i.eaF(new i.bdM(2,2),new i.BKk({name:"BackgroundMaterial",uniforms:(0,i.lxW)(c.background.uniforms),vertexShader:c.background.vertexShader,fragmentShader:c.background.fragmentShader,side:i.hB5,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),l.material.uniforms.t2D.value=s,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=i.ppV.getTransfer(s.colorSpace)!==i.KLL,!0===s.matrixAutoUpdate&&s.updateMatrix(),l.material.uniforms.uvTransform.value.copy(s.matrix),f===s&&g===s.version&&v===e.toneMapping||(l.material.needsUpdate=!0,f=s,g=s.version,v=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==p&&(p.geometry.dispose(),p.material.dispose(),p=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function m(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),a={},s=h(null);let o=s,r=!1;function l(t){return e.bindVertexArray(t)}function c(t){return e.deleteVertexArray(t)}function h(e){const t=[],a=[],i=[];for(let s=0;s=0){const t=i[o];let n=s[o];if(void 0===n&&("instanceMatrix"===o&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===o&&e.instanceColor&&(n=e.instanceColor)),void 0===t)return!0;if(t.attribute!==n)return!0;if(n&&t.data!==n.data)return!0;r++}}return o.attributesNum!==r||o.index!==a}(n,g,c,v),b&&function(e,t,n,a){const i={},s=t.attributes;let r=0;const l=n.getAttributes();for(const o in l){if(l[o].location>=0){let t=s[o];void 0===t&&("instanceMatrix"===o&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===o&&e.instanceColor&&(t=e.instanceColor));const n={};n.attribute=t,t&&t.data&&(n.data=t.data),i[o]=n,r++}}o.attributes=i,o.attributesNum=r,o.index=a}(n,g,c,v),null!==v&&t.update(v,e.ELEMENT_ARRAY_BUFFER),(b||r)&&(r=!1,function(n,a,s,o){d();const r=o.attributes,l=s.getAttributes(),c=a.defaultAttributeValues;for(const h in l){const a=l[h];if(a.location>=0){let s=r[h];if(void 0===s&&("instanceMatrix"===h&&n.instanceMatrix&&(s=n.instanceMatrix),"instanceColor"===h&&n.instanceColor&&(s=n.instanceColor)),void 0!==s){const r=s.normalized,l=s.itemSize,c=t.get(s);if(void 0===c)continue;const h=c.buffer,d=c.type,m=c.bytesPerElement,g=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===i.Yuy;if(s.isInterleavedBufferAttribute){const t=s.data,i=t.stride,c=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let r=void 0!==n.precision?n.precision:"highp";const l=o(r);l!==r&&((0,i.R8M)("WebGLRenderer:",r,"not supported, using",l,"instead."),r=l);const c=!0===n.logarithmicDepthBuffer,h=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control");!0===n.reversedDepthBuffer&&!1===h&&(0,i.R8M)("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==s)return s;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");s=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision:o,textureFormatReadable:function(t){return t===i.GWd||a.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const s=n===i.ix0&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==i.OUM&&a.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==i.RQf&&!s)},precision:r,logarithmicDepthBuffer:c,reversedDepthBuffer:h,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function v(e){const t=this;let n=null,a=0,s=!1,o=!1;const r=new i.Zcv,l=new i.dwI,c={value:null,needsUpdate:!1};function h(e,n,a,i){const s=null!==e?e.length:0;let o=null;if(0!==s){if(o=c.value,!0!==i||null===o){const t=a+4*s,i=n.matrixWorldInverse;l.getNormalMatrix(i),(null===o||o.length0);t.numPlanes=a,t.numIntersection=0}();else{const e=o?0:a,t=4*e;let i=m.clippingState||null;c.value=i,i=h(d,r,t,l);for(let a=0;a!==t;++a)i[a]=n[a];m.clippingState=i,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=e}}}u.set(-1,0,0,0,1,0,0,0,1);const b=[.125,.215,.35,.446,.526,.582],y=20,w=new i.qUd,x=new i.Q1f;let S=null,k=0,_=0,T=!1;const R=new i.Pq0;class A{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=i.size,o=void 0===s?256:s,r=i.position,l=void 0===r?R:r;S=this._renderer.getRenderTarget(),k=this._renderer.getActiveCubeFace(),_=this._renderer.getActiveMipmapLevel(),T=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,a,c,l),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}fromCubemap(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=M(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=E(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=b[r-e+4-1]:0===r&&(l=0),n.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,m=6,f=3,g=2,v=1,y=new Float32Array(f*m*p),w=new Float32Array(g*m*p),x=new Float32Array(v*m*p);for(let e=0;e2?0:-1,a=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];y.set(a,f*m*e),w.set(u,g*m*e);const i=[e,e,e,e,e,e];x.set(i,v*m*e)}const S=new i.LoY;S.setAttribute("position",new i.THS(y,f)),S.setAttribute("uv",new i.THS(w,g)),S.setAttribute("faceIndex",new i.THS(x,v)),a.push(new i.eaF(S,null)),s>4&&s--}return{lodMeshes:a,sizeLods:t,sigmas:n}}(a);this._lodMeshes=s.lodMeshes,this._sizeLods=s.sizeLods,this._sigmas=s.sigmas,this._blurMaterial=function(e,t,n){const a=new Float32Array(y),s=new i.Pq0(0,1,0),o=new i.BKk({name:"SphericalGaussianBlur",defines:{n:y,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:"".concat(e,".0")},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:a},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:i.XIg,depthTest:!1,depthWrite:!1});return o}(a,e,t),this._ggxMaterial=function(e,t,n){const a=new i.BKk({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:"".concat(e,".0")},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:i.XIg,depthTest:!1,depthWrite:!1});return a}(a,e,t)}return a}_compileMaterial(e){const t=new i.eaF(new i.LoY,e);this._renderer.compile(t,w)}_sceneToCubeUV(e,t,n,a,s){const o=new i.ubm(90,1,t,n),r=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,d=c.toneMapping;c.getClearColor(x),c.toneMapping=i.y_p,c.autoClear=!1;c.state.buffers.depth.getReversed()&&(c.setRenderTarget(a),c.clearDepth(),c.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new i.eaF(new i.iNn,new i.V9B({name:"PMREM.Background",side:i.hsX,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,p=u.material;let m=!1;const f=e.background;f?f.isColor&&(p.color.copy(f),e.background=null,m=!0):(p.color.copy(x),m=!0);for(let i=0;i<6;i++){const t=i%3;0===t?(o.up.set(0,r[i],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+l[i],s.y,s.z)):1===t?(o.up.set(0,0,r[i]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+l[i],s.z)):(o.up.set(0,r[i],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+l[i]));const n=this._cubeSize;N(a,t*n,i>2?n:0,n,n),c.setRenderTarget(a),m&&c.render(u,o),c.render(e,o)}c.toneMapping=d,c.autoClear=h,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,a=e.mapping===i.hy7||e.mapping===i.xFO;a?(null===this._cubemapMaterial&&(this._cubemapMaterial=M()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=E());const s=a?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;s.uniforms.envMap.value=e;const r=this._cubeSize;N(t,0,0,3*r,2*r),n.setRenderTarget(t),n.render(o,w)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const a=this._lodMeshes.length;for(let i=1;id-4?n-d+4:0),m=4*(this._cubeSize-u);r.envMap.value=e.texture,r.roughness.value=h,r.mipInt.value=d-t,N(i,p,m,3*u,2*u),a.setRenderTarget(i),a.render(o,w),r.envMap.value=i.texture,r.roughness.value=0,r.mipInt.value=d-n,N(e,p,m,3*u,2*u),a.setRenderTarget(e),a.render(o,w)}_blur(e,t,n,a,i){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,n,a,"latitudinal",i),this._halfBlur(s,e,n,n,a,"longitudinal",i)}_halfBlur(e,t,n,a,s,o,r){const l=this._renderer,c=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&(0,i.z3S)("blur direction must be either latitudinal or longitudinal!");const h=this._lodMeshes[a];h.material=c;const d=c.uniforms,u=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*u):2*Math.PI/39,m=s/p,f=isFinite(s)?1+Math.floor(3*m):y;f>y&&(0,i.R8M)("sigmaRadians, ".concat(s,", is too large and will clip, as it requested ").concat(f," samples when the maximum is set to ").concat(y));const g=[];let v=0;for(let i=0;ib-4?a-b+4:0),4*(this._cubeSize-x),3*x,2*x),l.setRenderTarget(t),l.render(h,w)}}function C(e,t,n){const a=new i.nWS(e,t,n);return a.texture.mapping=i.Om,a.texture.name="PMREM.cubeUv",a.scissorTest=!0,a}function N(e,t,n,a,i){e.viewport.set(t,n,a,i),e.scissor.set(t,n,a,i)}function E(){return new i.BKk({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:i.XIg,depthTest:!1,depthWrite:!1})}function M(){return new i.BKk({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:i.XIg,depthTest:!1,depthWrite:!1})}class L extends i.nWS{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},a=[n,n,n,n,n,n];this.texture=new i.b4q(a),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},a="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",s="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",o=new i.iNn(5,5,5),r=new i.BKk({name:"CubemapFromEquirect",uniforms:(0,i.lxW)(n),vertexShader:a,fragmentShader:s,side:i.hsX,blending:i.XIg});r.uniforms.tEquirect.value=t;const l=new i.eaF(o,r),c=t.minFilter;t.minFilter===i.$_I&&(t.minFilter=i.k6q);return new i.F1T(1,10,this).update(e,l),t.minFilter=c,l.geometry.dispose(),l.material.dispose(),this}clear(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const i=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,a);e.setRenderTarget(i)}}function I(e){let t=new WeakMap,n=new WeakMap,a=null;function s(e,t){return t===i.wfO?e.mapping=i.hy7:t===i.uV5&&(e.mapping=i.xFO),e}function o(e){const n=e.target;n.removeEventListener("dispose",o);const a=t.get(n);void 0!==a&&(t.delete(n),a.dispose())}function r(e){const t=e.target;t.removeEventListener("dispose",r);const a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}return{get:function(l){return null===l||void 0===l?null:arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(t){if(t&&t.isTexture){const s=t.mapping,o=s===i.wfO||s===i.uV5,l=s===i.hy7||s===i.xFO;if(o||l){let i=n.get(t);const s=void 0!==i?i.texture.pmremVersion:0;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return null===a&&(a=new A(e)),i=o?a.fromEquirectangular(t,i):a.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(void 0!==i)return i.texture;{const s=t.image;return o&&s&&s.height>0||l&&s&&function(e){let t=0;const n=6;for(let a=0;a0){const i=new L(a.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener("dispose",o),s(i.texture,n.mapping)}return null}}}return n}(l)},dispose:function(){t=new WeakMap,n=new WeakMap,null!==a&&(a.dispose(),a=null)}}}function X(e){const t={};function n(n){if(void 0!==t[n])return t[n];const a=e.getExtension(n);return t[n]=a,a}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&(0,i.mcG)("WebGLRenderer: "+e+" extension not supported."),t}}}function P(e,t,n,a){const s={},o=new WeakMap;function r(e){const i=e.target;null!==i.index&&t.remove(i.index);for(const n in i.attributes)t.remove(i.attributes[n]);i.removeEventListener("dispose",r),delete s[i.id];const l=o.get(i);l&&(t.remove(l),o.delete(i)),a.releaseStatesOfGeometry(i),!0===i.isInstancedBufferGeometry&&delete i._maxInstanceCount,n.memory.geometries--}function l(e){const n=[],a=e.index,s=e.attributes.position;let r=0;if(void 0===s)return;if(null!==a){const e=a.array;r=a.version;for(let t=0,a=e.length;t=65535?i.MW4:i.A$4)(n,1);l.version=r;const c=o.get(e);c&&t.remove(c),o.set(e,l)}return{get:function(e,t){return!0===s[t.id]||(t.addEventListener("dispose",r),s[t.id]=!0,n.memory.geometries++),t},update:function(n){const a=n.attributes;for(const i in a)t.update(a[i],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.versiont.maxTextureSize&&(x=Math.ceil(w/t.maxTextureSize),w=t.maxTextureSize);const S=new Float32Array(w*x*4*d),k=new i.rFo(S,w,x,d);k.type=i.RQf,k.needsUpdate=!0;const _=4*y;for(let R=0;R\n\t\t\t#include \n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),d=new i.eaF(c,h),u=new i.qUd(-1,1,1,-1,0,1);let p,m=null,f=null,g=!1,v=null,b=[],y=!1;this.setSize=function(e,t){r.setSize(e,t),l.setSize(e,t);for(let n=0;n0&&!0===b[0].isRenderPass;const t=r.width,n=r.height;for(let a=0;a0)return e;const i=t*n;let s=O[i];if(void 0===s&&(s=new Float32Array(i),O[i]=s),0!==t){a.toArray(s,0);for(let a=1,i=0;a!==t;++a)i+=n,e[a].toArray(s,i)}return s}function $(e,t){if(e.length!==t.length)return!1;for(let n=0,a=e.length;n0&&(this.seq=a.concat(i))}setValue(e,t,n,a){const i=this.map[t];void 0!==i&&i.setValue(e,n,a)}setOptional(e,t,n){const a=t[n];void 0!==a&&this.setValue(e,n,a)}static upload(e,t,n,a){for(let i=0,s=t.length;i!==s;++i){const s=t[i],o=n[s.id];!1!==o.needsUpdate&&s.setValue(e,o.value,a)}}static seqWithValue(e,t){const n=[];for(let a=0,i=e.length;a!==i;++a){const i=e[a];i.id in t&&n.push(i)}return n}}function Oe(e,t,n){const a=e.createShader(t);return e.shaderSource(a,n),e.compileShader(a),a}let ze=0;const Je=new i.dwI;function Ke(e,t,n){const a=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(a&&""===i)return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),a=[],i=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=i;o":" "," ").concat(e,": ").concat(n[o]))}return a.join("\n")}(e.getShaderSource(t),a)}return i}function Qe(e,t){const n=function(e){i.ppV._getMatrix(Je,i.ppV.workingColorSpace,e);const t="mat3( ".concat(Je.elements.map((e=>e.toFixed(4)))," )");switch(i.ppV.getTransfer(e)){case i.VxR:return[t,"LinearTransferOETF"];case i.KLL:return[t,"sRGBTransferOETF"];default:return(0,i.R8M)("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return["vec4 ".concat(e,"( vec4 value ) {"),"\treturn ".concat(n[1],"( vec4( value.rgb * ").concat(n[0],", value.a ) );"),"}"].join("\n")}const qe={[i.kyO]:"Linear",[i.Mjd]:"Reinhard",[i.nNL]:"Cineon",[i.FV]:"ACESFilmic",[i.LAk]:"AgX",[i.aJ8]:"Neutral",[i.g7M]:"Custom"};function $e(e,t){const n=qe[t];return void 0===n?((0,i.R8M)("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const et=new i.Pq0;function tt(){i.ppV.getLuminanceCoefficients(et);const e=et.x.toFixed(4),t=et.y.toFixed(4),n=et.z.toFixed(4);return["float luminance( const in vec3 rgb ) {","\tconst vec3 weights = vec3( ".concat(e,", ").concat(t,", ").concat(n," );"),"\treturn dot( weights, rgb );","}"].join("\n")}function nt(e){return""!==e}function at(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function it(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const st=/^[ \t]*#include +<([\w\d./]+)>/gm;function ot(e){return e.replace(st,lt)}const rt=new Map;function lt(e,t){let n=r[t];if(void 0===n){const e=rt.get(t);if(void 0===e)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">");n=r[e],(0,i.R8M)('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return ot(n)}const ct=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ht(e){return e.replace(ct,dt)}function dt(e,t,n,a){let i="";for(let s=parseInt(t);s0&&(b+="\n"),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(nt).join("\n"),y.length>0&&(y+="\n")):(b=[ut(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(nt).join("\n"),y=[ut(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.envMap?"#define "+u:"",n.envMap?"#define "+p:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==i.y_p?"#define TONE_MAPPING":"",n.toneMapping!==i.y_p?r.tonemapping_pars_fragment:"",n.toneMapping!==i.y_p?$e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",r.colorspace_pars_fragment,Qe("linearToOutputTexel",n.outputColorSpace),tt(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(nt).join("\n")),l=ot(l),l=at(l,n),l=it(l,n),c=ot(c),c=at(c,n),c=it(c,n),l=ht(l),c=ht(c),!0!==n.isRawShaderMaterial&&(w="#version 300 es\n",b=[f,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+b,y=["#define varying in",n.glslVersion===i.Wdf?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===i.Wdf?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+y);const x=w+b+l,S=w+y+c,k=Oe(s,s.VERTEX_SHADER,x),_=Oe(s,s.FRAGMENT_SHADER,S);function T(t){if(e.debug.checkShaderErrors){const n=s.getProgramInfoLog(v)||"",a=s.getShaderInfoLog(k)||"",o=s.getShaderInfoLog(_)||"",r=n.trim(),l=a.trim(),c=o.trim();let h=!0,d=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS))if(h=!1,"function"===typeof e.debug.onShaderError)e.debug.onShaderError(s,v,k,_);else{const e=Ke(s,k,"vertex"),n=Ke(s,_,"fragment");(0,i.z3S)("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+r+"\n"+e+"\n"+n)}else""!==r?(0,i.R8M)("WebGLProgram: Program Info Log:",r):""!==l&&""!==c||(d=!1);d&&(t.diagnostics={runnable:h,programLog:r,vertexShader:{log:l,prefix:b},fragmentShader:{log:c,prefix:y}})}s.deleteShader(k),s.deleteShader(_),R=new Ye(s,v),A=function(e,t){const n={},a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i0,J=s.clearcoat>0,K=s.dispersion>0,Q=s.iridescence>0,q=s.sheen>0,$=s.transmission>0,ee=z&&!!s.anisotropyMap,te=J&&!!s.clearcoatMap,ne=J&&!!s.clearcoatNormalMap,ae=J&&!!s.clearcoatRoughnessMap,ie=Q&&!!s.iridescenceMap,se=Q&&!!s.iridescenceThicknessMap,oe=q&&!!s.sheenColorMap,re=q&&!!s.sheenRoughnessMap,le=!!s.specularMap,ce=!!s.specularColorMap,he=!!s.specularIntensityMap,de=$&&!!s.transmissionMap,ue=$&&!!s.thicknessMap,pe=!!s.gradientMap,me=!!s.alphaMap,fe=s.alphaTest>0,ge=!!s.alphaHash,ve=!!s.extensions;let be=i.y_p;s.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(be=e.toneMapping));const ye={shaderID:T,shaderType:s.type,shaderName:s.name,vertexShader:C,fragmentShader:N,defines:s.defines,customVertexShaderID:E,customFragmentShaderID:M,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:m,batching:W,batchingColor:W&&null!==v._colorsTexture,instancing:P,instancingColor:P&&null!==v.instanceColor,instancingMorph:P&&null!==v.morphTexture,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:i.ppV.workingColorSpace,alphaToCoverage:!!s.alphaToCoverage,map:G,matcap:j,envMap:V,envMapMode:V&&k.mapping,envMapCubeUVHeight:_,aoMap:Z,lightMap:F,bumpMap:D,normalMap:B,displacementMap:H,emissiveMap:U,normalMapObjectSpace:B&&s.normalMapType===i.vyJ,normalMapTangentSpace:B&&s.normalMapType===i.bI3,packedNormalMap:B&&s.normalMapType===i.bI3&&(we=s.normalMap.format,we===i.paN||we===i.OtU||we===i.HO_),metalnessMap:Y,roughnessMap:O,anisotropy:z,anisotropyMap:ee,clearcoat:J,clearcoatMap:te,clearcoatNormalMap:ne,clearcoatRoughnessMap:ae,dispersion:K,iridescence:Q,iridescenceMap:ie,iridescenceThicknessMap:se,sheen:q,sheenColorMap:oe,sheenRoughnessMap:re,specularMap:le,specularColorMap:ce,specularIntensityMap:he,transmission:$,transmissionMap:de,thicknessMap:ue,gradientMap:pe,opaque:!1===s.transparent&&s.blending===i.NTi&&!1===s.alphaToCoverage,alphaMap:me,alphaTest:fe,alphaHash:ge,combine:s.combine,mapUv:G&&g(s.map.channel),aoMapUv:Z&&g(s.aoMap.channel),lightMapUv:F&&g(s.lightMap.channel),bumpMapUv:D&&g(s.bumpMap.channel),normalMapUv:B&&g(s.normalMap.channel),displacementMapUv:H&&g(s.displacementMap.channel),emissiveMapUv:U&&g(s.emissiveMap.channel),metalnessMapUv:Y&&g(s.metalnessMap.channel),roughnessMapUv:O&&g(s.roughnessMap.channel),anisotropyMapUv:ee&&g(s.anisotropyMap.channel),clearcoatMapUv:te&&g(s.clearcoatMap.channel),clearcoatNormalMapUv:ne&&g(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&g(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&g(s.iridescenceMap.channel),iridescenceThicknessMapUv:se&&g(s.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&g(s.sheenColorMap.channel),sheenRoughnessMapUv:re&&g(s.sheenRoughnessMap.channel),specularMapUv:le&&g(s.specularMap.channel),specularColorMapUv:ce&&g(s.specularColorMap.channel),specularIntensityMapUv:he&&g(s.specularIntensityMap.channel),transmissionMapUv:de&&g(s.transmissionMap.channel),thicknessMapUv:ue&&g(s.thicknessMap.channel),alphaMapUv:me&&g(s.alphaMap.channel),vertexTangents:!!w.attributes.tangent&&(B||z),vertexNormals:!!w.attributes.normal,vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!w.attributes.color&&4===w.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!w.attributes.uv&&(G||me),fog:!!y,useFog:!0===s.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!1===s.wireframe&&(!0===s.flatShading||void 0===w.attributes.normal&&!1===B&&(s.isMeshLambertMaterial||s.isMeshPhongMaterial||s.isMeshStandardMaterial||s.isMeshPhysicalMaterial)),sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:p,reversedDepthBuffer:X,skinning:!0===v.isSkinnedMesh,hasPositionAttribute:void 0!==w.attributes.position,morphTargets:void 0!==w.morphAttributes.position,morphNormals:void 0!==w.morphAttributes.normal,morphColors:void 0!==w.morphAttributes.color,morphTargetsCount:A,morphTextureStride:L,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numSpotLightMaps:r.spotLightMap.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numSpotLightShadowsWithMaps:r.numSpotLightShadowsWithMaps,numLightProbes:r.numLightProbes,numLightProbeGrids:b.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&d.length>0,shadowMapType:e.shadowMap.type,toneMapping:be,decodeVideoTexture:G&&!0===s.map.isVideoTexture&&i.ppV.getTransfer(s.map.colorSpace)===i.KLL,decodeVideoTextureEmissive:U&&!0===s.emissiveMap.isVideoTexture&&i.ppV.getTransfer(s.emissiveMap.colorSpace)===i.KLL,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===i.$EB,flipSided:s.side===i.hsX,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:ve&&!0===s.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&!0===s.extensions.multiDraw||W)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};var we;return ye.vertexUv1s=h.has(1),ye.vertexUv2s=h.has(2),ye.vertexUv3s=h.has(3),h.clear(),ye},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){r.disableAll(),t.instancing&&r.enable(0);t.instancingColor&&r.enable(1);t.instancingMorph&&r.enable(2);t.matcap&&r.enable(3);t.envMap&&r.enable(4);t.normalMapObjectSpace&&r.enable(5);t.normalMapTangentSpace&&r.enable(6);t.clearcoat&&r.enable(7);t.iridescence&&r.enable(8);t.alphaTest&&r.enable(9);t.vertexColors&&r.enable(10);t.vertexAlphas&&r.enable(11);t.vertexUv1s&&r.enable(12);t.vertexUv2s&&r.enable(13);t.vertexUv3s&&r.enable(14);t.vertexTangents&&r.enable(15);t.anisotropy&&r.enable(16);t.alphaHash&&r.enable(17);t.batching&&r.enable(18);t.dispersion&&r.enable(19);t.batchingColor&&r.enable(20);t.gradientMap&&r.enable(21);t.packedNormalMap&&r.enable(22);t.vertexNormals&&r.enable(23);e.push(r.mask),r.disableAll(),t.fog&&r.enable(0);t.useFog&&r.enable(1);t.flatShading&&r.enable(2);t.logarithmicDepthBuffer&&r.enable(3);t.reversedDepthBuffer&&r.enable(4);t.skinning&&r.enable(5);t.morphTargets&&r.enable(6);t.morphNormals&&r.enable(7);t.morphColors&&r.enable(8);t.premultipliedAlpha&&r.enable(9);t.shadowMapEnabled&&r.enable(10);t.doubleSided&&r.enable(11);t.flipSided&&r.enable(12);t.useDepthPacking&&r.enable(13);t.dithering&&r.enable(14);t.transmission&&r.enable(15);t.sheen&&r.enable(16);t.opaque&&r.enable(17);t.pointsUvs&&r.enable(18);t.decodeVideoTexture&&r.enable(19);t.decodeVideoTextureEmissive&&r.enable(20);t.alphaToCoverage&&r.enable(21);t.numLightProbeGrids>0&&r.enable(22);t.hasPositionAttribute&&r.enable(23);e.push(r.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=c[t];n=i.LlO.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let a=u.get(n);return void 0!==a?++a.usedTimes:(a=new vt(e,n,t,s),d.push(a),u.set(n,a)),a},releaseProgram:function(e){if(0===--e.usedTimes){const t=d.indexOf(e);d[t]=d[d.length-1],d.pop(),u.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:d,dispose:function(){l.dispose()}}}function St(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,a){e.get(t)[n]=a},dispose:function(){e=new WeakMap}}}function kt(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function _t(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Tt(){const e=[];let t=0;const n=[],a=[],i=[];function s(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(n,a,i,o,r,l){let c=e[t];return void 0===c?(c={id:n.id,object:n,geometry:a,material:i,materialVariant:s(n),groupOrder:o,renderOrder:n.renderOrder,z:r,group:l},e[t]=c):(c.id=n.id,c.object=n,c.geometry=a,c.material=i,c.materialVariant=s(n),c.groupOrder=o,c.renderOrder=n.renderOrder,c.z=r,c.group=l),t++,c}return{opaque:n,transmissive:a,transparent:i,init:function(){t=0,n.length=0,a.length=0,i.length=0},push:function(e,t,s,r,l,c){const h=o(e,t,s,r,l,c);s.transmission>0?a.push(h):!0===s.transparent?i.push(h):n.push(h)},unshift:function(e,t,s,r,l,c){const h=o(e,t,s,r,l,c);s.transmission>0?a.unshift(h):!0===s.transparent?i.unshift(h):n.unshift(h)},finish:function(){for(let n=t,a=e.length;n1&&n.sort(e||kt),a.length>1&&a.sort(t||_t),i.length>1&&i.sort(t||_t),s&&(n.reverse(),a.reverse(),i.reverse())}}}function Rt(){let e=new WeakMap;return{get:function(t,n){const a=e.get(t);let i;return void 0===a?(i=new Tt,e.set(t,[i])):n>=a.length?(i=new Tt,a.push(i)):i=a[n],i},dispose:function(){e=new WeakMap}}}function At(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new i.Pq0,color:new i.Q1f};break;case"SpotLight":n={position:new i.Pq0,direction:new i.Pq0,color:new i.Q1f,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new i.Pq0,color:new i.Q1f,distance:0,decay:0};break;case"HemisphereLight":n={direction:new i.Pq0,skyColor:new i.Q1f,groundColor:new i.Q1f};break;case"RectAreaLight":n={color:new i.Q1f,position:new i.Pq0,halfWidth:new i.Pq0,halfHeight:new i.Pq0}}return e[t.id]=n,n}}}let Ct=0;function Nt(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Et(e){const t=new At,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new i.I9Y};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new i.I9Y,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)a.probe.push(new i.Pq0);const s=new i.Pq0,o=new i.kn4,r=new i.kn4;return{setup:function(s){let o=0,r=0,c=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let h=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,b=0,y=0,w=0;s.sort(Nt);for(let e=0,l=s.length;e0&&(!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=l.LTC_FLOAT_1,a.rectAreaLTC2=l.LTC_FLOAT_2):(a.rectAreaLTC1=l.LTC_HALF_1,a.rectAreaLTC2=l.LTC_HALF_2)),a.ambient[0]=o,a.ambient[1]=r,a.ambient[2]=c;const x=a.hash;x.directionalLength===h&&x.pointLength===d&&x.spotLength===u&&x.rectAreaLength===p&&x.hemiLength===m&&x.numDirectionalShadows===f&&x.numPointShadows===g&&x.numSpotShadows===v&&x.numSpotMaps===b&&x.numLightProbes===w||(a.directional.length=h,a.spot.length=u,a.rectArea.length=p,a.point.length=d,a.hemi.length=m,a.directionalShadow.length=f,a.directionalShadowMap.length=f,a.pointShadow.length=g,a.pointShadowMap.length=g,a.spotShadow.length=v,a.spotShadowMap.length=v,a.directionalShadowMatrix.length=f,a.pointShadowMatrix.length=g,a.spotLightMatrix.length=v+b-y,a.spotLightMap.length=b,a.numSpotLightShadowsWithMaps=y,a.numLightProbes=w,x.directionalLength=h,x.pointLength=d,x.spotLength=u,x.rectAreaLength=p,x.hemiLength=m,x.numDirectionalShadows=f,x.numPointShadows=g,x.numSpotShadows=v,x.numSpotMaps=b,x.numLightProbes=w,a.version=Ct++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const d=t.matrixWorldInverse;for(let u=0,p=e.length;u1&&void 0!==arguments[1]?arguments[1]:0;const i=t.get(n);let s;return void 0===i?(s=new Mt(e),t.set(n,[s])):a>=i.length?(s=new Mt(e),i.push(s)):s=i[a],s},dispose:function(){t=new WeakMap}}}const It=[new i.Pq0(1,0,0),new i.Pq0(-1,0,0),new i.Pq0(0,1,0),new i.Pq0(0,-1,0),new i.Pq0(0,0,1),new i.Pq0(0,0,-1)],Xt=[new i.Pq0(0,-1,0),new i.Pq0(0,-1,0),new i.Pq0(0,0,1),new i.Pq0(0,0,-1),new i.Pq0(0,-1,0),new i.Pq0(0,-1,0)],Pt=new i.kn4,Wt=new i.Pq0,Gt=new i.Pq0;function jt(e,t,n){let a=new i.PPD;const s=new i.I9Y,o=new i.I9Y,r=new i.IUQ,l=new i.CSG,c=new i.aVO,h={},d=n.maxTextureSize,u={[i.hB5]:i.hsX,[i.hsX]:i.hB5,[i.$EB]:i.$EB},p=new i.BKk({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new i.I9Y},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const f=new i.LoY;f.setAttribute("position",new i.THS(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new i.eaF(f,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=i.QP0;let b=this.type;function y(n,a){const o=t.update(g);p.defines.VSM_SAMPLES!==n.blurSamples&&(p.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new i.nWS(s.x,s.y,{format:i.paN,type:i.ix0})),p.uniforms.shadow_pass.value=n.map.depthTexture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(a,null,o,p,g,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(a,null,o,m,g,null)}function w(t,n,a,s){let o=null;const r=!0===a.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==r)o=r;else if(o=!0===a.isPointLight?c:l,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=o.uuid,t=n.uuid;let a=h[e];void 0===a&&(a={},h[e]=a);let i=a[t];void 0===i&&(i=o.clone(),a[t]=i,n.addEventListener("dispose",S)),o=i}if(o.visible=n.visible,o.wireframe=n.wireframe,s===i.RyA?o.side=null!==n.shadowSide?n.shadowSide:n.side:o.side=null!==n.shadowSide?n.shadowSide:u[n.side],o.alphaMap=n.alphaMap,o.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,o.map=n.map,o.clipShadows=n.clipShadows,o.clippingPlanes=n.clippingPlanes,o.clipIntersection=n.clipIntersection,o.displacementMap=n.displacementMap,o.displacementScale=n.displacementScale,o.displacementBias=n.displacementBias,o.wireframeLinewidth=n.wireframeLinewidth,o.linewidth=n.linewidth,!0===a.isPointLight&&!0===o.isMeshDistanceMaterial){e.properties.get(o).light=a}return o}function x(n,s,o,r,l){if(!1===n.visible)return;if(n.layers.test(s.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===i.RyA)&&(!n.frustumCulled||a.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const a=t.update(n),i=n.material;if(Array.isArray(i)){const t=a.groups;for(let c=0,h=t.length;ce.needsUpdate=!0)):e.material.needsUpdate=!0)}));for(let f=0,g=t.length;fd||s.y>d)&&(s.x>d&&(o.x=Math.floor(d/u.x),s.x=o.x*u.x,h.mapSize.x=o.x),s.y>d&&(o.y=Math.floor(d/u.y),s.y=o.y*u.y,h.mapSize.y=o.y));const g=e.state.buffers.depth.getReversed();if(h.camera._reversedDepth=g,null===h.map||!0===m){if(null!==h.map&&(null!==h.map.depthTexture&&(h.map.depthTexture.dispose(),h.map.depthTexture=null),h.map.dispose()),this.type===i.RyA){if(c.isPointLight){(0,i.R8M)("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}h.map=new i.nWS(s.x,s.y,{format:i.paN,type:i.ix0,minFilter:i.k6q,magFilter:i.k6q,generateMipmaps:!1}),h.map.texture.name=c.name+".shadowMap",h.map.depthTexture=new i.VCu(s.x,s.y,i.RQf),h.map.depthTexture.name=c.name+".shadowMapDepth",h.map.depthTexture.format=i.zdS,h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=i.hxR,h.map.depthTexture.magFilter=i.hxR}else c.isPointLight?(h.map=new L(s.x),h.map.depthTexture=new i.Gc6(s.x,i.bkx)):(h.map=new i.nWS(s.x,s.y),h.map.depthTexture=new i.VCu(s.x,s.y,i.bkx)),h.map.depthTexture.name=c.name+".shadowMap",h.map.depthTexture.format=i.zdS,this.type===i.QP0?(h.map.depthTexture.compareFunction=g?i.gWB:i.TiK,h.map.depthTexture.minFilter=i.k6q,h.map.depthTexture.magFilter=i.k6q):(h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=i.hxR,h.map.depthTexture.magFilter=i.hxR);h.camera.updateProjectionMatrix()}const v=h.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t=1):-1!==I.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(I)[1]),M=L>=2);let X=null,P={};const W=e.getParameter(e.SCISSOR_BOX),G=e.getParameter(e.VIEWPORT),j=(new i.IUQ).fromArray(W),V=(new i.IUQ).fromArray(G);function Z(t,n,a,i){const s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let r=0;rn||s.height>n)&&(a=n/Math.max(s.width,s.height)),a<1){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!==typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(a*s.width),o=Math.floor(a*s.height);void 0===p&&(p=g(n,o));const r=t?g(n,o):p;r.width=n,r.height=o;return r.getContext("2d").drawImage(e,0,0,n,o),(0,i.R8M)("WebGLRenderer: Texture has been resized from ("+s.width+"x"+s.height+") to ("+n+"x"+o+")."),r}return"data"in e&&(0,i.R8M)("WebGLRenderer: Image in DataTexture is too big ("+s.width+"x"+s.height+")."),e}return e}function b(e){return e.generateMipmaps}function y(t){e.generateMipmap(t)}function w(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function x(n,a,s,o,r){let l,c=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(null!==n){if(void 0!==e[n])return e[n];(0,i.R8M)("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}o&&(l=t.get("EXT_texture_norm16"),l||(0,i.R8M)("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let h=a;if(a===e.RED&&(s===e.FLOAT&&(h=e.R32F),s===e.HALF_FLOAT&&(h=e.R16F),s===e.UNSIGNED_BYTE&&(h=e.R8),s===e.UNSIGNED_SHORT&&l&&(h=l.R16_EXT),s===e.SHORT&&l&&(h=l.R16_SNORM_EXT)),a===e.RED_INTEGER&&(s===e.UNSIGNED_BYTE&&(h=e.R8UI),s===e.UNSIGNED_SHORT&&(h=e.R16UI),s===e.UNSIGNED_INT&&(h=e.R32UI),s===e.BYTE&&(h=e.R8I),s===e.SHORT&&(h=e.R16I),s===e.INT&&(h=e.R32I)),a===e.RG&&(s===e.FLOAT&&(h=e.RG32F),s===e.HALF_FLOAT&&(h=e.RG16F),s===e.UNSIGNED_BYTE&&(h=e.RG8),s===e.UNSIGNED_SHORT&&l&&(h=l.RG16_EXT),s===e.SHORT&&l&&(h=l.RG16_SNORM_EXT)),a===e.RG_INTEGER&&(s===e.UNSIGNED_BYTE&&(h=e.RG8UI),s===e.UNSIGNED_SHORT&&(h=e.RG16UI),s===e.UNSIGNED_INT&&(h=e.RG32UI),s===e.BYTE&&(h=e.RG8I),s===e.SHORT&&(h=e.RG16I),s===e.INT&&(h=e.RG32I)),a===e.RGB_INTEGER&&(s===e.UNSIGNED_BYTE&&(h=e.RGB8UI),s===e.UNSIGNED_SHORT&&(h=e.RGB16UI),s===e.UNSIGNED_INT&&(h=e.RGB32UI),s===e.BYTE&&(h=e.RGB8I),s===e.SHORT&&(h=e.RGB16I),s===e.INT&&(h=e.RGB32I)),a===e.RGBA_INTEGER&&(s===e.UNSIGNED_BYTE&&(h=e.RGBA8UI),s===e.UNSIGNED_SHORT&&(h=e.RGBA16UI),s===e.UNSIGNED_INT&&(h=e.RGBA32UI),s===e.BYTE&&(h=e.RGBA8I),s===e.SHORT&&(h=e.RGBA16I),s===e.INT&&(h=e.RGBA32I)),a===e.RGB&&(s===e.UNSIGNED_SHORT&&l&&(h=l.RGB16_EXT),s===e.SHORT&&l&&(h=l.RGB16_SNORM_EXT),s===e.UNSIGNED_INT_5_9_9_9_REV&&(h=e.RGB9_E5),s===e.UNSIGNED_INT_10F_11F_11F_REV&&(h=e.R11F_G11F_B10F)),a===e.RGBA){const t=c?i.VxR:i.ppV.getTransfer(r);s===e.FLOAT&&(h=e.RGBA32F),s===e.HALF_FLOAT&&(h=e.RGBA16F),s===e.UNSIGNED_BYTE&&(h=t===i.KLL?e.SRGB8_ALPHA8:e.RGBA8),s===e.UNSIGNED_SHORT&&l&&(h=l.RGBA16_EXT),s===e.SHORT&&l&&(h=l.RGBA16_SNORM_EXT),s===e.UNSIGNED_SHORT_4_4_4_4&&(h=e.RGBA4),s===e.UNSIGNED_SHORT_5_5_5_1&&(h=e.RGB5_A1)}return h!==e.R16F&&h!==e.R32F&&h!==e.RG16F&&h!==e.RG32F&&h!==e.RGBA16F&&h!==e.RGBA32F||t.get("EXT_color_buffer_float"),h}function S(t,n){let a;return t?null===n||n===i.bkx||n===i.V3x?a=e.DEPTH24_STENCIL8:n===i.RQf?a=e.DEPTH32F_STENCIL8:n===i.cHt&&(a=e.DEPTH24_STENCIL8,(0,i.R8M)("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===i.bkx||n===i.V3x?a=e.DEPTH_COMPONENT24:n===i.RQf?a=e.DEPTH_COMPONENT32F:n===i.cHt&&(a=e.DEPTH_COMPONENT16),a}function k(e,t){return!0===b(e)||e.isFramebufferTexture&&e.minFilter!==i.hxR&&e.minFilter!==i.k6q?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function _(e){const t=e.target;t.removeEventListener("dispose",_),function(e){const t=a.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=m.get(n);if(i){const a=i[t.__cacheKey];a.usedTimes--,0===a.usedTimes&&R(e),0===Object.keys(i).length&&m.delete(n)}a.remove(e)}(t),t.isVideoTexture&&d.delete(t),t.isHTMLTexture&&u.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=a.get(t);t.depthTexture&&(t.depthTexture.dispose(),a.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let a=0;a<6;a++){if(Array.isArray(n.__webglFramebuffer[a]))for(let t=0;t0&&o.__version!==t.version){const e=t.image;if(null===e)(0,i.R8M)("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void P(o,t,s);(0,i.R8M)("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(o.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,o.__webglTexture,e.TEXTURE0+s)}const N={[i.GJx]:e.REPEAT,[i.ghU]:e.CLAMP_TO_EDGE,[i.kTW]:e.MIRRORED_REPEAT},E={[i.hxR]:e.NEAREST,[i.pHI]:e.NEAREST_MIPMAP_NEAREST,[i.Cfg]:e.NEAREST_MIPMAP_LINEAR,[i.k6q]:e.LINEAR,[i.kRr]:e.LINEAR_MIPMAP_NEAREST,[i.$_I]:e.LINEAR_MIPMAP_LINEAR},M={[i.amv]:e.NEVER,[i.FFZ]:e.ALWAYS,[i.vim]:e.LESS,[i.TiK]:e.LEQUAL,[i.kO0]:e.EQUAL,[i.gWB]:e.GEQUAL,[i.eoi]:e.GREATER,[i.jzd]:e.NOTEQUAL};function L(n,o){if(o.type!==i.RQf||!1!==t.has("OES_texture_float_linear")||o.magFilter!==i.k6q&&o.magFilter!==i.kRr&&o.magFilter!==i.Cfg&&o.magFilter!==i.$_I&&o.minFilter!==i.k6q&&o.minFilter!==i.kRr&&o.minFilter!==i.Cfg&&o.minFilter!==i.$_I||(0,i.R8M)("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,N[o.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,N[o.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,N[o.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E[o.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E[o.minFilter]),o.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,M[o.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(o.magFilter===i.hxR)return;if(o.minFilter!==i.Cfg&&o.minFilter!==i.$_I)return;if(o.type===i.RQf&&!1===t.has("OES_texture_float_linear"))return;if(o.anisotropy>1||a.get(o).__currentAnisotropy){const i=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,i.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,s.getMaxAnisotropy())),a.get(o).__currentAnisotropy=o.anisotropy}}}function I(t,n){let a=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",_));const i=n.source;let s=m.get(i);void 0===s&&(s={},m.set(i,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},r.memory.textures++,a=!0),s[o].usedTimes++;const i=s[t.__cacheKey];void 0!==i&&(s[t.__cacheKey].usedTimes--,0===i.usedTimes&&R(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return a}function X(e,t,n){return Math.floor(Math.floor(e/n)/t)}function P(t,r,l){let c=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(c=e.TEXTURE_3D);const h=I(t,r),d=r.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+l);const p=a.get(d);if(d.version!==p.__version||!0===h){n.activeTexture(e.TEXTURE0+l);if(!1===("undefined"!==typeof ImageBitmap&&r.image instanceof ImageBitmap)){const t=i.ppV.getPrimaries(i.ppV.workingColorSpace),a=r.colorSpace===i.jf0?null:i.ppV.getPrimaries(r.colorSpace),s=r.colorSpace===i.jf0||t===a?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,s)}n.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment);let t=v(r.image,!1,s.maxTextureSize);t=H(r,t);const a=o.convert(r.format,r.colorSpace),m=o.convert(r.type);let f,g=x(r.internalFormat,a,m,r.normalized,r.colorSpace,r.isVideoTexture);L(c,r);const w=r.mipmaps,_=!0!==r.isVideoTexture,T=void 0===p.__version||!0===h,R=d.dataReady,A=k(r,t);if(r.isDepthTexture)g=S(r.format===i.dcC,r.type),T&&(_?n.texStorage2D(e.TEXTURE_2D,1,g,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,g,t.width,t.height,0,a,m,null));else if(r.isDataTexture)if(w.length>0){_&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,w[0].width,w[0].height);for(let t=0,i=w.length;te.start-t.start));let r=0;for(let e=1;e0){const t=(0,i.Nex)(f.width,f.height,r.format,r.type);for(const i of r.layerUpdates){const o=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,s,0,0,i,f.width,f.height,1,a,o)}r.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,s,0,0,0,f.width,f.height,t.depth,a,f.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,s,g,f.width,f.height,t.depth,0,f.data,0,0);else(0,i.R8M)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _?R&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,s,0,0,0,f.width,f.height,t.depth,a,m,f.data):n.texImage3D(e.TEXTURE_2D_ARRAY,s,g,f.width,f.height,t.depth,0,a,m,f.data)}else{_&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,w[0].width,w[0].height);for(let t=0,s=w.length;t0){const s=(0,i.Nex)(t.width,t.height,r.format,r.type);for(const i of r.layerUpdates){const o=t.data.subarray(i*s/t.data.BYTES_PER_ELEMENT,(i+1)*s/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,t.width,t.height,1,a,m,o)}r.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,a,m,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,g,t.width,t.height,t.depth,0,a,m,t.data);else if(r.isData3DTexture)_?(T&&n.texStorage3D(e.TEXTURE_3D,A,g,t.width,t.height,t.depth),R&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,a,m,t.data)):n.texImage3D(e.TEXTURE_3D,0,g,t.width,t.height,t.depth,0,a,m,t.data);else if(r.isFramebufferTexture){if(T)if(_)n.texStorage2D(e.TEXTURE_2D,A,g,t.width,t.height);else{let i=t.width,s=t.height;for(let t=0;t>=1,s>>=1}}else if(r.isHTMLTexture){if("texElementImage2D"in e){const n=e.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),t.parentNode!==n)return n.appendChild(t),u.add(r),n.onpaint=e=>{const t=e.changedElements;for(const n of u)t.includes(n.image)&&(n.needsUpdate=!0)},void n.requestPaint();if(3===e.texElementImage2D.length)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{const n=0,a=e.RGBA,i=e.RGBA,s=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,n,a,i,s,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(w.length>0){if(_&&T){const t=U(w[0]);n.texStorage2D(e.TEXTURE_2D,A,g,t.width,t.height)}for(let t=0,i=w.length;t>h),a=Math.max(1,i.height>>h);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,t,a,i.depth,0,d,u,null):n.texImage2D(c,h,p,t,a,0,d,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),B(i)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,r,c,f.__webglTexture,0,D(i)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,r,c,f.__webglTexture,h),n.bindFramebuffer(e.FRAMEBUFFER,null)}function G(t,n,a){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const i=n.depthTexture,s=i&&i.isDepthTexture?i.type:null,o=S(n.stencilBuffer,s),r=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;B(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,D(n),o,n.width,n.height):a?e.renderbufferStorageMultisample(e.RENDERBUFFER,D(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,r,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(s)for(let e=0;e<6;e++)j(i.__webglFramebuffer[e],t,e);else{const e=t.texture.mipmaps;e&&e.length>0?j(i.__webglFramebuffer[0],t,0):j(i.__webglFramebuffer,t,0)}else if(s){i.__webglDepthbuffer=[];for(let a=0;a<6;a++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[a]),void 0===i.__webglDepthbuffer[a])i.__webglDepthbuffer[a]=e.createRenderbuffer(),G(i.__webglDepthbuffer[a],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,s=i.__webglDepthbuffer[a];e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,s)}}else{const a=t.texture.mipmaps;if(a&&a.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),void 0===i.__webglDepthbuffer)i.__webglDepthbuffer=e.createRenderbuffer(),G(i.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}const Z=[],F=[];function D(e){return Math.min(s.maxSamples,e.samples)}function B(e){const n=a.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function H(e,t){const n=e.colorSpace,a=e.format,s=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==i.Zr2&&n!==i.jf0&&(i.ppV.getTransfer(n)===i.KLL?a===i.GWd&&s===i.OUM||(0,i.R8M)("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):(0,i.z3S)("WebGLTextures: Unsupported texture color space:",n)),t}function U(e){return"undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement?(h.width=e.naturalWidth||e.width,h.height=e.naturalHeight||e.height):"undefined"!==typeof VideoFrame&&e instanceof VideoFrame?(h.width=e.displayWidth,h.height=e.displayHeight):(h.width=e.width,h.height=e.height),h}this.allocateTextureUnit=function(){const e=A;return e>=s.maxTextures&&(0,i.R8M)("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+s.maxTextures),A+=1,e},this.resetTextureUnits=function(){A=0},this.getTextureUnits=function(){return A},this.setTextureUnits=function(e){A=e},this.setTexture2D=C,this.setTexture2DArray=function(t,i){const s=a.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?P(s,t,i):(t.isExternalTexture&&(s.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+i))},this.setTexture3D=function(t,i){const s=a.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?P(s,t,i):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+i)},this.setTextureCube=function(t,r){const l=a.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&l.__version!==t.version?function(t,r,l){if(6!==r.image.length)return;const c=I(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+l);const d=a.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+l);const t=i.ppV.getPrimaries(i.ppV.workingColorSpace),a=r.colorSpace===i.jf0?null:i.ppV.getPrimaries(r.colorSpace),u=r.colorSpace===i.jf0||t===a?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const p=r.isCompressedTexture||r.image[0].isCompressedTexture,m=r.image[0]&&r.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=p||m?m?r.image[e].image:r.image[e]:v(r.image[e],!0,s.maxCubemapSize),f[e]=H(r,f[e]);const g=f[0],w=o.convert(r.format,r.colorSpace),S=o.convert(r.type),_=x(r.internalFormat,w,S,r.normalized,r.colorSpace),T=!0!==r.isVideoTexture,R=void 0===d.__version||!0===c,A=h.dataReady;let C,N=k(r,g);if(L(e.TEXTURE_CUBE_MAP,r),p){T&&R&&n.texStorage2D(e.TEXTURE_CUBE_MAP,N,_,g.width,g.height);for(let t=0;t<6;t++){C=f[t].mipmaps;for(let a=0;a0&&N++;const t=U(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,N,_,t.width,t.height)}for(let t=0;t<6;t++)if(m){T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,w,S,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,f[t].width,f[t].height,0,w,S,f[t].data);for(let a=0;a1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=i.version,r.memory.textures++),h){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&!1===B(t)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let a=0;a0)for(let n=0;n0)if(!1===B(t)){const i=t.textures,s=t.width,o=t.height;let r=e.COLOR_BUFFER_BIT;const l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=a.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,h.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,h.__webglFramebuffer);for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:i.jf0;const o=i.ppV.getTransfer(s);if(n===i.OUM)return e.UNSIGNED_BYTE;if(n===i.Wew)return e.UNSIGNED_SHORT_4_4_4_4;if(n===i.gJ2)return e.UNSIGNED_SHORT_5_5_5_1;if(n===i.Dmk)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===i.yT7)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===i.tJf)return e.BYTE;if(n===i.fBL)return e.SHORT;if(n===i.cHt)return e.UNSIGNED_SHORT;if(n===i.Yuy)return e.INT;if(n===i.bkx)return e.UNSIGNED_INT;if(n===i.RQf)return e.FLOAT;if(n===i.ix0)return e.HALF_FLOAT;if(n===i.wrO)return e.ALPHA;if(n===i.HIg)return e.RGB;if(n===i.GWd)return e.RGBA;if(n===i.zdS)return e.DEPTH_COMPONENT;if(n===i.dcC)return e.DEPTH_STENCIL;if(n===i.VT0)return e.RED;if(n===i.ZQM)return e.RED_INTEGER;if(n===i.paN)return e.RG;if(n===i.TkQ)return e.RG_INTEGER;if(n===i.c90)return e.RGBA_INTEGER;if(n===i.IE4||n===i.Nz6||n===i.jR7||n===i.BXX)if(o===i.KLL){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===i.IE4)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===i.Nz6)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===i.jR7)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===i.BXX)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===i.IE4)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===i.Nz6)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===i.jR7)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===i.BXX)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===i.k6Q||n===i.kTp||n===i.HXV||n===i.pBf){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(n===i.k6Q)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===i.kTp)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===i.HXV)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===i.pBf)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===i.CVz||n===i.Riy||n===i.KDk||n===i.BVL||n===i.gZr||n===i.OtU||n===i.jSS){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(n===i.CVz||n===i.Riy)return o===i.KLL?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===i.KDk)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(n===i.BVL)return a.COMPRESSED_R11_EAC;if(n===i.gZr)return a.COMPRESSED_SIGNED_R11_EAC;if(n===i.OtU)return a.COMPRESSED_RG11_EAC;if(n===i.jSS)return a.COMPRESSED_SIGNED_RG11_EAC}if(n===i.qa3||n===i.B_h||n===i.czI||n===i.rSH||n===i.Qrf||n===i.psI||n===i.a5J||n===i._QJ||n===i.uB5||n===i.lyL||n===i.bC7||n===i.y3Z||n===i.ojs||n===i.S$4){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(n===i.qa3)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===i.B_h)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===i.czI)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===i.rSH)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===i.Qrf)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===i.psI)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===i.a5J)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===i._QJ)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===i.uB5)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===i.lyL)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===i.bC7)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===i.y3Z)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===i.ojs)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===i.S$4)return o===i.KLL?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===i.Fn||n===i.H23||n===i.W9U){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===i.Fn)return o===i.KLL?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===i.H23)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===i.W9U)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===i.Kef||n===i.XG_||n===i.HO_||n===i.CWW){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===i.Kef)return a.COMPRESSED_RED_RGTC1_EXT;if(n===i.XG_)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===i.HO_)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===i.CWW)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===i.V3x?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class Dt{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new i.rjZ(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new i.BKk({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new i.eaF(new i.bdM(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Bt extends i.Qev{constructor(e,t){super();const n=this;let a=null,o=1,r=null,l="local-floor",c=1,h=null,d=null,u=null,p=null,m=null,f=null;const g="undefined"!==typeof XRWebGLBinding,v=new Dt,b={},y=t.getContextAttributes();let w=null,x=null;const S=[],k=[],_=new i.I9Y;let T=null;const R=new i.ubm;R.viewport=new i.IUQ;const A=new i.ubm;A.viewport=new i.IUQ;const C=[R,A],N=new i.nZQ;let E=null,M=null;function L(e){const t=k.indexOf(e.inputSource);if(-1===t)return;const n=S[t];void 0!==n&&(n.update(e.inputSource,e.frame,h||r),n.dispatchEvent({type:e.type,data:e.inputSource}))}function I(){a.removeEventListener("select",L),a.removeEventListener("selectstart",L),a.removeEventListener("selectend",L),a.removeEventListener("squeeze",L),a.removeEventListener("squeezestart",L),a.removeEventListener("squeezeend",L),a.removeEventListener("end",I),a.removeEventListener("inputsourceschange",X);for(let e=0;e=0&&(k[a]=null,S[a].disconnect(n))}for(let t=0;t=k.length){k.push(n),a=e;break}if(null===k[e]){k[e]=n,a=e;break}}if(-1===a)break}const i=S[a];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=S[e];return void 0===t&&(t=new i.R3r,S[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=S[e];return void 0===t&&(t=new i.R3r,S[e]=t),t.getGripSpace()},this.getHand=function(e){let t=S[e];return void 0===t&&(t=new i.R3r,S[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===n.isPresenting&&(0,i.R8M)("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){l=e,!0===n.isPresenting&&(0,i.R8M)("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||r},this.setReferenceSpace=function(e){h=e},this.getBaseLayer=function(){return null!==p?p:m},this.getBinding=function(){return null===u&&g&&(u=new XRWebGLBinding(a,t)),u},this.getFrame=function(){return f},this.getSession=function(){return a},this.setSession=async function(s){if(a=s,null!==a){w=e.getRenderTarget(),a.addEventListener("select",L),a.addEventListener("selectstart",L),a.addEventListener("selectend",L),a.addEventListener("squeeze",L),a.addEventListener("squeezestart",L),a.addEventListener("squeezeend",L),a.addEventListener("end",I),a.addEventListener("inputsourceschange",X),!0!==y.xrCompatible&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(_);if(g&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,s=null,r=null;y.depth&&(r=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=y.stencil?i.dcC:i.zdS,s=y.stencil?i.V3x:i.bkx);const l={colorFormat:t.RGBA8,depthFormat:r,scaleFactor:o};u=this.getBinding(),p=u.createProjectionLayer(l),a.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),x=new i.nWS(p.textureWidth,p.textureHeight,{format:i.GWd,type:i.OUM,depthTexture:new i.VCu(p.textureWidth,p.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:!1===p.ignoreDepthValues,resolveStencilBuffer:!1===p.ignoreDepthValues})}else{const n={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:o};m=new XRWebGLLayer(a,t,n),a.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new i.nWS(m.framebufferWidth,m.framebufferHeight,{format:i.GWd,type:i.OUM,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues})}x.isXRRenderTarget=!0,this.setFoveation(c),h=null,r=await a.requestReferenceSpace(l),V.setContext(a),V.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};const P=new i.Pq0,W=new i.Pq0;function G(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==v.texture&&(v.depthNear>0&&(t=v.depthNear),v.depthFar>0&&(n=v.depthFar)),N.near=A.near=R.near=t,N.far=A.far=R.far=n,E===N.near&&M===N.far||(a.updateRenderState({depthNear:N.near,depthFar:N.far}),E=N.near,M=N.far),N.layers.mask=6|e.layers.mask,R.layers.mask=-5&N.layers.mask,A.layers.mask=-3&N.layers.mask;const s=e.parent,o=N.cameras;G(N,s);for(let a=0;a0&&(e.alphaTest.value=a.alphaTest);const s=t.get(a),o=s.envMap,r=s.envMapRotation;o&&(e.envMap.value=o,e.envMapRotation.value.setFromMatrix4(Ht.makeRotationFromEuler(r)).transpose(),o.isCubeTexture&&!1===o.isRenderTargetTexture&&e.envMapRotation.value.premultiply(Ut),e.reflectivity.value=a.reflectivity,e.ior.value=a.ior,e.refractionRatio.value=a.refractionRatio),a.lightMap&&(e.lightMap.value=a.lightMap,e.lightMapIntensity.value=a.lightMapIntensity,n(a.lightMap,e.lightMapTransform)),a.aoMap&&(e.aoMap.value=a.aoMap,e.aoMapIntensity.value=a.aoMapIntensity,n(a.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,(0,i._Ut)(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,s,o,r,l){s.isNodeMaterial?s.uniformsNeedUpdate=!1:s.isMeshBasicMaterial?a(e,s):s.isMeshLambertMaterial?(a(e,s),s.envMap&&(e.envMapIntensity.value=s.envMapIntensity)):s.isMeshToonMaterial?(a(e,s),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,s)):s.isMeshPhongMaterial?(a(e,s),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,s),s.envMap&&(e.envMapIntensity.value=s.envMapIntensity)):s.isMeshStandardMaterial?(a(e,s),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,s),s.isMeshPhysicalMaterial&&function(e,t,a){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===i.hsX&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=a.texture,e.transmissionSamplerSize.value.set(a.width,a.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,s,l)):s.isMeshMatcapMaterial?(a(e,s),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,s)):s.isMeshDepthMaterial?a(e,s):s.isMeshDistanceMaterial?(a(e,s),function(e,n){const a=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(a.matrixWorld),e.nearDistance.value=a.shadow.camera.near,e.farDistance.value=a.shadow.camera.far}(e,s)):s.isMeshNormalMaterial?a(e,s):s.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,s),s.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,s)):s.isPointsMaterial?function(e,t,a,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*a,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,s,o,r):s.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,s):s.isShadowMaterial?(e.color.value.copy(s.color),e.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function Ot(e,t,n,a){let s={},o={},r=[];const l=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(t,n,a,i){if(!0===function(e,t,n,a){const i=e.value,s=t+"_"+n;if(void 0===a[s])return"number"===typeof i||"boolean"===typeof i?a[s]=i:ArrayBuffer.isView(i)?a[s]=i.slice():a[s]=i.clone(),!0;{const e=a[s];if("number"===typeof i||"boolean"===typeof i){if(e!==i)return a[s]=i,!0}else{if(ArrayBuffer.isView(i))return!0;if(!1===e.equals(i))return e.copy(i),!0}}return!1}(t,n,a,i)){const n=t.__offset,a=t.value;if(Array.isArray(a)){let e=0;for(let n=0;n0&&(n+=a-i);e.__size=n,e.__cache={}}(n),p=function(t){const n=function(){for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:{};const t=e.canvas,n=void 0===t?(0,i.lPF)():t,a=e.context,r=void 0===a?null:a,l=e.depth,c=void 0===l||l,h=e.stencil,d=void 0!==h&&h,u=e.alpha,b=void 0!==u&&u,y=e.antialias,w=void 0!==y&&y,x=e.premultipliedAlpha,S=void 0===x||x,k=e.preserveDrawingBuffer,_=void 0!==k&&k,T=e.powerPreference,R=void 0===T?"default":T,A=e.failIfMajorPerformanceCaveat,C=void 0!==A&&A,N=e.reversedDepthBuffer,E=void 0!==N&&N,M=e.outputBufferType,L=void 0===M?i.OUM:M;let Z;if(this.isWebGLRenderer=!0,null!==r){if("undefined"!==typeof WebGLRenderingContext&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");Z=r.getContextAttributes().alpha}else Z=b;const D=L,B=new Set([i.c90,i.TkQ,i.ZQM]),H=new Set([i.OUM,i.bkx,i.cHt,i.V3x,i.Wew,i.gJ2]),U=new Uint32Array(4),Y=new Int32Array(4),O=new i.Pq0;let z=null,J=null;const K=[],Q=[];let q=null;this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=i.y_p,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const $=this;let ee=!1,te=null,ne=null,ae=null,ie=null;this._outputColorSpace=i.er$;let se=0,oe=0,re=null,le=-1,ce=null;const he=new i.IUQ,de=new i.IUQ;let ue=null;const pe=new i.Q1f(0);let me=0,fe=n.width,ge=n.height,ve=1,be=null,ye=null;const we=new i.IUQ(0,0,fe,ge),xe=new i.IUQ(0,0,fe,ge);let Se=!1;const ke=new i.PPD;let _e=!1,Te=!1;const Re=new i.kn4,Ae=new i.Pq0,Ce=new i.IUQ,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ee=!1;function Me(){return null===re?ve:1}let Le,Ie,Xe,Pe,We,Ge,je,Ve,Ze,Fe,De,Be,He,Ue,Oe,ze,Je,Ke,Qe,qe,$e,et,tt,nt=r;function at(e,t){return n.getContext(e,t)}try{const e={alpha:!0,depth:c,stencil:d,antialias:w,premultipliedAlpha:S,preserveDrawingBuffer:_,powerPreference:R,failIfMajorPerformanceCaveat:C};if("setAttribute"in n&&n.setAttribute("data-engine","three.js r".concat(i.sPf)),n.addEventListener("webglcontextlost",ot,!1),n.addEventListener("webglcontextrestored",rt,!1),n.addEventListener("webglcontextcreationerror",lt,!1),null===nt){const t="webgl2";if(nt=at(t,e),null===nt)throw at(t)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(Tt){throw(0,i.z3S)("WebGLRenderer: "+Tt.message),Tt}function it(){Le=new X(nt),Le.init(),$e=new Ft(nt,Le),Ie=new g(nt,Le,e,$e),Xe=new Vt(nt,Le),Ie.reversedDepthBuffer&&E&&Xe.buffers.depth.setReversed(!0),ne=nt.createFramebuffer(),ae=nt.createFramebuffer(),ie=nt.createFramebuffer(),Pe=new G(nt),We=new St,Ge=new Zt(nt,Le,Xe,We,Ie,$e,Pe),je=new I($),Ve=new o(nt),et=new m(nt,Ve),Ze=new P(nt,Ve,Pe,et),Fe=new V(nt,Ze,Ve,et,Pe),Ke=new j(nt,Ie,Ge),Oe=new v(We),De=new xt($,je,Le,Ie,et,Oe),Be=new Yt($,We),He=new Rt,Ue=new Lt(Le),Je=new p($,je,Xe,Fe,Z,S),ze=new jt($,Fe,Ie),tt=new Ot(nt,Pe,Ie,Xe),Qe=new f(nt,Le,Pe),qe=new W(nt,Le,Pe),Pe.programs=De.programs,$.capabilities=Ie,$.extensions=Le,$.properties=We,$.renderLists=He,$.shadowMap=ze,$.state=Xe,$.info=Pe}it(),D!==i.OUM&&(q=new F(D,n.width,n.height,w,c,d));const st=new Bt($,nt);function ot(e){e.preventDefault(),(0,i.Rm2)("WebGLRenderer: Context Lost."),ee=!0}function rt(){(0,i.Rm2)("WebGLRenderer: Context Restored."),ee=!1;const e=Pe.autoReset,t=ze.enabled,n=ze.autoUpdate,a=ze.needsUpdate,s=ze.type;it(),Pe.autoReset=e,ze.enabled=t,ze.autoUpdate=n,ze.needsUpdate=a,ze.type=s}function lt(e){(0,i.z3S)("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function ct(e){const t=e.target;t.removeEventListener("dispose",ct),function(e){(function(e){const t=We.get(e).programs;void 0!==t&&(t.forEach((function(e){De.releaseProgram(e)})),e.isShaderMaterial&&De.releaseShaderCache(e))})(e),We.remove(e)}(t)}function ht(e,t,n){!0===e.transparent&&e.side===i.$EB&&!1===e.forceSinglePass?(e.side=i.hsX,e.needsUpdate=!0,wt(e,t,n),e.side=i.hB5,e.needsUpdate=!0,wt(e,t,n),e.side=i.$EB):wt(e,t,n)}this.xr=st,this.getContext=function(){return nt},this.getContextAttributes=function(){return nt.getContextAttributes()},this.forceContextLoss=function(){const e=Le.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Le.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ve},this.setPixelRatio=function(e){void 0!==e&&(ve=e,this.setSize(fe,ge,!1))},this.getSize=function(e){return e.set(fe,ge)},this.setSize=function(e,t){let a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];st.isPresenting?(0,i.R8M)("WebGLRenderer: Can't change size while VR device is presenting."):(fe=e,ge=t,n.width=Math.floor(e*ve),n.height=Math.floor(t*ve),!0===a&&(n.style.width=e+"px",n.style.height=t+"px"),null!==q&&q.setSize(n.width,n.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(fe*ve,ge*ve).floor()},this.setDrawingBufferSize=function(e,t,a){fe=e,ge=t,ve=a,n.width=Math.floor(e*a),n.height=Math.floor(t*a),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(D!==i.OUM){if(e)for(let t=0;t1&&void 0!==arguments[1])||arguments[1],t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=0;if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){let e=!1;if(null!==re){const t=re.texture.format;e=B.has(t)}if(e){const e=re.texture.type,t=H.has(e),n=Je.getClearColor(),a=Je.getClearAlpha(),i=n.r,s=n.g,o=n.b;t?(U[0]=i,U[1]=s,U[2]=o,U[3]=a,nt.clearBufferuiv(nt.COLOR,0,U)):(Y[0]=i,Y[1]=s,Y[2]=o,Y[3]=a,nt.clearBufferiv(nt.COLOR,0,Y))}else n|=nt.COLOR_BUFFER_BIT}e&&(n|=nt.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),t&&(n|=nt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==n&&nt.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),te=e},this.dispose=function(){n.removeEventListener("webglcontextlost",ot,!1),n.removeEventListener("webglcontextrestored",rt,!1),n.removeEventListener("webglcontextcreationerror",lt,!1),Je.dispose(),He.dispose(),Ue.dispose(),We.dispose(),je.dispose(),Fe.dispose(),et.dispose(),tt.dispose(),De.dispose(),st.dispose(),st.removeEventListener("sessionstart",ut),st.removeEventListener("sessionend",pt),mt.stop()},this.renderBufferDirect=function(e,t,n,a,s,o){null===t&&(t=Ne);const r=s.isMesh&&s.matrixWorld.determinantAffine()<0,l=function(e,t,n,a,s){!0!==t.isScene&&(t=Ne);Ge.resetTextureUnits();const o=t.fog,r=a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial?t.environment:null,l=null===re?$.outputColorSpace:!0===re.isXRRenderTarget?re.texture.colorSpace:i.ppV.workingColorSpace,c=a.isMeshStandardMaterial||a.isMeshLambertMaterial&&!a.envMap||a.isMeshPhongMaterial&&!a.envMap,h=je.get(a.envMap||r,c),d=!0===a.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!a.normalMap||a.anisotropy>0),p=!!n.morphAttributes.position,m=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let g=i.y_p;a.toneMapped&&(null!==re&&!0!==re.isXRRenderTarget||(g=$.toneMapping));const v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,b=void 0!==v?v.length:0,y=We.get(a),w=J.state.lights;if(!0===_e&&(!0===Te||e!==ce)){const t=e===ce&&a.id===le;Oe.setState(a,e,t)}let x=!1;a.version===y.__version?y.needsLights&&y.lightsStateVersion!==w.state.version||y.outputColorSpace!==l||s.isBatchedMesh&&!1===y.batching?x=!0:s.isBatchedMesh||!0!==y.batching?s.isBatchedMesh&&!0===y.batchingColor&&null===s.colorTexture||s.isBatchedMesh&&!1===y.batchingColor&&null!==s.colorTexture||s.isInstancedMesh&&!1===y.instancing?x=!0:s.isInstancedMesh||!0!==y.instancing?s.isSkinnedMesh&&!1===y.skinning?x=!0:s.isSkinnedMesh||!0!==y.skinning?s.isInstancedMesh&&!0===y.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===y.instancingColor&&null!==s.instanceColor||s.isInstancedMesh&&!0===y.instancingMorph&&null===s.morphTexture||s.isInstancedMesh&&!1===y.instancingMorph&&null!==s.morphTexture||y.envMap!==h||!0===a.fog&&y.fog!==o?x=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===Oe.numPlanes&&y.numIntersection===Oe.numIntersection?(y.vertexAlphas!==d||y.vertexTangents!==u||y.morphTargets!==p||y.morphNormals!==m||y.morphColors!==f||y.toneMapping!==g||y.morphTargetsCount!==b||!!y.lightProbeGrid!==J.state.lightProbeGridArray.length>0)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,y.__version=a.version);let S=y.currentProgram;!0===x&&(S=wt(a,t,s),te&&a.isNodeMaterial&&te.onUpdateProgram(a,S,y));let k=!1,_=!1,T=!1;const R=S.getUniforms(),A=y.uniforms;Xe.useProgram(S.program)&&(k=!0,_=!0,T=!0);a.id!==le&&(le=a.id,_=!0);if(y.needsLights){const e=function(e,t){if(0===e.length)return null;if(1===e.length)return null!==e[0].texture?e[0]:null;O.setFromMatrixPosition(t.matrixWorld);for(let n=0,a=e.length;n0&&R.setValue(nt,"directionalShadowMap",w.state.directionalShadowMap,Ge),w.state.spotShadowMap.length>0&&R.setValue(nt,"spotShadowMap",w.state.spotShadowMap,Ge),w.state.pointShadowMap.length>0&&R.setValue(nt,"pointShadowMap",w.state.pointShadowMap,Ge));if(s.isSkinnedMesh){R.setOptional(nt,s,"bindMatrix"),R.setOptional(nt,s,"bindMatrixInverse");const e=s.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(nt,"boneTexture",e.boneTexture,Ge))}s.isBatchedMesh&&(R.setOptional(nt,s,"batchingTexture"),R.setValue(nt,"batchingTexture",s._matricesTexture,Ge),R.setOptional(nt,s,"batchingIdTexture"),R.setValue(nt,"batchingIdTexture",s._indirectTexture,Ge),R.setOptional(nt,s,"batchingColorTexture"),null!==s._colorsTexture&&R.setValue(nt,"batchingColorTexture",s._colorsTexture,Ge));const C=n.morphAttributes;void 0===C.position&&void 0===C.normal&&void 0===C.color||Ke.update(s,n,S);(_||y.receiveShadow!==s.receiveShadow)&&(y.receiveShadow=s.receiveShadow,R.setValue(nt,"receiveShadow",s.receiveShadow));(a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial)&&null===a.envMap&&null!==t.environment&&(A.envMapIntensity.value=t.environmentIntensity);void 0!==A.dfgLUT&&(A.dfgLUT.value=(null===Jt&&(Jt=new i.GYF(zt,16,16,i.paN,i.ix0),Jt.name="DFG_LUT",Jt.minFilter=i.k6q,Jt.magFilter=i.k6q,Jt.wrapS=i.ghU,Jt.wrapT=i.ghU,Jt.generateMipmaps=!1,Jt.needsUpdate=!0),Jt));if(_){if(R.setValue(nt,"toneMappingExposure",$.toneMappingExposure),y.needsLights&&(E=T,(N=A).ambientLightColor.needsUpdate=E,N.lightProbe.needsUpdate=E,N.directionalLights.needsUpdate=E,N.directionalLightShadows.needsUpdate=E,N.pointLights.needsUpdate=E,N.pointLightShadows.needsUpdate=E,N.spotLights.needsUpdate=E,N.spotLightShadows.needsUpdate=E,N.rectAreaLights.needsUpdate=E,N.hemisphereLights.needsUpdate=E),o&&!0===a.fog&&Be.refreshFogUniforms(A,o),Be.refreshMaterialUniforms(A,a,ve,ge,J.state.transmissionRenderTarget[e.id]),y.needsLights&&y.lightProbeGrid){const e=y.lightProbeGrid;A.probesSH.value=e.texture,A.probesMin.value.copy(e.boundingBox.min),A.probesMax.value.copy(e.boundingBox.max),A.probesResolution.value.copy(e.resolution)}Ye.upload(nt,kt(y),A,Ge)}var N,E;a.isShaderMaterial&&!0===a.uniformsNeedUpdate&&(Ye.upload(nt,kt(y),A,Ge),a.uniformsNeedUpdate=!1);a.isSpriteMaterial&&R.setValue(nt,"center",s.center);if(R.setValue(nt,"modelViewMatrix",s.modelViewMatrix),R.setValue(nt,"normalMatrix",s.normalMatrix),R.setValue(nt,"modelMatrix",s.matrixWorld),void 0!==a.uniformsGroups){const e=a.uniformsGroups;for(let t=0,n=e.length;t2&&void 0!==arguments[2]?arguments[2]:null;null===n&&(n=e),J=Ue.get(n),J.init(t),Q.push(J),n.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(J.pushLight(e),e.castShadow&&J.pushShadow(e))})),e!==n&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(J.pushLight(e),e.castShadow&&J.pushShadow(e))})),J.setupLights();const a=new Set;return e.traverse((function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let i=0;i2&&void 0!==arguments[2]?arguments[2]:null;const a=this.compile(e,t,n);return new Promise((t=>{function n(){a.forEach((function(e){We.get(e).currentProgram.isReady()&&a.delete(e)})),0!==a.size?setTimeout(n,10):t(e)}null!==Le.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let dt=null;function ut(){mt.stop()}function pt(){mt.start()}const mt=new s;function ft(e,t,n,a){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLightProbeGrid)J.pushLightProbeGrid(e);else if(e.isLight)J.pushLight(e),e.castShadow&&J.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ke.intersectsSprite(e)){a&&Ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Re);const t=Fe.update(e),i=e.material;i.visible&&z.push(e,t,i,n,Ce.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ke.intersectsObject(e))){const t=Fe.update(e),i=e.material;if(a&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),Ce.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),Ce.copy(t.boundingSphere.center)),Ce.applyMatrix4(e.matrixWorld).applyMatrix4(Re)),Array.isArray(i)){const a=t.groups;for(let s=0,o=a.length;s0&&bt(i,t,n),s.length>0&&bt(s,t,n),o.length>0&&bt(o,t,n),Xe.buffers.depth.setTest(!0),Xe.buffers.depth.setMask(!0),Xe.buffers.color.setMask(!0),Xe.setPolygonOffset(!1)}function vt(e,t,n,a){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===J.state.transmissionRenderTarget[a.id]){const e=Le.has("EXT_color_buffer_half_float")||Le.has("EXT_color_buffer_float");J.state.transmissionRenderTarget[a.id]=new i.nWS(1,1,{generateMipmaps:!0,type:e?i.ix0:i.OUM,minFilter:i.$_I,samples:Math.max(4,Ie.samples),stencilBuffer:d,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:i.ppV.workingColorSpace})}const s=J.state.transmissionRenderTarget[a.id],o=a.viewport||he;s.setSize(o.z*$.transmissionResolutionScale,o.w*$.transmissionResolutionScale);const r=$.getRenderTarget(),l=$.getActiveCubeFace(),c=$.getActiveMipmapLevel();$.setRenderTarget(s),$.getClearColor(pe),me=$.getClearAlpha(),me<1&&$.setClearColor(16777215,.5),$.clear(),Ee&&Je.render(n);const h=$.toneMapping;$.toneMapping=i.y_p;const u=a.viewport;if(void 0!==a.viewport&&(a.viewport=void 0),J.setupLightsView(a),!0===_e&&Oe.setGlobalState($.clippingPlanes,a),bt(e,n,a),Ge.updateMultisampleRenderTarget(s),Ge.updateRenderTargetMipmap(s),!1===Le.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let s=0,o=t.length;s0,a.currentProgram=d,a.uniformsList=null,d}function kt(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=Ye.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function _t(e,t){const n=We.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}mt.setAnimationLoop((function(e){dt&&dt(e)})),"undefined"!==typeof self&&mt.setContext(self),this.setAnimationLoop=function(e){dt=e,st.setAnimationLoop(e),null===e?mt.stop():mt.start()},st.addEventListener("sessionstart",ut),st.addEventListener("sessionend",pt),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void(0,i.z3S)("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===ee)return;null!==te&&te.renderStart(e,t);const n=!0===st.enabled&&!0===st.isPresenting,a=null!==q&&(null===re||n)&&q.begin($,re);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0!==st.enabled||!0!==st.isPresenting||null!==q&&!1!==q.isCompositing()||(!0===st.cameraAutoUpdate&&st.updateCamera(t),t=st.getCamera()),!0===e.isScene&&e.onBeforeRender($,e,t,re),J=Ue.get(e,Q.length),J.init(t),J.state.textureUnits=Ge.getTextureUnits(),Q.push(J),Re.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ke.setFromProjectionMatrix(Re,i.TdN,t.reversedDepth),Te=this.localClippingEnabled,_e=Oe.init(this.clippingPlanes,Te),z=He.get(e,K.length),z.init(),K.push(z),!0===st.enabled&&!0===st.isPresenting){const e=$.xr.getDepthSensingMesh();null!==e&&ft(e,t,-1/0,$.sortObjects)}ft(e,t,0,$.sortObjects),z.finish(),!0===$.sortObjects&&z.sort(be,ye,t.reversedDepth),Ee=!1===st.enabled||!1===st.isPresenting||!1===st.hasDepthSensing(),Ee&&Je.addToRenderList(z,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===_e&&Oe.beginShadows();const s=J.state.shadowsArray;ze.render(s,e,t),!0===_e&&Oe.endShadows();if(!1===(a&&q.hasRenderPass())){const n=z.opaque,a=z.transmissive;if(J.setupLights(),t.isArrayCamera){const i=t.cameras;if(a.length>0)for(let t=0,s=i.length;t0&&vt(n,a,e,t),Ee&&Je.render(e),gt(z,e,t)}null!==re&&0===oe&&(Ge.updateMultisampleRenderTarget(re),Ge.updateRenderTargetMipmap(re)),a&&q.end($),!0===e.isScene&&e.onAfterRender($,e,t),et.resetDefaultState(),le=-1,ce=null,Q.pop(),Q.length>0?(J=Q[Q.length-1],Ge.setTextureUnits(J.state.textureUnits),!0===_e&&Oe.setGlobalState($.clippingPlanes,J.state.camera)):J=null,K.pop(),z=K.length>0?K[K.length-1]:null,null!==te&&te.renderEnd()},this.getActiveCubeFace=function(){return se},this.getActiveMipmapLevel=function(){return oe},this.getRenderTarget=function(){return re},this.setRenderTargetTextures=function(e,t,n){const a=We.get(e);a.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===a.__autoAllocateDepthBuffer&&(a.__useRenderToTexture=!1),We.get(e.texture).__webglTexture=t,We.get(e.depthTexture).__webglTexture=a.__autoAllocateDepthBuffer?void 0:n,a.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=We.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;re=e,se=t,oe=n;let a=null,i=!1,s=!1;if(e){const o=We.get(e);if(void 0!==o.__useDefaultFramebuffer)return Xe.bindFramebuffer(nt.FRAMEBUFFER,o.__webglFramebuffer),he.copy(e.viewport),de.copy(e.scissor),ue=e.scissorTest,Xe.viewport(he),Xe.scissor(de),Xe.setScissorTest(ue),void(le=-1);if(void 0===o.__webglFramebuffer)Ge.setupRenderTarget(e);else if(o.__hasExternalTextures)Ge.rebindTextures(e,We.get(e.texture).__webglTexture,We.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&We.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Ge.setupDepthRenderbuffer(e)}}const r=e.texture;(r.isData3DTexture||r.isDataArrayTexture||r.isCompressedArrayTexture)&&(s=!0);const l=We.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(a=Array.isArray(l[t])?l[t][n]:l[t],i=!0):a=e.samples>0&&!1===Ge.useMultisampledRTT(e)?We.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,he.copy(e.viewport),de.copy(e.scissor),ue=e.scissorTest}else he.copy(we).multiplyScalar(ve).floor(),de.copy(xe).multiplyScalar(ve).floor(),ue=Se;0!==n&&(a=ne);if(Xe.bindFramebuffer(nt.FRAMEBUFFER,a)&&Xe.drawBuffers(e,a),Xe.viewport(he),Xe.scissor(de),Xe.setScissorTest(ue),i){const a=We.get(e.texture);nt.framebufferTexture2D(nt.FRAMEBUFFER,nt.COLOR_ATTACHMENT0,nt.TEXTURE_CUBE_MAP_POSITIVE_X+t,a.__webglTexture,n)}else if(s){const a=t;for(let t=0;t7&&void 0!==arguments[7]?arguments[7]:0;if(!e||!e.isWebGLRenderTarget)return void(0,i.z3S)("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let c=We.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==r&&(c=c[r]),c){Xe.bindFramebuffer(nt.FRAMEBUFFER,c);try{const r=e.textures[l],c=r.format,h=r.type;if(e.textures.length>1&&nt.readBuffer(nt.COLOR_ATTACHMENT0+l),!Ie.textureFormatReadable(c))return void(0,i.z3S)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Ie.textureTypeReadable(h))return void(0,i.z3S)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-a&&n>=0&&n<=e.height-s&&nt.readPixels(t,n,a,s,$e.convert(c),$e.convert(h),o)}finally{const e=null!==re?We.get(re).__webglFramebuffer:null;Xe.bindFramebuffer(nt.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,a,s,o,r){let l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0;if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let c=We.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==r&&(c=c[r]),c){if(t>=0&&t<=e.width-a&&n>=0&&n<=e.height-s){Xe.bindFramebuffer(nt.FRAMEBUFFER,c);const r=e.textures[l],h=r.format,d=r.type;if(e.textures.length>1&&nt.readBuffer(nt.COLOR_ATTACHMENT0+l),!Ie.textureFormatReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ie.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=nt.createBuffer();nt.bindBuffer(nt.PIXEL_PACK_BUFFER,u),nt.bufferData(nt.PIXEL_PACK_BUFFER,o.byteLength,nt.STREAM_READ),nt.readPixels(t,n,a,s,$e.convert(h),$e.convert(d),0);const p=null!==re?We.get(re).__webglFramebuffer:null;Xe.bindFramebuffer(nt.FRAMEBUFFER,p);const m=nt.fenceSync(nt.SYNC_GPU_COMMANDS_COMPLETE,0);return nt.flush(),await(0,i.jej)(nt,m,4),nt.bindBuffer(nt.PIXEL_PACK_BUFFER,u),nt.getBufferSubData(nt.PIXEL_PACK_BUFFER,0,o),nt.deleteBuffer(u),nt.deleteSync(m),o}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=Math.pow(2,-n),i=Math.floor(e.image.width*a),s=Math.floor(e.image.height*a),o=null!==t?t.x:0,r=null!==t?t.y:0;Ge.setTexture2D(e,0),nt.copyTexSubImage2D(nt.TEXTURE_2D,n,0,0,o,r,i,s),Xe.unbindTexture()},this.copyTextureToTexture=function(e,t){let n,a,i,s,o,r,l,c,h,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,m=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;const f=e.isCompressedTexture?e.mipmaps[m]:e.image;if(null!==d)n=d.max.x-d.min.x,a=d.max.y-d.min.y,i=d.isBox3?d.max.z-d.min.z:1,s=d.min.x,o=d.min.y,r=d.isBox3?d.min.z:0;else{const t=Math.pow(2,-p);n=Math.floor(f.width*t),a=Math.floor(f.height*t),i=e.isDataArrayTexture?f.depth:e.isData3DTexture?Math.floor(f.depth*t):1,s=0,o=0,r=0}null!==u?(l=u.x,c=u.y,h=u.z):(l=0,c=0,h=0);const g=$e.convert(t.format),v=$e.convert(t.type);let b;t.isData3DTexture?(Ge.setTexture3D(t,0),b=nt.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Ge.setTexture2DArray(t,0),b=nt.TEXTURE_2D_ARRAY):(Ge.setTexture2D(t,0),b=nt.TEXTURE_2D),Xe.activeTexture(nt.TEXTURE0),Xe.pixelStorei(nt.UNPACK_FLIP_Y_WEBGL,t.flipY),Xe.pixelStorei(nt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Xe.pixelStorei(nt.UNPACK_ALIGNMENT,t.unpackAlignment);const y=Xe.getParameter(nt.UNPACK_ROW_LENGTH),w=Xe.getParameter(nt.UNPACK_IMAGE_HEIGHT),x=Xe.getParameter(nt.UNPACK_SKIP_PIXELS),S=Xe.getParameter(nt.UNPACK_SKIP_ROWS),k=Xe.getParameter(nt.UNPACK_SKIP_IMAGES);Xe.pixelStorei(nt.UNPACK_ROW_LENGTH,f.width),Xe.pixelStorei(nt.UNPACK_IMAGE_HEIGHT,f.height),Xe.pixelStorei(nt.UNPACK_SKIP_PIXELS,s),Xe.pixelStorei(nt.UNPACK_SKIP_ROWS,o),Xe.pixelStorei(nt.UNPACK_SKIP_IMAGES,r);const _=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const d=We.get(e),u=We.get(t),f=We.get(d.__renderTarget),g=We.get(u.__renderTarget);Xe.bindFramebuffer(nt.READ_FRAMEBUFFER,f.__webglFramebuffer),Xe.bindFramebuffer(nt.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let v=0;v1&&void 0!==arguments[1]?arguments[1]:"tDiffuse";super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof i.BKk?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=i.LlO.clone(e.uniforms),this.material=new i.BKk({name:void 0!==e.name?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new nn(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class sn extends qt{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const a=e.getContext(),i=e.state;let s,o;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0),this.inverse?(s=0,o=1):(s=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),i.buffers.stencil.setFunc(a.ALWAYS,s,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(a.EQUAL,1,4294967295),i.buffers.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),i.buffers.stencil.setLocked(!0)}}class on extends qt{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class rn{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){const n=e.getSize(new i.I9Y);this._width=n.width,this._height=n.height,(t=new i.nWS(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:i.ix0})).texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new an(Qt),this.copyPass.material.blending=i.XIg,this.timer=new i.M4G}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=a,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new i.Q1f}render(e,t,n){const a=e.autoClear;let i,s;e.autoClear=!1,null!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),null!==this.clearAlpha&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),!0===this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),null!==this.clearColor&&e.setClearColor(this._oldClearColor),null!==this.clearAlpha&&e.setClearAlpha(i),null!==this.overrideMaterial&&(this.scene.overrideMaterial=s),e.autoClear=a}}const cn={name:"LuminosityHighPassShader",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new i.Q1f(0)},defaultOpacity:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tfloat v = luminance( texel.xyz );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"};class hn extends qt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;super(),this.strength=t,this.radius=n,this.threshold=a,this.resolution=void 0!==e?new i.I9Y(e.x,e.y):new i.I9Y(256,256),this.clearColor=new i.Q1f(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let s=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new i.nWS(s,o,{type:i.ix0}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let c=0;c\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\n\t\t\t\t\tfor ( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\t\t\tfloat x = float( i );\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += ( sample1 + sample2 ) * w;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tgl_FragColor = vec4( diffuseSum, 1.0 );\n\n\t\t\t\t}"})}_getCompositeMaterial(e){return new i.BKk({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor( const in float factor ) {\n\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix( factor, mirrorFactor, bloomRadius );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t// 3.0 for backwards compatibility with previous alpha-based intensity\n\t\t\t\t\tvec3 bloom = 3.0 * bloomStrength * (\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb\n\t\t\t\t\t);\n\n\t\t\t\t\tfloat bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );\n\t\t\t\t\tgl_FragColor = vec4( bloom, bloomAlpha );\n\n\t\t\t\t}"})}}hn.BlurDirectionX=new i.I9Y(1,0),hn.BlurDirectionY=new i.I9Y(0,1);const dn="OutputShader",un={tDiffuse:{value:null},toneMappingExposure:{value:1}},pn="\n\t\tprecision highp float;\n\n\t\tuniform mat4 modelViewMatrix;\n\t\tuniform mat4 projectionMatrix;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",mn="\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t// tone mapping\n\n\t\t\t#ifdef LINEAR_TONE_MAPPING\n\n\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( AGX_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\n\t\t\t#endif\n\n\t\t\t// color space\n\n\t\t\t#ifdef SRGB_TRANSFER\n\n\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\n\t\t\t#endif\n\n\t\t}";class fn extends qt{constructor(){super(),this.isOutputPass=!0,this.uniforms=i.LlO.clone(un),this.material=new i.D$Q({name:dn,uniforms:this.uniforms,vertexShader:pn,fragmentShader:mn}),this._fsQuad=new nn(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,this._outputColorSpace===e.outputColorSpace&&this._toneMapping===e.toneMapping||(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},i.ppV.getTransfer(this._outputColorSpace)===i.KLL&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===i.kyO?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===i.Mjd?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===i.nNL?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===i.FV?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===i.LAk?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===i.aJ8?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===i.g7M&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),!0===this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}const gn={name:"WarmGradeShader",uniforms:{tDiffuse:{value:null},warmth:{value:.04},saturation:{value:1.1},contrast:{value:1.12},vignetteStrength:{value:.55}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float warmth;\n uniform float saturation;\n uniform float contrast;\n uniform float vignetteStrength;\n varying vec2 vUv;\n\n void main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n vec3 color = texel.rgb;\n\n // warm push: nudge toward amber. Light trim on blue \u2014 enough to warm\n // stone/wood without muddying a daylight sky, which leans on blue\n // for its own saturation.\n color.r += warmth;\n color.g += warmth * 0.35;\n color.b -= warmth * 0.25;\n\n // saturation lift \u2014 mix away from grayscale luminance\n float luma = dot(color, vec3(0.299, 0.587, 0.114));\n color = mix(vec3(luma), color, saturation);\n\n // contrast: crush shadows toward black, push highlights brighter \u2014\n // the dramatic light/dark separation a torch-lit scene wants.\n color = max((color - 0.5) * contrast + 0.5, vec3(0.0));\n\n // vignette \u2014 soft edge darken, center untouched\n vec2 uv = (vUv - 0.5) * 1.15;\n float vig = 1.0 - dot(uv, uv) * vignetteStrength;\n color *= clamp(vig, 0.0, 1.0);\n\n gl_FragColor = vec4(color, texel.a);\n }\n "},vn=2,bn=["N","E","S","W"],yn=[[0,-1],[1,0],[0,1],[-1,0]],wn=[0,-Math.PI/2,Math.PI,Math.PI/2],xn=e=>e*e*(3-2*e);function Sn(e){e.traverse((e=>{if(e.geometry&&e.geometry.dispose(),e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((e=>e.dispose()))}})),e.clear()}const kn=.04,_n=1.1,Tn=1.12,Rn=.55;class An{constructor(e){let t=e.container,n=e.entityFactory,a=e.onDisposeTextures;this.container=t,this.entityFactory=n||null,this.onDisposeTextures=a||null,this.disposed=!1,this.renderer=new Kt({antialias:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.domElement.style.display="block",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",t.appendChild(this.renderer.domElement),this.scene=new i.Z58,this.camera=new i.ubm(70,1,.1,400),this.scene.add(this.camera),this.lightGroup=new i.YJl,this.scene.add(this.lightGroup),this.torch=null,this.torchBase=0,this.starPoints=function(){const e=new Float32Array(2100),t=new Float32Array(2100);for(let i=0;i<700;i++){const n=Math.random()*Math.PI*2,a=Math.acos(Math.random());e[3*i]=180*Math.sin(a)*Math.cos(n),e[3*i+1]=180*Math.cos(a),e[3*i+2]=180*Math.sin(a)*Math.sin(n);const s=.55+.45*Math.random(),o=Math.random()<.25;t[3*i]=s*(o?1:.85),t[3*i+1]=s*(o?.9:.92),t[3*i+2]=s*(o?.75:1)}const n=new i.LoY;n.setAttribute("position",new i.THS(e,3)),n.setAttribute("color",new i.THS(t,3));const a=new i.ONl(n,new i.BH$({size:1.4,sizeAttenuation:!1,vertexColors:!0,transparent:!0,opacity:0,depthWrite:!1,fog:!1}));return a.frustumCulled=!1,a.renderOrder=-1,a}(),this.scene.add(this.starPoints),this.levelGroup=null,this.entityGroup=new i.YJl,this.scene.add(this.entityGroup),this.walkerGroup=new i.YJl,this.scene.add(this.walkerGroup),this.walkers=[],this.npcFactory=null,this.levelDef=null,this._animations=[],this.gridPos=[0,0],this.yaw=0,this.bumpOffset=new i.Pq0,this._tweens=[],this._clockStart=performance.now();const s=t.clientWidth||1,o=t.clientHeight||1;this.renderer.toneMapping=i.FV,this.renderer.toneMappingExposure=1.05,this.composer=new rn(this.renderer),this.composer.addPass(new ln(this.scene,this.camera)),this.bloomPass=new hn(new i.I9Y(s,o),.4,.45,.86),this.composer.addPass(this.bloomPass),this.gradePass=new an(gn),this.composer.addPass(this.gradePass),this.outputPass=new fn,this.composer.addPass(this.outputPass),this.setSize(s,o),this._frame=this._frame.bind(this),this._raf=requestAnimationFrame(this._frame)}get isAnimating(){return this._tweens.length>0}get maxAnisotropy(){return this.renderer.capabilities.getMaxAnisotropy()}buildLevel(e){var t,n,s,o;if(this.disposed)return;this.levelDef=e,this.levelGroup&&(this.scene.remove(this.levelGroup),Sn(this.levelGroup)),this.levelGroup=new i.YJl,this._animations=e.animations||[];const r=e.lighting;Sn(this.lightGroup),this.torch=null,this._lightTween=null,this.scene.fog=new i.cRK(r.fogColor,r.fogDensity),this._clearColor=new i.Q1f(null!=r.background?r.background:r.fogColor),this.renderer.setClearColor(this._clearColor),this.ambient=new i.$p8(r.ambientColor,r.ambientIntensity),this.lightGroup.add(this.ambient),this.hemi=null,r.hemi&&(this.hemi=new i.dth(r.hemi.skyColor,r.hemi.groundColor,r.hemi.intensity),this.lightGroup.add(this.hemi)),this.sun=null,r.sun&&(this.sun=new i.ZyN(r.sun.color,r.sun.intensity),this.sun.position.set(r.sun.x,r.sun.y,r.sun.z),this.lightGroup.add(this.sun)),r.torch?(this.torch=new i.HiM(r.torch.color,r.torch.intensity,8*vn,2),this.torch.position.set(.3,-.15,.2),this.torchBase=r.torch.intensity,this.camera.add(this.torch)):this.camera.children.length&&[...this.camera.children].forEach((e=>this.camera.remove(e))),this.starPoints.material.opacity=r.starsOpacity||0,this.starPoints.visible=this.starPoints.material.opacity>.001;const l=e.grade||{},c=this.gradePass.uniforms;c.warmth.value=null!==(t=l.warmth)&&void 0!==t?t:kn,c.saturation.value=null!==(n=l.saturation)&&void 0!==n?n:_n,c.contrast.value=null!==(s=l.contrast)&&void 0!==s?s:Tn,c.vignetteStrength.value=null!==(o=l.vignetteStrength)&&void 0!==o?o:Rn;const h=e=>new i._4j({map:e,roughness:.95,metalness:0}),d=new i.B69,u=new i.bdM(vn,vn);(e.surfaces||[]).forEach((e=>{if("wall"===e.kind){if(!e.faces.length)return;const t=new i.bdM(vn,e.height),n=new i.ZLX(t,h(e.texture),e.faces.length),s=e.yBase||0;e.faces.forEach(((t,i)=>{const o=(0,a.A)(yn[t.dir],2),r=o[0],l=o[1];d.position.set(t.x*vn+r*vn/2,s+e.height/2,t.y*vn+l*vn/2),d.rotation.set(0,wn[t.dir],0),d.updateMatrix(),n.setMatrixAt(i,d.matrix)})),n.instanceMatrix.needsUpdate=!0,this.levelGroup.add(n)}else{if(!e.cells.length)return;const t=new i.ZLX(u,h(e.texture),e.cells.length);e.cells.forEach(((n,a)=>{d.position.set(n.x*vn,e.y,n.y*vn),d.rotation.set("floor"===e.kind?-Math.PI/2:Math.PI/2,0,0),d.updateMatrix(),t.setMatrixAt(a,d.matrix)})),t.instanceMatrix.needsUpdate=!0,this.levelGroup.add(t)}})),e.extras&&this.levelGroup.add(e.extras),this.scene.add(this.levelGroup),this.setEntities(e.entities||[]),this._spawnWalkers(e.walkers||[])}_spawnWalkers(e){Sn(this.walkerGroup),this.walkers=[],this.npcFactory&&e.forEach((e=>{const t=this.npcFactory(e);t&&(t.position.x=e.x*vn,t.position.z=e.y*vn,this.walkerGroup.add(t),this.walkers.push({obj:t,gx:e.x,gy:e.y,home:[e.x,e.y],fromX:e.x*vn,fromZ:e.y*vn,toX:e.x*vn,toZ:e.y*vn,dur:0,t0:0,pauseUntil:performance.now()+2e3*Math.random()}))}))}_pickWalkerStep(e,t){const n=this.levelDef&&this.levelDef.isFloor;if(!n)return!1;const i=[];for(let l=0;l<4;l++){const t=(0,a.A)(yn[l],2),s=t[0],o=t[1],r=e.gx+s,c=e.gy+o;n(r,c)&&(Math.abs(r-e.home[0])>4||Math.abs(c-e.home[1])>4||r===this.gridPos[0]&&c===this.gridPos[1]||i.push([r,c]))}if(!i.length)return!1;const s=(0,a.A)(i[Math.floor(Math.random()*i.length)],2),o=s[0],r=s[1];return e.fromX=e.gx*vn,e.fromZ=e.gy*vn,e.toX=o*vn,e.toZ=r*vn,e.gx=o,e.gy=r,e.t0=t,e.dur=900+500*Math.random(),!0}setEntities(e){this.disposed||(Sn(this.entityGroup),this.entityFactory&&e.forEach((e=>{const t=this.entityFactory(e,{levelDef:this.levelDef});t&&(t.position.x=e.x*vn,t.position.z=e.y*vn,t.userData.baseY=t.position.y,this.entityGroup.add(t))})))}setPose(e,t,n){this._cancelTweens(),this.gridPos=[e,t],this.yaw=-n*Math.PI/2,this.camera.position.set(e*vn,1.4,t*vn),this.camera.rotation.set(0,this.yaw,0)}glideTo(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:280;const a=this.camera.position.clone().sub(this.bumpOffset),s=new i.Pq0(e*vn,1.4,t*vn);return this.gridPos=[e,t],this._cancelTweens("pos"),this._addTween("pos",n,(e=>{this.camera.position.lerpVectors(a,s,e).add(this.bumpOffset)}))}turnTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;let n=(-e*Math.PI/2-this.yaw)%(2*Math.PI);n>Math.PI&&(n-=2*Math.PI),n<-Math.PI&&(n+=2*Math.PI);const a=this.yaw;return this._cancelTweens("yaw"),this._addTween("yaw",t,(e=>{this.yaw=a+n*e,this.camera.rotation.set(0,this.yaw,0)}))}bump(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:180;const n=(0,a.A)(yn[e],2),i=n[0],s=n[1];return this._cancelTweens("bump"),this._addTween("bump",t,(e=>{const t=.3*Math.sin(e*Math.PI),n=this.bumpOffset.clone();this.bumpOffset.set(i*t,0,s*t),this.camera.position.sub(n).add(this.bumpOffset)}))}_addTween(e,t,n){return new Promise((a=>{this._tweens.push({kind:e,t0:performance.now(),dur:t,apply:n,resolve:a})}))}_cancelTweens(e){this._tweens=this._tweens.filter((t=>!(!e||t.kind===e)||(t.apply(1),t.resolve(),!1)))}setPaused(e){this.paused=!!e}_frame(e){if(this.disposed)return;if(this._raf=requestAnimationFrame(this._frame),this.paused)return;if(this._tweens.length){const t=[];this._tweens.forEach((n=>{const a=Math.min(1,(e-n.t0)/n.dur);n.apply(xn(a)),a>=1&&t.push(n)})),t.length&&(this._tweens=this._tweens.filter((e=>!t.includes(e))),t.forEach((e=>e.resolve())))}if(this._lightTween){const t=this._lightTween,n=xn(Math.min(1,(e-t.t0)/t.dur)),a=(e,t)=>e+(t-e)*n;this.scene.fog.color.lerpColors(t.from.fog,t.to.fog,n),this.scene.fog.density=a(t.from.fogDensity,t.to.fogDensity),this._clearColor.lerpColors(t.from.bg,t.to.bg,n),this.renderer.setClearColor(this._clearColor),this.ambient.color.lerpColors(t.from.ambient,t.to.ambient,n),this.ambient.intensity=a(t.from.ambientIntensity,t.to.ambientIntensity),this.hemi&&t.to.hemi&&(this.hemi.color.lerpColors(t.from.hemiSky,t.to.hemiSky,n),this.hemi.groundColor.lerpColors(t.from.hemiGround,t.to.hemiGround,n),this.hemi.intensity=a(t.from.hemiIntensity,t.to.hemiIntensity)),this.sun&&t.to.sun&&(this.sun.color.lerpColors(t.from.sunColor,t.to.sunColor,n),this.sun.intensity=a(t.from.sunIntensity,t.to.sunIntensity),this.sun.position.lerpVectors(t.from.sunPos,t.to.sunPos,n)),this.starPoints.material.opacity=a(t.from.starsOpacity,t.to.starsOpacity,n),this.starPoints.visible=this.starPoints.material.opacity>.001,n>=1&&(this._lightTween=null)}this.starPoints.position.set(this.camera.position.x,0,this.camera.position.z);const t=(e-this._clockStart)/1e3,n=Math.min(.1,(e-(this._lastNow||e))/1e3);if(this._lastNow=e,this._weather){const e=this._weather;e.obj.position.set(this.camera.position.x,0,this.camera.position.z);const a=e.pos;if("snow"===e.kind)for(let i=0;i{const a=n.obj.userData.walkFrames;if(e=1&&(n.dur=0,n.pauseUntil=e+500+2500*Math.random())})),this.torch&&(this.torch.intensity=this.torchBase*(1+.05*Math.sin(7.3*t)+.04*Math.sin(23.7*t+1.3))),this._animations.forEach((e=>{e.texture.offset.x=t*e.du%1,e.texture.offset.y=t*e.dv%1})),this.entityGroup.children.forEach((e=>{e.userData.spin&&(e.rotation.y=1.6*t,e.position.y=e.userData.baseY+.07*Math.sin(2.2*t))})),this.composer.render()}setSize(e,t){!this.disposed&&e&&t&&(this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.composer&&this.composer.setSize(e,t))}setWeather(e){var t;if(this.disposed)return;const n="storm"===e?"storm":"rain"===e?"rain":"snow"===e?"snow":null;if((null===(t=this._weather)||void 0===t?void 0:t.kind)===(n||"none"))return;if(this._weather&&(this.scene.remove(this._weather.obj),this._weather.obj.geometry.dispose(),this._weather.obj.material.dispose(),this._weather=null),!n)return void(this._weather=null);const a=10*vn;if("snow"===n){const e=1e3,t=new Float32Array(3*e),s=new Float32Array(e);for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:{}).duration,n=void 0===t?2500:t;!this.disposed&&e&&this.scene.fog&&(this._lightTween={t0:performance.now(),dur:Math.max(1,n),from:{fog:this.scene.fog.color.clone(),fogDensity:this.scene.fog.density,bg:this._clearColor.clone(),ambient:this.ambient.color.clone(),ambientIntensity:this.ambient.intensity,hemiSky:this.hemi?this.hemi.color.clone():null,hemiGround:this.hemi?this.hemi.groundColor.clone():null,hemiIntensity:this.hemi?this.hemi.intensity:0,sunColor:this.sun?this.sun.color.clone():null,sunIntensity:this.sun?this.sun.intensity:0,sunPos:this.sun?this.sun.position.clone():null,starsOpacity:this.starPoints.material.opacity},to:{fog:new i.Q1f(e.fogColor),fogDensity:e.fogDensity,bg:new i.Q1f(null!=e.background?e.background:e.fogColor),ambient:new i.Q1f(e.ambientColor),ambientIntensity:e.ambientIntensity,hemi:e.hemi||null,hemiSky:e.hemi?new i.Q1f(e.hemi.skyColor):null,hemiGround:e.hemi?new i.Q1f(e.hemi.groundColor):null,hemiIntensity:e.hemi?e.hemi.intensity:0,sun:e.sun||null,sunColor:e.sun?new i.Q1f(e.sun.color):null,sunIntensity:e.sun?e.sun.intensity:0,sunPos:e.sun?new i.Pq0(e.sun.x,e.sun.y,e.sun.z):null,starsOpacity:e.starsOpacity||0}})}dispose(){this.disposed||(this.disposed=!0,cancelAnimationFrame(this._raf),this._cancelTweens(),this.levelGroup&&Sn(this.levelGroup),Sn(this.entityGroup),Sn(this.walkerGroup),this.walkers=[],Sn(this.lightGroup),this.starPoints.geometry.dispose(),this.starPoints.material.dispose(),this._weather&&(this._weather.obj.geometry.dispose(),this._weather.obj.material.dispose(),this._weather=null),this.onDisposeTextures&&this.onDisposeTextures(),this.bloomPass.dispose(),this.gradePass.dispose(),this.outputPass.dispose(),this.composer.dispose(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement))}}},5993(e,t,n){"use strict";n.d(t,{$3:()=>h,Cu:()=>i,DO:()=>l,I7:()=>r,XP:()=>o,fB:()=>c,ir:()=>s,jZ:()=>d});var a=n(5544);function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!e.length)return"";const i=new Set(e.map((e=>{let t=(0,a.A)(e,2),n=t[0],i=t[1];return"".concat(n,",").concat(i)}))),s=(e,t)=>i.has("".concat(e,",").concat(t)),o=new Map,r=(e,t,n,a)=>{const i="".concat(e,",").concat(t);o.has(i)||o.set(i,[]),o.get(i).push([n,a])};for(const p of e){var l=(0,a.A)(p,2);const e=l[0],t=l[1];s(e,t-1)||r(e,t,e+1,t),s(e+1,t)||r(e+1,t,e+1,t+1),s(e,t+1)||r(e+1,t+1,e,t+1),s(e-1,t)||r(e,t+1,e,t)}const c=(e,t,n,i)=>{const s=o.get("".concat(e,",").concat(t));if(!s||!s.length)return null;if(1===s.length||void 0===n)return s.shift();const r=[[-i,n],[n,i],[i,-n]];for(const o of r){var l=(0,a.A)(o,2);const n=l[0],i=l[1],r=s.findIndex((s=>{let o=(0,a.A)(s,2),r=o[0],l=o[1];return Math.sign(r-e)===Math.sign(n)&&Math.sign(l-t)===Math.sign(i)}));if(r>=0)return s.splice(r,1)[0]}return s.shift()},h=[];for(const p of o){var d=(0,a.A)(p,2);const e=d[0],t=d[1];for(;t.length;){const n=e.split(",").map(Number),i=(0,a.A)(n,2),s=i[0],o=i[1],r=t.shift(),l=[[s,o],r];let d=(0,a.A)(r,2),p=d[0],m=d[1],f=p-s,g=m-o,v=0;for(;(p!==s||m!==o)&&v++<1e5;){const e=c(p,m,f,g);if(!e)break;f=e[0]-p,g=e[1]-m;var u=(0,a.A)(e,2);p=u[0],m=u[1],l.push(e)}const b=[];for(const e of l){const t=b.length;if(t>=2){const n=(0,a.A)(b[t-2],2),i=n[0],s=n[1],o=(0,a.A)(b[t-1],2),r=o[0],l=o[1];(r-i)*(e[1]-l)===(e[0]-r)*(l-s)&&b.pop()}b.push(e)}b.length>2&&b[0][0]===b[b.length-1][0]&&b[0][1]===b[b.length-1][1]&&b.pop(),b.length>=3&&h.push(b)}}return h.map((e=>{const i=e=>(e*t+n).toFixed(1);return"M"+e.map((e=>{let t=(0,a.A)(e,2),n=t[0],s=t[1];return"".concat(i(n)," ").concat(i(s))})).join(" L")+" Z"})).join(" ")}function s(e){let t=1/0,n=1/0,i=-1/0,s=-1/0;for(const r of e){var o=(0,a.A)(r,2);const e=o[0],l=o[1];ei&&(i=e),l>s&&(s=l)}return{x1:t,y1:n,x2:i,y2:s,w:i-t+1,h:s-n+1}}function o(e){let t=0,n=0;for(const s of e){var i=(0,a.A)(s,2);t+=i[0],n+=i[1]}return[t/e.length+.5,n/e.length+.5]}function r(e){if("h"===e.kind){const t=[Math.min(e.from,e.to),Math.max(e.from,e.to)],n=t[0],a=t[1];return{x:(n+a+1)/2,y:e.y+.5,rotate:0,length:a-n+1}}if("v"===e.kind){const t=[Math.min(e.from,e.to),Math.max(e.from,e.to)],n=t[0],a=t[1];return{x:e.x+.5,y:(n+a+1)/2,rotate:-90,length:a-n+1}}const t=[Math.min(e.x,e.from),Math.max(e.x,e.from)],n=t[0],a=t[1],i=[Math.min(e.y,e.to),Math.max(e.y,e.to)];return{x:(n+a+1)/2,y:(i[0]+i[1]+1)/2,rotate:0,length:a-n+1}}function l(e){const t=[],n=[],a=[],i=[],s=[],o=[];for(let r=0;rn>=0&&n=0&&t>>0)%e.length]}},4502(e,t,n){"use strict";n.d(t,{A:()=>g});var a=n(9379),i=n(5544),s=n(5043),o=n(1947),r=n(733),l=n(333),c=n(9435);const h=[{key:"villager",url:n.p+"static/media/villager_walking_south.5acd1a8beb4a9b0988aa.png",frameCount:4},{key:"acolyte",url:n.p+"static/media/acolyte_walking_south.9bb7a5a07d009ce7d050.png",frameCount:4},{key:"guard",url:n.p+"static/media/guard_walking_south.e2a9e73e67d77a199b31.png",frameCount:4},{key:"warrior",url:n.p+"static/media/warrior_walking_south.99548cc9e9888baa3c4b.png",frameCount:4}],d=new c.Tap,u=new Map;function p(){return e=>{const t=((e.variant||0)%h.length+h.length)%h.length,n=function(e){if(u.has(e.key))return u.get(e.key);const t=[];for(let n=0;n{t.forEach((t=>{t.image=e.image,t.needsUpdate=!0}))})),u.set(e.key,t),t}(h[t]),a=new c.kxk(new c.RoJ({map:n[0],transparent:!0,depthWrite:!1}));return a.scale.set(1.5,1.5,1),a.position.y=.75,a.userData.walkFrames=n,a}}var m=n(579);function f(){(0,l.Sz)(),u.forEach((e=>e.forEach((e=>e.dispose())))),u.clear()}const g=function(e){let t=e.cityMap,n=e.gameTime,l=e.onMove,c=e.onOpenShop,h=e.onEnterPlace,d=e.onBurgle,u=e.disabled;const g=(0,s.useRef)(null);g.current=n;const v=(0,s.useMemo)((()=>(0,r.a_)((null===n||void 0===n?void 0:n.phase)||"day",(null===n||void 0===n?void 0:n.weather)||"clear")),[null===n||void 0===n?void 0:n.phase,null===n||void 0===n?void 0:n.weather]),b=(0,s.useCallback)(((e,t)=>{t.entityFactory=null,t.npcFactory=p();const n=g.current;return(0,r.B7)(e,t.maxAnisotropy,{phase:(null===n||void 0===n?void 0:n.phase)||"day",weather:(null===n||void 0===n?void 0:n.weather)||"clear"})}),[]),y=(0,s.useCallback)(((e,t,n)=>(0,r.nF)(e.grid,t,n)),[]),w=(0,s.useMemo)((()=>(0,r.TP)(t)),[t]),x=(0,s.useState)(null),S=(0,i.A)(x,2),k=S[0],_=S[1],T=(0,s.useMemo)((()=>{const e={};return((null===t||void 0===t?void 0:t.buildings)||[]).forEach((t=>{e["".concat(t.doorX,",").concat(t.doorY)]=t.name})),e}),[null===t||void 0===t?void 0:t.buildings]),R=(0,s.useCallback)(((e,t,n)=>{var a;const i="".concat(t,",").concat(n);return T[i]||(null===e||void 0===e||null===(a=e.streets)||void 0===a?void 0:a[i])||null}),[T]),A=(0,s.useCallback)(((e,t,n)=>{const i=[],s=((null===e||void 0===e?void 0:e.buildings)||[]).find((e=>e.doorX===t&&e.doorY===n));s&&(s.hasShop&&c?i.push({id:"shop",label:"\ud83d\uded2 Enter Shop",onClick:()=>c(s.id)}):s.enterable&&h&&i.push({id:"enter",label:"\ud83d\udeaa Enter ".concat(s.name),onClick:()=>h(s.id)}),d&&i.push({id:"burgle",label:"\ud83e\udd77 Break In",onClick:()=>d(s.id)}));const o=w.find((e=>Math.abs(e.x-t)+Math.abs(e.y-n)<=1));return o&&i.push({id:"talk-".concat(o.id),label:"\ud83d\udcac Talk to ".concat(o.name),onClick:()=>_((0,a.A)((0,a.A)({},o),{},{t:Date.now()}))}),i}),[c,h,d,w]);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(o.A,{mapData:t,levelKey:"".concat(null===t||void 0===t?void 0:t.cityId,"|").concat(null===t||void 0===t?void 0:t.district,"|").concat(null===t||void 0===t?void 0:t.seed),buildLevel:b,buildEntities:null,isFloor:y,bannerFor:R,actionsFor:A,lighting:v,weather:null===n||void 0===n?void 0:n.weather,onMove:l,onDispose:f,disabled:u}),k&&(0,m.jsxs)("div",{className:"c3v-talk-popup",children:[(0,m.jsx)("strong",{children:k.name})," ",(0,m.jsxs)("span",{className:"c3v-talk-label",children:["\xb7 ",k.label]}),(0,m.jsx)("p",{children:k.blurb})]},"".concat(k.id,"-").concat(k.t))]})}},733(e,t,n){"use strict";n.d(t,{B7:()=>R,TP:()=>y,nF:()=>b,a_:()=>T});var a=n(9379),i=n(5544),s=n(9435),o=n(5996),r=n(5993),l=n(333);const c=["Aldric","Brynn","Cass","Dwyn","Elric","Fenna","Garrick","Hesper","Ivor","Jessa","Kestrel","Lorn","Maible","Nessa","Orin","Perrin","Quenna","Roswyn","Sable","Torvin"],h=["villager","acolyte","guard","warrior"],d={villager:["hums an old tune while carrying a basket of turnips.","is haggling loudly over the price of bread.","stops to admire a shopfront, then moves on.","nods a polite greeting and keeps walking."],acolyte:["murmurs a quiet prayer under their breath.","carries a small bundle of temple candles.","walks with hands folded, eyes downcast.","pauses to ring a small bell at a street shrine."],guard:["keeps a wary eye on the street corners.","adjusts a helmet strap, scanning the crowd.","walks a slow, deliberate patrol route.","nods stiffly \u2014 clearly on duty."],warrior:["has the look of someone between jobs.","checks a weapon strap out of old habit.","walks with a mercenary's unhurried swagger.","eyes the taverns like they know every one."]};function u(e,t,n){let a=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,1442695041)|0;return a=Math.imul(a^a>>>13,1274126177),((a^a>>>16)>>>0)/4294967296}var p=n(9265);const m={temple:5.2,landmark:5.2,guildhall:4.6,warehouse:4.1,tavern:4.1,market:3.5,blacksmith:3.5,apothecary:3.5,house:3.2},f=new Set(["temple","guildhall","landmark","warehouse"]),g=r.$3.map((e=>e.key));function v(e,t,n){let a=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,1442695041)|0;return a=Math.imul(a^a>>>13,1274126177),((a^a>>>16)>>>0)/4294967296}function b(e,t,n){const a=e[n];return!(t<0||n<0||!a||t>=a.length)&&"."===a[t]}function y(e){const t=e.grid||[],n=e.width||(t[0]?t[0].length:0),s=e.height||t.length,o=(e,n)=>b(t,e,n),r=[];for(let a=0;ae.x!==f||e.y!==g)).map((e=>(0,a.A)((0,a.A)({},e),{},{score:v(e.x,e.y,l+101)}))).sort(((e,t)=>t.score-e.score)).slice(0,y).map(((e,t)=>{const n=Math.floor(4*v(e.x,e.y,l+151));return(0,a.A)({id:"person-".concat(t),x:e.x,y:e.y,variant:n},function(e,t,n,a){const i=h[(n%h.length+h.length)%h.length],s=c[Math.floor(u(e,t,a)*c.length)],o=d[i]||d.villager,r=o[Math.floor(u(e,t,a+1)*o.length)];return{name:s,label:i.charAt(0).toUpperCase()+i.slice(1),blurb:r}}(e.x,e.y,n,l))}))}const w=[[0,-1],[1,0],[0,1],[-1,0]],x=[0,-Math.PI/2,Math.PI,Math.PI/2];const S={day:{background:10336726,fogColor:11059156,fogDensity:.011,ambientColor:10134960,ambientIntensity:.5,hemi:{skyColor:13624063,groundColor:9405544,intensity:1.15},sun:{color:16772560,intensity:2.2,x:18,y:30,z:10},torch:null,starsOpacity:0},dawn:{background:14262652,fogColor:13214858,fogDensity:.014,ambientColor:9274516,ambientIntensity:.45,hemi:{skyColor:16767408,groundColor:7300180,intensity:.85},sun:{color:16763024,intensity:1.4,x:30,y:12,z:4},torch:null,starsOpacity:0},dusk:{background:8018542,fogColor:8610416,fogDensity:.014,ambientColor:7300216,ambientIntensity:.45,hemi:{skyColor:14262440,groundColor:5195328,intensity:.7},sun:{color:16751196,intensity:1.1,x:-25,y:10,z:8},torch:null,starsOpacity:.25},night:{background:197897,fogColor:329744,fogDensity:.02,ambientColor:3358812,ambientIntensity:.35,hemi:{skyColor:2767452,groundColor:1841684,intensity:.45},sun:{color:12374271,intensity:.5,x:-12,y:26,z:-14},torch:null,starsOpacity:.9}},k=(e,t,n)=>Math.round(e+(t-e)*n);function _(e,t,n){return k(e>>16&255,t>>16&255,n)<<16|k(e>>8&255,t>>8&255,n)<<8|k(255&e,255&t,n)}function T(e,t){const n=S[e]||S.day,i=(0,a.A)((0,a.A)({},n),{},{hemi:(0,a.A)({},n.hemi),sun:(0,a.A)({},n.sun)}),s=9080985;switch(t){case"overcast":case"rain":i.background=_(i.background,s,.5),i.fogColor=_(i.fogColor,s,.5),i.fogDensity*=1.5,i.sun.intensity*=.4,i.hemi.intensity*=.85,i.starsOpacity=0;break;case"storm":i.background=_(i.background,4870236,.65),i.fogColor=_(i.fogColor,4870236,.65),i.fogDensity*=1.8,i.sun.intensity*=.25,i.hemi.intensity*=.7,i.starsOpacity=0;break;case"fog":i.fogDensity*=3,i.background=_(i.background,i.fogColor,.6),i.sun.intensity*=.6,i.starsOpacity=0;break;case"snow":i.background=_(i.background,12109008,.45),i.fogColor=_(i.fogColor,12109008,.45),i.fogDensity*=1.6,i.sun.intensity*=.6,i.starsOpacity=0}return i}function R(e,t,n){const a=e.grid||[],c=e.terrain||[],h=e.width||(a[0]?a[0].length:0),d=e.height||a.length,u=(0,l.rJ)(t),S={width:h,height:d,grid:a,terrain:c,streets:e.streetSegs||[],buildings:e.buildings||[]},k=(e,t)=>c[t]&&c[t][e]||"_",_=(e,t)=>a[t]&&a[t][e]||"",R=(e,t)=>b(a,e,t),A=(0,o.pA)(S),C=new Map;A.forEach(((e,t)=>e.cells.forEach((e=>{let n=(0,i.A)(e,2),a=n[0],s=n[1];return C.set("".concat(a,",").concat(s),t)}))));const N=A.map((e=>e.cells.some((e=>{let t=(0,i.A)(e,2),n=t[0],a=t[1];return 0===n||0===a||n===h-1||a===d-1})))),E=A.filter(((e,t)=>!N[t])),M=new Map;for(const i of S.buildings){const e=(0,o.E$)(E,i.doorX,i.doorY);if(e){const t=A.indexOf(e);M.has(t)||M.set(t,i)}}const L=Math.floor(1e6*v(h,d,7)),I={brick:{wall:u.brick,roof:u.roof},timberBw:{wall:u.timberBw,roof:u.roof},stone:{wall:u.stone,roof:u.slate},daub:{wall:u.daub,roof:u.thatch},plaster:{wall:u.plaster,roof:u.roof},plaster2:{wall:u.plaster2,roof:u.roof}},X=e.seed||e.name||"".concat(h,"x").concat(d),P=A.map(((e,t)=>{if(N[t])return{height:5.6,wallTex:u.stone,roofTex:u.plaza,building:null,isWall:!0};const n=M.get(t),a=(0,i.A)(e.cells[0],2),s=a[0],o=a[1],l=v(s,o,L),c=n?m[n.type]||3.5:3.1+.25*Math.round(3*l),h=(n&&g.includes(n.wallStyle)?n.wallStyle:null)||(n&&f.has(n.type)?"stone":(0,r.jZ)(g,"".concat(X,"-").concat(s,"-").concat(o))),d=I[h];return{height:c,wallTex:d.wall,roofTex:d.roof,building:n,isWall:!1}})),W=[],G=[],j=[],V=[],Z=new Map,F=new Map,D=[],B=[];for(let s=0;s=h||r>=d)continue;if(C.has("".concat(o,",").concat(r)))continue;const c="".concat(n.wallTex.uuid,"|").concat(n.height);Z.has(c)||Z.set(c,{texture:(0,l.Lm)(n.wallTex,1,Math.max(1,Math.round(n.height/4.4))),height:n.height,faces:[]}),Z.get(c).faces.push({x:o,y:r,dir:(t+2)%4})}if(n.isWall){const t="".concat(n.height,"|").concat(n.roofTex.uuid);F.has(t)||F.set(t,{cells:[],texture:n.roofTex,y:n.height}),F.get(t).cells.push({x:e,y:s})}}}const H=[{kind:"floor",cells:W,texture:u.cobble,y:0},{kind:"floor",cells:G,texture:u.plaza,y:0},{kind:"floor",cells:j,texture:u.grass,y:0},...[...Z.values()].map((e=>({kind:"wall",faces:e.faces,texture:e.texture,height:e.height}))),...[...F.values()].map((e=>({kind:"floor",cells:e.cells,texture:e.texture,y:e.y})))],U=new s.YJl,Y=new s.B69,O=new s._4j({color:7629406,roughness:.9});A.forEach(((e,t)=>{if(N[t])return;const n=P[t],a=function(e){const t=new Set(e.map((e=>{let t=(0,i.A)(e,2),n=t[0],a=t[1];return"".concat(n,",").concat(a)}))),n=new Set,a=[],s=e.slice().sort(((e,t)=>e[1]-t[1]||e[0]-t[0]));for(const r of s){var o=(0,i.A)(r,2);const e=o[0],s=o[1];if(n.has("".concat(e,",").concat(s)))continue;let l=1;for(;t.has("".concat(e+l,",").concat(s))&&!n.has("".concat(e+l,",").concat(s));)l++;let c=1,h=!0;for(;h;){for(let a=0;a{const t=e.x0,i=e.x0+e.w-1,r=e.y0,l=e.y0+e.h-1,c=e.w,h=e.h,d=c*p.JA+.44,u=h*p.JA+.44,m=(t+i)/2*p.JA,f=(r+l)/2*p.JA,g=1===a.length&&n.building&&("landmark"===n.building.type||"temple"===n.building.type)&&c<=2&&h<=2;let b;if(g){const e=Math.max(d,u),t=e*Math.SQRT1_2;b=Math.min(2.6,Math.max(1.1,.6*e));const a=new s.qFE(t,b,4,1);a.rotateY(Math.PI/4);const i=new s.eaF(a,o);i.position.set(m,n.height+b/2,f),U.add(i)}else{const e=c>h||c===h&&v(t,r,L+61)<.5,a=e?u:d,i=e?d:u;b=Math.min(2.1,Math.max(.9,.55*a));const l=function(e,t,n){const a=e/2,i=t/2,o=Math.hypot(a,n)/p.JA,r=t/p.JA,l=e/p.JA,c=[],h=[],d=(e,t,n,a,i,s)=>{c.push(...e,...t,...n),h.push(...a,...i,...s)},u=[-a,0,-i],m=[a,0,-i],f=[a,0,i],g=[-a,0,i],v=[0,n,-i],b=[0,n,i];d(u,g,b,[0,0],[r,0],[r,o]),d(u,b,v,[0,0],[r,o],[0,o]),d(m,f,b,[0,0],[r,0],[r,o]),d(m,b,v,[0,0],[r,o],[0,o]),d(u,m,v,[0,0],[l,0],[l/2,n/p.JA]),d(g,f,b,[0,0],[l,0],[l/2,n/p.JA]);const y=new s.LoY;return y.setAttribute("position",new s.qtW(c,3)),y.setAttribute("uv",new s.qtW(h,2)),y.computeVertexNormals(),y}(a,i,b);e&&l.rotateY(Math.PI/2);const g=new s.eaF(l,o);g.position.set(m,n.height,f),U.add(g)}if(!g&&c*h>=2&&v(t,r,L+41)>.35){const e=.34,a=.85+.3*v(t,r,L+43),i=v(t,r,L+47)<.5?-1:1,o=v(t,r,L+53)<.5?-1:1,l=i*(.65+.25*v(t,r,L+57))*(d/2-e),c=o*(.65+.25*v(t,r,L+59))*(u/2-e),h=new s.eaF(new s.iNn(e,a,e),O);h.position.set(m+l,n.height+a/2,f+c),U.add(h)}}))}));const z=(0,l.Lm)(u.water,1,1);if(V.length){const e=new s.bdM(p.JA,p.JA),t=new s.ZLX(e,new s._4j({map:z,roughness:.25,metalness:.08}),V.length);V.forEach(((e,n)=>{Y.position.set(e.x*p.JA,-.16,e.y*p.JA),Y.rotation.set(-Math.PI/2,0,0),Y.scale.set(1,1,1),Y.updateMatrix(),t.setMatrixAt(n,Y.matrix)})),t.instanceMatrix.needsUpdate=!0,U.add(t)}if(D.length){const e=new s._4j({color:5914664,roughness:.95}),t=new s._4j({color:4156207,roughness:.9}),n=new s.ZLX(new s.Ho_(.11,.17,1.6,7),e,D.length),a=new s.ZLX(new s.qFE(.7,2.1,8),t,D.length);D.forEach(((e,t)=>{const i=.4*(v(e.x,e.y,L+11)-.5),s=.4*(v(e.x,e.y,L+13)-.5),o=.75+.35*v(e.x,e.y,L+17),r=v(e.x,e.y,L+19)*Math.PI*2;Y.position.set(e.x*p.JA+i,.8*o,e.y*p.JA+s),Y.rotation.set(0,r,0),Y.scale.set(o,o,o),Y.updateMatrix(),n.setMatrixAt(t,Y.matrix),Y.position.y=2.6*o,Y.updateMatrix(),a.setMatrixAt(t,Y.matrix)})),n.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,U.add(n,a)}if(B.length){const e=new s._4j({color:4616239,roughness:.95}),t=new s.ZLX(new s.WBB(.55,1),e,B.length);B.forEach(((e,n)=>{const a=1*(v(e.x,e.y,L+23)-.5),i=1*(v(e.x,e.y,L+29)-.5),s=.7+.6*v(e.x,e.y,L+31);Y.position.set(e.x*p.JA+a,.3*s,e.y*p.JA+i),Y.rotation.set(0,0,0),Y.scale.set(s,.65*s,s),Y.updateMatrix(),t.setMatrixAt(n,Y.matrix)})),t.instanceMatrix.needsUpdate=!0,U.add(t)}const J=new s._4j({color:4861974,roughness:.85}),K=new s._4j({color:3811346,roughness:.9}),Q=new s._4j({color:12097086,roughness:.35,metalness:.7});for(const r of S.buildings){const e=(0,o.E$)(E,r.doorX,r.doorY);if(!e)continue;const t=new Set(e.cells.map((e=>{let t=(0,i.A)(e,2),n=t[0],a=t[1];return"".concat(n,",").concat(a)})));for(let n=0;n<4;n++){const e=(0,i.A)(w[n],2),a=e[0],o=e[1];if(!t.has("".concat(r.doorX+a,",").concat(r.doorY+o)))continue;const l=new s.YJl,c=new s.eaF(new s.iNn(1.15,2.3,.1),J);c.position.y=1.15;const h=new s.eaF(new s.iNn(1.5,.2,.16),K);h.position.y=2.4;const d=new s.eaF(new s.Gu$(.055,8,8),Q);d.position.set(.38,1.15,-.08),l.add(c,h,d),l.position.set(r.doorX*p.JA+a*(p.JA/2-.06),0,r.doorY*p.JA+o*(p.JA/2-.06)),l.rotation.y=x[n]+Math.PI,U.add(l);break}}const q=y(e),$=new s.eaF(new s.bdM(h*p.JA*8,d*p.JA*8),new s._4j({map:(0,l.Lm)(u.grass,4*h,4*d),roughness:1}));return $.rotation.x=-Math.PI/2,$.position.set(h*p.JA/2,-.3,d*p.JA/2),U.add($),{isFloor:R,lighting:T((null===n||void 0===n?void 0:n.phase)||"day",(null===n||void 0===n?void 0:n.weather)||"clear"),grade:{warmth:.02,saturation:1.04,contrast:1,vignetteStrength:.32},surfaces:H,extras:U,animations:[{texture:z,du:.012,dv:.007}],entities:[],walkers:q}}},333(e,t,n){"use strict";n.d(t,{Sz:()=>k,rJ:()=>x,Lm:()=>S});var a=n(9435);const i=n.p+"static/media/plaster.2eda486e13aec217d771.png",s=n.p+"static/media/plaster2.2c9ce57adbd288dd8517.png",o=n.p+"static/media/timber-bw.9d7d984e9d30ccb0ba3f.png",r=n.p+"static/media/daub.b81c4a665143d98bcfbd.png",l=n.p+"static/media/brickwall.7c267b262252349a61b5.png",c=n.p+"static/media/stone.826b9b3cc55d65c3292a.png",h=n.p+"static/media/roof.92a97887e9762c911ec8.png",d=n.p+"static/media/thatch.cb72d5316d6d44e40b3e.png",u=n.p+"static/media/slate.ec8fa551e1fb6eebdbca.png",p=n.p+"static/media/cobble.8a8f4c232bc38a8b87e9.png",m=n.p+"static/media/plaza.1005085622d22391752e.png",f=n.p+"static/media/grass.66d8ede44f02d512376f.png",g=n.p+"static/media/water.872108b0d642add237ee.png",v=new a.Tap,b=new Map,y=new Set;function w(e,t){if(b.has(e))return b.get(e);const n=v.load(e);return n.colorSpace=a.er$,n.wrapS=a.GJx,n.wrapT=a.GJx,n.minFilter=a.$_I,n.magFilter=a.k6q,n.anisotropy=Math.min(8,t||1),b.set(e,n),n}function x(e){return{plaster:w(i,e),plaster2:w(s,e),timberBw:w(o,e),daub:w(r,e),brick:w(l,e),stone:w(c,e),roof:w(h,e),thatch:w(d,e),slate:w(u,e),cobble:w(p,e),plaza:w(m,e),grass:w(f,e),water:w(g,e)}}function S(e,t,n){const a=e.clone();return a.repeat.set(t,n),a.needsUpdate=!0,y.add(a),a}function k(){y.forEach((e=>e.dispose())),y.clear(),b.forEach((e=>e.dispose())),b.clear()}},1927(e,t,n){"use strict";n.d(t,{K:()=>h});var a=n(5544),i=n(9379),s=n(8634);const o={small:{dim:24,rooms:6},medium:{dim:32,rooms:9},large:{dim:40,rooms:13}},r={crypt:{nameParts:{prefix:["The Sunken","The Silent","The Forgotten","The Weeping","The Hollow"],noun:["Crypt","Barrow","Ossuary","Tomb","Sepulcher","Catacombs"],suffix:["of the Pale King","of Whispered Names","of the Nine","Below the Chapel","of Cold Candles"]},rooms:[{name:"Bone Gallery",desc:"Femurs and skulls are mortared into the walls in careful, dreadful patterns."},{name:"Embalming Chamber",desc:"Stone slabs, rusted hooks, and jars whose contents are best left sealed."},{name:"Sunken Chapel",desc:"A drowned altar to a god nobody prays to anymore. The water is ankle-deep and cold."},{name:"Hall of Names",desc:"Every wall is carved with names \u2014 the newest ones look freshly cut."},{name:"Collapsed Vault",desc:"Half the ceiling has come down. Something has been digging through the rubble."},{name:"The Long Stair",desc:"Steps descend further than any lantern shows. The air rises cold and slow."},{name:"Reliquary",desc:"Broken display cases and empty pedestals. One reliquary remains untouched."},{name:"Warden's Cell",desc:"A living quarters for whoever kept this place. The bed is made. Recently."},{name:"Flooded Gallery",desc:"Black water hides the floor. Ripples move against the direction you'd expect."},{name:"Ossuary Well",desc:"A shaft ringed by shelves of bones, descending into dark."},{name:"The Quiet Court",desc:"A burial court for the wealthy dead \u2014 their statues still argue over precedence."},{name:"Sealed Antechamber",desc:"The seals on the far door were placed from THIS side."},{name:"Crypt of the Founder",desc:"The grandest tomb here, and the only one standing open."}],monsters:{1:["Grave Rat","Bone Shard Swarm","Crypt Beetle"],2:["Restless Skeleton","Barrow Ghoul","Tomb Robber"],3:["Crypt Warden","Wight of the Nine","Embalmed Horror"],4:["The Pale King's Herald","Bone Tyrant","The Founder, Risen"]},props:["bones","altar","pillar","chest","trap"],ambientProp:"bones"},cave:{nameParts:{prefix:["The Howling","The Deep","The Glimmering","The Black","The Dripping"],noun:["Caverns","Hollows","Warrens","Grotto","Depths","Chasm"],suffix:["of Echoes","Below the Fell","of the Blind Ones","Under Old Tor","of Still Water"]},rooms:[{name:"Echo Chamber",desc:"Every sound returns threefold, slightly wrong each time."},{name:"Mushroom Grove",desc:"Pale fungus stands taller than a man, glowing faintly where touched."},{name:"Underground Pool",desc:"Water so still it mirrors your lantern perfectly \u2014 until something moves beneath."},{name:"The Squeeze",desc:"The passage narrows to shoulder width. Scratch marks line the walls at head height."},{name:"Crystal Vault",desc:"Veins of raw crystal split lantern light into shivering colors."},{name:"Bat Roost",desc:"The ceiling rustles. The floor is soft, and best not examined."},{name:"Old Camp",desc:"A cold firepit, a torn bedroll, and a journal that ends mid-sentence."},{name:"The Bonepile",desc:"Something eats here. Regularly. The bones are sorted by size."},{name:"Rushing Gallery",desc:"An underground stream roars through, drowning every other sound."},{name:"Smugglers' Cache",desc:"Crates with faded stamps and a rowboat far from any known water."},{name:"The Great Dome",desc:"A cavern vast enough to hold a village, its ceiling lost to dark."},{name:"Sulfur Vents",desc:"The air stings and shimmers. Breathing here is a decision."},{name:"The Deep Door",desc:"A worked-stone door in natural rock, older than any mason's guild."}],monsters:{1:["Cave Rat","Fungus Crawler","Blind Snapper"],2:["Cave Lurker","Rock Spider","Feral Troglodyte"],3:["Cave Troll","Chitin Broodmother","The Sorted-Bones Eater"],4:["The Blind One","Chasm Wyrm","Elder Troglodyte Shaman"]},props:["bones","barrel","pillar","chest","trap"],ambientProp:"bones"},fortress:{nameParts:{prefix:["The Broken","The Iron","The Last","The Fallen","The Grim"],noun:["Keep","Garrison","Bastion","Redoubt","Watch","Hold"],suffix:["of the Border Wars","of Captain Vane","on the Scarp","of the Tenth Legion","at World's Edge"]},rooms:[{name:"Gatehouse",desc:"The portcullis is down and rusted in place. Someone has cut a man-sized hole through it."},{name:"Mess Hall",desc:"Long tables set for a meal that was never eaten. The plates have been licked clean."},{name:"Armory",desc:"Racks stripped bare, except for the weapons too broken \u2014 or too strange \u2014 to take."},{name:"Barracks",desc:"Rows of bunks, blankets folded with military precision, under years of dust."},{name:"Commander's Quarters",desc:"Maps still pinned to the table, marking an enemy position that no longer exists."},{name:"The Undercroft",desc:"Supply cellars, mostly empty. The rats here don't run from light."},{name:"Chapel of the Legion",desc:"Regimental banners rot on the walls. The offering box was pried open long ago."},{name:"Training Yard",desc:"An interior court, open to a grey sliver of sky. Practice dummies stand at attention."},{name:"The Oubliette",desc:"Cells below the cells. The last prisoner left a calendar scratched into stone \u2014 it's still being updated."},{name:"Siege Store",desc:"Coils of rope, barrels of pitch, and enough arrows to fight a war that already happened."},{name:"The Breach",desc:"Where the wall failed. Rubble frames a view of nothing anyone would want to enter from."},{name:"Signal Tower Base",desc:"The stairs up end in sky. The signal brazier fell \u2014 or was pushed."},{name:"War Room",desc:"The final orders are still chalked on the slate board. They end with: HOLD."}],monsters:{1:["Rusted Servitor","Carrion Crow Swarm","Looter"],2:["Deserter Ghost","Mercenary Scavenger","Animated Armor"],3:["The Sergeant's Shade","Ogre Squatter","Siege Wraith"],4:["Captain Vane's Revenant","The Breach-Maker","Warlord of the Ruin"]},props:["barrel","pillar","chest","trap","bookshelf"],ambientProp:"barrel"},sewer:{nameParts:{prefix:["The Old","The Drowned","The Rat King's","The Forgotten","The Under-"],noun:["Sewers","Cisterns","Drains","Channels","Sump","Works"],suffix:["Below Market Row","of the First City","Under the Weighyard","of Quiet Commerce","Below the Baths"]},rooms:[{name:"Junction Chamber",desc:"Four channels meet in a round chamber. The echoes make it sound like eight."},{name:"The Grate Room",desc:"Light falls in bars from a street grate far above. So does everything else."},{name:"Silt Trap",desc:"Waist-deep sediment that remembers every boot that ever crossed it."},{name:"Smuggler's Landing",desc:"A dry ledge with mooring rings, crates, and a ledger written in cipher."},{name:"The Great Cistern",desc:"A cathedral of water storage, columns marching into the dark."},{name:"Overflow Gallery",desc:"High-water marks stripe the walls like rings in a tree \u2014 the top one is fresh."},{name:"Ratspeaker's Court",desc:"Bones, bottle-glass and candle stubs arranged in a rough throne room."},{name:"The Blocked Main",desc:"Something built a dam here on purpose. It's still maintained."},{name:"Alchemist's Runoff",desc:"The water glows faintly here, and the moss grows in geometric patterns."},{name:"The Warden's Walk",desc:"A maintenance path with lanterns still burning. Somebody pays for that oil."},{name:"Collapsed Channel",desc:"The brickwork gave out into an older tunnel beneath \u2014 much older."},{name:"The Sluice Gate",desc:"A wheel that could flood half the system. The chain is new."},{name:"The King's Nest",desc:"Warm, dry, carpeted in stolen finery. Whatever lives here lives well."}],monsters:{1:["Sewer Rat","Sludge Crab","Biting Swarm"],2:["Giant Rat","Drain Lurker","Mudclot Shambler"],3:["Rat King's Champion","Cistern Serpent","The Warden Below"],4:["The Rat King","Elder Sludge Horror","The Thing in the Old Tunnel"]},props:["barrel","bones","chest","trap","pillar"],ambientProp:"barrel"}},l={crypt:{name:"Descending Gallery",desc:"Worn steps lead down from the surface. Daylight gives up a few paces in."},cave:{name:"Cave Mouth",desc:"The last of the daylight pools here among old ash circles and older bones."},fortress:{name:"Shattered Gate",desc:"The way in is over the fallen door, under the gaze of empty arrow slits."},sewer:{name:"Access Stair",desc:"An iron ladder and a stone stair, both slick, both descending."}};var c=n(1015);function h(e,t){for(let a=0;a<3;a++){const n=d(e,0===a?t:"".concat(t,"#").concat(a));if(n.seed=t,0===(0,c.t)(n).length)return n}const n=d(e,"".concat(t,"#2"));return n.seed=t,n}function d(e,t){const n=(0,s.sK)((0,s.M1)(t)),c=o[e.size]||o.medium,h=r[e.theme]||r.crypt,d=r[e.theme]?e.theme:"crypt",u=c.dim,p=Math.min(5,Math.max(1,e.density||3)),m=Array.from({length:u},(()=>Array(u).fill("#"))),f=[];let g=0;for(;f.lengthan.x&&in.y))||f.push({x:a,y:i,w:e,h:t,cx:a+Math.floor(e/2),cy:i+Math.floor(t/2)})}const v=(e,t)=>{((e,t)=>e>=1&&e<=u-2&&t>=1&&t<=u-2)(e,t)&&(m[t][e]=".")};for(const a of f)for(let e=a.y;e{if(n()<.5){for(let n=Math.min(e,a);n<=Math.max(e,a);n++)v(n,t);for(let e=Math.min(t,i);e<=Math.max(t,i);e++)v(a,e)}else{for(let n=Math.min(t,i);n<=Math.max(t,i);n++)v(e,n);for(let t=Math.min(e,a);t<=Math.max(e,a);t++)v(t,i)}};for(let a=1;a8?1:0);for(let a=0;a3;a++){const e=(0,s.Up)(n,f),t=(0,s.Up)(n,f);e!==t&&b(e.cx,e.cy,t.cx,t.cy)}const w=f.length?f[0].cx:1,x=f.length?f[0].cy:1;!function(e,t,n,i){const s=[[1,0],[-1,0],[0,1],[0,-1]];for(let r=0;r<6;r++){const r=new Set;if("."!==e[i][n])return;const l=[[n,i]];for(r.add("".concat(n,",").concat(i));l.length;){const n=l.pop(),i=(0,a.A)(n,2),c=i[0],h=i[1];for(const d of s){var o=(0,a.A)(d,2);const n=c+o[0],i=h+o[1],s="".concat(n,",").concat(i);n>=0&&n=0&&ik&&(k=e,S=a)}const _=(0,s.k4)(n,h.rooms).slice(0,Math.max(0,f.length-1));let T=0;const R=f.map(((e,t)=>{const a=0===t,i=t===S&&f.length>1,o=a?l[d]:_[t-1]||(0,s.Up)(n,h.rooms),r=[];if(i){const e=(0,s.XU)(n,3,4);T++,r.push({id:"enc-".concat(T),name:(0,s.Up)(n,h.monsters[e]),tier:e}),n()<.6&&(T++,r.push({id:"enc-".concat(T),name:(0,s.Up)(n,h.monsters[1]),tier:1}))}else if(!a&&n()<.6){const e=n()<.35?2:1;for(let t=0;t"".concat(e.x,",").concat(e.y))));C.add("".concat(w,",").concat(x));for(let a=0;a1;let i=n()<.7?(0,s.XU)(n,1,2):0;t&&(i=Math.max(i,1));const o=[];for(t&&o.push("chest");o.lengthe.join(""))),rooms:R,props:A,startX:w,startY:x,edited:!1}}},1015(e,t,n){"use strict";n.d(t,{t:()=>i});var a=n(5544);function i(e){const t=[],n=e.width,i=e.height,s=e.grid;if(!Array.isArray(s)||s.length!==i)return t.push("grid has ".concat(s?s.length:0," rows, expected ").concat(i)),t;for(let a=0;a=0&&e=0&&l0&&t.push("".concat(l," floor cell(s) unreachable from start"));const c=new Set,h=new Set,d=new Set;for(const a of e.rooms||[]){c.has(a.id)&&t.push("duplicate room id ".concat(a.id)),c.add(a.id);const e="".concat(a.x,",").concat(a.y);h.has(e)&&t.push("two rooms share anchor cell (".concat(e,")")),h.add(e),s[a.y]&&"."===s[a.y][a.x]||t.push('room "'.concat(a.name,'" anchor (').concat(a.x,",").concat(a.y,") is not a floor cell")),(a.name||"").trim()||t.push("room ".concat(a.id," has no name"));for(const n of a.encounters||[])d.has(n.id)&&t.push("duplicate encounter id ".concat(n.id)),d.add(n.id),n.tier>=1&&n.tier<=4||t.push('encounter "'.concat(n.name,'" has invalid tier ').concat(n.tier)),(n.name||"").trim()||t.push("encounter ".concat(n.id," has no name"))}const u=new Set(["chest","barrel","bones","altar","bookshelf","trap","pillar"]);for(const a of e.props||[])s[a.y]&&"."===s[a.y][a.x]||t.push("prop ".concat(a.type," at (").concat(a.x,",").concat(a.y,") is not on a floor cell")),u.has(a.type)||t.push('unknown prop type "'.concat(a.type,'"'));return t}},8207(e,t,n){"use strict";n.d(t,{s:()=>I});var a=n(9379),i=n(5544),s=n(8634);const o=["Tallow","Copper","Salt","Wyrm","Dray","Miller's","Tanner's","Ash","Rook","Lantern","Hollow","Bell","Iron","Cinder","Fletcher's","Hearth","Silver","Bramble","Chandler's","Cooper's","Weaver's","Old King's","Pilgrim's","Beggar's","Harrow","Marsh","Thorn","Anchor","Gull","Ferry"],r=["Way","Lane","Row","Walk","Alley","Street","Rise","Reach","Cut"],l=["Way","Road","Street","Gate Road"],c=["Market Square","The Weighyard","Old Well Square","Founders' Green","Gallows Square","The Commons","Temple Court","Harvest Square"],h=["Adwen","Bram","Cerys","Dovan","Edda","Fenwick","Grisla","Hale","Isolde","Jorun","Kestrel","Lunet","Maddoc","Nella","Osric","Petra","Quill","Rosamund","Sorrel","Tamsin","Ulric","Verna","Wystan","Ysolt","Alder","Brenna","Corwin","Dagny","Emeric","Fia","Garrick","Hedda"],d=["Ashdown","Blackbriar","Coppermane","Dunmore","Everfield","Fairweather","Grimsby","Hollowell","Ironwood","Kettleworth","Longstride","Marchbank","Nightingale","Oakhart","Pennyworth","Quickwater","Ravenscroft","Saltmarsh","Thistlewood","Underhill","Vane","Wexley","Yarrow","Amberly"],u=["keeps a ledger of every favor owed","laughs too loudly at their own jokes","never forgets a face or a slight","superstitious about crows","generous to strangers, cold to kin","speaks in half-finished proverbs","quietly devout","an incorrigible gossip","haunted by an old debt","fiercely proud of their trade","suspicious of outsiders","hums old marching songs while working","collects odd trinkets","always seems to know the weather","soft-hearted beneath a gruff shell","ambitious past their station","loyal to a fault","afraid of deep water","tells the same three stories on repeat","sharp-tongued but fair"],p=["broad-shouldered with flour-dusted forearms","wiry, with ink-stained fingers","stooped, with bright darting eyes","ruddy-cheeked and barrel-chested","tall and spare, hair like straw","scarred along one jaw","silver-haired with a limp from an old fall","young-faced but grey early","missing two fingers on the left hand","sun-browned with a braided beard","small and quick, always half-smiling","heavyset with kind eyes","gaunt, wrapped in a patched cloak","freckled, with a gap-toothed grin","square-jawed with calloused hands","sharp-featured with a merchant's squint"],m=["Opens {building} at dawn and works until the light goes","Mornings at {building}, evenings arguing politics at {tavern}","Works {building} by day; walks the walls at dusk out of old habit","Keeps odd hours at {building} and naps through midday","At {building} most days, at temple every seventh","Runs errands across town all morning, then holds court at {tavern}","Rarely leaves {building} except for market day","Tends {building} with quiet efficiency, then drinks alone at {tavern}"],f=["Wanders the streets selling odds and ends from a battered tray","Sweeps the square at dawn and knows everyone's comings and goings","Runs messages between the gates for a copper a time","Sits by the well most days, watching and remembering","Patrols the streets at night with a lantern and a cudgel","Begs by the gate by day; nobody knows where they sleep"],g=["family","rival","ally","owes-debt-to","romantic","mentor","protects"],v={hamlet:{dim:24,notables:4,people:6,gates:1,plazas:0,secondaryBudget:3},village:{dim:32,notables:8,people:12,gates:2,plazas:1,secondaryBudget:6},town:{dim:40,notables:13,people:20,gates:2,plazas:1,secondaryBudget:10},city:{dim:52,notables:20,people:30,gates:3,plazas:2,secondaryBudget:16},"large-city":{dim:64,notables:28,people:40,gates:4,plazas:2,secondaryBudget:24}},b=[{type:"house",weight:5},{type:"market",weight:2},{type:"blacksmith",weight:2},{type:"apothecary",weight:1},{type:"warehouse",weight:2},{type:"guildhall",weight:1},{type:"landmark",weight:1},{type:"tavern",weight:1}],y={tavern:["The Gilded Flagon","The Drowned Rat","The Wanderer's Rest","The Broken Wheel","The Salt and Candle","The Crooked Stair","The Old Drum","The Hearthstone"],blacksmith:["{last}'s Forge","The Ember Anvil","Gatehouse Smithy","The Bent Nail"],temple:["Shrine of {religion}","Chapel of {religion}","House of {religion}","The {religion} Sanctum"],market:["The Open Stalls","{street} Market","The Exchange","Fishrow Stalls"],apothecary:["The Green Mortar","{last}'s Remedies","The Dried Root","Willowbark House"],house:["{last} House","The {last} Residence","Old {last} Cottage","{first} {last}'s Home"],landmark:["The Old Well","The Standing Stone","The Burned Tower","The Founder's Statue","The Sundial Court"],guildhall:["{faction} Chapterhouse","The Guildhall","Hall of the {faction}","The Charter House"],warehouse:["{last} & Sons Storehouse","The Long Store","Riverside Warehouse","The Bonded Store"]},w={tavern:"A well-worn tavern, its sign swinging over a door that never quite latches.",blacksmith:"A working smithy, the forge-heat spilling out into the street.",temple:"A modest place of worship, kept clean by whoever still cares to.",market:"A cluster of stalls and awnings, busiest in the morning light.",apothecary:"A narrow shop of jars and bundled herbs, its shelves crowded to the ceiling.",house:"An ordinary home, indistinguishable from its neighbors at a glance.",landmark:"A small landmark the locals navigate by without a second thought.",guildhall:"A guildhall of plain stone, its business conducted behind closed doors.",warehouse:"A squat storehouse, its doors banded in iron against the damp."},x={tavern:"ale, rumors, hot meals, and a corner table",blacksmith:"horseshoes, nails, blade-work, and honest repair",temple:"blessings, quiet counsel, and rites for the dead",market:"produce, cloth, trinkets, and haggling",apothecary:"salves, tinctures, and remedies of uneven repute",house:"a private residence",landmark:"a place people meet, swear oaths, and tell stories about",guildhall:"contracts, dues, and closed-door dealings",warehouse:"storage, freight, and things best not asked about"},S={tavern:"The party steps into {name}. Describe the common room in this {size}: the drinkers, the smells, the keeper {keeper} behind the bar. Surface one rumor or hook if the party lingers or buys a round.",temple:"The party enters {name}. Describe the quiet interior, its icons and offerings, and {keeper} tending the place. If the party seeks blessing or counsel, play it warmly but note what donation is customary.",guildhall:"The party enters {name}. Describe the hall's guarded formality and {keeper} sizing them up. Business here runs on introductions and dues \u2014 make that felt.",blacksmith:"The party steps into the heat of {name}. Describe the forge at work and {keeper} mid-task. They will trade and talk shop, but their time is money.",apothecary:"The party enters {name}, all hanging herbs and stoppered jars. {keeper} appraises them from behind the counter. Remedies are for sale; questions cost extra.",market:"The party moves through {name}. Describe the press of stalls, the calls of sellers, and one vendor worth talking to. Small purchases and small talk come easily here.",default:"The party enters {name}. Describe the interior and whoever is present, keeping the scene grounded in daily town life. Offer one small hook if the party engages."},k=["A cart rattles past, its driver cursing the ruts.","Somewhere nearby, a smith's hammer keeps slow time.","Two neighbors argue over a fence line in doorway voices.","A dog trots by with something unidentifiable in its mouth.","Washing lines sway overhead between the upper storeys.","A child chases a hoop past, nearly clipping your knees.","The smell of baking bread drifts from an unseen oven.","A bell tolls the hour, slightly cracked and flat.","An old woman watches you from a shaded stoop, unblinking.","Chickens scatter from underfoot, indignant.","A town crier's voice carries from a few streets over.","Gutters trickle with last night's rain."],_=["Gulls wheel and scream over the rooftops.","The smell of wet rope and fish hangs in the air.","Water slaps against pilings somewhere out of sight.","A ferryman's bell rings twice, then falls silent."],T=["Two figures wearing {faction} colors pass, deep in low conversation.","A {faction} notice is nailed to a post, already defaced."],R=["Ald","Bray","Cald","Dun","Elm","Fen","Gled","Har","Kil","Mar","Nor","Oak","Peb","Ras","Stan","Thorn","Wex","Yar"],A=["bridge","ford","haven","mere","stead","wick","field","combe","market","cross","hollow","gate"],C={tavern:["innkeeper","cook","serving hand","cellarman"],blacksmith:["blacksmith","apprentice smith","farrier"],temple:["priest","acolyte","sexton"],market:["stallholder","fishmonger","cloth merchant","spice seller"],apothecary:["apothecary","herbalist"],house:["retired soldier","seamstress","clerk","midwife","carpenter"],landmark:["caretaker","storyteller"],guildhall:["guild factor","scribe","dues collector"],warehouse:["warehouse master","porter","tallyman"]},N=["peddler","street sweeper","messenger","night watchman","beggar","busker"];var E=n(7365),M=n(5996);const L=[[1,0],[-1,0],[0,1],[0,-1]];function I(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(let i=0;i<3;i++){const a=X(e,0===i?t:"".concat(t,"#").concat(i),n);if(a.seed=t,0===(0,E.f)(a).length)return a}const a=X(e,"".concat(t,"#2"),n);return a.seed=t,a}function X(e,t,n){const b=(0,s.sK)((0,s.M1)(t)),R=v[e.size]||v.town,A=R.dim,E=Math.min(5,Math.max(1,e.density||3)),M=Array.from({length:A},(()=>Array(A).fill("#"))),I=Array.from({length:A},(()=>Array(A).fill("_"))),X=[],F=new Set;let D=0;const B=(e,t)=>e>=1&&e<=A-2&&t>=1&&t<=A-2,H=(e,t)=>"~"===I[t][e],U=(e,t,n)=>{B(e,t)&&(M[t][e]=".",I[t][e]=n?"p":"_")},Y=function(e,t,n,a,i,s){let o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(D++,X.push({id:"st-".concat(D),name:e,kind:t,x:n,y:a,from:i,to:s}),"h"===t)for(let r=Math.min(i,s);r<=Math.max(i,s);r++)U(r,a,o);else if("v"===t)for(let r=Math.min(i,s);r<=Math.max(i,s);r++)U(n,r,o);else if("square"===t)for(let r=Math.min(a,s);r<=Math.max(a,s);r++)for(let e=Math.min(n,i);e<=Math.max(n,i);e++)U(e,r,o)},O=e=>{for(let n=0;n<40;n++){const t="".concat((0,s.Up)(b,o)," ").concat((0,s.Up)(b,e));if(!F.has(t))return F.add(t),t}const t="".concat((0,s.Up)(b,o)," ").concat((0,s.Up)(b,e)," ").concat(D+1);return F.add(t),t},z=e.water||"none";let J=[];if("river"===z){const e=b()<.5,t=(0,s.XU)(b,2,3);let n=(0,s.XU)(b,Math.floor(.3*A),Math.floor(.7*A));for(let a=0;a!J.includes(e))),q=(0,s.k4)(b,Q).slice(0,Math.max(1,Math.min(R.gates,Q.length))).map((e=>{const t=(0,s.XU)(b,Math.floor(.3*A),Math.floor(.7*A));return"n"===e?{x:t,y:1,edge:e}:"s"===e?{x:t,y:A-2,edge:e}:"w"===e?{x:1,y:t,edge:e}:{x:A-2,y:t,edge:e}})),$=e.roads||"organic";for(const a of q){const e=O(l);if("organic"===$){const t=(0,s.XU)(b,-Math.floor(A/8),Math.floor(A/8));if("n"===a.edge||"s"===a.edge){const n=Math.max(2,Math.min(A-3,Math.floor((a.y+K.y)/2)+t));Y(e,"v",a.x,0,a.y,n),Y(e,"h",0,n,a.x,K.x),Y(e,"v",K.x,0,n,K.y)}else{const n=Math.max(2,Math.min(A-3,Math.floor((a.x+K.x)/2)+t));Y(e,"h",0,a.y,a.x,n),Y(e,"v",n,0,a.y,K.y),Y(e,"h",0,K.y,n,K.x)}}else"n"===a.edge||"s"===a.edge?(Y(e,"v",a.x,0,a.y,K.y),Y(e,"h",0,K.y,a.x,K.x)):(Y(e,"h",0,a.y,a.x,K.x),Y(e,"v",K.x,0,a.y,K.y))}if("radial"===$&&A>=32){const e=Math.floor(.3*A),t=Math.max(2,K.x-e),n=Math.min(A-3,K.x+e),a=Math.max(2,K.y-e),i=Math.min(A-3,K.y+e),s=O(["Ring","Circle","Round"]);Y(s,"h",0,a,t,n),Y(s,"h",0,i,t,n),Y(s,"v",t,0,a,i),Y(s,"v",n,0,a,i)}if(R.plazas>0){const e=(0,s.XU)(b,4,6),t=(0,s.XU)(b,3,5),n=Math.max(2,Math.min(A-3-e,K.x-Math.floor(e/2))),a=Math.max(2,Math.min(A-3-t,K.y-Math.floor(t/2)));if(Y((0,s.Up)(b,c),"square",n,a,n+e-1,a+t-1,!0),R.plazas>1){const e=P(M,A).filter((e=>{let t=(0,i.A)(e,2),n=t[0],a=t[1];return Math.abs(n-K.x)+Math.abs(a-K.y)>A/3}));if(e.length){const t=(0,s.Up)(b,e),n=(0,i.A)(t,2),a=n[0],o=n[1],r=(0,s.XU)(b,3,4),l=(0,s.XU)(b,2,3),h=Math.max(2,Math.min(A-3-r,a-1)),d=Math.max(2,Math.min(A-3-l,o-1));Y((0,s.Up)(b,c.filter((e=>!F.has(e))))||"Little Square","square",h,d,h+r-1,d+l-1,!0)}}}const ee=Math.round(R.secondaryBudget*(.6+.2*E));let te=0,ne=0;for(;te{let a=(0,i.A)(n,2),s=a[0],o=a[1];const r=e+s,l=t+o;return r>=0&&r=0&&l(D++,"st-".concat(D))),O);for(let a=1;ae>=2&&e<=A-3&&t>=2&&t<=A-3;for(let a=1;a{let n=(0,i.A)(t,2),s=n[0],o=n[1];return M[a+o]&&"."===M[a+o][e+s]}))&&oe.push([e,a]);for(const a of(0,s.k4)(b,oe)){var le=(0,i.A)(a,2);const e=le[0],t=le[1],n="".concat(e,",").concat(t);if(se.has(n)||b()>ie)continue;const o=[[e,t]],r=(0,s.k4)(b,L),l=(0,s.XU)(b,1,4);for(;o.lengthe.join(""))),terrain:I.map((e=>e.join(""))),streets:X,buildings:[],people:[],ambient:[],startX:ae[0],startY:ae[1],edited:!1};return de.buildings=function(e,t,n,a,o){const r=e.width,l=new Map,c=[];for(let s=1;s{let a=(0,i.A)(n,2),o=a[0],r=a[1];const l=t+o,c=s+r;return e.grid[c]&&"#"===e.grid[c][l]&&"_"===e.terrain[c][l]}))&&!l.has("".concat(t,",").concat(s))&&(l.set("".concat(t,",").concat(s),!0),c.push([t,s]))}if(!c.length)return[];const h=Math.floor(r/2),u=Math.floor(r/2);let p=c[0],m=1/0;for(const s of c){var f=(0,i.A)(s,2);const e=f[0],t=f[1],n=Math.abs(e-h)+Math.abs(t-u);ne!==p)),b=Math.min(t.notables,c.length);for(;g.lengtht&&(t=l,e=v[a],n=a)}g.push(e),v.splice(n,1)}const k=["tavern"];for(let i=0;i<(n.religions||[]).length;i++)k.push("temple");for(;k.length!n.factionIds||!n.factionIds.length||n.factionIds.includes(e.id))).map((e=>e.name)).filter(Boolean),T=e.streets.map((e=>e.name)),R=new Set;let A=0;const C=[];for(let N=0;N"tavern"===e.type)),l=r?r.name:"the tavern",c=(e,t)=>{o++;let a=(0,s.Up)(n,h),r=(0,s.Up)(n,d),c=0;for(;i.has("".concat(a," ").concat(r))&&c++<30;)a=(0,s.Up)(n,h),r=(0,s.Up)(n,d);i.add("".concat(a," ").concat(r));const g=t?(0,s.Up)(n,m):(0,s.Up)(n,f);return{id:"per-".concat(o),name:"".concat(a," ").concat(r),trade:e,personality:"".concat((0,s.Up)(n,u),"; ").concat((0,s.Up)(n,u)),appearance:(0,s.Up)(n,p),routine:(v=g,b={building:t?t.name:"",tavern:l},v.replace(/\{(\w+)\}/g,((e,t)=>b[t]||""))),secret:"",relations:[],npcId:"",buildingId:t?t.id:"",lastName:r};var v,b};for(const h of e.buildings){if(a.length>=t.people)break;const e=C[h.type]||C.house,o="house"===h.type?(0,s.XU)(n,1,2):(0,s.XU)(n,1,3),r=c(e[0],h);a.push(r);for(let l=1;l=2||(v.get(n.id)||0)>=2||(t.relations.push({toId:n.id,kind:"family"}),v.set(t.id,(v.get(t.id)||0)+1),v.set(n.id,(v.get(n.id)||0)+1)))}for(const h of a){const e=n()<.6?n()<.35?2:1:0;for(let t=0;tt.toId===e.id)))continue;const t=(0,s.Up)(n,g.filter((e=>"family"!==e)));h.relations.push({toId:e.id,kind:t})}}for(const s of a)delete s.lastName;return a}(de,R,b),function(e){const t=new Map;for(const n of e.people)n.buildingId&&(t.has(n.buildingId)||t.set(n.buildingId,[]),t.get(n.buildingId).push(n.id));for(const n of e.buildings)n.occupantIds=t.get(n.id)||[];for(const n of e.people)delete n.buildingId}(de),function(e,t){const n={hamlet:"sleepy hamlet",village:"village",town:"market town",city:"city","large-city":"sprawling city"}[t.size]||"town";for(const a of e.buildings){if(!a.enterable)continue;const t=a.occupantIds.length&&(e.people.find((e=>e.id===a.occupantIds[0]))||{}).name||"the keeper",i=S[a.type]||S.default;a.scene=V(i,{name:a.name,size:n,keeper:t})}}(de,e),de.ambient=function(e,t,n){const a=k.slice();e.water&&"none"!==e.water&&a.push(..._);const i=(n.factions||[]).filter((t=>(e.factionIds||[]).includes(t.id))).map((e=>e.name)).filter(Boolean);if(i.length)for(const r of T)a.push(V(r,{faction:(0,s.Up)(t,i)}));const o=Math.min((0,s.XU)(t,8,10),a.length);return(0,s.k4)(t,a).slice(0,o)}(e,b,n),de}function P(e,t){const n=[];for(let a=1;a=0&&n=0&&ae+t.weight),0);let n=e()*t;for(const a of b)if(n-=a.weight,n<=0)return a.type;return"house"}function V(e,t){return e.replace(/\{(\w+)\}/g,((e,n)=>t[n]||""))}function Z(e,t,n,a){const s=e.width,o=e.height,r=e.grid,l=e.terrain,c=(e,t)=>e<2||e>=s-2||t<2||t>=o-2,h=(0,M.E$)((0,M.pA)(e),t,n);if(h&&h.cells.some((e=>{let t=(0,i.A)(e,2),n=t[0],a=t[1];return c(n,a)})))return;let d=null;for(const A of L){var u=(0,i.A)(A,2);const e=u[0],a=u[1],s=t+e,o=n+a;if(r[o]&&"#"===r[o][s]&&l[o]&&"~"!==l[o][s]){d=[e,a];break}}if(!d)return;const p=d,m=(0,i.A)(p,2),f=m[0],g=m[1],v=0!==g,b=a()<.5?3:4,y=a()<.5?3:4,w=Math.floor((b-1)/2),x=[];for(let i=-w;iv?[t+x[a],n+g*S[e]]:[t+f*S[e],n+x[a]];let _=0;for(let A=0;A.25)return;const T=new Set;if(a()<.55&&y>=3&&b>=3){const e=b>=4?2:1,t=Math.floor((b-e)/2);for(let n=1;ne.split("")));for(let A=0;Ae.join("")))}},8634(e,t,n){"use strict";function a(e){let t=1779033703^e.length;for(let n=0;n>>19;return t>>>0}function i(e){return function(){e=(e|=0)+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function s(e,t){return t[Math.floor(e()*t.length)]}function o(e,t){const n=t.slice();for(let i=n.length-1;i>0;i--){const t=Math.floor(e()*(i+1));var a=[n[t],n[i]];n[i]=a[0],n[t]=a[1]}return n}function r(e,t,n){return t+Math.floor(e()*(n-t+1))}n.d(t,{M1:()=>a,Up:()=>s,XU:()=>r,k4:()=>o,sK:()=>i})},5996(e,t,n){"use strict";n.d(t,{E$:()=>r,dG:()=>s,pA:()=>o});var a=n(5544);function i(e){const t=[];if("h"===e.kind){const n=e.from<=e.to?[e.from,e.to]:[e.to,e.from],i=(0,a.A)(n,2),s=i[0],o=i[1];for(let a=s;a<=o;a++)t.push([a,e.y])}else if("v"===e.kind){const n=e.from<=e.to?[e.from,e.to]:[e.to,e.from],i=(0,a.A)(n,2),s=i[0],o=i[1];for(let a=s;a<=o;a++)t.push([e.x,a])}else if("square"===e.kind){const n=e.x<=e.from?[e.x,e.from]:[e.from,e.x],i=(0,a.A)(n,2),s=i[0],o=i[1],r=e.y<=e.to?[e.y,e.to]:[e.to,e.y],l=(0,a.A)(r,2),c=l[0],h=l[1];for(let e=c;e<=h;e++)for(let n=s;n<=o;n++)t.push([n,e])}return t}function s(e){const t={};for(const s of e.streets||[])for(const o of i(s)){var n=(0,a.A)(o,2);const i=n[0],r=n[1];if(r<0||r>=e.height||i<0||i>=e.width)continue;if("."!==(e.grid[r]||"")[i])continue;const l="".concat(i,",").concat(r);t[l]||(t[l]=s.name)}return t}function o(e){const t=new Set,n=[],i=(t,n)=>{if(t<0||t>=e.width||n<0||n>=e.height)return!1;if("#"!==(e.grid[n]||"")[t])return!1;const a=e.terrain&&e.terrain[n]&&e.terrain[n][t]||"_";return"~"!==a&&"g"!==a&&"t"!==a};for(let o=0;oi});var a=n(5996);function i(e,t){return{cityId:"preview-town",district:"preview",name:e.name||"Untitled Town",townRender:!0,seed:t||e.seed,grid:e.grid,terrain:e.terrain,width:e.width,height:e.height,currentPos:[e.startX,e.startY],explored:[],exits:[],streets:(0,a.dG)(e),streetSegs:e.streets,buildings:e.buildings}}},7365(e,t,n){"use strict";n.d(t,{f:()=>s});var a=n(5544),i=n(5996);function s(e){const t=[],n=e.width,s=e.height,o=e.grid;if(!Array.isArray(o)||o.length!==s)return t.push("grid has ".concat(o?o.length:0," rows, expected ").concat(s)),t;for(let a=0;a=0&&e=0&&i0&&t.push("".concat(h," street cell(s) unreachable from start"));const d=new Set;for(const a of e.buildings||[])d.has(a.id)&&t.push("duplicate building id ".concat(a.id)),d.add(a.id),o[a.doorY]&&"."===o[a.doorY][a.doorX]||t.push('building "'.concat(a.name,'" door (').concat(a.doorX,",").concat(a.doorY,") is not on a street cell")),a.enterable&&!(a.scene||"").trim()&&t.push('enterable building "'.concat(a.name,'" has no scene'));const u=new Set;for(const a of e.buildings||[]){const e="".concat(a.doorX,",").concat(a.doorY);u.has(e)&&t.push("two buildings share door cell (".concat(e,")")),u.add(e)}const p=new Set;for(const a of e.people||[])p.has(a.id)&&t.push("duplicate person id ".concat(a.id)),p.add(a.id);for(const a of e.people||[])for(const e of a.relations||[])p.has(e.toId)||t.push('person "'.concat(a.name,'" relation targets unknown id ').concat(e.toId));return t}},6159(e,t,n){e.exports=function e(t,n,a){function i(o,r){if(!n[o]){if(!t[o]){if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};t[o][0].call(c.exports,(function(e){return i(t[o][1][e]||e)}),c,c.exports,e,t,n,a)}return n[o].exports}for(var s=void 0,o=0;o>2,r=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&o)<<4|(r=s.indexOf(e.charAt(c++)))>>2,a=(3&r)<<6|(l=s.indexOf(e.charAt(c++))),u[h++]=t,64!==r&&(u[h++]=n),64!==l&&(u[h++]=a);return u}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var a=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function r(e,t,n,a,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=a,this.compressedContent=i}r.prototype={getContentWorker:function(){var e=new i(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},r.createWorkerFrom=function(e,t,n){return e.pipe(new s).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=r},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var a=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var a=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var a=0;a<8;a++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==a.getTypeOf(e)?function(e,t,n,a){var s=i,o=a+n;e^=-1;for(var r=a;r>>8^s[255&(e^t[r])];return~e}(0|t,e,e.length,0):function(e,t,n,a){var s=i,o=a+n;e^=-1;for(var r=a;r>>8^s[255&(e^t.charCodeAt(r))];return~e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var a=null;a="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:a}},{lie:37}],7:[function(e,t,n){"use strict";var a="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),o=e("./stream/GenericWorker"),r=a?"uint8array":"array";function l(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",s.inherits(l,o),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(r,e.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function a(e,t){var n,a="";for(n=0;n>>=8;return a}function i(e,t,n,i,o,h){var d,u,p=e.file,m=e.compression,f=h!==r.utf8encode,g=s.transformTo("string",h(p.name)),v=s.transformTo("string",r.utf8encode(p.name)),b=p.comment,y=s.transformTo("string",h(b)),w=s.transformTo("string",r.utf8encode(b)),x=v.length!==p.name.length,S=w.length!==b.length,k="",_="",T="",R=p.dir,A=p.date,C={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(C.crc32=e.crc32,C.compressedSize=e.compressedSize,C.uncompressedSize=e.uncompressedSize);var N=0;t&&(N|=8),f||!x&&!S||(N|=2048);var E=0,M=0;R&&(E|=16),"UNIX"===o?(M=798,E|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(p.unixPermissions,R)):(M=20,E|=function(e){return 63&(e||0)}(p.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,u=A.getUTCFullYear()-1980,u<<=4,u|=A.getUTCMonth()+1,u<<=5,u|=A.getUTCDate(),x&&(_=a(1,1)+a(l(g),4)+v,k+="up"+a(_.length,2)+_),S&&(T=a(1,1)+a(l(y),4)+w,k+="uc"+a(T.length,2)+T);var L="";return L+="\n\0",L+=a(N,2),L+=m.magic,L+=a(d,2),L+=a(u,2),L+=a(C.crc32,4),L+=a(C.compressedSize,4),L+=a(C.uncompressedSize,4),L+=a(g.length,2),L+=a(k.length,2),{fileRecord:c.LOCAL_FILE_HEADER+L+g+k,dirRecord:c.CENTRAL_FILE_HEADER+a(M,2)+L+a(y.length,2)+"\0\0\0\0"+a(E,4)+a(i,4)+g+k+y}}var s=e("../utils"),o=e("../stream/GenericWorker"),r=e("../utf8"),l=e("../crc32"),c=e("../signature");function h(e,t,n,a){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=a,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,o),h.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,a=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-a-1))/n:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+a(e.crc32,4)+a(e.compressedSize,4)+a(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return a.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var a=e("./Uint8ArrayReader");function i(e){a.call(this,e)}e("../utils").inherits(i,a),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var a=e("./DataReader");function i(e){a.call(this,e)}e("../utils").inherits(i,a),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var a=e("./ArrayReader");function i(e){a.call(this,e)}e("../utils").inherits(i,a),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var a=e("../utils"),i=e("../support"),s=e("./ArrayReader"),o=e("./StringReader"),r=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=a.getTypeOf(e);return a.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new r(e):i.uint8array?new l(a.transformTo("uint8array",e)):new s(a.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK\x03\x04",n.CENTRAL_FILE_HEADER="PK\x01\x02",n.CENTRAL_DIRECTORY_END="PK\x05\x06",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,t,n){"use strict";var a=e("./GenericWorker"),i=e("../utils");function s(e){a.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,a),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var a=e("./GenericWorker"),i=e("../crc32");function s(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,a),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var a=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}a.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var a=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=a.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}a.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function a(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=a},{}],29:[function(e,t,n){"use strict";var a=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),o=e("../base64"),r=e("../support"),l=e("../external"),c=null;if(r.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function h(e,t){return new l.Promise((function(n,i){var s=[],r=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){s.push(e),t&&t(n)})).on("error",(function(e){s=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return a.newBlob(a.transformTo("arraybuffer",t),n);case"base64":return o.encode(t);default:return a.transformTo(e,t)}}(l,function(e,t){var n,a=0,i=null,s=0;for(n=0;n>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?a.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,s,o=e.length,l=new Array(2*o);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),a.applyFromCharCode(l)}(e=a.transformTo(i.uint8array?"uint8array":"array",e))},a.inherits(c,o),c.prototype.processChunk=function(e){var t=a.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+r[e[n]]>t?n:t}(t),l=t;o!==t.length&&(i.uint8array?(l=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(l=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,a.inherits(h,o),h.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var a=e("./support"),i=e("./base64"),s=e("./nodejsUtils"),o=e("./external");function r(e){return e}function l(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=a(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,a,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new a.Buf8(e.length),n=0,i=t.length;n>10&1023,c[a++]=56320|1023&i)}return l(c,a)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,a){for(var i=65535&e,s=e>>>16&65535,o=0;0!==n;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var s=a,o=i+n;e^=-1;for(var r=i;r>>8^s[255&(e^t[r])];return~e}},{}],46:[function(e,t,n){"use strict";var a,i=e("../utils/common"),s=e("./trees"),o=e("./adler32"),r=e("./crc32"),l=e("./messages"),c=0,h=4,d=0,u=-2,p=-1,m=4,f=2,g=8,v=9,b=286,y=30,w=19,x=2*b+1,S=15,k=3,_=258,T=_+k+1,R=42,A=113,C=1,N=2,E=3,M=4;function L(e,t){return e.msg=l[t],t}function I(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function W(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,P(e.strm)}function G(e,t){e.pending_buf[e.pending++]=t}function j(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function V(e,t){var n,a,i=e.max_chain_length,s=e.strstart,o=e.prev_length,r=e.nice_match,l=e.strstart>e.w_size-T?e.strstart-(e.w_size-T):0,c=e.window,h=e.w_mask,d=e.prev,u=e.strstart+_,p=c[s+o-1],m=c[s+o];e.prev_length>=e.good_match&&(i>>=2),r>e.lookahead&&(r=e.lookahead);do{if(c[(n=t)+o]===m&&c[n+o-1]===p&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&sl&&0!=--i);return o<=e.lookahead?o:e.lookahead}function Z(e){var t,n,a,s,l,c,h,d,u,p,m=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-T)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;a=e.head[--t],e.head[t]=m<=a?a-m:0,--n;);for(t=n=m;a=e.prev[--t],e.prev[t]=m<=a?a-m:0,--n;);s+=m}if(0===e.strm.avail_in)break;if(c=e.strm,h=e.window,d=e.strstart+e.lookahead,p=void 0,(u=s)<(p=c.avail_in)&&(p=u),n=0===p?0:(c.avail_in-=p,i.arraySet(h,c.input,c.next_in,p,d),1===c.state.wrap?c.adler=o(c.adler,h,p,d):2===c.state.wrap&&(c.adler=r(c.adler,h,p,d)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=k)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=k&&(e.ins_h=(e.ins_h<=k)if(a=s._tr_tally(e,e.strstart-e.match_start,e.match_length-k),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=k){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=k&&(e.ins_h=(e.ins_h<=k&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-k,a=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-k),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Z(e),0===e.lookahead&&t===c)return C;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var a=e.block_start+n;if((0===e.strstart||e.strstart>=a)&&(e.lookahead=e.strstart-a,e.strstart=a,W(e,!1),0===e.strm.avail_out))return C;if(e.strstart-e.block_start>=e.w_size-T&&(W(e,!1),0===e.strm.avail_out))return C}return e.insert=0,t===h?(W(e,!0),0===e.strm.avail_out?E:M):(e.strstart>e.block_start&&(W(e,!1),e.strm.avail_out),C)})),new B(4,4,8,4,F),new B(4,5,16,8,F),new B(4,6,32,32,F),new B(4,4,16,16,D),new B(8,16,32,32,D),new B(8,16,128,128,D),new B(8,32,128,256,D),new B(32,128,258,1024,D),new B(32,258,258,4096,D)],n.deflateInit=function(e,t){return O(e,t,g,15,8,0)},n.deflateInit2=O,n.deflateReset=Y,n.deflateResetKeep=U,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,d):u},n.deflate=function(e,t){var n,i,o,l;if(!e||!e.state||5>8&255),G(i,i.gzhead.time>>16&255),G(i,i.gzhead.time>>24&255),G(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),G(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(G(i,255&i.gzhead.extra.length),G(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=r(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(G(i,0),G(i,0),G(i,0),G(i,0),G(i,0),G(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),G(i,3),i.status=A);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(p|=32),p+=31-p%31,i.status=A,j(i,p),0!==i.strstart&&(j(i,e.adler>>>16),j(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending!==i.pending_buf_size));)G(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexo&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexo&&(e.adler=r(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&P(e),i.pending+2<=i.pending_buf_size&&(G(i,255&e.adler),G(i,e.adler>>8&255),e.adler=0,i.status=A)):i.status=A),0!==i.pending){if(P(e),0===e.avail_out)return i.last_flush=-1,d}else if(0===e.avail_in&&I(t)<=I(n)&&t!==h)return L(e,-5);if(666===i.status&&0!==e.avail_in)return L(e,-5);if(0!==e.avail_in||0!==i.lookahead||t!==c&&666!==i.status){var m=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(Z(e),0===e.lookahead)){if(t===c)return C;break}if(e.match_length=0,n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(W(e,!1),0===e.strm.avail_out))return C}return e.insert=0,t===h?(W(e,!0),0===e.strm.avail_out?E:M):e.last_lit&&(W(e,!1),0===e.strm.avail_out)?C:N}(i,t):3===i.strategy?function(e,t){for(var n,a,i,o,r=e.window;;){if(e.lookahead<=_){if(Z(e),e.lookahead<=_&&t===c)return C;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=k&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=k?(n=s._tr_tally(e,1,e.match_length-k),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(W(e,!1),0===e.strm.avail_out))return C}return e.insert=0,t===h?(W(e,!0),0===e.strm.avail_out?E:M):e.last_lit&&(W(e,!1),0===e.strm.avail_out)?C:N}(i,t):a[i.level].func(i,t);if(m!==E&&m!==M||(i.status=666),m===C||m===E)return 0===e.avail_out&&(i.last_flush=-1),d;if(m===N&&(1===t?s._tr_align(i):5!==t&&(s._tr_stored_block(i,0,0,!1),3===t&&(X(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),P(e),0===e.avail_out))return i.last_flush=-1,d}return t!==h?d:i.wrap<=0?1:(2===i.wrap?(G(i,255&e.adler),G(i,e.adler>>8&255),G(i,e.adler>>16&255),G(i,e.adler>>24&255),G(i,255&e.total_in),G(i,e.total_in>>8&255),G(i,e.total_in>>16&255),G(i,e.total_in>>24&255)):(j(i,e.adler>>>16),j(i,65535&e.adler)),P(e),0=n.w_size&&(0===r&&(X(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,t,m-n.w_size,n.w_size,0),t=p,m=n.w_size),l=e.avail_in,c=e.next_in,h=e.input,e.avail_in=m,e.next_in=0,e.input=t,Z(n);n.lookahead>=k;){for(a=n.strstart,s=n.lookahead-(k-1);n.ins_h=(n.ins_h<>>=w=y>>>24,m-=w,0===(w=y>>>16&255))R[s++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=f[(65535&y)+(p&(1<>>=w,m-=w),m<15&&(p+=T[a++]<>>=w=y>>>24,m-=w,!(16&(w=y>>>16&255))){if(0==(64&w)){y=g[(65535&y)+(p&(1<>>=w,m-=w,(w=s-o)>3,p&=(1<<(m-=x<<3))-1,e.next_in=a,e.next_out=s,e.avail_in=a>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=u,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new a.Buf32(p),t.distcode=t.distdyn=new a.Buf32(m),t.sane=1,t.back=-1,h):d}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,v(e)):d}function y(e,t){var n,a;return e&&e.state?(a=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(a.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(s=o.wsize-o.wnext)&&(s=i),a.arraySet(o.window,t,n-i,s,o.wnext),(i-=s)?(a.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=s(n.check,Z,2,0),x=w=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&w)<<8)+(w>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&w)){e.msg="unknown compression method",n.mode=30;break}if(x-=4,P=8+(15&(w>>>=4)),0===n.wbits)n.wbits=P;else if(P>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(Z[0]=255&w,Z[1]=w>>>8&255,n.check=s(n.check,Z,2,0)),x=w=0,n.mode=3;case 3:for(;x<32;){if(0===b)break e;b--,w+=p[g++]<>>8&255,Z[2]=w>>>16&255,Z[3]=w>>>24&255,n.check=s(n.check,Z,4,0)),x=w=0,n.mode=4;case 4:for(;x<16;){if(0===b)break e;b--,w+=p[g++]<>8),512&n.flags&&(Z[0]=255&w,Z[1]=w>>>8&255,n.check=s(n.check,Z,2,0)),x=w=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(0===b)break e;b--,w+=p[g++]<>>8&255,n.check=s(n.check,Z,2,0)),x=w=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(b<(R=n.length)&&(R=b),R&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),a.arraySet(n.head.extra,p,g,R,P)),512&n.flags&&(n.check=s(n.check,p,R,g)),b-=R,g+=R,n.length-=R),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===b)break e;for(R=0;P=p[g+R++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&R>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(0===b)break e;b--,w+=p[g++]<>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(0===b)break e;b--,w+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(_(n),n.mode=20,6!==t)break;w>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}w>>>=2,x-=2;break;case 14:for(w>>>=7&x,x-=7&x;x<32;){if(0===b)break e;b--,w+=p[g++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&w,x=w=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(R=n.length){if(b>>=5,x-=5,n.ndist=1+(31&w),w>>>=5,x-=5,n.ncode=4+(15&w),w>>>=4,x-=4,286>>=3,x-=3}for(;n.have<19;)n.lens[F[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,G={bits:n.lenbits},W=r(0,n.lens,0,19,n.lencode,0,n.work,G),n.lenbits=G.bits,W){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,M=65535&V,!((N=V>>>24)<=x);){if(0===b)break e;b--,w+=p[g++]<>>=N,x-=N,n.lens[n.have++]=M;else{if(16===M){for(j=N+2;x>>=N,x-=N,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}P=n.lens[n.have-1],R=3+(3&w),w>>>=2,x-=2}else if(17===M){for(j=N+3;x>>=N)),w>>>=3,x-=3}else{for(j=N+7;x>>=N)),w>>>=7,x-=7}if(n.have+R>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;R--;)n.lens[n.have++]=P}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,G={bits:n.lenbits},W=r(l,n.lens,0,n.nlen,n.lencode,0,n.work,G),n.lenbits=G.bits,W){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,G={bits:n.distbits},W=r(c,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,G),n.distbits=G.bits,W){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=b&&258<=y){e.next_out=v,e.avail_out=y,e.next_in=g,e.avail_in=b,n.hold=w,n.bits=x,o(e,k),v=e.next_out,m=e.output,y=e.avail_out,g=e.next_in,p=e.input,b=e.avail_in,w=n.hold,x=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;E=(V=n.lencode[w&(1<>>16&255,M=65535&V,!((N=V>>>24)<=x);){if(0===b)break e;b--,w+=p[g++]<>L)])>>>16&255,M=65535&V,!(L+(N=V>>>24)<=x);){if(0===b)break e;b--,w+=p[g++]<>>=L,x-=L,n.back+=L}if(w>>>=N,x-=N,n.back+=N,n.length=M,0===E){n.mode=26;break}if(32&E){n.back=-1,n.mode=12;break}if(64&E){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&E,n.mode=22;case 22:if(n.extra){for(j=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;E=(V=n.distcode[w&(1<>>16&255,M=65535&V,!((N=V>>>24)<=x);){if(0===b)break e;b--,w+=p[g++]<>L)])>>>16&255,M=65535&V,!(L+(N=V>>>24)<=x);){if(0===b)break e;b--,w+=p[g++]<>>=L,x-=L,n.back+=L}if(w>>>=N,x-=N,n.back+=N,64&E){e.msg="invalid distance code",n.mode=30;break}n.offset=M,n.extra=15&E,n.mode=24;case 24:if(n.extra){for(j=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===y)break e;if(R=k-y,n.offset>R){if((R=n.offset-R)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}A=R>n.wnext?(R-=n.wnext,n.wsize-R):n.wnext-R,R>n.length&&(R=n.length),C=n.window}else C=m,A=v-n.offset,R=n.length;for(yb?(w=G[j+d[_]],I[X+d[_]]):(w=96,0),p=1<>N)+(m-=p)]=y<<24|w<<16|x,0!==m;);for(p=1<>=1;if(0!==p?(L&=p-1,L+=p):L=0,_++,0==--P[k]){if(k===R)break;k=t[n+d[_]]}if(A>>7)]}function G(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function j(e,t,n){e.bi_valid>f-n?(e.bi_buf|=t<>f-e.bi_valid,e.bi_valid+=n-f):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function F(e,t,n){var a,i,s=new Array(m+1),o=0;for(a=1;a<=m;a++)s[a]=o=o+n[a-1]<<1;for(i=0;i<=t;i++){var r=e[2*i+1];0!==r&&(e[2*i]=Z(s[r]++,r))}}function D(e){var t;for(t=0;t>1;1<=n;n--)U(e,s,n);for(i=l;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],U(e,s,1),a=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=a,s[2*i]=s[2*n]+s[2*a],e.depth[i]=(e.depth[n]>=e.depth[a]?e.depth[n]:e.depth[a])+1,s[2*n+1]=s[2*a+1]=i,e.heap[1]=i++,U(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,a,i,s,o,r,l=t.dyn_tree,c=t.max_code,h=t.stat_desc.static_tree,d=t.stat_desc.has_stree,u=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,g=t.stat_desc.max_length,v=0;for(s=0;s<=m;s++)e.bl_count[s]=0;for(l[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n>=7;a>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return i;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return s;for(t=32;t>>3,(r=e.static_len+3+7>>>3)<=o&&(o=r)):o=r=n+5,n+4<=o&&-1!==t?Q(e,t,n,a):4===e.strategy||r===o?(j(e,2+(a?1:0),3),Y(e,T,R)):(j(e,4+(a?1:0),3),function(e,t,n,a){var i;for(j(e,t-257,5),j(e,n-1,5),j(e,a-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(C[n]+c+1)]++,e.dyn_dtree[2*W(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){j(e,2,3),V(e,v,T),function(e){16===e.bi_valid?(G(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,a){(function(e){!function(e,t){"use strict";if(!e.setImmediate){var n,a,i,s,o=1,r={},l=!1,c=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){u(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(s="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",p,!1):e.attachEvent("onmessage",p),function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){u(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(a=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){u(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):function(e){setTimeout(u,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),a=0;a0?Math.floor(e):Math.ceil(e)};function P(e,t,n){return e instanceof I?e:v(e)?new I(e[0],e[1]):void 0===e||null===e?e:"object"===typeof e&&"x"in e&&"y"in e?new I(e.x,e.y):new I(e,t,n)}function W(e,t){if(e)for(var n=t?[e,t]:e,a=0,i=n.length;a=this.min.x&&n.x<=this.max.x&&t.y>=this.min.y&&n.y<=this.max.y},intersects:function(e){e=G(e);var t=this.min,n=this.max,a=e.min,i=e.max,s=i.x>=t.x&&a.x<=n.x,o=i.y>=t.y&&a.y<=n.y;return s&&o},overlaps:function(e){e=G(e);var t=this.min,n=this.max,a=e.min,i=e.max,s=i.x>t.x&&a.xt.y&&a.y=a.lat&&n.lat<=i.lat&&t.lng>=a.lng&&n.lng<=i.lng},intersects:function(e){e=V(e);var t=this._southWest,n=this._northEast,a=e.getSouthWest(),i=e.getNorthEast(),s=i.lat>=t.lat&&a.lat<=n.lat,o=i.lng>=t.lng&&a.lng<=n.lng;return s&&o},overlaps:function(e){e=V(e);var t=this._southWest,n=this._northEast,a=e.getSouthWest(),i=e.getNorthEast(),s=i.lat>t.lat&&a.latt.lng&&a.lng1,Ce=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassiveEventSupport",c,t),window.removeEventListener("testPassiveEventSupport",c,t)}catch(n){}return e}(),Ne=!!document.createElement("canvas").getContext,Ee=!(!document.createElementNS||!K("svg").createSVGRect),Me=!!Ee&&function(){var e=document.createElement("div");return e.innerHTML="","http://www.w3.org/2000/svg"===(e.firstChild&&e.firstChild.namespaceURI)}(),Le=!Ee&&function(){try{var e=document.createElement("div");e.innerHTML='';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&"object"===typeof t.adj}catch(n){return!1}}(),Ie=0===navigator.platform.indexOf("Mac"),Xe=0===navigator.platform.indexOf("Linux");function Pe(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var We={ie:$,ielt9:ee,edge:te,webkit:ne,android:ae,android23:ie,androidStock:oe,opera:re,chrome:le,gecko:ce,safari:he,phantom:de,opera12:ue,win:pe,ie3d:me,webkit3d:fe,gecko3d:ge,any3d:ve,mobile:be,mobileWebkit:ye,mobileWebkit3d:we,msPointer:xe,pointer:Se,touch:_e,touchNative:ke,mobileOpera:Te,mobileGecko:Re,retina:Ae,passiveEvents:Ce,canvas:Ne,svg:Ee,vml:Le,inlineSvg:Me,mac:Ie,linux:Xe},Ge=We.msPointer?"MSPointerDown":"pointerdown",je=We.msPointer?"MSPointerMove":"pointermove",Ve=We.msPointer?"MSPointerUp":"pointerup",Ze=We.msPointer?"MSPointerCancel":"pointercancel",Fe={touchstart:Ge,touchmove:je,touchend:Ve,touchcancel:Ze},De={touchstart:qe,touchmove:Qe,touchend:Qe,touchcancel:Qe},Be={},He=!1;function Ue(e,t,n){return"touchstart"===t&&Ke(),De[t]?(n=De[t].bind(this,n),e.addEventListener(Fe[t],n,!1),n):(console.warn("wrong event specified:",t),c)}function Ye(e,t,n){Fe[t]?e.removeEventListener(Fe[t],n,!1):console.warn("wrong event specified:",t)}function Oe(e){Be[e.pointerId]=e}function ze(e){Be[e.pointerId]&&(Be[e.pointerId]=e)}function Je(e){delete Be[e.pointerId]}function Ke(){He||(document.addEventListener(Ge,Oe,!0),document.addEventListener(je,ze,!0),document.addEventListener(Ve,Je,!0),document.addEventListener(Ze,Je,!0),He=!0)}function Qe(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||"mouse")){for(var n in t.touches=[],Be)t.touches.push(Be[n]);t.changedTouches=[t],e(t)}}function qe(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&Ot(t),Qe(e,t)}function $e(e){var t,n,a={};for(n in e)t=e[n],a[n]=t&&t.bind?t.bind(e):t;return e=a,a.type="dblclick",a.detail=2,a.isTrusted=!1,a._simulated=!0,a}var et=200;function tt(e,t){e.addEventListener("dblclick",t);var n,a=0;function i(e){if(1===e.detail){if("mouse"!==e.pointerType&&(!e.sourceCapabilities||e.sourceCapabilities.firesTouchEvents)){var i=Jt(e);if(!i.some((function(e){return e instanceof HTMLLabelElement&&e.attributes.for}))||i.some((function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement}))){var s=Date.now();s-a<=et?2===++n&&t($e(e)):n=1,a=s}}}else n=e.detail}return e.addEventListener("click",i),{dblclick:t,simDblclick:i}}function nt(e,t){e.removeEventListener("dblclick",t.dblclick),e.removeEventListener("click",t.simDblclick)}var at,it,st,ot,rt,lt=Tt(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ct=Tt(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ht="webkitTransition"===ct||"OTransition"===ct?ct+"End":"transitionend";function dt(e){return"string"===typeof e?document.getElementById(e):e}function ut(e,t){var n=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!n||"auto"===n)&&document.defaultView){var a=document.defaultView.getComputedStyle(e,null);n=a?a[t]:null}return"auto"===n?null:n}function pt(e,t,n){var a=document.createElement(e);return a.className=t||"",n&&n.appendChild(a),a}function mt(e){var t=e.parentNode;t&&t.removeChild(e)}function ft(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function gt(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function vt(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function bt(e,t){if(void 0!==e.classList)return e.classList.contains(t);var n=St(e);return n.length>0&&new RegExp("(^|\\s)"+t+"(\\s|$)").test(n)}function yt(e,t){if(void 0!==e.classList)for(var n=u(t),a=0,i=n.length;a0?2*window.devicePixelRatio:1;function qt(e){return We.edge?e.wheelDeltaY/2:e.deltaY&&0===e.deltaMode?-e.deltaY/Qt:e.deltaY&&1===e.deltaMode?20*-e.deltaY:e.deltaY&&2===e.deltaMode?60*-e.deltaY:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?20*-e.detail:e.detail?e.detail/-32765*60:0}function $t(e,t){var n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch(a){return!1}return n!==e}var en={__proto__:null,on:Gt,off:Vt,stopPropagation:Ht,disableScrollPropagation:Ut,disableClickPropagation:Yt,preventDefault:Ot,stop:zt,getPropagationPath:Jt,getMousePosition:Kt,getWheelDelta:qt,isExternalTarget:$t,addListener:Gt,removeListener:Vt},tn=M.extend({run:function(e,t,n,a){this.stop(),this._el=e,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(a||.5,.2),this._startPos=Ct(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,n=1e3*this._duration;tthis.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var n=this.getCenter(),a=this._limitCenter(n,this._zoom,V(e));return n.equals(a)||this.panTo(a,t),this._enforcingBounds=!1,this},panInside:function(e,t){var n=P((t=t||{}).paddingTopLeft||t.padding||[0,0]),a=P(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),s=this.project(e),o=this.getPixelBounds(),r=G([o.min.add(n),o.max.subtract(a)]),l=r.getSize();if(!r.contains(s)){this._enforcingBounds=!0;var c=s.subtract(r.getCenter()),h=r.extend(s).getSize().subtract(l);i.x+=c.x<0?-h.x:h.x,i.y+=c.y<0?-h.y:h.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=n({animate:!1,pan:!0},!0===e?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var a=this.getSize(),s=t.divideBy(2).round(),o=a.divideBy(2).round(),r=s.subtract(o);return r.x||r.y?(e.animate&&e.pan?this.panBy(r):(e.pan&&this._rawPanBy(r),this.fire("move"),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(i(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:t,newSize:a})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(e){if(e=this._locateOptions=n({timeout:1e4,watch:!1},e),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var t=i(this._handleGeolocationResponse,this),a=i(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,a,e):navigator.geolocation.getCurrentPosition(t,a,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,n=e.message||(1===t?"permission denied":2===t?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:t,message:"Geolocation error: "+n+"."})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=new Z(e.coords.latitude,e.coords.longitude),n=t.toBounds(2*e.coords.accuracy),a=this._locateOptions;if(a.setView){var i=this.getBoundsZoom(n);this.setView(t,a.maxZoom?Math.min(i,a.maxZoom):i)}var s={latlng:t,bounds:n,timestamp:e.timestamp};for(var o in e.coords)"number"===typeof e.coords[o]&&(s[o]=e.coords[o]);this.fire("locationfound",s)}},addHandler:function(e,t){if(!t)return this;var n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}var e;for(e in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),mt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(R(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[e].remove();for(e in this._panes)mt(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var n=pt("div","leaflet-pane"+(e?" leaflet-"+e.replace("Pane","")+"-pane":""),t||this._mapPane);return e&&(this._panes[e]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new j(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=V(e),n=P(n||[0,0]);var a=this.getZoom()||0,i=this.getMinZoom(),s=this.getMaxZoom(),o=e.getNorthWest(),r=e.getSouthEast(),l=this.getSize().subtract(n),c=G(this.project(r,a),this.project(o,a)).getSize(),h=We.any3d?this.options.zoomSnap:1,d=l.x/c.x,u=l.y/c.y,p=t?Math.max(d,u):Math.min(d,u);return a=this.getScaleZoom(p,a),h&&(a=Math.round(a/(h/100))*(h/100),a=t?Math.ceil(a/h)*h:Math.floor(a/h)*h),Math.max(i,Math.min(s,a))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new I(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var n=this._getTopLeftPoint(e,t);return new W(n,n.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(void 0===e?this.getZoom():e)},getPane:function(e){return"string"===typeof e?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var n=this.options.crs;return t=void 0===t?this._zoom:t,n.scale(e)/n.scale(t)},getScaleZoom:function(e,t){var n=this.options.crs;t=void 0===t?this._zoom:t;var a=n.zoom(e*n.scale(t));return isNaN(a)?1/0:a},project:function(e,t){return t=void 0===t?this._zoom:t,this.options.crs.latLngToPoint(F(e),t)},unproject:function(e,t){return t=void 0===t?this._zoom:t,this.options.crs.pointToLatLng(P(e),t)},layerPointToLatLng:function(e){var t=P(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(F(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(F(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(V(e))},distance:function(e,t){return this.options.crs.distance(F(e),F(t))},containerPointToLayerPoint:function(e){return P(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return P(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(P(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(F(e)))},mouseEventToContainerPoint:function(e){return Kt(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=dt(e);if(!t)throw new Error("Map container not found.");if(t._leaflet_id)throw new Error("Map container is already initialized.");Gt(t,"scroll",this._onScroll,this),this._containerId=o(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&We.any3d,yt(e,"leaflet-container"+(We.touch?" leaflet-touch":"")+(We.retina?" leaflet-retina":"")+(We.ielt9?" leaflet-oldie":"")+(We.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var t=ut(e,"position");"absolute"!==t&&"relative"!==t&&"fixed"!==t&&"sticky"!==t&&(e.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),At(this._mapPane,new I(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(yt(e.markerPane,"leaflet-zoom-hide"),yt(e.shadowPane,"leaflet-zoom-hide"))},_resetView:function(e,t,n){At(this._mapPane,new I(0,0));var a=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire("viewprereset");var i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire("viewreset"),a&&this.fire("load")},_moveStart:function(e,t){return e&&this.fire("zoomstart"),t||this.fire("movestart"),this},_move:function(e,t,n,a){void 0===t&&(t=this._zoom);var i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),a?n&&n.pinch&&this.fire("zoom",n):((i||n&&n.pinch)&&this.fire("zoom",n),this.fire("move",n)),this},_moveEnd:function(e){return e&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return R(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){At(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){this._targets={},this._targets[o(this._container)]=this;var t=e?Vt:Gt;t(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&t(window,"resize",this._onResize,this),We.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){R(this._resizeRequest),this._resizeRequest=T((function(){this.invalidateSize({debounceMoveend:!0})}),this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var n,a=[],i="mouseout"===t||"mouseover"===t,s=e.target||e.srcElement,r=!1;s;){if((n=this._targets[o(s)])&&("click"===t||"preclick"===t)&&this._draggableMoved(n)){r=!0;break}if(n&&n.listens(t,!0)){if(i&&!$t(s,e))break;if(a.push(n),i)break}if(s===this._container)break;s=s.parentNode}return a.length||r||i||!this.listens(t,!0)||(a=[this]),a},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||"click"===e.type&&this._isClickDisabled(t))){var n=e.type;"mousedown"===n&&Lt(t),this._fireDOMEvent(e,n)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(e,t,a){if("click"===e.type){var i=n({},e);i.type="preclick",this._fireDOMEvent(i,i.type,a)}var s=this._findEventTargets(e,t);if(a){for(var o=[],r=0;r0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),n=this.getMaxZoom(),a=We.any3d?this.options.zoomSnap:1;return a&&(e=Math.round(e/a)*a),Math.max(t,Math.min(n,e))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){wt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(e,t){var n=this._getCenterOffset(e)._trunc();return!(!0!==(t&&t.animate)&&!this.getSize().contains(n))&&(this.panBy(n,t),!0)},_createAnimProxy:function(){var e=this._proxy=pt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(e),this.on("zoomanim",(function(e){var t=lt,n=this._proxy.style[t];Rt(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()}),this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){mt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();Rt(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(e,t,n){if(this._animatingZoom)return!0;if(n=n||{},!this._zoomAnimated||!1===n.animate||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var a=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/a);return!(!0!==n.animate&&!this.getSize().contains(i))&&(T((function(){this._moveStart(!0,n.noMoveStart||!1)._animateZoom(e,t,!0)}),this),!0)},_animateZoom:function(e,t,n,a){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,yt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:e,zoom:t,noUpdate:a}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(i(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&wt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function an(e,t){return new nn(e,t)}var sn=C.extend({options:{position:"topright"},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),n=this.getPosition(),a=e._controlCorners[n];return yt(t,"leaflet-control"),-1!==n.indexOf("bottom")?a.insertBefore(t,a.firstChild):a.appendChild(t),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(mt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),on=function(e){return new sn(e)};nn.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t="leaflet-",n=this._controlContainer=pt("div",t+"control-container",this._container);function a(a,i){var s=t+a+" "+t+i;e[a+i]=pt("div",s,n)}a("top","left"),a("top","right"),a("bottom","left"),a("bottom","right")},_clearControlPos:function(){for(var e in this._controlCorners)mt(this._controlCorners[e]);mt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var rn=sn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,n,a){return n1,this._baseLayersList.style.display=e?"":"none"),this._separator.style.display=t&&e?"":"none",this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(o(e.target)),n=t.overlay?"add"===e.type?"overlayadd":"overlayremove":"add"===e.type?"baselayerchange":null;n&&this._map.fire(n,t)},_createRadioElement:function(e,t){var n='",a=document.createElement("div");return a.innerHTML=n,a.firstChild},_addItem:function(e){var t,n=document.createElement("label"),a=this._map.hasLayer(e.layer);e.overlay?((t=document.createElement("input")).type="checkbox",t.className="leaflet-control-layers-selector",t.defaultChecked=a):t=this._createRadioElement("leaflet-base-layers_"+o(this),a),this._layerControlInputs.push(t),t.layerId=o(e.layer),Gt(t,"click",this._onInputClick,this);var i=document.createElement("span");i.innerHTML=" "+e.name;var s=document.createElement("span");return n.appendChild(s),s.appendChild(t),s.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(n),this._checkDisabledLayers(),n},_onInputClick:function(){if(!this._preventClick){var e,t,n=this._layerControlInputs,a=[],i=[];this._handlingClick=!0;for(var s=n.length-1;s>=0;s--)e=n[s],t=this._getLayer(e.layerId).layer,e.checked?a.push(t):e.checked||i.push(t);for(s=0;s=0;i--)e=n[i],t=this._getLayer(e.layerId).layer,e.disabled=void 0!==t.options.minZoom&&at.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,Gt(e,"click",Ot),this.expand();var t=this;setTimeout((function(){Vt(e,"click",Ot),t._preventClick=!1}))}}),ln=function(e,t,n){return new rn(e,t,n)},cn=sn.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(e){var t="leaflet-control-zoom",n=pt("div",t+" leaflet-bar"),a=this.options;return this._zoomInButton=this._createButton(a.zoomInText,a.zoomInTitle,t+"-in",n,this._zoomIn),this._zoomOutButton=this._createButton(a.zoomOutText,a.zoomOutTitle,t+"-out",n,this._zoomOut),this._updateDisabled(),e.on("zoomend zoomlevelschange",this._updateDisabled,this),n},onRemove:function(e){e.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,n,a,i){var s=pt("a",n,a);return s.innerHTML=e,s.href="#",s.title=t,s.setAttribute("role","button"),s.setAttribute("aria-label",t),Yt(s),Gt(s,"click",zt),Gt(s,"click",i,this),Gt(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var e=this._map,t="leaflet-disabled";wt(this._zoomInButton,t),wt(this._zoomOutButton,t),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||e._zoom===e.getMinZoom())&&(yt(this._zoomOutButton,t),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||e._zoom===e.getMaxZoom())&&(yt(this._zoomInButton,t),this._zoomInButton.setAttribute("aria-disabled","true"))}});nn.mergeOptions({zoomControl:!0}),nn.addInitHook((function(){this.options.zoomControl&&(this.zoomControl=new cn,this.addControl(this.zoomControl))}));var hn=function(e){return new cn(e)},dn=sn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t="leaflet-control-scale",n=pt("div",t),a=this.options;return this._addScales(a,t+"-line",n),e.on(a.updateWhenIdle?"moveend":"move",this._update,this),e.whenReady(this._update,this),n},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,t,n){e.metric&&(this._mScale=pt("div",t,n)),e.imperial&&(this._iScale=pt("div",t,n))},_update:function(){var e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),n=t<1e3?t+" m":t/1e3+" km";this._updateScale(this._mScale,n,t/e)},_updateImperial:function(e){var t,n,a,i=3.2808399*e;i>5280?(t=i/5280,n=this._getRoundNum(t),this._updateScale(this._iScale,n+" mi",n/t)):(a=this._getRoundNum(i),this._updateScale(this._iScale,a+" ft",a/i))},_updateScale:function(e,t,n){e.style.width=Math.round(this.options.maxWidth*n)+"px",e.innerHTML=t},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),n=e/t;return t*(n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1)}}),un=function(e){return new dn(e)},pn='',mn=sn.extend({options:{position:"bottomright",prefix:''+(We.inlineSvg?pn+" ":"")+"Leaflet"},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=pt("div","leaflet-control-attribution"),Yt(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on("layeradd",this._addAttribution,this),this._container},onRemove:function(e){e.off("layeradd",this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once("remove",(function(){this.removeAttribution(e.layer.getAttribution())}),this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e?(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this):this},removeAttribution:function(e){return e?(this._attributions[e]&&(this._attributions[e]--,this._update()),this):this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(", ")),this._container.innerHTML=n.join(' ')}}});nn.mergeOptions({attributionControl:!0}),nn.addInitHook((function(){this.options.attributionControl&&(new mn).addTo(this)}));var fn=function(e){return new mn(e)};sn.Layers=rn,sn.Zoom=cn,sn.Scale=dn,sn.Attribution=mn,on.layers=ln,on.zoom=hn,on.scale=un,on.attribution=fn;var gn=C.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});gn.addTo=function(e,t){return e.addHandler(t,this),this};var vn={Events:E},bn=We.touch?"touchstart mousedown":"mousedown",yn=M.extend({options:{clickTolerance:3},initialize:function(e,t,n,a){p(this,a),this._element=e,this._dragStartTarget=t||e,this._preventOutline=n},enable:function(){this._enabled||(Gt(this._dragStartTarget,bn,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(yn._dragging===this&&this.finishDrag(!0),Vt(this._dragStartTarget,bn,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!bt(this._element,"leaflet-zoom-anim")))if(e.touches&&1!==e.touches.length)yn._dragging===this&&this.finishDrag();else if(!(yn._dragging||e.shiftKey||1!==e.which&&1!==e.button&&!e.touches)&&(yn._dragging=this,this._preventOutline&&Lt(this._element),Et(),at(),!this._moving)){this.fire("down");var t=e.touches?e.touches[0]:e,n=Xt(this._element);this._startPoint=new I(t.clientX,t.clientY),this._startPos=Ct(this._element),this._parentScale=Pt(n);var a="mousedown"===e.type;Gt(document,a?"mousemove":"touchmove",this._onMove,this),Gt(document,a?"mouseup":"touchend touchcancel",this._onUp,this)}},_onMove:function(e){if(this._enabled)if(e.touches&&e.touches.length>1)this._moved=!0;else{var t=e.touches&&1===e.touches.length?e.touches[0]:e,n=new I(t.clientX,t.clientY)._subtract(this._startPoint);(n.x||n.y)&&(Math.abs(n.x)+Math.abs(n.y)l&&(s=o,l=r);l>n&&(t[s]=1,Nn(e,t,n,a,s),Nn(e,t,n,s,i))}function En(e,t){for(var n=[e[0]],a=1,i=0,s=e.length;at&&(n.push(e[a]),i=a);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n}function Xn(e,t){var n=t.x-e.x,a=t.y-e.y;return n*n+a*a}function Pn(e,t,n,a){var i,s=t.x,o=t.y,r=n.x-s,l=n.y-o,c=r*r+l*l;return c>0&&((i=((e.x-s)*r+(e.y-o)*l)/c)>1?(s=n.x,o=n.y):i>0&&(s+=r*i,o+=l*i)),r=e.x-s,l=e.y-o,a?r*r+l*l:new I(s,o)}function Wn(e){return!v(e[0])||"object"!==typeof e[0][0]&&"undefined"!==typeof e[0][0]}function Gn(e){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Wn(e)}function jn(e,t){var n,a,i,s,o,r,l,c;if(!e||0===e.length)throw new Error("latlngs not passed");Wn(e)||(console.warn("latlngs are not flat! Only the first ring will be used"),e=e[0]);var h=F([0,0]),d=V(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(h=Sn(e));var u=e.length,p=[];for(n=0;na){l=(s-a)/i,c=[r.x-l*(r.x-o.x),r.y-l*(r.y-o.y)];break}var f=t.unproject(P(c));return F([f.lat+h.lat,f.lng+h.lng])}var Vn={__proto__:null,simplify:Tn,pointToSegmentDistance:Rn,closestPointOnSegment:An,clipSegment:Mn,_getEdgeIntersection:Ln,_getBitCode:In,_sqClosestPointOnSegment:Pn,isFlat:Wn,_flat:Gn,polylineCenter:jn},Zn={project:function(e){return new I(e.lng,e.lat)},unproject:function(e){return new Z(e.y,e.x)},bounds:new W([-180,-90],[180,90])},Fn={R:6378137,R_MINOR:6356752.314245179,bounds:new W([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,n=this.R,a=e.lat*t,i=this.R_MINOR/n,s=Math.sqrt(1-i*i),o=s*Math.sin(a),r=Math.tan(Math.PI/4-a/2)/Math.pow((1-o)/(1+o),s/2);return a=-n*Math.log(Math.max(r,1e-10)),new I(e.lng*t*n,a)},unproject:function(e){for(var t,n=180/Math.PI,a=this.R,i=this.R_MINOR/a,s=Math.sqrt(1-i*i),o=Math.exp(-e.y/a),r=Math.PI/2-2*Math.atan(o),l=0,c=.1;l<15&&Math.abs(c)>1e-7;l++)t=s*Math.sin(r),t=Math.pow((1-t)/(1+t),s/2),r+=c=Math.PI/2-2*Math.atan(o*t)-r;return new Z(r*n,e.x*n/a)}},Dn={__proto__:null,LonLat:Zn,Mercator:Fn,SphericalMercator:U},Bn=n({},B,{code:"EPSG:3395",projection:Fn,transformation:function(){var e=.5/(Math.PI*Fn.R);return O(e,.5,-e,.5)}()}),Hn=n({},B,{code:"EPSG:4326",projection:Zn,transformation:O(1/180,1,-1/180,.5)}),Un=n({},D,{projection:Zn,transformation:O(1,0,-1,0),scale:function(e){return Math.pow(2,e)},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var n=t.lng-e.lng,a=t.lat-e.lat;return Math.sqrt(n*n+a*a)},infinite:!0});D.Earth=B,D.EPSG3395=Bn,D.EPSG3857=z,D.EPSG900913=J,D.EPSG4326=Hn,D.Simple=Un;var Yn=M.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[o(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[o(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var n=this.getEvents();t.on(n,this),this.once("remove",(function(){t.off(n,this)}),this)}this.onAdd(t),this.fire("add"),t.fire("layeradd",{layer:this})}}});nn.include({addLayer:function(e){if(!e._layerAdd)throw new Error("The provided object is not a Layer.");var t=o(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer:function(e){var t=o(e);return this._layers[t]?(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire("layerremove",{layer:e}),e.fire("remove")),e._map=e._mapToAdd=null,this):this},hasLayer:function(e){return o(e)in this._layers},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},_addLayers:function(e){for(var t=0,n=(e=e?v(e)?e:[e]:[]).length;tthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()=2&&t[0]instanceof Z&&t[0].equals(t[n-1])&&t.pop(),t},_setLatLngs:function(e){la.prototype._setLatLngs.call(this,e),Wn(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Wn(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,n=new I(t,t);if(e=new W(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e))if(this.options.noClip)this._parts=this._rings;else for(var a,i=0,s=this._rings.length;ie.y!==a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(c=!c);return c||la.prototype._containsPoint.call(this,e,!0)}});function da(e,t){return new ha(e,t)}var ua=Jn.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t,n,a,i=v(e)?e:e.features;if(i){for(t=0,n=i.length;t0&&i.push(i[0].slice()),i}function ya(e,t){return e.feature?n({},e.feature,{geometry:t}):wa(t)}function wa(e){return"Feature"===e.type||"FeatureCollection"===e.type?e:{type:"Feature",properties:{},geometry:e}}var xa={toGeoJSON:function(e){return ya(this,{type:"Point",coordinates:va(this.getLatLng(),e)})}};function Sa(e,t){return new ua(e,t)}ta.include(xa),oa.include(xa),ia.include(xa),la.include({toGeoJSON:function(e){var t=!Wn(this._latlngs);return ya(this,{type:(t?"Multi":"")+"LineString",coordinates:ba(this._latlngs,t?1:0,!1,e)})}}),ha.include({toGeoJSON:function(e){var t=!Wn(this._latlngs),n=t&&!Wn(this._latlngs[0]),a=ba(this._latlngs,n?2:t?1:0,!0,e);return t||(a=[a]),ya(this,{type:(n?"Multi":"")+"Polygon",coordinates:a})}}),On.include({toMultiPoint:function(e){var t=[];return this.eachLayer((function(n){t.push(n.toGeoJSON(e).geometry.coordinates)})),ya(this,{type:"MultiPoint",coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint(e);var n="GeometryCollection"===t,a=[];return this.eachLayer((function(t){if(t.toGeoJSON){var i=t.toGeoJSON(e);if(n)a.push(i.geometry);else{var s=wa(i);"FeatureCollection"===s.type?a.push.apply(a,s.features):a.push(s)}}})),n?ya(this,{geometries:a,type:"GeometryCollection"}):{type:"FeatureCollection",features:a}}});var ka=Sa,_a=Yn.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(e,t,n){this._url=e,this._bounds=V(t),p(this,n)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(yt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){mt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&>(this._image),this},bringToBack:function(){return this._map&&vt(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=V(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e="IMG"===this._url.tagName,t=this._image=e?this._url:pt("img");yt(t,"leaflet-image-layer"),this._zoomAnimated&&yt(t,"leaflet-zoom-animated"),this.options.className&&yt(t,this.options.className),t.onselectstart=c,t.onmousemove=c,t.onload=i(this.fire,this,"load"),t.onerror=i(this._overlayOnError,this,"error"),(this.options.crossOrigin||""===this.options.crossOrigin)&&(t.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Rt(this._image,n,t)},_reset:function(){var e=this._image,t=new W(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();At(e,t.min),e.style.width=n.x+"px",e.style.height=n.y+"px"},_updateOpacity:function(){kt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),Ta=function(e,t,n){return new _a(e,t,n)},Ra=_a.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e="VIDEO"===this._url.tagName,t=this._image=e?this._url:pt("video");if(yt(t,"leaflet-image-layer"),this._zoomAnimated&&yt(t,"leaflet-zoom-animated"),this.options.className&&yt(t,this.options.className),t.onselectstart=c,t.onmousemove=c,t.onloadeddata=i(this.fire,this,"load"),e){for(var n=t.getElementsByTagName("source"),a=[],s=0;s0?a:[t.src]}else{v(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,"objectFit")&&(t.style.objectFit="fill"),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var o=0;oi?(t.height=i+"px",yt(e,s)):wt(e,s),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();At(this._container,t.add(n))},_adjustPan:function(){if(this.options.autoPan)if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var e=this._map,t=parseInt(ut(this._container,"marginBottom"),10)||0,n=this._container.offsetHeight+t,a=this._containerWidth,i=new I(this._containerLeft,-n-this._containerBottom);i._add(Ct(this._container));var s=e.layerPointToContainerPoint(i),o=P(this.options.autoPanPadding),r=P(this.options.autoPanPaddingTopLeft||o),l=P(this.options.autoPanPaddingBottomRight||o),c=e.getSize(),h=0,d=0;s.x+a+l.x>c.x&&(h=s.x+a-c.x+l.x),s.x-h-r.x<0&&(h=s.x-r.x),s.y+n+l.y>c.y&&(d=s.y+n-c.y+l.y),s.y-d-r.y<0&&(d=s.y-r.y),(h||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire("autopanstart").panBy([h,d]))}},_getAnchor:function(){return P(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),La=function(e,t){return new Ma(e,t)};nn.mergeOptions({closePopupOnClick:!0}),nn.include({openPopup:function(e,t,n){return this._initOverlay(Ma,e,t,n).openOn(this),this},closePopup:function(e){return(e=arguments.length?e:this._popup)&&e.close(),this}}),Yn.include({bindPopup:function(e,t){return this._popup=this._initOverlay(Ma,this._popup,e,t),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(e){return this._popup&&(this instanceof Jn||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(e){return this._popup&&this._popup.setContent(e),this},getPopup:function(){return this._popup},_openPopup:function(e){if(this._popup&&this._map){zt(e);var t=e.layer||e.target;this._popup._source!==t||t instanceof aa?(this._popup._source=t,this.openPopup(e.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng)}},_movePopup:function(e){this._popup.setLatLng(e.latlng)},_onKeyPress:function(e){13===e.originalEvent.keyCode&&this._openPopup(e)}});var Ia=Ea.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(e){Ea.prototype.onAdd.call(this,e),this.setOpacity(this.options.opacity),e.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(e){Ea.prototype.onRemove.call(this,e),e.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var e=Ea.prototype.getEvents.call(this);return this.options.permanent||(e.preclick=this.close),e},_initLayout:function(){var e="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=pt("div",e),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+o(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(e){var t,n,a=this._map,i=this._container,s=a.latLngToContainerPoint(a.getCenter()),o=a.layerPointToContainerPoint(e),r=this.options.direction,l=i.offsetWidth,c=i.offsetHeight,h=P(this.options.offset),d=this._getAnchor();"top"===r?(t=l/2,n=c):"bottom"===r?(t=l/2,n=0):"center"===r?(t=l/2,n=c/2):"right"===r?(t=0,n=c/2):"left"===r?(t=l,n=c/2):o.xthis.options.maxZoom||na&&this._retainParent(i,s,o,a))},_retainChildren:function(e,t,n,a){for(var i=2*e;i<2*e+2;i++)for(var s=2*t;s<2*t+2;s++){var o=new I(i,s);o.z=n+1;var r=this._tileCoordsToKey(o),l=this._tiles[r];l&&l.active?l.retain=!0:(l&&l.loaded&&(l.retain=!0),n+1this.options.maxZoom||void 0!==this.options.minZoom&&i1)this._setView(e,n);else{for(var d=i.min.y;d<=i.max.y;d++)for(var u=i.min.x;u<=i.max.x;u++){var p=new I(u,d);if(p.z=this._tileZoom,this._isValidTile(p)){var m=this._tiles[this._tileCoordsToKey(p)];m?m.current=!0:o.push(p)}}if(o.sort((function(e,t){return e.distanceTo(s)-t.distanceTo(s)})),0!==o.length){this._loading||(this._loading=!0,this.fire("loading"));var f=document.createDocumentFragment();for(u=0;un.max.x)||!t.wrapLat&&(e.yn.max.y))return!1}if(!this.options.bounds)return!0;var a=this._tileCoordsToBounds(e);return V(this.options.bounds).overlaps(a)},_keyToBounds:function(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))},_tileCoordsToNwSe:function(e){var t=this._map,n=this.getTileSize(),a=e.scaleBy(n),i=a.add(n);return[t.unproject(a,e.z),t.unproject(i,e.z)]},_tileCoordsToBounds:function(e){var t=this._tileCoordsToNwSe(e),n=new j(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n},_tileCoordsToKey:function(e){return e.x+":"+e.y+":"+e.z},_keyToTileCoords:function(e){var t=e.split(":"),n=new I(+t[0],+t[1]);return n.z=+t[2],n},_removeTile:function(e){var t=this._tiles[e];t&&(mt(t.el),delete this._tiles[e],this.fire("tileunload",{tile:t.el,coords:this._keyToTileCoords(e)}))},_initTile:function(e){yt(e,"leaflet-tile");var t=this.getTileSize();e.style.width=t.x+"px",e.style.height=t.y+"px",e.onselectstart=c,e.onmousemove=c,We.ielt9&&this.options.opacity<1&&kt(e,this.options.opacity)},_addTile:function(e,t){var n=this._getTilePos(e),a=this._tileCoordsToKey(e),s=this.createTile(this._wrapCoords(e),i(this._tileReady,this,e));this._initTile(s),this.createTile.length<2&&T(i(this._tileReady,this,e,null,s)),At(s,n),this._tiles[a]={el:s,coords:e,current:!0},t.appendChild(s),this.fire("tileloadstart",{tile:s,coords:e})},_tileReady:function(e,t,n){t&&this.fire("tileerror",{error:t,tile:n,coords:e});var a=this._tileCoordsToKey(e);(n=this._tiles[a])&&(n.loaded=+new Date,this._map._fadeAnimated?(kt(n.el,0),R(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),t||(yt(n.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),We.ielt9||!this._map._fadeAnimated?T(this._pruneTiles,this):setTimeout(i(this._pruneTiles,this),250)))},_getTilePos:function(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(e){var t=new I(this._wrapX?l(e.x,this._wrapX):e.x,this._wrapY?l(e.y,this._wrapY):e.y);return t.z=e.z,t},_pxBoundsToTileRange:function(e){var t=this.getTileSize();return new W(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var e in this._tiles)if(!this._tiles[e].loaded)return!1;return!0}});function ja(e){return new Ga(e)}var Va=Ga.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(e,t){this._url=e,(t=p(this,t)).detectRetina&&We.retina&&t.maxZoom>0?(t.tileSize=Math.floor(t.tileSize/2),t.zoomReverse?(t.zoomOffset--,t.minZoom=Math.min(t.maxZoom,t.minZoom+1)):(t.zoomOffset++,t.maxZoom=Math.max(t.minZoom,t.maxZoom-1)),t.minZoom=Math.max(0,t.minZoom)):t.zoomReverse?t.minZoom=Math.min(t.maxZoom,t.minZoom):t.maxZoom=Math.max(t.minZoom,t.maxZoom),"string"===typeof t.subdomains&&(t.subdomains=t.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(e,t){return this._url===e&&void 0===t&&(t=!0),this._url=e,t||this.redraw(),this},createTile:function(e,t){var n=document.createElement("img");return Gt(n,"load",i(this._tileOnLoad,this,t,n)),Gt(n,"error",i(this._tileOnError,this,t,n)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(n.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"===typeof this.options.referrerPolicy&&(n.referrerPolicy=this.options.referrerPolicy),n.alt="",n.src=this.getTileUrl(e),n},getTileUrl:function(e){var t={r:We.retina?"@2x":"",s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var a=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=a),t["-y"]=a}return g(this._url,n(t,this.options))},_tileOnLoad:function(e,t){We.ielt9?setTimeout(i(e,this,null,t),0):e(null,t)},_tileOnError:function(e,t,n){var a=this.options.errorTileUrl;a&&t.getAttribute("src")!==a&&(t.src=a),e(n,t)},_onTileRemove:function(e){e.tile.onload=null},_getZoomForUrl:function(){var e=this._tileZoom,t=this.options.maxZoom;return this.options.zoomReverse&&(e=t-e),e+this.options.zoomOffset},_getSubdomain:function(e){var t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_abortLoading:function(){var e,t;for(e in this._tiles)if(this._tiles[e].coords.z!==this._tileZoom&&((t=this._tiles[e].el).onload=c,t.onerror=c,!t.complete)){t.src=y;var n=this._tiles[e].coords;mt(t),delete this._tiles[e],this.fire("tileabort",{tile:t,coords:n})}},_removeTile:function(e){var t=this._tiles[e];if(t)return t.el.setAttribute("src",y),Ga.prototype._removeTile.call(this,e)},_tileReady:function(e,t,n){if(this._map&&(!n||n.getAttribute("src")!==y))return Ga.prototype._tileReady.call(this,e,t,n)}});function Za(e,t){return new Va(e,t)}var Fa=Va.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(e,t){this._url=e;var a=n({},this.defaultWmsParams);for(var i in t)i in this.options||(a[i]=t[i]);var s=(t=p(this,t)).detectRetina&&We.retina?2:1,o=this.getTileSize();a.width=o.x*s,a.height=o.y*s,this.wmsParams=a},onAdd:function(e){this._crs=this.options.crs||e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var t=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[t]=this._crs.code,Va.prototype.onAdd.call(this,e)},getTileUrl:function(e){var t=this._tileCoordsToNwSe(e),n=this._crs,a=G(n.project(t[0]),n.project(t[1])),i=a.min,s=a.max,o=(this._wmsVersion>=1.3&&this._crs===Hn?[i.y,i.x,s.y,s.x]:[i.x,i.y,s.x,s.y]).join(","),r=Va.prototype.getTileUrl.call(this,e);return r+m(this.wmsParams,r,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+o},setParams:function(e,t){return n(this.wmsParams,e),t||this.redraw(),this}});function Da(e,t){return new Fa(e,t)}Va.WMS=Fa,Za.wms=Da;var Ba=Yn.extend({options:{padding:.1},initialize:function(e){p(this,e),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),yt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var e={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(e,t){var n=this._map.getZoomScale(t,this._zoom),a=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),s=a.multiplyBy(-n).add(i).subtract(this._map._getNewPixelOrigin(e,t));We.any3d?Rt(this._container,s,n):At(this._container,s)},_reset:function(){for(var e in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[e]._reset()},_onZoomEnd:function(){for(var e in this._layers)this._layers[e]._project()},_updatePaths:function(){for(var e in this._layers)this._layers[e]._update()},_update:function(){var e=this.options.padding,t=this._map.getSize(),n=this._map.containerPointToLayerPoint(t.multiplyBy(-e)).round();this._bounds=new W(n,n.add(t.multiplyBy(1+2*e)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Ha=Ba.extend({options:{tolerance:0},getEvents:function(){var e=Ba.prototype.getEvents.call(this);return e.viewprereset=this._onViewPreReset,e},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Ba.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var e=this._container=document.createElement("canvas");Gt(e,"mousemove",this._onMouseMove,this),Gt(e,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Gt(e,"mouseout",this._handleMouseOut,this),e._leaflet_disable_events=!0,this._ctx=e.getContext("2d")},_destroyContainer:function(){R(this._redrawRequest),delete this._ctx,mt(this._container),Vt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var e in this._redrawBounds=null,this._layers)this._layers[e]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){Ba.prototype._update.call(this);var e=this._bounds,t=this._container,n=e.getSize(),a=We.retina?2:1;At(t,e.min),t.width=a*n.x,t.height=a*n.y,t.style.width=n.x+"px",t.style.height=n.y+"px",We.retina&&this._ctx.scale(2,2),this._ctx.translate(-e.min.x,-e.min.y),this.fire("update")}},_reset:function(){Ba.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(e){this._updateDashArray(e),this._layers[o(e)]=e;var t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(e){this._requestRedraw(e)},_removePath:function(e){var t=e._order,n=t.next,a=t.prev;n?n.prev=a:this._drawLast=a,a?a.next=n:this._drawFirst=n,delete e._order,delete this._layers[o(e)],this._requestRedraw(e)},_updatePath:function(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)},_updateStyle:function(e){this._updateDashArray(e),this._requestRedraw(e)},_updateDashArray:function(e){if("string"===typeof e.options.dashArray){var t,n,a=e.options.dashArray.split(/[, ]+/),i=[];for(n=0;n')}}catch(e){}return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Oa={_initContainer:function(){this._container=pt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Ba.prototype._update.call(this),this.fire("update"))},_initPath:function(e){var t=e._container=Ya("shape");yt(t,"leaflet-vml-shape "+(this.options.className||"")),t.coordsize="1 1",e._path=Ya("path"),t.appendChild(e._path),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){var t=e._container;this._container.appendChild(t),e.options.interactive&&e.addInteractiveTarget(t)},_removePath:function(e){var t=e._container;mt(t),e.removeInteractiveTarget(t),delete this._layers[o(e)]},_updateStyle:function(e){var t=e._stroke,n=e._fill,a=e.options,i=e._container;i.stroked=!!a.stroke,i.filled=!!a.fill,a.stroke?(t||(t=e._stroke=Ya("stroke")),i.appendChild(t),t.weight=a.weight+"px",t.color=a.color,t.opacity=a.opacity,a.dashArray?t.dashStyle=v(a.dashArray)?a.dashArray.join(" "):a.dashArray.replace(/( *, *)/g," "):t.dashStyle="",t.endcap=a.lineCap.replace("butt","flat"),t.joinstyle=a.lineJoin):t&&(i.removeChild(t),e._stroke=null),a.fill?(n||(n=e._fill=Ya("fill")),i.appendChild(n),n.color=a.fillColor||a.color,n.opacity=a.fillOpacity):n&&(i.removeChild(n),e._fill=null)},_updateCircle:function(e){var t=e._point.round(),n=Math.round(e._radius),a=Math.round(e._radiusY||n);this._setPath(e,e._empty()?"M0 0":"AL "+t.x+","+t.y+" "+n+","+a+" 0,23592600")},_setPath:function(e,t){e._path.v=t},_bringToFront:function(e){gt(e._container)},_bringToBack:function(e){vt(e._container)}},za=We.vml?Ya:K,Ja=Ba.extend({_initContainer:function(){this._container=za("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=za("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){mt(this._container),Vt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){Ba.prototype._update.call(this);var e=this._bounds,t=e.getSize(),n=this._container;this._svgSize&&this._svgSize.equals(t)||(this._svgSize=t,n.setAttribute("width",t.x),n.setAttribute("height",t.y)),At(n,e.min),n.setAttribute("viewBox",[e.min.x,e.min.y,t.x,t.y].join(" ")),this.fire("update")}},_initPath:function(e){var t=e._path=za("path");e.options.className&&yt(t,e.options.className),e.options.interactive&&yt(t,"leaflet-interactive"),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)},_removePath:function(e){mt(e._path),e.removeInteractiveTarget(e._path),delete this._layers[o(e)]},_updatePath:function(e){e._project(),e._update()},_updateStyle:function(e){var t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute("stroke",n.color),t.setAttribute("stroke-opacity",n.opacity),t.setAttribute("stroke-width",n.weight),t.setAttribute("stroke-linecap",n.lineCap),t.setAttribute("stroke-linejoin",n.lineJoin),n.dashArray?t.setAttribute("stroke-dasharray",n.dashArray):t.removeAttribute("stroke-dasharray"),n.dashOffset?t.setAttribute("stroke-dashoffset",n.dashOffset):t.removeAttribute("stroke-dashoffset")):t.setAttribute("stroke","none"),n.fill?(t.setAttribute("fill",n.fillColor||n.color),t.setAttribute("fill-opacity",n.fillOpacity),t.setAttribute("fill-rule",n.fillRule||"evenodd")):t.setAttribute("fill","none"))},_updatePoly:function(e,t){this._setPath(e,Q(e._parts,t))},_updateCircle:function(e){var t=e._point,n=Math.max(Math.round(e._radius),1),a="a"+n+","+(Math.max(Math.round(e._radiusY),1)||n)+" 0 1,0 ",i=e._empty()?"M0 0":"M"+(t.x-n)+","+t.y+a+2*n+",0 "+a+2*-n+",0 ";this._setPath(e,i)},_setPath:function(e,t){e._path.setAttribute("d",t)},_bringToFront:function(e){gt(e._path)},_bringToBack:function(e){vt(e._path)}});function Ka(e){return We.svg||We.vml?new Ja(e):null}We.vml&&Ja.include(Oa),nn.include({getRenderer:function(e){var t=e.options.renderer||this._getPaneRenderer(e.options.pane)||this.options.renderer||this._renderer;return t||(t=this._renderer=this._createRenderer()),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(e){if("overlayPane"===e||void 0===e)return!1;var t=this._paneRenderers[e];return void 0===t&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer:function(e){return this.options.preferCanvas&&Ua(e)||Ka(e)}});var Qa=ha.extend({initialize:function(e,t){ha.prototype.initialize.call(this,this._boundsToLatLngs(e),t)},setBounds:function(e){return this.setLatLngs(this._boundsToLatLngs(e))},_boundsToLatLngs:function(e){return[(e=V(e)).getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}});function qa(e,t){return new Qa(e,t)}Ja.create=za,Ja.pointsToPath=Q,ua.geometryToLayer=pa,ua.coordsToLatLng=fa,ua.coordsToLatLngs=ga,ua.latLngToCoords=va,ua.latLngsToCoords=ba,ua.getFeature=ya,ua.asFeature=wa,nn.mergeOptions({boxZoom:!0});var $a=gn.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane,this._resetStateTimeout=0,e.on("unload",this._destroy,this)},addHooks:function(){Gt(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Vt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){mt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(e){if(!e.shiftKey||1!==e.which&&1!==e.button)return!1;this._clearDeferredResetState(),this._resetState(),at(),Et(),this._startPoint=this._map.mouseEventToContainerPoint(e),Gt(document,{contextmenu:zt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=pt("div","leaflet-zoom-box",this._container),yt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(e);var t=new W(this._point,this._startPoint),n=t.getSize();At(this._box,t.min),this._box.style.width=n.x+"px",this._box.style.height=n.y+"px"},_finish:function(){this._moved&&(mt(this._box),wt(this._container,"leaflet-crosshair")),it(),Mt(),Vt(document,{contextmenu:zt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(e){if((1===e.which||1===e.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(i(this._resetState,this),0);var t=new j(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire("boxzoomend",{boxZoomBounds:t})}},_onKeyDown:function(e){27===e.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});nn.addInitHook("addHandler","boxZoom",$a),nn.mergeOptions({doubleClickZoom:!0});var ei=gn.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(e){var t=this._map,n=t.getZoom(),a=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-a:n+a;"center"===t.options.doubleClickZoom?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}});nn.addInitHook("addHandler","doubleClickZoom",ei),nn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var ti=gn.extend({addHooks:function(){if(!this._draggable){var e=this._map;this._draggable=new yn(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),e.on("zoomend",this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}yt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){wt(this._map._container,"leaflet-grab"),wt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var t=V(this._map.options.maxBounds);this._offsetLimit=G(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire("movestart").fire("dragstart"),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var t=this._lastTime=+new Date,n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(t),this._prunePositions(t)}this._map.fire("move",e).fire("drag",e)},_prunePositions:function(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(e,t){return e-(e-t)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.xt.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}},_onPreDragWrap:function(){var e=this._worldWidth,t=Math.round(e/2),n=this._initialWorldOffset,a=this._draggable._newPos.x,i=(a-t+n)%e+t-n,s=(a+t+n)%e-t-n,o=Math.abs(i+n)0?s:-s))-t;this._delta=0,this._startTime=null,o&&("center"===e.options.scrollWheelZoom?e.setZoom(t+o):e.setZoomAround(this._lastMousePos,t+o))}});nn.addInitHook("addHandler","scrollWheelZoom",ai);var ii=600;nn.mergeOptions({tapHold:We.touchNative&&We.safari&&We.mobile,tapTolerance:15});var si=gn.extend({addHooks:function(){Gt(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Vt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(e){if(clearTimeout(this._holdTimeout),1===e.touches.length){var t=e.touches[0];this._startPos=this._newPos=new I(t.clientX,t.clientY),this._holdTimeout=setTimeout(i((function(){this._cancel(),this._isTapValid()&&(Gt(document,"touchend",Ot),Gt(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",t))}),this),ii),Gt(document,"touchend touchcancel contextmenu",this._cancel,this),Gt(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function e(){Vt(document,"touchend",Ot),Vt(document,"touchend touchcancel",e)},_cancel:function(){clearTimeout(this._holdTimeout),Vt(document,"touchend touchcancel contextmenu",this._cancel,this),Vt(document,"touchmove",this._onMove,this)},_onMove:function(e){var t=e.touches[0];this._newPos=new I(t.clientX,t.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(e,t){var n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}});nn.addInitHook("addHandler","tapHold",si),nn.mergeOptions({touchZoom:We.touch,bounceAtZoomLimits:!0});var oi=gn.extend({addHooks:function(){yt(this._map._container,"leaflet-touch-zoom"),Gt(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){wt(this._map._container,"leaflet-touch-zoom"),Vt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(e){var t=this._map;if(e.touches&&2===e.touches.length&&!t._animatingZoom&&!this._zooming){var n=t.mouseEventToContainerPoint(e.touches[0]),a=t.mouseEventToContainerPoint(e.touches[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),"center"!==t.options.touchZoom&&(this._pinchStartLatLng=t.containerPointToLatLng(n.add(a)._divideBy(2))),this._startDist=n.distanceTo(a),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),Gt(document,"touchmove",this._onTouchMove,this),Gt(document,"touchend touchcancel",this._onTouchEnd,this),Ot(e)}},_onTouchMove:function(e){if(e.touches&&2===e.touches.length&&this._zooming){var t=this._map,n=t.mouseEventToContainerPoint(e.touches[0]),a=t.mouseEventToContainerPoint(e.touches[1]),s=n.distanceTo(a)/this._startDist;if(this._zoom=t.getScaleZoom(s,this._startZoom),!t.options.bounceAtZoomLimits&&(this._zoomt.getMaxZoom()&&s>1)&&(this._zoom=t._limitZoom(this._zoom)),"center"===t.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{var o=n._add(a)._divideBy(2)._subtract(this._centerPoint);if(1===s&&0===o.x&&0===o.y)return;this._center=t.unproject(t.project(this._pinchStartLatLng,this._zoom).subtract(o),this._zoom)}this._moved||(t._moveStart(!0,!1),this._moved=!0),R(this._animRequest);var r=i(t._move,t,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=T(r,this,!0),Ot(e)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,R(this._animRequest),Vt(document,"touchmove",this._onTouchMove,this),Vt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});nn.addInitHook("addHandler","touchZoom",oi),nn.BoxZoom=$a,nn.DoubleClickZoom=ei,nn.Drag=ti,nn.Keyboard=ni,nn.ScrollWheelZoom=ai,nn.TapHold=si,nn.TouchZoom=oi,e.Bounds=W,e.Browser=We,e.CRS=D,e.Canvas=Ha,e.Circle=oa,e.CircleMarker=ia,e.Class=C,e.Control=sn,e.DivIcon=Pa,e.DivOverlay=Ea,e.DomEvent=en,e.DomUtil=Wt,e.Draggable=yn,e.Evented=M,e.FeatureGroup=Jn,e.GeoJSON=ua,e.GridLayer=Ga,e.Handler=gn,e.Icon=Qn,e.ImageOverlay=_a,e.LatLng=Z,e.LatLngBounds=j,e.Layer=Yn,e.LayerGroup=On,e.LineUtil=Vn,e.Map=nn,e.Marker=ta,e.Mixin=vn,e.Path=aa,e.Point=I,e.PolyUtil=_n,e.Polygon=ha,e.Polyline=la,e.Popup=Ma,e.PosAnimation=tn,e.Projection=Dn,e.Rectangle=Qa,e.Renderer=Ba,e.SVG=Ja,e.SVGOverlay=Ca,e.TileLayer=Va,e.Tooltip=Ia,e.Transformation=Y,e.Util=A,e.VideoOverlay=Ra,e.bind=i,e.bounds=G,e.canvas=Ua,e.circle=ra,e.circleMarker=sa,e.control=on,e.divIcon=Wa,e.extend=n,e.featureGroup=Kn,e.geoJSON=Sa,e.geoJson=ka,e.gridLayer=ja,e.icon=qn,e.imageOverlay=Ta,e.latLng=F,e.latLngBounds=V,e.layerGroup=zn,e.map=an,e.marker=na,e.point=P,e.polygon=da,e.polyline=ca,e.popup=La,e.rectangle=qa,e.setOptions=p,e.stamp=o,e.svg=Ka,e.svgOverlay=Na,e.tileLayer=Za,e.tooltip=Xa,e.transformation=O,e.version=t,e.videoOverlay=Aa;var ri=window.L;e.noConflict=function(){return window.L=ri,this},window.L=e}(t)},2160(e,t,n){"use strict";var a=n(5043);function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n