@inweb/viewer-three 26.12.6 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/loaders/GLTFFileLoader.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.module.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.js +2 -2
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
- package/dist/extensions/loaders/IFCXLoader.module.js +2 -2
- package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/viewer-three.js +466 -170
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -2
- package/dist/viewer-three.module.js +464 -168
- package/dist/viewer-three.module.js.map +1 -1
- package/extensions/loaders/GLTFFileLoader.ts +1 -1
- package/extensions/loaders/IFCX/IFCXCloudLoader.ts +1 -1
- package/extensions/loaders/IFCX/IFCXFileLoader.ts +1 -1
- package/lib/Viewer/Viewer.d.ts +2 -1
- package/lib/Viewer/components/ExtentsComponent.d.ts +1 -1
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +3 -3
- package/lib/Viewer/measurement/Snapper.d.ts +1 -0
- package/lib/Viewer/measurement/UnitConverter.d.ts +20 -13
- package/lib/Viewer/models/IModelImpl.d.ts +2 -6
- package/lib/Viewer/models/ModelImpl.d.ts +4 -6
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +25 -15
- package/src/Viewer/commands/GetSelected2.ts +2 -2
- package/src/Viewer/commands/ZoomTo.ts +3 -3
- package/src/Viewer/components/CameraComponent.ts +4 -4
- package/src/Viewer/components/ExtentsComponent.ts +3 -3
- package/src/Viewer/components/HighlighterComponent.ts +11 -17
- package/src/Viewer/components/SelectionComponent.ts +14 -13
- package/src/Viewer/draggers/MeasureLineDragger.ts +1 -0
- package/src/Viewer/draggers/OrbitDragger.ts +2 -0
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +287 -22
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +94 -18
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +1 -1
- package/src/Viewer/measurement/Snapper.ts +6 -3
- package/src/Viewer/measurement/UnitConverter.ts +19 -12
- package/src/Viewer/measurement/UnitFormatter.ts +2 -2
- package/src/Viewer/models/IModelImpl.ts +2 -10
- package/src/Viewer/models/ModelImpl.ts +111 -61
package/dist/viewer-three.min.js
CHANGED
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
* Copyright 2010-2025 Three.js Authors
|
|
33
33
|
* SPDX-License-Identifier: MIT
|
|
34
34
|
*/
|
|
35
|
-
function Jc(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Qc(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_);const $c={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 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( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\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}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\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 = inverseTransformDirection( 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 * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\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\t\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 = inverseTransformDirection( 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, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( 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 = inverseTransformDirection( 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 = inverseTransformDirection( 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",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 * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), 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.07, 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:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\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#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\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\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.specularColor;\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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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}\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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\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\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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 );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\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 )\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#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\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\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",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#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\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#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\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\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#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\treturn depth * ( near - far ) - near;\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\treturn ( near * far ) / ( ( far - near ) * depth - far );\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\tuniform sampler2D directionalShadowMap[ 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\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\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 sampler2D pointShadowMap[ 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\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D 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\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\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\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\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\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 = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, 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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), 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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},td={common:{diffuse:{value:new Jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ri},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ri}},envmap:{envMap:{value:null},envMapRotation:{value:new ri},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ri}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ri}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ri},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ri},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ri},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ri}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ri}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ri}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Jn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0},uvTransform:{value:new ri}},sprite:{diffuse:{value:new Jn(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ri},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0}}},ed={basic:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.fog]),vertexShader:$c.meshbasic_vert,fragmentShader:$c.meshbasic_frag},lambert:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.fog,td.lights,{emissive:{value:new Jn(0)}}]),vertexShader:$c.meshlambert_vert,fragmentShader:$c.meshlambert_frag},phong:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.fog,td.lights,{emissive:{value:new Jn(0)},specular:{value:new Jn(1118481)},shininess:{value:30}}]),vertexShader:$c.meshphong_vert,fragmentShader:$c.meshphong_frag},standard:{uniforms:Nr([td.common,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.roughnessmap,td.metalnessmap,td.fog,td.lights,{emissive:{value:new Jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$c.meshphysical_vert,fragmentShader:$c.meshphysical_frag},toon:{uniforms:Nr([td.common,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.gradientmap,td.fog,td.lights,{emissive:{value:new Jn(0)}}]),vertexShader:$c.meshtoon_vert,fragmentShader:$c.meshtoon_frag},matcap:{uniforms:Nr([td.common,td.bumpmap,td.normalmap,td.displacementmap,td.fog,{matcap:{value:null}}]),vertexShader:$c.meshmatcap_vert,fragmentShader:$c.meshmatcap_frag},points:{uniforms:Nr([td.points,td.fog]),vertexShader:$c.points_vert,fragmentShader:$c.points_frag},dashed:{uniforms:Nr([td.common,td.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$c.linedashed_vert,fragmentShader:$c.linedashed_frag},depth:{uniforms:Nr([td.common,td.displacementmap]),vertexShader:$c.depth_vert,fragmentShader:$c.depth_frag},normal:{uniforms:Nr([td.common,td.bumpmap,td.normalmap,td.displacementmap,{opacity:{value:1}}]),vertexShader:$c.meshnormal_vert,fragmentShader:$c.meshnormal_frag},sprite:{uniforms:Nr([td.sprite,td.fog]),vertexShader:$c.sprite_vert,fragmentShader:$c.sprite_frag},background:{uniforms:{uvTransform:{value:new ri},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$c.background_vert,fragmentShader:$c.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ri}},vertexShader:$c.backgroundCube_vert,fragmentShader:$c.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$c.cube_vert,fragmentShader:$c.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$c.equirect_vert,fragmentShader:$c.equirect_frag},distanceRGBA:{uniforms:Nr([td.common,td.displacementmap,{referencePosition:{value:new ei},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$c.distanceRGBA_vert,fragmentShader:$c.distanceRGBA_frag},shadow:{uniforms:Nr([td.lights,td.fog,{color:{value:new Jn(0)},opacity:{value:1}}]),vertexShader:$c.shadow_vert,fragmentShader:$c.shadow_frag}};ed.physical={uniforms:Nr([ed.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ri},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ri},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ri},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ri},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ri},sheen:{value:0},sheenColor:{value:new Jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ri},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ri},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ri},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ri},attenuationDistance:{value:0},attenuationColor:{value:new Jn(0)},specularColor:{value:new Jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ri},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ri},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ri}}]),vertexShader:$c.meshphysical_vert,fragmentShader:$c.meshphysical_frag};const id={r:0,b:0,g:0},nd=new fn,rd=new sn;function sd(t,e,i,n,r,s,a){const o=new Jn(0);let h,l,c=!0===s?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(id,Ur(t)),n.buffers.color.setClear(id.r,id.g,id.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const r=m(e);null===r?f(o,c):r&&r.isColor&&(f(r,1),i=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===rt)?(void 0===l&&(l=new Lr(new Dr(1,1,1),new zr({name:"BackgroundCubeMaterial",uniforms:Or(ed.backgroundCube.uniforms),vertexShader:ed.backgroundCube.vertexShader,fragmentShader:ed.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),nd.copy(i.backgroundRotation),nd.x*=-1,nd.y*=-1,nd.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(nd.y*=-1,nd.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(rd.makeRotationFromEuler(nd)),l.material.toneMapped=fi.getTransfer(n.colorSpace)!==Ae,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Lr(new lh(2,2),new zr({name:"BackgroundMaterial",uniforms:Or(ed.background.uniforms),vertexShader:ed.background.vertexShader,fragmentShader:ed.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=fi.getTransfer(n.colorSpace)!==Ae,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function ad(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=l(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function f(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,h,f,g){let v=!1;const y=function(e,i,r){const s=!0===r.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[s];void 0===h&&(h=l(t.createVertexArray()),o[s]=h);return h}(f,h,r);s!==y&&(s=y,o(s.object)),v=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,f,h,g),v&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===yt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,h*p,(g+a/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)h(r[t].object),delete r[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function od(t,e,i){let n;function r(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))}this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];i.update(e,n,1)}}}function hd(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=!0===i.logarithmicDepthBuffer,l=!0===i.reversedDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===Rt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===wt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==mt&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==xt&&!r)},precision:a,logarithmicDepthBuffer:h,reversedDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function ld(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Zs,o=new ri,h={value:null,needsUpdate:!1};function l(t,i,n,r){const s=null!==t?t.length:0;let l=null;if(0!==s){if(l=h.value,!0!==r||null===l){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;h.value=r,r=l(d,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function cd(t){let e=new WeakMap;function i(t,e){return e===it?t.mapping=tt:e===nt&&(t.mapping=et),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===it||s===nt){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Yr(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const dd=[.125,.215,.35,.446,.526,.582],ud=20,pd=new xl,md=new Jn;let fd=null,gd=0,vd=0,yd=!1;const _d=(1+Math.sqrt(5))/2,xd=1/_d,wd=[new ei(-_d,xd,0),new ei(_d,xd,0),new ei(-xd,0,_d),new ei(xd,0,_d),new ei(0,_d,-xd),new ei(0,_d,xd),new ei(-1,1,-1),new ei(1,1,-1),new ei(-1,1,1),new ei(1,1,1)],bd=new ei;class Sd{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100,r={}){const{size:s=256,position:a=bd}=r;fd=this._renderer.getRenderTarget(),gd=this._renderer.getActiveCubeFace(),vd=this._renderer.getActiveMipmapLevel(),yd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ad(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Td(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(fd,gd,vd),this._renderer.xr.enabled=yd,t.scissorTest=!1,Ed(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===tt||t.mapping===et?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),fd=this._renderer.getRenderTarget(),gd=this._renderer.getActiveCubeFace(),vd=this._renderer.getActiveMipmapLevel(),yd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:dt,minFilter:dt,generateMipmaps:!1,type:wt,format:Rt,colorSpace:Ee,depthBuffer:!1},n=Md(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Md(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+dd.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);i.push(s);let o=1/s;a>t-4?o=dd[a-t+4-1]:0===a&&(o=0),n.push(o);const h=1/(s-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),y=new Float32Array(f*p*u),_=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),y.set(d,f*p*t);const r=[t,t,t,t,t,t];_.set(r,g*p*t)}const x=new _r;x.setAttribute("position",new hr(v,m)),x.setAttribute("uv",new hr(y,f)),x.setAttribute("faceIndex",new hr(_,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(ud),r=new ei(0,1,0),s=new zr({name:"SphericalGaussianBlur",defines:{n:ud,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Cd(),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 <cube_uv_reflection_fragment>\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:0,depthTest:!1,depthWrite:!1});return s}(n,t,e)}return n}_compileMaterial(t){const e=new Lr(this._lodPlanes[0],t);this._renderer.compile(e,pd)}_sceneToCubeUV(t,e,i,n,r){const s=new Vr(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],h=this._renderer,l=h.autoClear,c=h.toneMapping;h.getClearColor(md),h.toneMapping=0,h.autoClear=!1;h.state.buffers.depth.getReversed()&&(h.setRenderTarget(n),h.clearDepth(),h.setRenderTarget(null));const d=new er({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Lr(new Dr,d);let p=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,p=!0):(d.color.copy(md),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[e],r.y,r.z)):1===i?(s.up.set(0,0,a[e]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[e],r.z)):(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[e]));const l=this._cubeSize;Ed(n,i*l,e>2?l:0,l,l),h.setRenderTarget(n),p&&h.render(u,s),h.render(t,s)}u.geometry.dispose(),u.material.dispose(),h.toneMapping=c,h.autoClear=l,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===tt||t.mapping===et;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ad()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Td());const r=n?this._cubemapMaterial:this._equirectMaterial,s=new Lr(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;Ed(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,pd)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodPlanes.length;for(let e=1;e<n;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=wd[(n-e-1)%wd.length];this._blur(t,e-1,e,i,r)}e.autoClear=i}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new Lr(this._lodPlanes[n],h),c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):ud;m>ud&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<ud;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const y=this._sizeLods[n];Ed(e,3*y*(n>v-4?n-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(e),o.render(l,pd)}}function Md(t,e,i){const n=new Ci(t,e,i);return n.texture.mapping=rt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ed(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function Td(){return new zr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cd(),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 <common>\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:0,depthTest:!1,depthWrite:!1})}function Ad(){return new zr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cd(),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:0,depthTest:!1,depthWrite:!1})}function Cd(){return"\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"}function Rd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===it||s===nt,o=s===tt||s===et;if(a||o){let s=e.get(r);const h=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==h)return null===i&&(i=new Sd(t)),s=a?i.fromEquirectangular(r,s):i.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const h=r.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new Sd(t)),s=a?i.fromEquirectangular(r):i.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",n),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Pd(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&ui("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ld(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(e.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}}const o=new(ai(i)?cr:lr)(i,1);o.version=a;const h=s.get(t);h&&e.remove(h),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function Id(t,e,i){let n,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,r,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function Dd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Od(t,e,i){const n=new WeakMap,r=new Ti;return{update:function(s,a,o){const h=s.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let y=0;!0===u&&(y=1),!0===p&&(y=2),!0===m&&(y=3);let _=a.attributes.position.count*y,x=1;_>e.maxTextureSize&&(x=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const w=new Float32Array(_*x*4*c),b=new Ri(w,_,x,c);b.type=xt,b.needsUpdate=!0;const S=4*y;for(let E=0;E<c;E++){const T=f[E],A=g[E],C=v[E],R=_*x*4*E;for(let P=0;P<T.count;P++){const L=P*S;!0===u&&(r.fromBufferAttribute(T,P),w[R+L+0]=r.x,w[R+L+1]=r.y,w[R+L+2]=r.z,w[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),w[R+L+4]=r.x,w[R+L+5]=r.y,w[R+L+6]=r.z,w[R+L+7]=0),!0===m&&(r.fromBufferAttribute(C,P),w[R+L+8]=r.x,w[R+L+9]=r.y,w[R+L+10]=r.z,w[R+L+11]=4===C.itemSize?r.w:1)}}function M(){b.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:b,size:new $e(_,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let I=0;for(let O=0;O<h.length;O++)I+=h[O];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Nd(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(r.get(l)!==o&&(e.update(l),r.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return l},dispose:function(){r=new WeakMap}}}const Ud=new Ei,Fd=new ja(1,1),zd=new Ri,kd=new Pi,Bd=new Xr,Gd=[],Hd=[],Vd=new Float32Array(16),Wd=new Float32Array(9),jd=new Float32Array(4);function Xd(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=Gd[r];if(void 0===s&&(s=new Float32Array(r),Gd[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Yd(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function qd(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Zd(t,e){let i=Hd[e];void 0===i&&(i=new Int32Array(e),Hd[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Kd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Jd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2fv(this.addr,e),qd(i,e)}}function Qd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Yd(i,e))return;t.uniform3fv(this.addr,e),qd(i,e)}}function $d(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4fv(this.addr,e),qd(i,e)}}function tu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;jd.set(n),t.uniformMatrix2fv(this.addr,!1,jd),qd(i,n)}}function eu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;Wd.set(n),t.uniformMatrix3fv(this.addr,!1,Wd),qd(i,n)}}function iu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;Vd.set(n),t.uniformMatrix4fv(this.addr,!1,Vd),qd(i,n)}}function nu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function ru(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2iv(this.addr,e),qd(i,e)}}function su(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Yd(i,e))return;t.uniform3iv(this.addr,e),qd(i,e)}}function au(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4iv(this.addr,e),qd(i,e)}}function ou(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function hu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2uiv(this.addr,e),qd(i,e)}}function lu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Yd(i,e))return;t.uniform3uiv(this.addr,e),qd(i,e)}}function cu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4uiv(this.addr,e),qd(i,e)}}function du(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Fd.compareFunction=515,s=Fd):s=Ud,i.setTexture2D(e||s,r)}function uu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||kd,r)}function pu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Bd,r)}function mu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||zd,r)}function fu(t,e){t.uniform1fv(this.addr,e)}function gu(t,e){const i=Xd(e,this.size,2);t.uniform2fv(this.addr,i)}function vu(t,e){const i=Xd(e,this.size,3);t.uniform3fv(this.addr,i)}function yu(t,e){const i=Xd(e,this.size,4);t.uniform4fv(this.addr,i)}function _u(t,e){const i=Xd(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function xu(t,e){const i=Xd(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function wu(t,e){const i=Xd(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function bu(t,e){t.uniform1iv(this.addr,e)}function Su(t,e){t.uniform2iv(this.addr,e)}function Mu(t,e){t.uniform3iv(this.addr,e)}function Eu(t,e){t.uniform4iv(this.addr,e)}function Tu(t,e){t.uniform1uiv(this.addr,e)}function Au(t,e){t.uniform2uiv(this.addr,e)}function Cu(t,e){t.uniform3uiv(this.addr,e)}function Ru(t,e){t.uniform4uiv(this.addr,e)}function Pu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||Ud,s[t])}function Lu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||kd,s[t])}function Iu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Bd,s[t])}function Du(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||zd,s[t])}class Ou{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Kd;case 35664:return Jd;case 35665:return Qd;case 35666:return $d;case 35674:return tu;case 35675:return eu;case 35676:return iu;case 5124:case 35670:return nu;case 35667:case 35671:return ru;case 35668:case 35672:return su;case 35669:case 35673:return au;case 5125:return ou;case 36294:return hu;case 36295:return lu;case 36296:return cu;case 35678:case 36198:case 36298:case 36306:case 35682:return du;case 35679:case 36299:case 36307:return uu;case 35680:case 36300:case 36308:case 36293:return pu;case 36289:case 36303:case 36311:case 36292:return mu}}(e.type)}}class Nu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return fu;case 35664:return gu;case 35665:return vu;case 35666:return yu;case 35674:return _u;case 35675:return xu;case 35676:return wu;case 5124:case 35670:return bu;case 35667:case 35671:return Su;case 35668:case 35672:return Mu;case 35669:case 35673:return Eu;case 5125:return Tu;case 36294:return Au;case 36295:return Cu;case 36296:return Ru;case 35678:case 36198:case 36298:case 36306:case 35682:return Pu;case 35679:case 36299:case 36307:return Lu;case 35680:case 36300:case 36308:case 36293:return Iu;case 36289:case 36303:case 36311:case 36292:return Du}}(e.type)}}class Uu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const Fu=/(\w+)(\])?(\[|\.)?/g;function zu(t,e){t.seq.push(e),t.map[e.id]=e}function ku(t,e,i){const n=t.name,r=n.length;for(Fu.lastIndex=0;;){const s=Fu.exec(n),a=Fu.lastIndex;let o=s[1];const h="]"===s[2],l=s[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===r){zu(i,void 0===l?new Ou(o,t,e):new Nu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new Uu(o),zu(i,t)),i=t}}}class Bu{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);ku(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Gu(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Hu=0;const Vu=new ri;function Wu(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function ju(t,e){const i=function(t){fi._getMatrix(Vu,fi.workingColorSpace,t);const e=`mat3( ${Vu.elements.map(t=>t.toFixed(4))} )`;switch(fi.getTransfer(t)){case Te:return[e,"LinearTransferOETF"];case Ae:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}function Xu(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Cineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 7:i="Neutral";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const Yu=new ei;function qu(){fi.getLuminanceCoefficients(Yu);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Yu.x.toFixed(4)}, ${Yu.y.toFixed(4)}, ${Yu.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Zu(t){return""!==t}function Ku(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ju(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Qu=/^[ \t]*#include +<([\w\d./]+)>/gm;function $u(t){return t.replace(Qu,ep)}const tp=new Map;function ep(t,e){let i=$c[e];if(void 0===i){const t=tp.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=$c[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return $u(i)}const ip=/#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 np(t){return t.replace(ip,rp)}function rp(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function sp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function ap(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case tt:case et:e="ENVMAP_TYPE_CUBE";break;case rt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===et&&(e="ENVMAP_MODE_REFRACTION");return e}(i),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zu).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),f=r.createProgram();let g,v,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Zu).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Zu).join("\n"),v.length>0&&(v+="\n")):(g=[sp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.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(Zu).join("\n"),v=[sp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?$c.tonemapping_pars_fragment:"",0!==i.toneMapping?Xu("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",$c.colorspace_pars_fragment,ju("linearToOutputTexel",i.outputColorSpace),qu(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Zu).join("\n")),a=$u(a),a=Ku(a,i),a=Ju(a,i),o=$u(o),o=Ku(o,i),o=Ju(o,i),a=np(a),o=np(o),!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ze?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ze?"":"#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"+v);const _=y+g+a,x=y+v+o,w=Gu(r,r.VERTEX_SHADER,_),b=Gu(r,r.FRAGMENT_SHADER,x);function S(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(f)||"",n=r.getShaderInfoLog(w)||"",s=r.getShaderInfoLog(b)||"",a=i.trim(),o=n.trim(),h=s.trim();let l=!0,c=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(l=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,w,b);else{const t=Wu(r,w,"vertex"),i=Wu(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?console.warn("THREE.WebGLProgram: Program Info Log:",a):""!==o&&""!==h||(c=!1);c&&(e.diagnostics={runnable:l,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:h,prefix:v}})}r.deleteShader(w),r.deleteShader(b),M=new Bu(r,f),E=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,f)}let M,E;r.attachShader(f,w),r.attachShader(f,b),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===M&&S(this),M},this.getAttributes=function(){return void 0===E&&S(this),E};let T=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===T&&(T=r.getProgramParameter(f,37297)),T},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Hu++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=w,this.fragmentShader=b,this}let op=0;class hp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new lp(t),e.set(t,i)),i}}class lp{constructor(t){this.id=op++,this.code=t,this.usedTimes=0}}function cp(t,e,i,n,r,s,a){const o=new gn,h=new hp,l=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,v){const y=g.fog,_=v.geometry,x=s.isMeshStandardMaterial?g.environment:null,w=(s.isMeshStandardMaterial?i:e).get(s.envMap||x),b=w&&w.mapping===rt?w.image.height:null,S=m[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const M=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,E=void 0!==M?M.length:0;let T,A,C,R,P=0;if(void 0!==_.morphAttributes.position&&(P=1),void 0!==_.morphAttributes.normal&&(P=2),void 0!==_.morphAttributes.color&&(P=3),S){const t=ed[S];T=t.vertexShader,A=t.fragmentShader}else T=s.vertexShader,A=s.fragmentShader,h.update(s),C=h.getVertexShaderID(s),R=h.getFragmentShaderID(s);const L=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),D=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,N=!!s.map,U=!!s.matcap,F=!!w,z=!!s.aoMap,k=!!s.lightMap,B=!!s.bumpMap,G=!!s.normalMap,H=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,j=!!s.roughnessMap,X=s.anisotropy>0,Y=s.clearcoat>0,q=s.dispersion>0,Z=s.iridescence>0,K=s.sheen>0,J=s.transmission>0,Q=X&&!!s.anisotropyMap,$=Y&&!!s.clearcoatMap,tt=Y&&!!s.clearcoatNormalMap,et=Y&&!!s.clearcoatRoughnessMap,it=Z&&!!s.iridescenceMap,nt=Z&&!!s.iridescenceThicknessMap,st=K&&!!s.sheenColorMap,at=K&&!!s.sheenRoughnessMap,ot=!!s.specularMap,ht=!!s.specularColorMap,lt=!!s.specularIntensityMap,ct=J&&!!s.transmissionMap,dt=J&&!!s.thicknessMap,ut=!!s.gradientMap,pt=!!s.alphaMap,mt=s.alphaTest>0,ft=!!s.alphaHash,gt=!!s.extensions;let vt=0;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping));const yt={shaderID:S,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:A,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:D,instancingColor:D&&null!==v.instanceColor,instancingMorph:D&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ee,alphaToCoverage:!!s.alphaToCoverage,map:N,matcap:U,envMap:F,envMapMode:F&&w.mapping,envMapCubeUVHeight:b,aoMap:z,lightMap:k,bumpMap:B,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:Q,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:Z,iridescenceMap:it,iridescenceThicknessMap:nt,sheen:K,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:ht,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:dt,gradientMap:ut,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:s.combine,mapUv:N&&f(s.map.channel),aoMapUv:z&&f(s.aoMap.channel),lightMapUv:k&&f(s.lightMap.channel),bumpMapUv:B&&f(s.bumpMap.channel),normalMapUv:G&&f(s.normalMap.channel),displacementMapUv:H&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:W&&f(s.metalnessMap.channel),roughnessMapUv:j&&f(s.roughnessMap.channel),anisotropyMapUv:Q&&f(s.anisotropyMap.channel),clearcoatMapUv:$&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:nt&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&f(s.sheenRoughnessMap.channel),specularMapUv:ot&&f(s.specularMap.channel),specularColorMapUv:ht&&f(s.specularColorMap.channel),specularIntensityMapUv:lt&&f(s.specularIntensityMap.channel),transmissionMapUv:ct&&f(s.transmissionMap.channel),thicknessMapUv:dt&&f(s.thicknessMap.channel),alphaMapUv:pt&&f(s.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(G||X),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!_.attributes.uv&&(N||pt),fog:!!y,useFog:!0===s.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===s.flatShading&&!1===s.wireframe,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:E,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,decodeVideoTexture:N&&!0===s.map.isVideoTexture&&fi.getTransfer(s.map.colorSpace)===Ae,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&fi.getTransfer(s.emissiveMap.colorSpace)===Ae,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:gt&&!0===s.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===s.extensions.multiDraw||O)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return yt.vertexUv1s=l.has(1),yt.vertexUv2s=l.has(2),yt.vertexUv3s=l.has(3),l.clear(),yt},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&o.enable(21);e.gradientMap&&o.enable(22);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reversedDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=ed[e];i=Fr.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new ap(t,i,e,s),c.push(n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function dp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function up(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function pp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function mp(){const t=[];let e=0;const i=[],n=[],r=[];function s(i,n,r,s,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,groupOrder:s,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?r.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||up),n.length>1&&n.sort(e||pp),r.length>1&&r.sort(e||pp)}}}function fp(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new mp,t.set(e,[r])):i>=n.length?(r=new mp,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function gp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new ei,color:new Jn};break;case"SpotLight":i={position:new ei,direction:new ei,color:new Jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ei,color:new Jn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ei,skyColor:new Jn,groundColor:new Jn};break;case"RectAreaLight":i={color:new Jn,position:new ei,halfWidth:new ei,halfHeight:new ei}}return t[e.id]=i,i}}}let vp=0;function yp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function _p(t){const e=new gp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)n.probe.push(new ei);const r=new ei,s=new sn,a=new sn;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,y=0;r.sort(yp);for(let t=0,_=r.length;t<_;t++){const _=r[t],x=_.color,w=_.intensity,b=_.distance,S=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)s+=x.r*w,a+=x.g*w,o+=x.b*w;else if(_.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(_.sh.coefficients[t],w);y++}else if(_.isDirectionalLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){const t=_.shadow,e=i.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=S,n.directionalShadowMatrix[h]=_.shadow.matrix,p++}n.directional[h]=t,h++}else if(_.isSpotLight){const t=e.get(_);t.position.setFromMatrixPosition(_.matrixWorld),t.color.copy(x).multiplyScalar(w),t.distance=b,t.coneCos=Math.cos(_.angle),t.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),t.decay=_.decay,n.spot[c]=t;const r=_.shadow;if(_.map&&(n.spotLightMap[g]=_.map,g++,r.updateMatrices(_),_.castShadow&&v++),n.spotLightMatrix[c]=r.matrix,_.castShadow){const t=i.get(_);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=S,f++}c++}else if(_.isRectAreaLight){const t=e.get(_);t.color.copy(x).multiplyScalar(w),t.halfWidth.set(.5*_.width,0,0),t.halfHeight.set(0,.5*_.height,0),n.rectArea[d]=t,d++}else if(_.isPointLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),t.distance=_.distance,t.decay=_.decay,_.castShadow){const t=_.shadow,e=i.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=S,n.pointShadowMatrix[l]=_.shadow.matrix,m++}n.point[l]=t,l++}else if(_.isHemisphereLight){const t=e.get(_);t.skyColor.copy(_.color).multiplyScalar(w),t.groundColor.copy(_.groundColor).multiplyScalar(w),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=td.LTC_FLOAT_1,n.rectAreaLTC2=td.LTC_FLOAT_2):(n.rectAreaLTC1=td.LTC_HALF_1,n.rectAreaLTC2=td.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const _=n.hash;_.directionalLength===h&&_.pointLength===l&&_.spotLength===c&&_.rectAreaLength===d&&_.hemiLength===u&&_.numDirectionalShadows===p&&_.numPointShadows===m&&_.numSpotShadows===f&&_.numSpotMaps===g&&_.numLightProbes===y||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=y,_.directionalLength=h,_.pointLength=l,_.spotLength=c,_.rectAreaLength=d,_.hemiLength=u,_.numDirectionalShadows=p,_.numPointShadows=m,_.numSpotShadows=f,_.numSpotMaps=g,_.numLightProbes=y,n.version=vp++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function xp(t){const e=new _p(t),i=[],n=[];const r={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,i.length=0,n.length=0},state:r,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function wp(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new xp(t),e.set(i,[s])):n>=r.length?(s=new xp(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}function bp(t,e,i){let n=new $s;const r=new $e,s=new $e,a=new Ti,o=new Ch({depthPacking:3201}),h=new Rh,l={},c=i.maxTextureSize,d={[b]:1,[S]:0,[M]:2},u=new zr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},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;\n#include <packing>\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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new _r;m.setAttribute("position",new hr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Lr(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(i,n){const s=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Ci(r.x,r.y)),u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,p,f,null)}function _(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=s.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",w)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],s.alphaMap=i.alphaMap,s.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function x(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=_(i,d,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(h.visible){const e=_(i,h,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],r,s,a,o)}function w(t){t.target.removeEventListener("dispose",w);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=3!==v&&3===this.type,m=3===v&&3!==this.type;for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const f=d.getFrameExtents();if(r.multiply(f),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/f.x),r.x=s.x*f.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/f.y),r.y=s.y*f.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ht,magFilter:ht}:{};null!==d.map&&d.map.dispose(),d.map=new Ci(r.x,r.y,t),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(l,t),n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&y(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const Sp={[V]:1,[j]:6,[Y]:7,[X]:5,[W]:0,[Z]:2,[K]:4,[q]:3};function Mp(t,e){const i=new function(){let e=!1;const i=new Ti;let n=null;const r=new Ti(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const r=a;a=null,this.setClear(r)}},getReversed:function(){return n},setTest:function(e){e?rt(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=Sp[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?rt(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null}}},s=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,y=null,_=null,x=new Jn(0,0,0),w=0,b=!1,S=null,M=null,V=null,W=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new Ti).fromArray(Q),et=(new Ti).fromArray($);function it(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const nt={};function rt(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function st(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),rt(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),rt(t.CULL_FACE),ht(0);const at={[E]:t.FUNC_ADD,[T]:t.FUNC_SUBTRACT,[A]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[C]:t.ZERO,[R]:t.ONE,[P]:t.SRC_COLOR,[I]:t.SRC_ALPHA,[z]:t.SRC_ALPHA_SATURATE,[U]:t.DST_COLOR,[O]:t.DST_ALPHA,[L]:t.ONE_MINUS_SRC_COLOR,[D]:t.ONE_MINUS_SRC_ALPHA,[F]:t.ONE_MINUS_DST_COLOR,[N]:t.ONE_MINUS_DST_ALPHA,[k]:t.CONSTANT_COLOR,[B]:t.ONE_MINUS_CONSTANT_COLOR,[G]:t.CONSTANT_ALPHA,[H]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,h,l,c){if(0!==e){if(!1===u&&(rt(t.BLEND),u=!0),5===e)s=s||i,a=a||n,o=o||r,i===m&&s===v||(t.blendEquationSeparate(at[i],at[s]),m=i,v=s),n===f&&r===g&&a===y&&o===_||(t.blendFuncSeparate(ot[n],ot[r],ot[a],ot[o]),f=n,g=r,y=a,_=o),!1!==h.equals(x)&&l===w||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),w=l),p=e,b=!1;else if(e!==p||c!==b){if(m===E&&v===E||(t.blendEquation(t.FUNC_ADD),m=E,v=E),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,g=null,y=null,_=null,x.set(0,0,0),w=0,p=e,b=c}}else!0===u&&(st(t.BLEND),u=!1)}function lt(e){S!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),S=e)}function ct(e){0!==e?(rt(t.CULL_FACE),e!==M&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),M=e}function dt(e,i,n){e?(rt(t.POLYGON_OFFSET_FILL),W===i&&j===n||(t.polygonOffset(i,n),W=i,j=n)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:rt,disable:st,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,r=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?st(t.CULL_FACE):rt(t.CULL_FACE);let a=1===e.side;s&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?rt(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==V&&(Y&&t.lineWidth(e),V=e)},setPolygonOffset:dt,setScissorTest:function(e){e?rt(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),K!==e&&(t.activeTexture(e),K=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===K?t.TEXTURE0+X-1:K);let r=J[n];void 0===r&&(r={type:void 0,texture:void 0},J[n]=r),r.type===e&&r.texture===i||(K!==n&&(t.activeTexture(n),K=n),t.bindTexture(e,i||nt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=J[K];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},K=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,y=null,_=null,x=new Jn(0,0,0),w=0,b=!1,S=null,M=null,V=null,W=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function Ep(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new $e,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):li("canvas")}function f(t,e,i){let n=1;const r=V(t);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=m(i,s));const a=e?m(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function y(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function _(i,n,r,s,a=!1){if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),n===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),n===t.RGB&&(r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),n===t.RGBA){const e=a?Te:fi.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ae?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===_t||i===Mt?n=t.DEPTH24_STENCIL8:i===xt?n=t.DEPTH32F_STENCIL8:i===vt&&(n=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===_t||i===Mt?n=t.DEPTH_COMPONENT24:i===xt?n=t.DEPTH_COMPONENT32F:i===vt&&(n=t.DEPTH_COMPONENT16),n}function w(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==ht&&t.minFilter!==dt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=u.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(r).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete u.get(r)[i.__cacheKey],a.memory.textures--}let E=0;function T(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[st]:t.REPEAT,[at]:t.CLAMP_TO_EDGE,[ot]:t.MIRRORED_REPEAT},C={[ht]:t.NEAREST,[lt]:t.NEAREST_MIPMAP_NEAREST,[ct]:t.NEAREST_MIPMAP_LINEAR,[dt]:t.LINEAR,[ut]:t.LINEAR_MIPMAP_NEAREST,[pt]:t.LINEAR_MIPMAP_LINEAR},R={[Re]:t.NEVER,[Ue]:t.ALWAYS,[Pe]:t.LESS,[Ie]:t.LEQUAL,[Le]:t.EQUAL,[Ne]:t.GEQUAL,[De]:t.GREATER,[Oe]:t.NOTEQUAL};function P(i,s){if(s.type!==xt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==dt&&s.magFilter!==ut&&s.magFilter!==ct&&s.magFilter!==pt&&s.minFilter!==dt&&s.minFilter!==ut&&s.minFilter!==ct&&s.minFilter!==pt||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===ht)return;if(s.minFilter!==ct&&s.minFilter!==pt)return;if(s.type===xt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b));const r=i.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function I(t,e,i){return Math.floor(Math.floor(t/i)/e)}function D(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=L(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),n=a.colorSpace===Se?null:fi.getPrimaries(a.colorSpace),u=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,r.maxTextureSize);p=H(a,p);const m=s.convert(a.format,a.colorSpace),y=s.convert(a.type);let b,S=_(a.internalFormat,m,y,a.colorSpace,a.isVideoTexture);P(h,a);const M=a.mipmaps,E=!0!==a.isVideoTexture,T=void 0===d.__version||!0===l,A=c.dataReady,C=w(a,p);if(a.isDepthTexture)S=x(a.format===Lt,a.type),T&&(E?i.texStorage2D(t.TEXTURE_2D,1,S,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,y,null));else if(a.isDataTexture)if(M.length>0){E&&T&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)b=M[e],E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,y,b.data):i.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,m,y,b.data);a.generateMipmaps=!1}else E?(T&&i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height),A&&function(e,n,r,s){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,r,s,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],r=e.start+e.count,s=I(i.start,n.width,4),h=I(e.start,n.width,4);i.start<=r+1&&s===h&&I(i.start+i.count-1,n.width,4)===s?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const h=t.getParameter(t.UNPACK_ROW_LENGTH),l=t.getParameter(t.UNPACK_SKIP_PIXELS),c=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],h=Math.floor(o.start/4),l=Math.ceil(o.count/4),c=h%n.width,d=Math.floor(h/n.width),u=l,p=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,c),t.pixelStorei(t.UNPACK_SKIP_ROWS,d),i.texSubImage2D(t.TEXTURE_2D,0,c,d,u,p,r,s,n.data)}e.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,h),t.pixelStorei(t.UNPACK_SKIP_PIXELS,l),t.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,p,m,y)):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,y,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){E&&T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(b=M[e],a.format!==Rt)if(null!==m)if(E){if(A)if(a.layerUpdates.size>0){const n=Kc(b.width,b.height,a.format,a.type);for(const r of a.layerUpdates){const s=b.data.subarray(r*n/b.data.BYTES_PER_ELEMENT,(r+1)*n/b.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,b.width,b.height,1,m,s)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,b.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,y,b.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,m,y,b.data)}else{E&&T&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)b=M[e],a.format!==Rt?null!==m?E?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,b.data):i.compressedTexImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,y,b.data):i.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,m,y,b.data)}else if(a.isDataArrayTexture)if(E){if(T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Kc(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const r=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,y,r)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,y,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,S,p.width,p.height,p.depth,0,m,y,p.data);else if(a.isData3DTexture)E?(T&&i.texStorage3D(t.TEXTURE_3D,C,S,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,y,p.data)):i.texImage3D(t.TEXTURE_3D,0,S,p.width,p.height,p.depth,0,m,y,p.data);else if(a.isFramebufferTexture){if(T)if(E)i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height);else{let e=p.width,n=p.height;for(let r=0;r<C;r++)i.texImage2D(t.TEXTURE_2D,r,S,e,n,0,m,y,null),e>>=1,n>>=1}}else if(M.length>0){if(E&&T){const e=V(M[0]);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)b=M[e],E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,y,b):i.texImage2D(t.TEXTURE_2D,e,S,m,y,b);a.generateMipmaps=!1}else if(E){if(T){const e=V(p);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,y,p)}else i.texImage2D(t.TEXTURE_2D,0,S,m,y,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function O(e,r,a,h,l,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=_(a.internalFormat,d,u,a.colorSpace),m=n.get(r),f=n.get(a);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>c),n=Math.max(1,r.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,r.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,B(r)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(i.stencilBuffer,s),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,l=B(i);G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,l,a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,l,a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r<e.length;r++){const a=e[r],h=s.convert(a.format,a.colorSpace),l=s.convert(a.type),c=_(a.internalFormat,h,l,a.colorSpace),d=B(i);n&&!1===G(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,i.width,i.height):G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=n.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const a=s.__webglTexture,h=B(r);if(r.depthTexture.format===Pt)G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Lt)throw new Error("Unknown depthTexture format");G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}function F(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");const t=e.texture.mipmaps;t&&t.length>0?U(r.__webglFramebuffer[0],e):U(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),N(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),N(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const z=[],k=[];function B(t){return Math.min(r.maxSamples,t.samples)}function G(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Ee&&i!==Se&&(fi.getTransfer(i)===Ae?n===Rt&&r===mt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),e}function V(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=T,this.setTexture2DArray=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=L(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),n=a.colorSpace===Se?null:fi.getPrimaries(a.colorSpace),d=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,r.maxCubemapSize),m[t]=H(a,m[t]);const y=m[0],x=s.convert(a.format,a.colorSpace),b=s.convert(a.type),S=_(a.internalFormat,x,b,a.colorSpace),M=!0!==a.isVideoTexture,E=void 0===c.__version||!0===h,T=l.dataReady;let A,C=w(a,y);if(P(t.TEXTURE_CUBE_MAP,a),u){M&&E&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,y.width,y.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const r=A[n];a.format!==Rt?null!==x?M?T&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,x,b,r.data)}}}else{if(A=a.mipmaps,M&&E){A.length>0&&C++;const e=V(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,b,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,m[e].width,m[e].height,0,x,b,m[e].data);for(let n=0;n<A.length;n++){const r=A[n].image[e].image;M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,x,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,r.width,r.height,0,x,b,r.data)}}else{M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,b,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,x,b,m[e]);for(let n=0;n<A.length;n++){const r=A[n];M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,b,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,x,b,r.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&O(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&F(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),h=n.get(r);e.addEventListener("dispose",S);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),h=_(n.internalFormat,r,a,n.colorSpace,!0===e.isXRRenderTarget),c=B(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(r)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let r=0,s=l.length;r<s;r++){const s=l[r],a=n.get(s);let h=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(h=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(h,a.__webglTexture),P(h,s),O(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,h,0),g(s)&&v(h)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),P(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);g(r)&&v(n),i.unbindTexture()}e.depthBuffer&&F(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=y(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===G(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===h&&(z.length=0,k.length=0,z.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(z.push(l),k.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,k)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G}function Tp(t,e){return{convert:function(i,n=""){let r;const s=fi.getTransfer(n);if(i===mt)return t.UNSIGNED_BYTE;if(i===bt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===St)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Et)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===Tt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===ft)return t.BYTE;if(i===gt)return t.SHORT;if(i===vt)return t.UNSIGNED_SHORT;if(i===yt)return t.INT;if(i===_t)return t.UNSIGNED_INT;if(i===xt)return t.FLOAT;if(i===wt)return t.HALF_FLOAT;if(i===At)return t.ALPHA;if(i===Ct)return t.RGB;if(i===Rt)return t.RGBA;if(i===Pt)return t.DEPTH_COMPONENT;if(i===Lt)return t.DEPTH_STENCIL;if(i===It)return t.RED;if(i===Dt)return t.RED_INTEGER;if(i===Ot)return t.RG;if(i===Nt)return t.RG_INTEGER;if(i===Ut)return t.RGBA_INTEGER;if(i===Ft||i===zt||i===kt||i===Bt)if(s===Ae){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ft)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ft)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Gt||i===Ht||i===Vt||i===Wt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===jt||i===Xt||i===Yt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===jt||i===Xt)return s===Ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Yt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===qt||i===Zt||i===Kt||i===Jt||i===Qt||i===$t||i===te||i===ee||i===ie||i===ne||i===re||i===se||i===ae||i===oe){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Zt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Kt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===te)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ee)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ie)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ne)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===re)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ae)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===oe)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===he||i===le||i===ce){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===he)return s===Ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===de||i===ue||i===pe||i===me){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===de)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pe)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===me)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Mt?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class Ap{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new Xa(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new zr({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:e.z},depthHeight:{value:e.w}}});this.mesh=new Lr(new lh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Cp extends Ge{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new Ap,g={},v=e.getContextAttributes();let y=null,_=null;const x=[],w=[],b=new $e;let S=null;const M=new Vr;M.viewport=new Ti;const E=new Vr;E.viewport=new Ti;const T=[M,E],A=new Bl;let C=null,R=null;function P(t){const e=w.indexOf(t.inputSource);if(-1===e)return;const i=x[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function L(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",L),n.removeEventListener("inputsourceschange",I);for(let t=0;t<x.length;t++){const e=w[t];null!==e&&(w[t]=null,x[t].disconnect(e))}C=null,R=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(y),u=null,d=null,c=null,n=null,_=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(S),t.setSize(b.width,b.height,!1),i.dispatchEvent({type:"sessionend"})}function I(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=w.indexOf(i);n>=0&&(w[n]=null,x[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=w.indexOf(i);if(-1===n){for(let t=0;t<x.length;t++){if(t>=w.length){w.push(i),n=t;break}if(null===w[t]){w[t]=i,n=t;break}}if(-1===n)break}const r=x[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){y=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",L),n.addEventListener("inputsourceschange",I),!0!==v.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(b);if(m&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;v.depth&&(a=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=v.stencil?Lt:Pt,s=v.stencil?Mt:_t);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=this.getBinding(),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new Ci(d.textureWidth,d.textureHeight,{format:Rt,type:mt,depthTexture:new ja(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),_=new Ci(u.framebufferWidth,u.framebufferHeight,{format:Rt,type:mt,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}_.isXRRenderTarget=!0,this.setFoveation(o),h=null,s=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new ei,O=new ei;function N(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(i=f.depthFar)),A.near=E.near=M.near=e,A.far=E.far=M.far=i,C===A.near&&R===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,M.layers.mask=3&A.layers.mask,E.layers.mask=5&A.layers.mask;const r=t.parent,s=A.cameras;N(A,r);for(let t=0;t<s.length;t++)N(s[t],r);2===s.length?function(t,e,i){D.setFromMatrixPosition(e.matrixWorld),O.setFromMatrixPosition(i.matrixWorld);const n=D.distanceTo(O),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,r=u-f,s=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(r,s,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,M,E):A.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*je*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new Jc;F.setAnimationLoop(function(e,r){if(l=r.getViewerPose(h||s),p=r,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(_,u.framebuffer),t.setRenderTarget(_));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let i=0;i<e.length;i++){const n=e[i];let s=null;if(null!==u)s=u.getViewport(n);else{const e=c.getViewSubImage(d,n);s=e.viewport,0===i&&(t.setRenderTargetTextures(_,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(_))}let a=T[i];void 0===a&&(a=new Vr,a.layers.enable(i),a.viewport=new Ti,T[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(a)}const s=n.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&m){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,n.renderState)}if(s&&s.includes("camera-access")&&m){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new Xa,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=w[t],i=x[t];null!==e&&void 0!==i&&i.update(e,r,h||s)}U&&U(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const Rp=new fn,Pp=new sn;function Lp(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,Rp.copy(a),Rp.x*=-1,Rp.y*=-1,Rp.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(Rp.y*=-1,Rp.z*=-1),t.envMapRotation.value.setFromMatrix4(Pp.makeRotationFromEuler(Rp)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,Ur(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ip(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return n[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=r[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=l(s[t]),a=i%n,o=a%r.boundary,h=a+o;i+=o,0!==h&&n-h<r.storage&&(i+=n-h),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===h(r,e,n,s)){const e=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const a=i[s],o=l(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class Dp{constructor(t={}){const{canvas:e=ci(),context:i=null,depth:n=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:d=!1}=t;let u;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=s;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const v=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const x=this;let w=!1;this._outputColorSpace=Me;let b=0,S=0,M=null,E=-1,T=null;const A=new Ti,C=new Ti;let R=null;const P=new Jn(0);let L=0,I=e.width,D=e.height,O=1,N=null,U=null;const F=new Ti(0,0,I,D),z=new Ti(0,0,I,D);let k=!1;const B=new $s;let G=!1,H=!1;const V=new sn,W=new ei,j=new Ti,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function q(){return null===M?O:1}let Z,K,J,Q,$,tt,et,it,nt,rt,st,at,ot,ht,lt,ct,dt,ut,ft,gt,yt,xt,Et,Tt,At=i;function Ct(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_}`),e.addEventListener("webglcontextlost",Lt,!1),e.addEventListener("webglcontextrestored",It,!1),e.addEventListener("webglcontextcreationerror",Ot,!1),null===At){const e="webgl2";if(At=Ct(e,t),null===At)throw Ct(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Rt(){Z=new Pd(At),Z.init(),xt=new Tp(At,Z),K=new hd(At,Z,t,xt),J=new Mp(At,Z),K.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),Q=new Dd(At),$=new dp,tt=new Ep(At,Z,J,$,K,xt,Q),et=new cd(x),it=new Rd(x),nt=new Qc(At),Et=new ad(At,nt),rt=new Ld(At,nt,Q,Et),st=new Nd(At,rt,nt,Q),ft=new Od(At,K,tt),ct=new ld($),at=new cp(x,et,it,Z,K,Et,ct),ot=new Lp(x,$),ht=new fp,lt=new wp(Z),ut=new sd(x,et,it,J,st,u,o),dt=new bp(x,st,K),Tt=new Ip(At,Q,K,J),gt=new od(At,Z,Q),yt=new Id(At,Z,Q),Q.programs=at.programs,x.capabilities=K,x.extensions=Z,x.properties=$,x.renderLists=ht,x.shadowMap=dt,x.state=J,x.info=Q}Rt();const Pt=new Cp(x,At);function Lt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function It(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;const t=Q.autoReset,e=dt.enabled,i=dt.autoUpdate,n=dt.needsUpdate,r=dt.type;Rt(),Q.autoReset=t,dt.enabled=e,dt.autoUpdate=i,dt.needsUpdate=n,dt.type=r}function Ot(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Ft(t){const e=t.target;e.removeEventListener("dispose",Ft),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach(function(t){at.releaseProgram(t)}),t.isShaderMaterial&&at.releaseShaderCache(t))})(t),$.remove(t)}(e)}function zt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,qt(t,e,i),t.side=0,t.needsUpdate=!0,qt(t,e,i),t.side=2):qt(t,e,i)}this.xr=Pt,this.getContext=function(){return At},this.getContextAttributes=function(){return At.getContextAttributes()},this.forceContextLoss=function(){const t=Z.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Z.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(I,D,!1))},this.getSize=function(t){return t.set(I,D)},this.setSize=function(t,i,n=!0){Pt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(I=t,D=i,e.width=Math.floor(t*O),e.height=Math.floor(i*O),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(I*O,D*O).floor()},this.setDrawingBufferSize=function(t,i,n){I=t,D=i,O=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(F)},this.setViewport=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),J.viewport(A.copy(F).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(z)},this.setScissor=function(t,e,i,n){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,i,n),J.scissor(C.copy(z).multiplyScalar(O).round())},this.getScissorTest=function(){return k},this.setScissorTest=function(t){J.setScissorTest(k=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.copy(ut.getClearColor())},this.setClearColor=function(){ut.setClearColor(...arguments)},this.getClearAlpha=function(){return ut.getClearAlpha()},this.setClearAlpha=function(){ut.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==M){const e=M.texture.format;t=e===Ut||e===Nt||e===Dt}if(t){const t=M.texture.type,e=t===mt||t===_t||t===vt||t===Mt||t===bt||t===St,i=ut.getClearColor(),n=ut.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(p[0]=r,p[1]=s,p[2]=a,p[3]=n,At.clearBufferuiv(At.COLOR,0,p)):(m[0]=r,m[1]=s,m[2]=a,m[3]=n,At.clearBufferiv(At.COLOR,0,m))}else n|=At.COLOR_BUFFER_BIT}e&&(n|=At.DEPTH_BUFFER_BIT),i&&(n|=At.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),At.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Lt,!1),e.removeEventListener("webglcontextrestored",It,!1),e.removeEventListener("webglcontextcreationerror",Ot,!1),ut.dispose(),ht.dispose(),lt.dispose(),$.dispose(),et.dispose(),it.dispose(),st.dispose(),Et.dispose(),Tt.dispose(),at.dispose(),Pt.dispose(),Pt.removeEventListener("sessionstart",Bt),Pt.removeEventListener("sessionend",Gt),Ht.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=X);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=X);tt.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===M?x.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:Ee,h=(n.isMeshStandardMaterial?it:et).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=x.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==f?f.length:0,y=$.get(n),_=g.state.lights;if(!0===G&&(!0===H||t!==T)){const e=t===T&&n.id===E;ct.setState(n,t,e)}let w=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==_.state.version||y.outputColorSpace!==o||r.isBatchedMesh&&!1===y.batching?w=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?w=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?w=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==h||!0===n.fog&&y.fog!==s?w=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ct.numPlanes&&y.numIntersection===ct.numIntersection?(y.vertexAlphas!==l||y.vertexTangents!==c||y.morphTargets!==d||y.morphNormals!==u||y.morphColors!==p||y.toneMapping!==m||y.morphTargetsCount!==v)&&(w=!0):w=!0:w=!0:w=!0:w=!0:(w=!0,y.__version=n.version);let b=y.currentProgram;!0===w&&(b=qt(n,e,r));let S=!1,A=!1,C=!1;const R=b.getUniforms(),P=y.uniforms;J.useProgram(b.program)&&(S=!0,A=!0,C=!0);n.id!==E&&(E=n.id,A=!0);if(S||T!==t){J.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),R.setValue(At,"projectionMatrix",t.projectionMatrix),R.setValue(At,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(At,W.setFromMatrixPosition(t.matrixWorld)),K.logarithmicDepthBuffer&&R.setValue(At,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(At,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,A=!0,C=!0)}if(r.isSkinnedMesh){R.setOptional(At,r,"bindMatrix"),R.setOptional(At,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(At,"boneTexture",t.boneTexture,tt))}r.isBatchedMesh&&(R.setOptional(At,r,"batchingTexture"),R.setValue(At,"batchingTexture",r._matricesTexture,tt),R.setOptional(At,r,"batchingIdTexture"),R.setValue(At,"batchingIdTexture",r._indirectTexture,tt),R.setOptional(At,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(At,"batchingColorTexture",r._colorsTexture,tt));const L=i.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||ft.update(r,i,b);(A||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,R.setValue(At,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=h,P.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);A&&(R.setValue(At,"toneMappingExposure",x.toneMappingExposure),y.needsLights&&(N=C,(I=P).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),s&&!0===n.fog&&ot.refreshFogUniforms(P,s),ot.refreshMaterialUniforms(P,n,O,D,g.state.transmissionRenderTarget[t.id]),Bu.upload(At,Zt(y),P,tt));var I,N;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Bu.upload(At,Zt(y),P,tt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(At,"center",r.center);if(R.setValue(At,"modelViewMatrix",r.modelViewMatrix),R.setValue(At,"normalMatrix",r.normalMatrix),R.setValue(At,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];Tt.update(i,b),Tt.bind(i,b)}}return b}(t,e,i,n,r);J.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=rt.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==s&&(u=Math.max(u,s.start*l),p=Math.min(p,(s.start+s.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Et.setup(r,n,o,i,h);let v=gt;if(null!==h&&(f=nt.get(h),v=yt,v.setIndex(f)),r.isMesh)!0===n.wireframe?(J.setLineWidth(n.wireframeLinewidth*q()),v.setMode(At.LINES)):v.setMode(At.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),J.setLineWidth(t*q()),r.isLineSegments?v.setMode(At.LINES):r.isLineLoop?v.setMode(At.LINE_LOOP):v.setMode(At.LINE_STRIP)}else r.isPoints?v.setMode(At.POINTS):r.isSprite&&v.setMode(At.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)ui("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),v.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))v.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=h?nt.get(h).bytesPerElement:1,a=$.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(At,"_gl_DrawID",n),v.render(t[n]/s,e[n])}else if(r.isInstancedMesh)v.renderInstances(u,m,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);v.renderInstances(u,m,e)}else v.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),g=lt.get(i),g.init(e),y.push(g),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),g.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];zt(s,i,t),n.add(s)}else zt(e,i,t),n.add(e)}),g=y.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){$.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==Z.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let kt=null;function Bt(){Ht.stop()}function Gt(){Ht.start()}const Ht=new Jc;function Vt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||B.intersectsSprite(t)){n&&j.setFromMatrixPosition(t.matrixWorld).applyMatrix4(V);const e=st.update(t),r=t.material;r.visible&&f.push(t,e,r,i,j.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||B.intersectsObject(t))){const e=st.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),j.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),j.copy(e.boundingSphere.center)),j.applyMatrix4(t.matrixWorld).applyMatrix4(V)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&f.push(t,e,o,i,j.z,a)}}else r.visible&&f.push(t,e,r,i,j.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Vt(r[t],e,i,n)}function Wt(t,e,i,n){const r=t.opaque,s=t.transmissive,a=t.transparent;g.setupLightsView(i),!0===G&&ct.setGlobalState(x.clippingPlanes,i),n&&J.viewport(A.copy(n)),r.length>0&&Xt(r,e,i),s.length>0&&Xt(s,e,i),a.length>0&&Xt(a,e,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function jt(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[n.id]&&(g.state.transmissionRenderTarget[n.id]=new Ci(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?wt:mt,minFilter:pt,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fi.workingColorSpace}));const s=g.state.transmissionRenderTarget[n.id],a=n.viewport||A;s.setSize(a.z*x.transmissionResolutionScale,a.w*x.transmissionResolutionScale);const o=x.getRenderTarget(),h=x.getActiveCubeFace(),l=x.getActiveMipmapLevel();x.setRenderTarget(s),x.getClearColor(P),L=x.getClearAlpha(),L<1&&x.setClearColor(16777215,.5),x.clear(),Y&&ut.render(i);const c=x.toneMapping;x.toneMapping=0;const d=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),g.setupLightsView(n),!0===G&&ct.setGlobalState(x.clippingPlanes,n),Xt(t,i,n),tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s),!1===Z.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=s.material,l=s.group;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,Yt(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s))}x.setRenderTarget(o,h,l),x.setClearColor(P,L),void 0!==d&&(n.viewport=d),x.toneMapping=c}function Xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,h=s.group;let l=s.material;!0===l.allowOverride&&null!==n&&(l=n),a.layers.test(i.layers)&&Yt(a,e,i,o,l,h)}}function Yt(t,e,i,n,r,s){t.onBeforeRender(x,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(x,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=2):x.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(x,e,i,n,r,s)}function qt(t,e,i){!0!==e.isScene&&(e=X);const n=$.get(t),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=at.getParameters(t,r.state,s,e,i),h=at.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?it:et).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",Ft),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Kt(t,o),c}else o.uniforms=at.getUniforms(t),t.onBeforeCompile(o,x),c=at.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ct.uniform),Kt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Bu.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Kt(t,e){const i=$.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Ht.setAnimationLoop(function(t){kt&&kt(t)}),"undefined"!=typeof self&&Ht.setContext(self),this.setAnimationLoop=function(t){kt=t,Pt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Pt.addEventListener("sessionstart",Bt),Pt.addEventListener("sessionend",Gt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===w)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Pt.enabled&&!0===Pt.isPresenting&&(!0===Pt.cameraAutoUpdate&&Pt.updateCamera(e),e=Pt.getCamera()),!0===t.isScene&&t.onBeforeRender(x,t,e,M),g=lt.get(t,y.length),g.init(e),y.push(g),V.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),B.setFromProjectionMatrix(V,ke,e.reversedDepth),H=this.localClippingEnabled,G=ct.init(this.clippingPlanes,H),f=ht.get(t,v.length),f.init(),v.push(f),!0===Pt.enabled&&!0===Pt.isPresenting){const t=x.xr.getDepthSensingMesh();null!==t&&Vt(t,e,-1/0,x.sortObjects)}Vt(t,e,0,x.sortObjects),f.finish(),!0===x.sortObjects&&f.sort(N,U),Y=!1===Pt.enabled||!1===Pt.isPresenting||!1===Pt.hasDepthSensing(),Y&&ut.addToRenderList(f,t),this.info.render.frame++,!0===G&&ct.beginShadows();const i=g.state.shadowsArray;dt.render(i,t,e),!0===G&&ct.endShadows(),!0===this.info.autoReset&&this.info.reset();const n=f.opaque,r=f.transmissive;if(g.setupLights(),e.isArrayCamera){const i=e.cameras;if(r.length>0)for(let e=0,s=i.length;e<s;e++){jt(n,r,t,i[e])}Y&&ut.render(t);for(let e=0,n=i.length;e<n;e++){const n=i[e];Wt(f,t,n,n.viewport)}}else r.length>0&&jt(n,r,t,e),Y&&ut.render(t),Wt(f,t,e);null!==M&&0===S&&(tt.updateMultisampleRenderTarget(M),tt.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(x,t,e),Et.resetDefaultState(),E=-1,T=null,y.pop(),y.length>0?(g=y[y.length-1],!0===G&&ct.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,v.pop(),f=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,i){const n=$.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),$.get(t.texture).__webglTexture=e,$.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=$.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const Jt=At.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){M=t,b=e,S=i;let n=!0,r=null,s=!1,a=!1;if(t){const o=$.get(t);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(At.FRAMEBUFFER,null),n=!1;else if(void 0===o.__webglFramebuffer)tt.setupRenderTarget(t);else if(o.__hasExternalTextures)tt.rebindTextures(t,$.get(t.texture).__webglTexture,$.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&$.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(t)}}const h=t.texture;(h.isData3DTexture||h.isDataArrayTexture||h.isCompressedArrayTexture)&&(a=!0);const l=$.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(l[e])?l[e][i]:l[e],s=!0):r=t.samples>0&&!1===tt.useMultisampledRTT(t)?$.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,A.copy(t.viewport),C.copy(t.scissor),R=t.scissorTest}else A.copy(F).multiplyScalar(O).floor(),C.copy(z).multiplyScalar(O).floor(),R=k;0!==i&&(r=Jt);if(J.bindFramebuffer(At.FRAMEBUFFER,r)&&n&&J.drawBuffers(t,r),J.viewport(A),J.scissor(C),J.setScissorTest(R),s){const n=$.get(t.texture);At.framebufferTexture2D(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=e;for(let e=0;e<t.textures.length;e++){const r=$.get(t.textures[e]);At.framebufferTextureLayer(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0+e,r.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=$.get(t.texture);At.framebufferTexture2D(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,e.__webglTexture,i)}E=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){J.bindFramebuffer(At.FRAMEBUFFER,h);try{const a=t.textures[o],h=a.format,l=a.type;if(!K.textureFormatReadable(h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&(t.textures.length>1&&At.readBuffer(At.COLOR_ATTACHMENT0+o),At.readPixels(e,i,n,r,xt.convert(h),xt.convert(l),s))}finally{const t=null!==M?$.get(M).__webglFramebuffer:null;J.bindFramebuffer(At.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){J.bindFramebuffer(At.FRAMEBUFFER,h);const a=t.textures[o],l=a.format,c=a.type;if(!K.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=At.createBuffer();At.bindBuffer(At.PIXEL_PACK_BUFFER,d),At.bufferData(At.PIXEL_PACK_BUFFER,s.byteLength,At.STREAM_READ),t.textures.length>1&&At.readBuffer(At.COLOR_ATTACHMENT0+o),At.readPixels(e,i,n,r,xt.convert(l),xt.convert(c),0);const u=null!==M?$.get(M).__webglFramebuffer:null;J.bindFramebuffer(At.FRAMEBUFFER,u);const p=At.fenceSync(At.SYNC_GPU_COMMANDS_COMPLETE,0);return At.flush(),await function(t,e,i){return new Promise(function(n,r){setTimeout(function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}},i)})}(At,p,4),At.bindBuffer(At.PIXEL_PACK_BUFFER,d),At.getBufferSubData(At.PIXEL_PACK_BUFFER,0,s),At.deleteBuffer(d),At.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;tt.setTexture2D(t,0),At.copyTexSubImage2D(At.TEXTURE_2D,i,0,0,a,o,r,s),J.unbindTexture()};const Qt=At.createFramebuffer(),$t=At.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=null){let a,o,h,l,c,d,u,p,m;null===s&&(0!==r?(ui("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const f=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=xt.convert(e.format),v=xt.convert(e.type);let y;e.isData3DTexture?(tt.setTexture3D(e,0),y=At.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(tt.setTexture2DArray(e,0),y=At.TEXTURE_2D_ARRAY):(tt.setTexture2D(e,0),y=At.TEXTURE_2D),At.pixelStorei(At.UNPACK_FLIP_Y_WEBGL,e.flipY),At.pixelStorei(At.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),At.pixelStorei(At.UNPACK_ALIGNMENT,e.unpackAlignment);const _=At.getParameter(At.UNPACK_ROW_LENGTH),x=At.getParameter(At.UNPACK_IMAGE_HEIGHT),w=At.getParameter(At.UNPACK_SKIP_PIXELS),b=At.getParameter(At.UNPACK_SKIP_ROWS),S=At.getParameter(At.UNPACK_SKIP_IMAGES);At.pixelStorei(At.UNPACK_ROW_LENGTH,f.width),At.pixelStorei(At.UNPACK_IMAGE_HEIGHT,f.height),At.pixelStorei(At.UNPACK_SKIP_PIXELS,l),At.pixelStorei(At.UNPACK_SKIP_ROWS,c),At.pixelStorei(At.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=$.get(t),n=$.get(e),f=$.get(i.__renderTarget),g=$.get(n.__renderTarget);J.bindFramebuffer(At.READ_FRAMEBUFFER,f.__webglFramebuffer),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(At.framebufferTextureLayer(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,$.get(t).__webglTexture,r,d+i),At.framebufferTextureLayer(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,$.get(e).__webglTexture,s,m+i)),At.blitFramebuffer(l,c,a,o,u,p,a,o,At.DEPTH_BUFFER_BIT,At.NEAREST);J.bindFramebuffer(At.READ_FRAMEBUFFER,null),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||$.has(t)){const i=$.get(t),n=$.get(e);J.bindFramebuffer(At.READ_FRAMEBUFFER,Qt),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,$t);for(let t=0;t<h;t++)M?At.framebufferTextureLayer(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,i.__webglTexture,r,d+t):At.framebufferTexture2D(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,i.__webglTexture,r),E?At.framebufferTextureLayer(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,n.__webglTexture,s,m+t):At.framebufferTexture2D(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,n.__webglTexture,s),0!==r?At.blitFramebuffer(l,c,a,o,u,p,a,o,At.COLOR_BUFFER_BIT,At.NEAREST):E?At.copyTexSubImage3D(y,s,u,p,m+t,l,c,a,o):At.copyTexSubImage2D(y,s,u,p,l,c,a,o);J.bindFramebuffer(At.READ_FRAMEBUFFER,null),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,null)}else E?t.isDataTexture||t.isData3DTexture?At.texSubImage3D(y,s,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?At.compressedTexSubImage3D(y,s,u,p,m,a,o,h,g,f.data):At.texSubImage3D(y,s,u,p,m,a,o,h,g,v,f):t.isDataTexture?At.texSubImage2D(At.TEXTURE_2D,s,u,p,a,o,g,v,f.data):t.isCompressedTexture?At.compressedTexSubImage2D(At.TEXTURE_2D,s,u,p,f.width,f.height,g,f.data):At.texSubImage2D(At.TEXTURE_2D,s,u,p,a,o,g,v,f);At.pixelStorei(At.UNPACK_ROW_LENGTH,_),At.pixelStorei(At.UNPACK_IMAGE_HEIGHT,x),At.pixelStorei(At.UNPACK_SKIP_PIXELS,w),At.pixelStorei(At.UNPACK_SKIP_ROWS,b),At.pixelStorei(At.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&At.generateMipmap(y),J.unbindTexture()},this.initRenderTarget=function(t){void 0===$.get(t).__webglFramebuffer&&tt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?tt.setTextureCube(t,0):t.isData3DTexture?tt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?tt.setTexture2DArray(t,0):tt.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){b=0,S=0,M=null,J.reset(),Et.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ke}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=fi._getDrawingBufferColorSpace(t),e.unpackColorSpace=fi._getUnpackColorSpace()}}var Op=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:E,AddOperation:2,AdditiveAnimationBlendMode:be,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:At,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Sl,AnimationAction:cc,AnimationClip:Zh,AnimationLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new nl(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=Zh.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends Ge{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=n[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Ql(lc.create(i,h,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),s[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new kh(new Float32Array(2),new Float32Array(2),1,dc),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?Zh.findByName(n,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:we),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const l=new cc(this,s,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,r),l}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?Zh.findByName(i,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Xe(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new lc(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[u];e[u]=s,void 0===a&&(a=new lc(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,h=e[o];if(void 0!==h&&h>=r){const s=r++,l=t[s];e[l.uuid]=h,t[h]=l,e[o]=s,t[s]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[h];e[h]=n,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<r){const a=--r,o=t[a],l=--s,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],r=e[l];e[h]=n,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=r.length,i[t]=n,s.push(t),a.push(e),r.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new lc(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=i,s[i]=o,s.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:class{static convertArray(t,e){return Ih(t,e)}static isTypedArray(t){return Dh(t)}static getKeyframeOrder(t){return Oh(t)}static sortedArray(t,e,i){return Nh(t,e,i)}static flattenJSON(t,e,i,n){Uh(t,e,i,n)}static subclip(t,e,i,n,r=30){return function(t,e,i,n,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],o=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<i||s>=n)){h.push(e.times[t]);for(let i=0;i<o;++i)l.push(e.values[t*o+i])}}0!==h.length&&(e.times=Ih(h,e.times.constructor),e.values=Ih(l,e.values.constructor),a.push(e))}s.tracks=a;let o=1/0;for(let t=0;t<s.tracks.length;++t)o>s.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*o);return s.resetDuration(),s}(t,e,i,n,r)}static makeClipAdditive(t,e=0,i=t,n=30){return function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,s=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const a=t.tracks.find(function(t){return t.name===n.name&&t.ValueTypeName===r});if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let l=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const d=n.times.length-1;let u;if(s<=n.times[0]){const t=o,e=h-o;u=n.values.slice(t,e)}else if(s>=n.times[d]){const t=d*h+o,e=t+h-o;u=n.values.slice(t,e)}else{const t=n.createInterpolant(),e=o,i=h-o;t.evaluate(s),u=t.resultBuffer.slice(e,i)}"quaternion"===r&&(new ti).fromArray(u).normalize().conjugate().toArray(u);const p=a.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===r)ti.multiplyQuaternionsFlat(a.values,e,u,0,a.values,e);else{const t=c-2*l;for(let i=0;i<t;++i)a.values[e+i]-=u[i]}}}return t.blendMode=be,t}(t,e,i,n)}},ArcCurve:ao,ArrayCamera:Bl,ArrowHelper:class extends In{constructor(t=new ei(0,0,1),e=new ei(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===Yc&&(Yc=new _r,Yc.setAttribute("position",new dr([0,0,0,0,1,0],3)),qc=new Ka(.5,1,5,1),qc.translate(0,-.5,0)),this.position.copy(e),this.line=new Ra(Yc,new wa({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Lr(qc,new er({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Xc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Xc,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:J,Audio:Yl,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:Ul,AudioListener:class extends In{constructor(){super(),this.type="AudioListener",this.context=Ul.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Gl}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Hl,Vl,Wl),jl.set(0,0,-1).applyQuaternion(Vl),Xl.set(0,1,0).applyQuaternion(Vl),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Hl.x,t),e.positionY.linearRampToValueAtTime(Hl.y,t),e.positionZ.linearRampToValueAtTime(Hl.z,t),e.forwardX.linearRampToValueAtTime(jl.x,t),e.forwardY.linearRampToValueAtTime(jl.y,t),e.forwardZ.linearRampToValueAtTime(jl.z,t),e.upX.linearRampToValueAtTime(Xl.x,t),e.upY.linearRampToValueAtTime(Xl.y,t),e.upZ.linearRampToValueAtTime(Xl.z,t)}else e.setPosition(Hl.x,Hl.y,Hl.z),e.setOrientation(jl.x,jl.y,jl.z,Xl.x,Xl.y,Xl.z)}},AudioLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new nl(this.manager);function a(e){n?n(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(t){try{const i=t.slice(0);Ul.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,n)}},AxesHelper:class extends Da{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new _r;i.setAttribute("position",new dr(e,3)),i.setAttribute("color",new dr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new wa({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new Jn,r=this.geometry.attributes.color.array;return n.set(t),n.toArray(r,0),n.toArray(r,3),n.set(e),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:xa,Bone:Is,BooleanKeyframeTrack:Hh,Box2:class{constructor(t=new $e(1/0,1/0),e=new $e(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=bc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,bc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Li,Box3Helper:class extends Da{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new _r;n.setIndex(new hr(i,1)),n.setAttribute("position",new dr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new wa({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Dr,BoxHelper:class extends Da{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new _r;r.setIndex(new hr(i,1)),r.setAttribute("position",new hr(n,3)),super(r,new wa({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&jc.setFromObject(this.object),jc.isEmpty())return;const t=jc.min,e=jc.max,i=this.geometry.attributes.position,n=i.array;n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=t.x,n[4]=e.y,n[5]=e.z,n[6]=t.x,n[7]=t.y,n[8]=e.z,n[9]=e.x,n[10]=t.y,n[11]=e.z,n[12]=e.x,n[13]=e.y,n[14]=t.z,n[15]=t.x,n[16]=e.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=e.x,n[22]=t.y,n[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:hr,BufferGeometry:_r,BufferGeometryLoader:Pl,ByteType:ft,Cache:Jh,Camera:kr,CameraHelper:class extends Da{constructor(t){const e=new _r,i=new wa({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new dr(n,3)),e.setAttribute("color",new dr(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const h=new Jn(16755200),l=new Jn(16711680),c=new Jn(43775),d=new Jn(16777215),u=new Jn(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let i,n;if(Vc.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===ke)i=-1,n=1;else{if(this.camera.coordinateSystem!==Be)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}Wc("c",e,t,Vc,0,0,i),Wc("t",e,t,Vc,0,0,n),Wc("n1",e,t,Vc,-1,-1,i),Wc("n2",e,t,Vc,1,-1,i),Wc("n3",e,t,Vc,-1,1,i),Wc("n4",e,t,Vc,1,1,i),Wc("f1",e,t,Vc,-1,-1,n),Wc("f2",e,t,Vc,1,-1,n),Wc("f3",e,t,Vc,-1,1,n),Wc("f4",e,t,Vc,1,1,n),Wc("u1",e,t,Vc,.7,1.1,i),Wc("u2",e,t,Vc,-.7,1.1,i),Wc("u3",e,t,Vc,0,2,i),Wc("cf1",e,t,Vc,-1,0,n),Wc("cf2",e,t,Vc,1,0,n),Wc("cf3",e,t,Vc,0,-1,n),Wc("cf4",e,t,Vc,0,1,n),Wc("cn1",e,t,Vc,-1,0,i),Wc("cn2",e,t,Vc,1,0,i),Wc("cn3",e,t,Vc,0,-1,i),Wc("cn4",e,t,Vc,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:Wa,CapsuleGeometry:Ya,CatmullRomCurve3:po,CineonToneMapping:3,CircleGeometry:qa,ClampToEdgeWrapping:at,Clock:Gl,Color:Jn,ColorKeyframeTrack:Vh,ColorManagement:fi,CompressedArrayTexture:class extends Va{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=at,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Va{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,tt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Va,CompressedTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=[],a=new Va,o=new nl(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let h=0;function l(l){o.load(t[l],function(t){const i=r.parse(t,!0);s[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=dt),a.image=s,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}a.image=s}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=dt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Ka,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:Zc,CubeCamera:jr,CubeReflectionMapping:tt,CubeRefractionMapping:et,CubeTexture:Xr,CubeTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=new Xr;r.colorSpace=Me;const s=new sl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,n)}for(let e=0;e<t.length;++e)o(e);return r}},CubeUVReflectionMapping:rt,CubicBezierCurve:vo,CubicBezierCurve3:yo,CubicInterpolant:zh,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:ro,CurvePath:Eo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:Za,Cylindrical:class{constructor(t=1,e=0,i=0){this.radius=t,this.theta=e,this.y=i}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Pi,DataArrayTexture:Ri,DataTexture:Ds,DataTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Ds,a=new nl(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(t){let i;try{i=r.parse(t)}catch(t){if(void 0===n)return void console.error(t);n(t)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:at,s.wrapT=void 0!==i.wrapT?i.wrapT:at,s.magFilter=void 0!==i.magFilter?i.magFilter:dt,s.minFilter=void 0!==i.minFilter?i.minFilter:dt,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=pt),1===i.mipmapCount&&(s.minFilter=dt),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)},i,n),s}},DataUtils:class{static toHalfFloat(t){return nr(t)}static fromHalfFloat(t){return rr(t)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:$h,DepthFormat:Pt,DepthStencilFormat:Lt,DepthTexture:ja,DetachedBindMode:Q,DirectionalLight:bl,DirectionalLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new _r;n.setAttribute("position",new dr([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new wa({fog:!1,toneMapped:!1});this.lightPlane=new Ra(n,r),this.add(this.lightPlane),n=new _r,n.setAttribute("position",new dr([0,0,0,0,0,1],3)),this.targetLine=new Ra(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),kc.setFromMatrixPosition(this.light.matrixWorld),Bc.setFromMatrixPosition(this.light.target.matrixWorld),Gc.subVectors(Bc,kc),this.lightPlane.lookAt(Bc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Bc),this.targetLine.scale.z=Gc.length()}},DiscreteInterpolant:Bh,DodecahedronGeometry:Qa,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:no,EllipseCurve:so,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:it,EquirectangularRefractionMapping:nt,Euler:fn,EventDispatcher:Ge,ExternalTexture:Xa,ExtrudeGeometry:rh,FileLoader:nl,Float16BufferAttribute:class extends hr{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=rr(this.array[t*this.itemSize]);return this.normalized&&(e=Ke(e,this.array)),e}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize]=nr(e),this}getY(t){let e=rr(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ke(e,this.array)),e}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+1]=nr(e),this}getZ(t){let e=rr(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ke(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+2]=nr(e),this}getW(t){let e=rr(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ke(e,this.array)),e}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+3]=nr(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this.array[t+2]=nr(n),this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array),r=Je(r,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this.array[t+2]=nr(n),this.array[t+3]=nr(r),this}},Float32BufferAttribute:dr,FloatType:xt,Fog:Qr,FogExp2:Jr,FramebufferTexture:class extends Ei{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ht,this.minFilter=ht,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:$s,FrustumArray:ia,GLBufferAttribute:class{constructor(t,e,i,n,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.normalized=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ze,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends Da{constructor(t=10,e=10,i=4473924,n=8947848){i=new Jn(i),n=new Jn(n);const r=e/2,s=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=s){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new _r;l.setAttribute("position",new dr(o,3)),l.setAttribute("color",new dr(h,3));super(l,new wa({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:qr,HalfFloatType:wt,HemisphereLight:hl,HemisphereLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new hh(e);n.rotateY(.5*Math.PI),this.material=new er({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new hr(s,3)),this.add(new Lr(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Fc.copy(this.light.color),zc.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?Fc:zc;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Uc.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:ah,ImageBitmapLoader:class extends tl{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Jh.get(`image-bitmap:${t}`);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then(i=>{if(!0!==Ol.has(s))return e&&e(i),r.manager.itemEnd(t),i;n&&n(Ol.get(s)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){return Jh.add(`image-bitmap:${t}`,i),e&&e(i),r.manager.itemEnd(t),i}).catch(function(e){n&&n(e),Ol.set(o,e),Jh.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Jh.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ImageLoader:sl,ImageUtils:_i,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Fs,InstancedBufferGeometry:Rl,InstancedInterleavedBuffer:mc,InstancedMesh:js,Int16BufferAttribute:class extends hr{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends hr{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends hr{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:yt,InterleavedBuffer:ts,InterleavedBufferAttribute:is,Interpolant:Fh,InterpolateDiscrete:fe,InterpolateLinear:ge,InterpolateSmooth:ve,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:Ce,KeyframeTrack:Gh,LOD:ws,LatheGeometry:oh,Layers:gn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:ol,LightProbe:Tl,Line:Ra,Line3:Pc,LineBasicMaterial:wa,LineCurve:_o,LineCurve3:xo,LineDashedMaterial:Lh,LineLoop:Oa,LineSegments:Da,LinearFilter:dt,LinearInterpolant:kh,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:pt,LinearMipmapNearestFilter:ut,LinearSRGBColorSpace:Ee,LinearToneMapping:1,LinearTransfer:Te,Loader:tl,LoaderUtils:Cl,LoadingManager:Qh,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:x,Material:tr,MaterialLoader:Al,MathUtils:Qe,Matrix2:wc,Matrix3:ri,Matrix4:sn,MaxEquation:104,Mesh:Lr,MeshBasicMaterial:er,MeshDepthMaterial:Ch,MeshDistanceMaterial:Rh,MeshLambertMaterial:Ah,MeshMatcapMaterial:Ph,MeshNormalMaterial:Th,MeshPhongMaterial:Mh,MeshPhysicalMaterial:Sh,MeshStandardMaterial:bh,MeshToonMaterial:Eh,MinEquation:103,MirroredRepeatWrapping:ot,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ht,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:ct,NearestMipmapNearestFilter:lt,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:Se,NoToneMapping:0,NormalAnimationBlendMode:we,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:Wh,Object3D:In,ObjectLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?Cl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new nl(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(s,e)},i,n)}async loadAsync(t,e){const i=""===this.path?Cl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new nl(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),s=this.parseImages(t.images,function(){void 0!==e&&e(h)}),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,r,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,n,a,s,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new Ao).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Us).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Pl;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(a);break;default:a.type in _h?s=_h[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new Al;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=Zh.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:hi(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new Qh(e);r=new sl(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=s(r[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ds(i.data,i.width,i.height)))}n[i.uuid]=new wi(t)}else{const t=s(i.url);n[i.uuid]=new wi(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function r(t){if("string"==typeof t){const i=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(r)}return t.data?{data:hi(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new sl(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=s[e],n=await r(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Ds(n.data,n.width,n.height)))}i[n.uuid]=new wi(t)}else{const t=await r(n.url);i[n.uuid]=new wi(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let h;Array.isArray(o)?(h=new Xr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new Ds:new Ei,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.mapping&&(h.mapping=i(s.mapping,Ll)),void 0!==s.channel&&(h.channel=s.channel),void 0!==s.offset&&h.offset.fromArray(s.offset),void 0!==s.repeat&&h.repeat.fromArray(s.repeat),void 0!==s.center&&h.center.fromArray(s.center),void 0!==s.rotation&&(h.rotation=s.rotation),void 0!==s.wrap&&(h.wrapS=i(s.wrap[0],Il),h.wrapT=i(s.wrap[1],Il)),void 0!==s.format&&(h.format=s.format),void 0!==s.internalFormat&&(h.internalFormat=s.internalFormat),void 0!==s.type&&(h.type=s.type),void 0!==s.colorSpace&&(h.colorSpace=s.colorSpace),void 0!==s.minFilter&&(h.minFilter=i(s.minFilter,Dl)),void 0!==s.magFilter&&(h.magFilter=i(s.magFilter,Dl)),void 0!==s.anisotropy&&(h.anisotropy=s.anisotropy),void 0!==s.flipY&&(h.flipY=s.flipY),void 0!==s.generateMipmaps&&(h.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(h.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(h.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(h.compareFunction=s.compareFunction),void 0!==s.userData&&(h.userData=s.userData),n[s.uuid]=h}return n}parseObject(t,e,i,n,r){let s,a,o;function h(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":s=new $r,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new Jn(t.background):s.background=c(t.background)),void 0!==t.environment&&(s.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new Qr(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new Jr(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new Vr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new xl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new Sl(t.color,t.intensity);break;case"DirectionalLight":s=new bl(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new _l(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new Ml(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new ml(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new hl(t.color,t.groundColor,t.intensity);break;case"LightProbe":s=(new Tl).fromJSON(t);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),s=new Ls(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),s=new Lr(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;s=new js(a,o,e),s.instanceMatrix=new Fs(new Float32Array(i.array),16),void 0!==n&&(s.instanceColor=new Fs(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),s=new xa(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._geometryInfo=t.geometryInfo.map(t=>{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Li).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new Zi).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),s._instanceInfo=t.instanceInfo,s._availableInstanceIds=t._availableInstanceIds,s._availableGeometryIds=t._availableGeometryIds,s._nextIndexStart=t.nextIndexStart,s._nextVertexStart=t.nextVertexStart,s._geometryCount=t.geometryCount,s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._matricesTexture=c(t.matricesTexture.uuid),s._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(s.boundingSphere=(new Zi).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(s.boundingBox=(new Li).fromJSON(t.boundingBox));break;case"LOD":s=new ws;break;case"Line":s=new Ra(h(t.geometry),l(t.material));break;case"LineLoop":s=new Oa(h(t.geometry),l(t.material));break;case"LineSegments":s=new Da(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":s=new Ba(h(t.geometry),l(t.material));break;case"Sprite":s=new vs(l(t.material));break;case"Group":s=new qr;break;case"Bone":s=new Is;break;default:s=new In}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,i,n,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];s.animations.push(r[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new In}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:hh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:D,OneMinusSrcColorFactor:203,OrthographicCamera:xl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Sd,Path:To,PerspectiveCamera:Vr,Plane:Zs,PlaneGeometry:lh,PlaneHelper:class extends Ra{constructor(t,e=1,i=16776960){const n=i,r=new _r;r.setAttribute("position",new dr([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new wa({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new _r;s.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Lr(s,new er({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:_l,PointLightHelper:class extends Lr{constructor(t,e,i){super(new uh(e,4,2),new er({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:Ba,PointsMaterial:Na,PolarGridHelper:class extends Da{constructor(t=10,e=16,i=8,n=64,r=4473924,s=8947848){r=new Jn(r),s=new Jn(s);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?r:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?r:s,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l;a.push(i,0,r),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l,a.push(i,0,r),o.push(h.r,h.g,h.b)}}const h=new _r;h.setAttribute("position",new dr(a,3)),h.setAttribute("color",new dr(o,3));super(h,new wa({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Ja,PositionalAudio:class extends Yl{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(ql,Zl,Kl),Jl.set(0,0,1).applyQuaternion(Zl);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(ql.x,t),e.positionY.linearRampToValueAtTime(ql.y,t),e.positionZ.linearRampToValueAtTime(ql.z,t),e.orientationX.linearRampToValueAtTime(Jl.x,t),e.orientationY.linearRampToValueAtTime(Jl.y,t),e.orientationZ.linearRampToValueAtTime(Jl.z,t)}else e.setPosition(ql.x,ql.y,ql.z),e.setOrientation(Jl.x,Jl.y,Jl.z)}},PropertyBinding:lc,PropertyMixer:Ql,QuadraticBezierCurve:wo,QuadraticBezierCurve3:bo,Quaternion:ti,QuaternionKeyframeTrack:Xh,QuaternionLinearInterpolant:jh,RED_GREEN_RGTC2_Format:pe,RED_RGTC1_Format:de,REVISION:_,RGBADepthPacking:3201,RGBAFormat:Rt,RGBAIntegerFormat:Ut,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ie,RGBA_ASTC_10x6_Format:ne,RGBA_ASTC_10x8_Format:re,RGBA_ASTC_12x10_Format:ae,RGBA_ASTC_12x12_Format:oe,RGBA_ASTC_4x4_Format:qt,RGBA_ASTC_5x4_Format:Zt,RGBA_ASTC_5x5_Format:Kt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Qt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:te,RGBA_ASTC_8x8_Format:ee,RGBA_BPTC_Format:he,RGBA_ETC2_EAC_Format:Yt,RGBA_PVRTC_2BPPV1_Format:Wt,RGBA_PVRTC_4BPPV1_Format:Vt,RGBA_S3TC_DXT1_Format:zt,RGBA_S3TC_DXT3_Format:kt,RGBA_S3TC_DXT5_Format:Bt,RGBDepthPacking:3202,RGBFormat:Ct,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:ce,RGB_ETC1_Format:jt,RGB_ETC2_Format:Xt,RGB_PVRTC_2BPPV1_Format:Ht,RGB_PVRTC_4BPPV1_Format:Gt,RGB_S3TC_DXT1_Format:Ft,RGDepthPacking:3203,RGFormat:Ot,RGIntegerFormat:Nt,RawShaderMaterial:wh,Ray:rn,Raycaster:gc,RectAreaLight:Ml,RedFormat:It,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Ai,RenderTarget3D:class extends Ai{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Pi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:st,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:ch,SIGNED_RED_GREEN_RGTC2_Format:me,SIGNED_RED_RGTC1_Format:ue,SRGBColorSpace:Me,SRGBTransfer:Ae,Scene:$r,ShaderChunk:$c,ShaderLib:ed,ShaderMaterial:zr,ShadowMaterial:xh,Shape:Ao,ShapeGeometry:dh,ShapePath:class{constructor(){this.type="ShapePath",this.color=new Jn,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new To,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],a=e[s],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[s],o=-o,a=e[r],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=eh.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,a;const o=[];if(1===n.length)return s=n[0],a=new Ao,a.curves=s.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)s=n[e],d=s.getPoints(),r=i(d),r=t?!r:r,r?(!h&&c[m]&&m++,c[m]={s:new Ao,p:d},c[m].s.curves=s.curves,h&&m++,p[m]=[]):p[m].push({h:s,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new Ao;r.curves=n.curves,e.push(r)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,r=c.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(n!==r&&i++,o?(o=!1,l[r].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:eh,ShortType:gt,Skeleton:Us,SkeletonHelper:class extends Da{constructor(t){const e=Nc(t),i=new _r,n=[],r=[];for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new dr(n,3)),i.setAttribute("color",new dr(r,3));super(i,new wa({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const s=new Jn(255),a=new Jn(65280);this.setColors(s,a)}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Oc.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(Dc.multiplyMatrices(Oc,r.matrixWorld),Ic.setFromMatrixPosition(Dc),n.setXYZ(i,Ic.x,Ic.y,Ic.z),Dc.multiplyMatrices(Oc,r.parent.matrixWorld),Ic.setFromMatrixPosition(Dc),n.setXYZ(i+1,Ic.x,Ic.y,Ic.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,t.r,t.g,t.b),i.setXYZ(n+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ls,Source:wi,Sphere:Zi,SphereGeometry:uh,Spherical:xc,SphericalHarmonics3:El,SplineCurve:So,SpotLight:ml,SpotLightHelper:class extends In{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new _r,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new dr(n,3));const r=new wa({fog:!1,toneMapped:!1});this.cone=new Da(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Lc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:vs,SpriteMaterial:ns,SrcAlphaFactor:I,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Fe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Vr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Vr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,kl.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,r=e.near*Math.tan(We*e.fov*.5)/e.zoom;let s,a;zl.elements[12]=-i,Fl.elements[12]=i,s=-r*e.aspect+n,a=r*e.aspect+n,kl.elements[0]=2*e.near/(a-s),kl.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(kl),s=-r*e.aspect-n,a=r*e.aspect-n,kl.elements[0]=2*e.near/(a-s),kl.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(kl)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(zl),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Fl)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Yh,SubtractEquation:101,SubtractiveBlending:3,TOUCH:w,TangentSpaceNormalMap:0,TetrahedronGeometry:ph,Texture:Ei,TextureLoader:al,TextureUtils:class{static contain(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,n){return Kc(t,e,i,n)}},Timer:class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=_c.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}},TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:mh,TorusKnotGeometry:fh,Triangle:Xn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:gh,UVMapping:$,Uint16BufferAttribute:lr,Uint32BufferAttribute:cr,Uint8BufferAttribute:class extends hr{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends hr{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:uc,UniformsGroup:class extends Ge{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:pc++}),this.name="",this.usage=Fe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:td,UniformsUtils:Fr,UnsignedByteType:mt,UnsignedInt101111Type:Tt,UnsignedInt248Type:Mt,UnsignedInt5999Type:Et,UnsignedIntType:_t,UnsignedShort4444Type:bt,UnsignedShort5551Type:St,UnsignedShortType:vt,VSMShadowMap:3,Vector2:$e,Vector3:ei,Vector4:Ti,VectorKeyframeTrack:qh,VideoFrameTexture:class extends Ha{constructor(t,e,i,n,r,s,a,o){super({},t,e,i,n,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:Ha,WebGL3DRenderTarget:class extends Ci{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Pi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Ci{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ri(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:ke,WebGLCubeRenderTarget:Yr,WebGLRenderTarget:Ci,WebGLRenderer:Dp,WebGLUtils:Tp,WebGPUCoordinateSystem:Be,WebXRController:Kr,WireframeGeometry:vh,WrapAroundEnding:xe,ZeroCurvatureEnding:ye,ZeroFactor:200,ZeroSlopeEnding:_e,ZeroStencilOp:0,createCanvasElement:ci});const Np=new gc,Up=new ei,Fp=new ei,zp=new ti,kp={X:new ei(1,0,0),Y:new ei(0,1,0),Z:new ei(0,0,1)},Bp={type:"change"},Gp={type:"mouseDown",mode:null},Hp={type:"mouseUp",mode:null},Vp={type:"objectChange"};class Wp extends Zc{constructor(t,e=null){super(void 0,e);const i=new dm(this);this._root=i;const n=new um;this._gizmo=n,i.add(n);const r=new pm;this._plane=r,i.add(r);const s=this;function a(t,e){let i=e;Object.defineProperty(s,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,r[t]=e,n[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Bp))}}),s[t]=e,r[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new ei,h=new ei,l=new ti,c=new ti,d=new ei,u=new ti,p=new ei,m=new ei,f=new ei,g=new ei;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new ei,this._startNorm=new ei,this._endNorm=new ei,this._cameraScale=new ei,this._parentPosition=new ei,this._parentQuaternion=new ti,this._parentQuaternionInv=new ti,this._parentScale=new ei,this._worldScaleStart=new ei,this._worldQuaternionInv=new ti,this._worldScale=new ei,this._positionStart=new ei,this._quaternionStart=new ti,this._scaleStart=new ei,this._getPointer=jp.bind(this),this._onPointerDown=Yp.bind(this),this._onPointerHover=Xp.bind(this),this._onPointerMove=qp.bind(this),this._onPointerUp=Zp.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&Np.setFromCamera(t,this.camera);const e=Kp(this._gizmo.picker[this.mode],Np);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&Np.setFromCamera(t,this.camera);const e=Kp(this._plane,Np,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,Gp.mode=this.mode,this.dispatchEvent(Gp)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&Np.setFromCamera(t,this.camera);const s=Kp(this._plane,Np,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(zp.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(Up.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Up.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),Fp.set(t,t,t)}else Up.copy(this.pointStart),Fp.copy(this.pointEnd),Up.applyQuaternion(this._worldQuaternionInv),Fp.applyQuaternion(this._worldQuaternionInv),Fp.divide(Up),-1===e.search("X")&&(Fp.x=1),-1===e.search("Y")&&(Fp.y=1),-1===e.search("Z")&&(Fp.z=1);n.scale.copy(this._scaleStart).multiply(Fp),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(Up.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Up.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(kp[e]),Up.copy(kp[e]),"local"===r&&Up.applyQuaternion(this.worldQuaternion),Up.cross(this.eye),0===Up.length()?i=!0:this.rotationAngle=this._offset.dot(Up.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(zp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(zp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Bp),this.dispatchEvent(Vp)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(Hp.mode=this.mode,this.dispatchEvent(Hp)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Bp),this.dispatchEvent(Vp),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Np}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,i,n){const r=this._gizmo.materialLib;r.xAxis.color.set(t),r.yAxis.color.set(e),r.zAxis.color.set(i),r.active.color.set(n),r.xAxisTransparent.color.set(t),r.yAxisTransparent.color.set(e),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(n),r.xAxis._color&&r.xAxis._color.set(t),r.yAxis._color&&r.yAxis._color.set(e),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(n),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(t),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(e),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(n)}}function jp(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Xp(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Yp(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function qp(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Zp(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Kp(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Jp=new fn,Qp=new ei(0,1,0),$p=new ei(0,0,0),tm=new sn,em=new ti,im=new ti,nm=new ei,rm=new sn,sm=new ei(1,0,0),am=new ei(0,1,0),om=new ei(0,0,1),hm=new ei,lm=new ei,cm=new ei;class dm extends In{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class um extends In{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new er({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new wa({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;const u=t.clone();u.color.setHex(16776960);const p=t.clone();p.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:s,zAxis:a,active:u,xAxisTransparent:o,yAxisTransparent:h,zAxisTransparent:l,activeTransparent:d};const m=new Za(0,.04,.1,12);m.translate(0,.05,0);const f=new Dr(.08,.08,.08);f.translate(0,.04,0);const g=new _r;g.setAttribute("position",new dr([0,0,0,1,0,0],3));const v=new Za(.0075,.0075,.5,3);function y(t,e){const i=new mh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}v.translate(0,.25,0);const _={X:[[new Lr(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(m,r),[-.5,0,0],[0,0,Math.PI/2]],[new Lr(v,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Lr(m,s),[0,.5,0]],[new Lr(m,s),[0,-.5,0],[Math.PI,0,0]],[new Lr(v,s)]],Z:[[new Lr(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Lr(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Lr(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new Lr(new hh(.1,0),c),[0,0,0]]],XY:[[new Lr(new Dr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Lr(new Dr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new Lr(new Za(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Lr(new Za(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(new Za(.2,0,.6,4),i),[0,.3,0]],[new Lr(new Za(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Lr(new Za(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Lr(new Za(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new hh(.2,0),i)]],XY:[[new Lr(new Dr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Lr(new Dr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new Lr(new hh(.01,2),n),null,null,null,"helper"]],END:[[new Lr(new hh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Ra(function(){const t=new _r;return t.setAttribute("position",new dr([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ra(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ra(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},b={XYZE:[[new Lr(y(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new Lr(y(.5,.5),r)]],Y:[[new Lr(y(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Lr(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Lr(y(.75,1),d),null,[0,Math.PI/2,0]]]},S={AXIS:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Lr(new uh(.25,10,8),i)]],X:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Lr(new mh(.75,.1,2,24),i)]]},E={X:[[new Lr(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(v,r),[0,0,0],[0,0,-Math.PI/2]],[new Lr(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(f,s),[0,.5,0]],[new Lr(v,s)],[new Lr(f,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Lr(f,a),[0,0,.5],[Math.PI/2,0,0]],[new Lr(v,a),[0,0,0],[Math.PI/2,0,0]],[new Lr(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Lr(new Dr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Lr(new Dr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new Dr(.1,.1,.1),c)]]},T={X:[[new Lr(new Za(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Lr(new Za(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(new Za(.2,0,.6,4),i),[0,.3,0]],[new Lr(new Za(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Lr(new Za(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Lr(new Za(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Lr(new Dr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Lr(new Dr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new Dr(.2,.2,.2),i),[0,0,0]]]},A={X:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ra(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ra(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new In;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];r.name=i,r.tag=h,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const l=r.geometry.clone();l.applyMatrix4(r.matrix),r.geometry=l,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(_)),this.add(this.gizmo.rotate=C(b)),this.add(this.gizmo.scale=C(E)),this.add(this.picker.translate=C(x)),this.add(this.picker.rotate=C(M)),this.add(this.picker.scale=C(T)),this.add(this.helper.translate=C(w)),this.add(this.helper.rotate=C(S)),this.add(this.helper.scale=C(A)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:im;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(em.copy(e),Qp.copy(this.eye).applyQuaternion(zp.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(tm.lookAt(this.eye,$p,am)),"X"===n.name&&(zp.setFromAxisAngle(sm,Math.atan2(-Qp.y,Qp.z)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)),"Y"===n.name&&(zp.setFromAxisAngle(am,Math.atan2(Qp.x,Qp.z)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)),"Z"===n.name&&(zp.setFromAxisAngle(om,Math.atan2(Qp.y,Qp.x)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(t){return n.name===t}))&&(n.material.color.copy(this.materialLib.active.color),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(zp.setFromEuler(Jp.set(0,0,0)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(zp.setFromEuler(Jp.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(zp.setFromEuler(Jp.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(zp.setFromEuler(Jp.set(0,Math.PI/2,0)),Qp.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(tm.lookAt($p,Qp,am)),n.quaternion.multiply(zp),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),Up.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Up.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(Up),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class pm extends Lr{constructor(){super(new lh(1e5,1e5,2,2),new er({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),hm.copy(sm).applyQuaternion("local"===e?this.worldQuaternion:im),lm.copy(am).applyQuaternion("local"===e?this.worldQuaternion:im),cm.copy(om).applyQuaternion("local"===e?this.worldQuaternion:im),Qp.copy(lm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Qp.copy(this.eye).cross(hm),nm.copy(hm).cross(Qp);break;case"Y":Qp.copy(this.eye).cross(lm),nm.copy(lm).cross(Qp);break;case"Z":Qp.copy(this.eye).cross(cm),nm.copy(cm).cross(Qp);break;case"XY":nm.copy(cm);break;case"YZ":nm.copy(hm);break;case"XZ":Qp.copy(cm),nm.copy(lm);break;case"XYZ":case"E":nm.set(0,0,0)}break;default:nm.set(0,0,0)}0===nm.length()?this.quaternion.copy(this.cameraQuaternion):(rm.lookAt(Up.set(0,0,0),nm,Qp),this.quaternion.setFromRotationMatrix(rm)),super.updateMatrixWorld(t)}}class mm extends Ra{constructor(t,e=1,i=16776960,n=new ei){const r=new _r;r.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new wa({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const s=new _r;s.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Lr(s,new er({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const fm={type:"change"},gm={type:"start"},vm={type:"end"},ym=-1,_m=0,xm=1,wm=2,bm=3,Sm=4,Mm=5,Em=6;class Tm extends Ge{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new ei,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.DOLLY,RIGHT:x.PAN},this.touches={ONE:w.ROTATE,TWO:w.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(fm),i.update(),i.state=ym},this.update=function(){const e=new ei,a=(new ti).setFromUnitVectors(t.up,new ei(0,1,0)),h=a.clone().invert(),l=new ei,c=new ti,d=new ei,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),r.setFromVector3(e),i.autoRotate&&i.state===ym&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(r.theta+=s.theta*i.dampingFactor,r.phi+=s.phi*i.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),r.theta=p<=m?Math.max(p,Math.min(m,r.theta)):r.theta>(p+m)/2?Math.max(p,r.theta):Math.min(m,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=i.scale,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(r),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(s.theta*=1-i.dampingFactor,s.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(s.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent(fm),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",R),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",T),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",E),i.domElement.removeEventListener("pointerup",T),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=ym;const n=1e-6,r=new xc,s=new xc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){s.theta-=t}function h(t){s.phi-=t}i.scale=1,i.panOffset=new ei,i.zoomChanged=!1,i.rotateStart=new $e,i.rotateEnd=new $e,i.rotateDelta=new $e,i.panStart=new $e,i.panEnd=new $e,i.panDelta=new $e,i.dollyStart=new $e,i.dollyEnd=new $e,i.dollyDelta=new $e,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new ei;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new ei;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new ei;return function(e,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const s=i.object.position;t.copy(s).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/r.clientHeight,i.object.matrix),c(2*n*a/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function y(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function _(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.rotateEnd.set(n,r)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function b(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.panEnd.set(n,r)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function S(t){const e=L(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);i.dollyEnd.set(0,s),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",E),i.domElement.addEventListener("pointerup",T)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(P(t),i.pointers.length){case 1:switch(i.touches.ONE){case w.ROTATE:if(!1===i.enableRotate)return;g(),i.state=bm;break;case w.PAN:if(!1===i.enablePan)return;v(),i.state=Sm;break;default:i.state=ym}break;case 2:switch(i.touches.TWO){case w.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&y(),i.enablePan&&v(),i.state=Mm;break;case w.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&y(),i.enableRotate&&g(),i.state=Em;break;default:i.state=ym}break;default:i.state=ym}i.state!==ym&&i.dispatchEvent(gm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case x.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=xm;break;case x.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=wm}else{if(!1===i.enableRotate)return;m(t),i.state=_m}break;case x.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=_m}else{if(!1===i.enablePan)return;f(t),i.state=wm}break;default:i.state=ym}i.state!==ym&&i.dispatchEvent(gm)}(t))}function E(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(P(t),i.state){case bm:if(!1===i.enableRotate)return;_(t),i.update();break;case Sm:if(!1===i.enablePan)return;b(t),i.update();break;case Mm:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&S(t),i.enablePan&&b(t)}(t),i.update();break;case Em:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&S(t),i.enableRotate&&_(t)}(t),i.update();break;default:i.state=ym}}(t):function(t){switch(i.state){case _m:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case xm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case wm:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function T(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",E),i.domElement.removeEventListener("pointerup",T)),i.dispatchEvent(vm),i.state=ym}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===ym&&(t.preventDefault(),i.dispatchEvent(gm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=xm,i.dispatchEvent(fm),i.state=ym)}(t),i.dispatchEvent(vm))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function R(t){!1!==i.enabled&&t.preventDefault()}function P(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new $e,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function L(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",R),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",T),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class Am{constructor(t){this.updateControls=()=>{this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.updateControlsCamera=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.update()},this.optionsChange=({data:t})=>{this.orbit.zoomSpeed=Math.abs(this.orbit.zoomSpeed)*(t.reverseZoomWheel?-1:1)},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case _m:case bm:this.viewer.emitEvent({type:"orbit"});break;case wm:case Sm:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case xm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.viewer.emitEvent({type:"changecamera"}),this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new Tm(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.PAN,RIGHT:x.PAN},this.orbit.touches={ONE:w.ROTATE,TWO:w.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls()}initialize(){}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class Cm extends Am{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new ei).length(),this.viewer.update()},this.updateTransformCamera=()=>{this.transform.camera=this.viewer.camera},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new ei).length(),r=t.extents.getCenter(new ei),s=-r.dot(e);this.plane=new Zs(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new mm(this.plane,n,i,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new In,this.planeCenter.position.copy(t.extents.getCenter(new ei)),this.viewer.helpers.add(this.planeCenter),this.transform=new Wp(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.addEventListener("explode",this.updatePlaneSize),this.viewer.addEventListener("show",this.updatePlaneSize),this.viewer.addEventListener("showall",this.updatePlaneSize),this.viewer.addEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.removeEventListener("explode",this.updatePlaneSize),this.viewer.removeEventListener("show",this.updatePlaneSize),this.viewer.removeEventListener("showall",this.updatePlaneSize),this.viewer.removeEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class Rm extends Cm{constructor(t){super(t,new ei(1,0,0),16711680)}}class Pm extends Cm{constructor(t){super(t,new ei(0,1,0),65280)}}class Lm extends Cm{constructor(t){super(t,new ei(0,0,1),255)}}const Im={Meters:{name:"Meters",type:"m",scale:1},Centimeters:{name:"Centimeters",type:"cm",scale:.01},Millimeters:{name:"Millimeters",type:"mm",scale:.001},Feet:{name:"Feet",type:"ft",scale:.3048},Inches:{name:"Inches",type:"in",scale:.0254},Yards:{name:"Yards",type:"yd",scale:.9144},Kilometers:{name:"Kilometers",type:"km",scale:1e3},Miles:{name:"Miles",type:"mi",scale:1609.344},Micrometers:{name:"Micrometers",type:"µm",scale:1e-6},Mils:{name:"Mils",type:"mil",scale:254e-7},MicroInches:{name:"Micro-inches",type:"µin",scale:2.54e-8},Default:{name:"File units",type:"unit",scale:1}};function Dm(t,e,i){return i*(1/(Im[t]||Im.Default).scale)*((Im[e]||Im.Default).scale||1)}function Om(t,e,i){let n=t.toFixed(e);return"Auto"===i&&(n=n.replace(/\.0+$/,"").replace(/\.$/,"")),+n!==t&&(n="~ "+n),n}function Nm(t,e,i=2){let n;return n="Auto"===i?function(t){const e=Math.abs(t);return e>=1e3?0:e>=10?1:e>=.1?2:e>=.001?3:e>0?Math.floor(-Math.log10(e))+1:2}(t):Number.isFinite(i)?i:parseFloat(i),Number.isFinite(n)?n<0?n=0:n>10&&(n=10):n=2,Im[e]?Om(t,n,i)+" "+Im[e].type:e?Om(t,n,i)+" "+e:Om(t,n,i)}const Um=new ei,Fm=new ei,zm=new ei,km=new Pc,Bm=new ei,Gm=new ei;class Hm{constructor(t,e,i){this.camera=t,this.renderer=e,this.canvas=i,this.raycaster=new gc,this.detectRadiusInPixels=this.isMobile()?50:10,this.edgesCache=new WeakMap}isMobile(){return"undefined"!=typeof navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,r=-(t.y-i.top)/i.height*2+1,s=new $e(n,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:.05},Line2:{threshold:.05},LOD:{},Points:{threshold:.01},Sprite:{}};let a=this.raycaster.intersectObjects(e,!1);return(this.renderer.clippingPlanes||[]).forEach(t=>{a=a.filter(e=>t.distanceToPoint(e.point)>=0)}),a}getDetectRadius(t){const e=this.camera;if(e.isOrthographicCamera){const t=(e.top-e.bottom)/e.zoom/this.canvas.height;return this.detectRadiusInPixels*t}if(e.isPerspectiveCamera){const i=e.position.distanceTo(t),n=2*Math.tan(Qe.degToRad(.5*e.fov))*i/this.canvas.height;return this.detectRadiusInPixels*n}return.1}getSnapPoint(t,e){const i=this.getPointerIntersects(t,e);if(0===i.length)return;const n=i[0].object,r=i[0].point,s=n.worldToLocal(r.clone());let a,o=this.getDetectRadius(r);const h=n.geometry,l=h.attributes.position.array;for(let t=0;t<l.length;t+=3){Um.set(l[t],l[t+1],l[t+2]);const e=Um.distanceTo(s);e<o&&(o=e,a=Um.clone())}if(a)return n.localToWorld(a);let c=this.edgesCache.get(h);c||(c=new no(h),this.edgesCache.set(h,c));const d=c.attributes.position.array;for(let t=0;t<d.length;t+=6){Fm.set(d[t],d[t+1],d[t+2]),zm.set(d[t+3],d[t+4],d[t+5]),km.set(Fm,zm),km.getCenter(Bm);const e=Bm.distanceTo(s);if(e<o){o=e,a=Bm.clone();continue}km.closestPointToPoint(s,!0,Gm);const i=Gm.distanceTo(s);i<o&&(o=i,a=Gm.clone())}return a?n.localToWorld(a):r.clone()}}const Vm=new $e;class Wm extends Am{constructor(t){super(t),this.scale=1,this.units="",this.precision=2,this.onPointerDown=t=>{if(0!==t.button)return;const e=this.snapper.getMousePosition(t,Vm);this.line.startPoint=this.snapper.getSnapPoint(e,this.objects),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint},this.onPointerMove=t=>{if(this.orbit.enabled&&-1!==this.orbit.state)return;const e=this.snapper.getMousePosition(t,Vm),i=this.snapper.getSnapPoint(e,this.objects);i&&this.line.endPoint&&i.equals(this.line.endPoint)||(this.line.endPoint=i,this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>0?(this.line=new Ym(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.clearOverlay=()=>{this.overlay.clear(),this.line=new Ym(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)},this.renderOverlay=()=>{this.overlay.render()},this.updateObjects=()=>{this.objects.length=0,this.viewer.models.forEach(t=>{t.getVisibleObjects().forEach(t=>this.objects.push(t))})},this.updateSnapperCamera=()=>{this.snapper.camera=this.viewer.camera,this.overlay.camera=this.viewer.camera},this.updateUnits=()=>{var t,e;const i=this.viewer.models[0],n=null!==(t=this.viewer.options.rulerUnit)&&void 0!==t?t:"Default",r=null!==(e=this.viewer.options.rulerPrecision)&&void 0!==e?e:"Default";"Default"===n?(this.scale=i.getUnitScale(),this.units=i.getUnitString()):(this.scale=Dm(i.getUnits(),n,1),this.units=n),this.precision="Default"===r?i.getPrecision():r,this.overlay.updateLineUnits(this.scale,this.units,this.precision)},this.overlay=new jm(t.camera,t.canvas),this.overlay.attach(),this.line=new Ym(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line),this.snapper=new Hm(t.camera,t.renderer,t.canvas),this.objects=[],this.updateObjects(),this.updateUnits(),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateObjects),this.viewer.addEventListener("isolate",this.updateObjects),this.viewer.addEventListener("show",this.updateObjects),this.viewer.addEventListener("showall",this.updateObjects),this.viewer.addEventListener("changecameramode",this.updateSnapperCamera),this.viewer.addEventListener("optionschange",this.updateUnits)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateObjects),this.viewer.removeEventListener("isolate",this.updateObjects),this.viewer.removeEventListener("show",this.updateObjects),this.viewer.removeEventListener("showall",this.updateObjects),this.viewer.removeEventListener("changecameramode",this.updateSnapperCamera),this.viewer.removeEventListener("optionschange",this.updateUnits),this.objects.length=0,this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class jm{constructor(t,e){this.lines=[],this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this.canvas;i&&n&&(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.width=`${i}px`,this.container.style.height=`${n}px`)},this.camera=t,this.canvas=e,this.projector=new sf(t,e),this.resizeObserver=new ResizeObserver(this.resizeContainer)}dispose(){this.clear()}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.position="absolute",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement&&(this.canvas.parentElement.appendChild(this.container),this.resizeObserver.observe(this.canvas))}detach(){this.resizeObserver.disconnect(),this.container.remove(),this.container=void 0}clear(){this.lines.forEach(t=>t.dispose()),this.lines.length=0}render(){this.projector.setFromCamera(this.camera),this.lines.forEach(t=>t.render())}update(){this.lines.forEach(t=>t.update())}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter(e=>e!==t)}updateLineUnits(t,e,i){this.lines.forEach(n=>{n.scale=t,n.units=e,n.precision=i})}}const Xm=new ei;class Ym{constructor(t,e,i,n){this.id=Qe.generateUUID(),this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.scale=e,this.units=i,this.precision=n,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove(),this.elementStartPoint=void 0,this.elementEndPoint=void 0,this.elementLine=void 0,this.elementLabel=void 0}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const r=i.angle(),s=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){Xm.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(Xm),n=this.getDistance();this.elementLabel.style.display=i&&n>0?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=Nm(n,this.units,this.precision)}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let qm,Zm;const Km=new sn,Jm=new sn,Qm=new ei,$m=new Ti,tf=new Ti,ef=new $e,nf=new $e,rf=new $e;class sf{constructor(t,e){this.camera=t,this.canvas=e}setFromCamera(t){this.camera=t,this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();qm=t.width/2,Zm=t.height/2,Km.copy(this.camera.matrixWorldInverse),Jm.multiplyMatrices(this.camera.projectionMatrix,Km)}projectPoint(t){Qm.copy(t).applyMatrix4(Jm);const e=Qm.z>=-1&&Qm.z<=1;return ef.x=(Qm.x+1)*qm,ef.y=(1-Qm.y)*Zm,{point:ef,visible:e}}projectLine(t,e){let i;$m.copy(t).applyMatrix4(Jm),tf.copy(e).applyMatrix4(Jm);const n=$m.z+$m.w,r=tf.z+tf.w,s=-$m.z+$m.w,a=-tf.z+tf.w;if(n>=0&&r>=0&&s>=0&&a>=0)i=!0;else if(n<0&&r<0||s<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-r)):r<0&&(e=Math.min(e,n/(n-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),i=e>=t,i&&($m.lerp(tf,t),tf.lerp($m,1-e))}return $m.multiplyScalar(1/$m.w),tf.multiplyScalar(1/tf.w),nf.x=($m.x+1)*qm,nf.y=(1-$m.y)*Zm,rf.x=(tf.x+1)*qm,rf.y=(1-tf.y)*Zm,{point1:nf,point2:rf,visible:i}}}class af extends Am{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.PAN,MIDDLE:x.PAN,RIGHT:x.PAN}}}class of extends Zc{constructor(t,e,i){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.LOOK_SPEED=.1,this.WALK_SPEED_DELIMITER=4,this.WHEEL_SPEED_DELIMITER=15e3,this.movementSpeed=.1,this.multiplier=3,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.camera=t,this.groundObjects=i,this.raycaster=new gc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.moveKeys=new Set,this.moveClock=new Gl,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}updateGroundFollowing(){const t=(new ei).copy(this.camera.up);this.raycaster.set(this.object.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.object.position.y=Qe.lerp(this.object.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){let t=!1,e=!1;const i=new ei,n=new ei;if(this.moveKeys.size>0){e=!0;const r=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),n.setFromMatrixColumn(this.object.matrix,0),n.y=0,n.normalize(),this.moveKeys.has("KeyW")&&this.object.position.addScaledVector(i,r),this.moveKeys.has("KeyS")&&this.object.position.addScaledVector(i,-r),this.moveKeys.has("KeyA")&&this.object.position.addScaledVector(n,-r),this.moveKeys.has("KeyD")&&this.object.position.addScaledVector(n,r),this.moveKeys.has("KeyQ")&&(this.object.translateY(r),e=!1),this.moveKeys.has("KeyE")&&(this.object.translateY(-r),e=!1);const s=this.LOOK_SPEED+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-s/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,s/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(s,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-s,0))),this.moveWheel=0,t=!0}if(0!==this.moveWheel){const e=this.moveWheel*this.multiplier*this.movementSpeed/this.WHEEL_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),this.object.position.addScaledVector(i,-e),this.moveWheel+=-1*Math.sign(this.moveWheel),t=!0}e&&this.updateGroundFollowing(),t&&this.dispatchEvent({type:"change"}),0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new ti;n.setFromAxisAngle(this.object.up,e);const r=new ti;r.setFromAxisAngle(new ei(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class hf extends Zc{constructor(t,e,i,n){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.WALK_SPEED_DELIMITER=4,this.movementSpeed=.1,this.multiplier=3,this.isActive=!1,this.MAX_JOYSTICK_DISTANCE=100,this.INTERNAL_RADIUS=35,this.MAX_MOVE_STICK=40,this.EXTERNAL_RADIUS=65,this.CANVAS_SIZE=200,this.pressed=!1,this.onPointerDown=t=>{t.preventDefault(),this.pressed=!0},this.onPointerMove=t=>{if(t.preventDefault(),!this.pressed)return;let e=t.pageX,i=t.pageY;this.joyStickCanvas.offsetParent&&"BODY"===this.joyStickCanvas.offsetParent.tagName.toUpperCase()?(e-=this.joyStickCanvas.offsetLeft,i-=this.joyStickCanvas.offsetTop):this.joyStickCanvas.offsetParent&&(e-=this.joyStickCanvas.offsetParent.offsetLeft,i-=this.joyStickCanvas.offsetParent.offsetTop);const n=(e-this.centerX)/this.MAX_MOVE_STICK*100,r=(i-this.centerY)/this.MAX_MOVE_STICK*100*-1;Math.sqrt(n*n+r*r)>20?(this.joyStickPosition.set(n,r),this.isActive=!0):(this.joyStickPosition.set(0,0),this.isActive=!1),this.draw(),this.moveClock.start(),this.update()},this.onPointerUp=t=>{t.preventDefault(),this.pressed=!1,this.joyStickPosition.set(0,0),this.isActive=!1,this.moveClock.stop(),this.draw()},this.onResize=()=>{this.updateVisibility(),this.updatePosition()},this.camera=t,this.canvas=i,this.moveClock=new Gl(!1),this.joyStickPosition=new $e(0,0),this.groundObjects=n,this.raycaster=new gc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.centerX=this.CANVAS_SIZE/2,this.centerY=this.CANVAS_SIZE/2,this.overlayElement=document.createElement("div"),this.overlayElement.id="joyStickDiv",this.overlayElement.style.background="rgba(0,0,0,0)",this.overlayElement.style.position="fixed",this.overlayElement.style.zIndex="0",this.overlayElement.style.touchAction="none",i.parentElement.appendChild(this.overlayElement),this.joyStickCanvas=document.createElement("canvas"),this.joyStickCanvas.id="joyStickCanvas",this.joyStickCanvas.width=this.CANVAS_SIZE,this.joyStickCanvas.height=this.CANVAS_SIZE,this.overlayElement.appendChild(this.joyStickCanvas),this.context=this.joyStickCanvas.getContext("2d"),this.joyStickCanvas.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),window.addEventListener("resize",this.onResize),document.addEventListener("fullscreenchange",this.onResize),this.updateVisibility(),this.updatePosition(),this.draw()}dispose(){this.joyStickCanvas.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onResize),document.removeEventListener("fullscreenchange",this.onResize),this.overlayElement.remove(),super.dispose()}updateVisibility(){const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),e=window.innerWidth<1024;this.overlayElement.style.display=t||e?"block":"none"}updatePosition(){const t=this.canvas.getBoundingClientRect();this.overlayElement.style.top=t.height-this.CANVAS_SIZE+"px",this.overlayElement.style.left=`${t.left}px`,this.overlayElement.style.width=`${this.CANVAS_SIZE}px`,this.overlayElement.style.height=`${this.CANVAS_SIZE}px`}draw(){this.context.clearRect(0,0,this.CANVAS_SIZE,this.CANVAS_SIZE),this.context.beginPath(),this.context.arc(this.centerX,this.centerY,this.EXTERNAL_RADIUS,0,2*Math.PI,!1),this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.stroke();let t=this.centerX+this.joyStickPosition.x*this.MAX_MOVE_STICK/100,e=this.centerY-this.joyStickPosition.y*this.MAX_MOVE_STICK/100;t=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,t)),e=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,e)),this.context.beginPath(),this.context.arc(t,e,this.INTERNAL_RADIUS,0,2*Math.PI,!1),this.context.fillStyle="#35436E",this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.fill(),this.context.stroke()}updateGroundFollowing(){const t=(new ei).copy(this.camera.up);this.raycaster.set(this.camera.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.camera.position.y=Qe.lerp(this.camera.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){if(!this.isActive)return;const t=this.joyStickPosition.y/this.MAX_JOYSTICK_DISTANCE,e=this.joyStickPosition.x/this.MAX_JOYSTICK_DISTANCE,i=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER,n=new ei,r=new ei;this.camera.getWorldDirection(n),this.groundObjects.length>0&&(n.y=0),n.normalize(),r.setFromMatrixColumn(this.camera.matrix,0),this.groundObjects.length>0&&(r.y=0),r.normalize(),0!==t&&this.camera.position.addScaledVector(n,i*t),0!==e&&this.camera.position.addScaledVector(r,i*e),0===t&&0===e||(this.groundObjects.length>0&&this.updateGroundFollowing(),this.dispatchEvent({type:"change"}))}}class lf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new ei);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.walkspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update(),this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)};const e=[];t.models.forEach(t=>t.getVisibleObjects().forEach(t=>{t instanceof Lr&&e.push(t)})),this.controls=new of(t.camera,t.canvas,e),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.joyStickControls=new hf(t.camera,t.canvas,t.canvas,e),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class cf extends Zc{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new Gl,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new ti;n.setFromAxisAngle(this.object.up,e);const r=new ti;r.setFromAxisAngle(new ei(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class df{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new ei);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.flyspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update(),this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new cf(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("flyspeedchange",this.flyspeedChange),this.joyStickControls=new hf(t.camera,t.canvas,t.canvas,[]),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("flyspeedchange",this.flyspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class uf extends Am{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.DOLLY,MIDDLE:x.PAN,RIGHT:x.PAN}}}const pf=a("threejs");function mf(t,e=0){t.models.forEach(t=>t.explode(e)),t.update(),t.emitEvent({type:"explode",data:e})}function ff(t,e){if(e.isEmpty())return;const i=e.getCenter(new ei),n=e.getBoundingSphere(new Zi).radius,r=t.renderer.getSize(new $e),s=r.x/r.y,a=t.camera;if(a.isPerspectiveCamera){const t=new ei(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(n/Math.tan(Qe.degToRad(.5*a.fov)));a.position.copy(t).add(i),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n,a.bottom=-n,a.left=a.bottom*s,a.right=a.top*s,a.zoom=1,a.updateProjectionMatrix();const e=new ei(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(3*t.extents.getBoundingSphere(new Zi).radius);a.position.copy(e).add(i),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}pf.registerDragger("Pan",t=>new af(t)),pf.registerDragger("Orbit",t=>new Am(t)),pf.registerDragger("Zoom",t=>new uf(t)),pf.registerDragger("MeasureLine",t=>new Wm(t)),pf.registerDragger("CuttingPlaneXAxis",t=>new Rm(t)),pf.registerDragger("CuttingPlaneYAxis",t=>new Pm(t)),pf.registerDragger("CuttingPlaneZAxis",t=>new Lm(t)),pf.registerDragger("Walk",t=>new lf(t)),pf.registerDragger("Fly",t=>new df(t));const gf={front:new ei(0,0,-1),back:new ei(0,0,1),left:new ei(1,0,0),right:new ei(-1,0,0),bottom:new ei(0,-1,0),top:new ei(0,1,0),se:new ei(-1,1,-1).normalize(),sw:new ei(1,1,-1).normalize(),ne:new ei(-1,1,1).normalize(),nw:new ei(1,1,1).normalize()};function vf(t,e){const i=t.extents.getCenter(new ei),n=2*t.extents.getBoundingSphere(new Zi).radius,r=new ei(0,1,0),s=gf[e]||gf.sw,a=(new ei).copy(t.camera.up),o=(new ti).setFromUnitVectors(r,a),h=(new ei).copy(s).applyQuaternion(o),l=t.camera;l.position.copy(h).multiplyScalar(n).add(i),l.lookAt(i),l.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),ff(t,t.extents)}const yf=n("threejs");yf.registerCommand("applyModelTransform",function(t,e){console.warn("applyModelTransform not implemented")}),yf.registerCommand("clearMarkup",function(t){t.clearOverlay()}),yf.registerCommand("clearSelected",function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),yf.registerCommand("clearSlices",function(t){t.clearSlices()}),yf.registerCommand("collect",function(t){mf(t,0)}),yf.registerCommand("createPreview",function(t,e="image/jpeg",i=.25){return t.update(!0),t.canvas.toDataURL(e,i)}),yf.registerCommand("explode",mf),yf.registerCommand("getDefaultViewPositions",function(){return Object.keys(gf)}),yf.registerCommand("getModels",function(t){return t.models.map(t=>t.id)}),yf.registerCommand("getSelected",function(t){return t.executeCommand("getSelected2").map(t=>t.slice(t.indexOf(":")+1))}),yf.registerCommand("getSelected2",function(t){const e=[];return t.models.forEach(i=>{e.push(...i.getHandlesByObjects(t.selected))}),e}),yf.registerCommand("hideSelected",function(t){t.models.forEach(e=>e.hideObjects(t.selected)),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),yf.registerCommand("isolateSelected",function(t){t.models.forEach(e=>e.isolateObjects(t.selected)),t.update(),t.emitEvent({type:"isolate"})}),yf.registerCommand("regenerateAll",function(t){t.emit({type:"regenerateall"})}),yf.registerCommand("resetView",function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.emit({type:"resetview"})}),yf.registerCommand("selectModel",function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter(t=>t.id===e).forEach(t=>i.select(t.getObjects(),t)),t.update(),t.emitEvent({type:"select",handles:t.getSelected()}),t.emitEvent({type:"select2",handles:t.getSelected2()})}),yf.registerCommand("setActiveDragger",function(t,e=""){t.setActiveDragger(e)}),yf.registerCommand("setDefaultViewPosition",vf),yf.registerCommand("setMarkupColor",function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)}),yf.registerCommand("setSelected",function(t,e=[]){const i=[];e.forEach(e=>{e.includes(":")?i.push(e):t.models.forEach(t=>{i.push(`${t.id}:${e}`)})}),t.executeCommand("setSelected2",i)}),yf.registerCommand("setSelected2",function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach(t=>{const n=t.getObjectsByHandles(e);t.showObjects(n),i.select(n,t)}),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:t.getSelected()}),t.emitEvent({type:"select2",data:void 0,handles:e})}),yf.registerCommand("showAll",function(t){t.models.forEach(t=>t.showAllObjects()),t.update(),t.emitEvent({type:"showall"})}),yf.registerCommand("zoomToExtents",function(t){ff(t,t.extents)}),yf.registerCommand("zoomToObjects",function(t,e=[]){const i=new Li;t.models.forEach(t=>{t.getObjectsByHandles(e).forEach(t=>i.expandByObject(t))}),i.isEmpty()&&i.copy(t.extents),ff(t,i)}),yf.registerCommand("zoomToSelected",function(t){const e=new Li;t.selected.forEach(t=>e.expandByObject(t)),e.isEmpty()&&e.copy(t.extents),ff(t,e)}),yf.registerCommand("top",t=>vf(t,"top")),yf.registerCommand("bottom",t=>vf(t,"bottom")),yf.registerCommand("left",t=>vf(t,"left")),yf.registerCommand("right",t=>vf(t,"right")),yf.registerCommand("front",t=>vf(t,"front")),yf.registerCommand("back",t=>vf(t,"back")),yf.registerCommand("sw",t=>vf(t,"sw")),yf.registerCommand("se",t=>vf(t,"se")),yf.registerCommand("ne",t=>vf(t,"ne")),yf.registerCommand("nw",t=>vf(t,"nw")),yf.registerCommandAlias("clearMarkup","clearOverlay"),yf.registerCommandAlias("clearSelected","unselect"),yf.registerCommandAlias("zoomToExtents","zoomExtents"),yf.registerCommandAlias("top","k3DViewTop"),yf.registerCommandAlias("bottom","k3DViewBottom"),yf.registerCommandAlias("left","k3DViewLeft"),yf.registerCommandAlias("right","k3DViewRight"),yf.registerCommandAlias("front","k3DViewFront"),yf.registerCommandAlias("back","k3DViewBack"),yf.registerCommandAlias("se","k3DViewSE"),yf.registerCommandAlias("sw","k3DViewSW"),yf.registerCommandAlias("ne","k3DViewNE"),yf.registerCommandAlias("nw","k3DViewNW");class _f{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new Jn(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class xf{constructor(t){this.optionsChange=()=>{this.switchCameraMode(this.viewer.options.cameraMode)},this.geometryEnd=()=>{if(this.viewer.models.length>1)return void this.switchCamera(this.viewer.camera);let t;if(this.viewer.scene.traverse(e=>{e.isCamera&&(t?e.isPerspectiveCamera&&t.isOrthographicCamera&&(t=e):t=e)}),t){t.isDefaultCamera=!0,t.scale.set(1,1,1),this.switchCamera(t);const e=this.getCameraMode(t);this.viewer.options.cameraMode=e,this.viewer.emitEvent({type:"changecameramode",mode:e})}else this.switchCamera(this.viewer.camera),this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("initialize",this.optionsChange)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("initialize",this.optionsChange)}getCameraMode(t){return t.isOrthographicCamera?"orthographic":"perspective"}switchCamera(t){const e=2*this.viewer.extents.getBoundingSphere(new Zi).radius||1,i=this.viewer.renderer.getSize(new $e),n=i.x/i.y;t.isPerspectiveCamera&&(t.aspect=n,t.near=e/1e3,t.far=1e3*e),t.isOrthographicCamera&&(t.left=t.bottom*n,t.right=t.top*n,t.near=0,t.far=1e3*e),t.updateProjectionMatrix(),this.viewer.camera=t,this.viewer.renderPass.camera=t,this.viewer.helpersPass.camera=t,this.viewer.ssaaRenderPass.camera=t,this.viewer.update()}switchCameraMode(t){if(!t)return;const e=this.viewer.camera;if(t===this.getCameraMode(e))return;const i=this.viewer.target.clone();let n;if(e.isOrthographicCamera){const t=e.userData.fov||45,r=(e.top-e.bottom)/e.zoom/(2*Math.tan(Qe.degToRad(t)/2)),s=(new ei).subVectors(e.position,i).normalize();n=new Vr(t),n.position.copy(s).multiplyScalar(r).add(i)}if(e.isPerspectiveCamera){const t=e.fov,r=e.position.distanceTo(i),s=2*Math.tan(Qe.degToRad(t)/2)*r;n=new xl,n.top=s/2,n.bottom=-s/2,n.position.copy(e.position),n.userData.fov=t}n&&(n.up.copy(e.up),n.quaternion.copy(e.quaternion),this.switchCamera(n),this.viewer.emitEvent({type:"changecameramode",mode:t}))}}class wf{constructor(t){this.syncExtents=()=>{const t=new Li;this.viewer.models.forEach(e=>e.getExtents(t)),this.viewer.extents.copy(t),this.viewer.models.length>1||this.viewer.extents.getCenter(this.viewer.target)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class bf{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new ei),e=this.viewer.extents.getBoundingSphere(new Zi).radius,i=new ei(0,1,0),n=new ei(0,0,-1),r=(new ei).copy(this.viewer.camera.up),s=(new ti).setFromUnitVectors(i,r),a=(new ei).copy(n).applyQuaternion(s).negate();this.directionalLight.position.copy(r).applyAxisAngle(a,30*-Math.PI/180).multiplyScalar(2*e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.copy(a).multiplyScalar(2*e).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.copy(a).multiplyScalar(3*e).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new Sl(16777215,1.5),this.directionalLight=new bl(16777215,1),this.frontLight=new bl(16777215,1.25),this.hemisphereLight=new hl(16777215,4473924,1.25),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class Sf{constructor(t){this.initialize=()=>{try{const t=this.viewer.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.viewer.info.system.webglRenderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.viewer.info.system.webglVendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}catch(t){console.error("Error reading WebGL info.",t)}console.log("THREE.WebGLRenderer:",_),console.log("WebGL Renderer:",this.viewer.info.system.webglRenderer),console.log("WebGL Vendor:",this.viewer.info.system.webglVendor),this.resize(),this.optionsChange({data:this.viewer.options})},this.clear=()=>{this.viewer.info.performance.timeToFirstRender=0,this.viewer.info.performance.loadTime=0,this.viewer.info.scene.objects=0,this.viewer.info.scene.triangles=0,this.viewer.info.scene.points=0,this.viewer.info.scene.lines=0,this.viewer.info.scene.edges=0,this.viewer.info.optimizedScene.objects=0,this.viewer.info.optimizedScene.triangles=0,this.viewer.info.optimizedScene.points=0,this.viewer.info.optimizedScene.lines=0,this.viewer.info.optimizedScene.edges=0,this.viewer.info.memory.geometries=0,this.viewer.info.memory.geometryBytes=0,this.viewer.info.memory.textures=0,this.viewer.info.memory.textureBytes=0,this.viewer.info.memory.materials=0,this.viewer.info.memory.totalEstimatedGpuBytes=0,this.viewer.info.memory.usedJSHeapSize=0},this.optionsChange=({data:t})=>{!1===t.antialiasing?this.viewer.info.render.antialiasing="":!0===t.antialiasing?this.viewer.info.render.antialiasing="mxaa":this.viewer.info.render.antialiasing=t.antialiasing},this.geometryStart=()=>{this.startTime=performance.now()},this.databaseChunk=()=>{this.viewer.info.performance.timeToFirstRender+=performance.now()-this.startTime,console.log("Time to first render:",this.viewer.info.performance.timeToFirstRender,"ms")},this.geometryEnd=()=>{const t=this.viewer.models[this.viewer.models.length-1].getInfo();this.viewer.info.scene.objects+=t.scene.objects,this.viewer.info.scene.triangles+=t.scene.triangles,this.viewer.info.scene.points+=t.scene.points,this.viewer.info.scene.lines+=t.scene.lines,this.viewer.info.scene.edges+=t.scene.edges,this.viewer.info.optimizedScene.objects+=t.optimizedScene.objects,this.viewer.info.optimizedScene.triangles+=t.optimizedScene.triangles,this.viewer.info.optimizedScene.points+=t.optimizedScene.points,this.viewer.info.optimizedScene.lines+=t.optimizedScene.lines,this.viewer.info.optimizedScene.edges+=t.optimizedScene.edges,this.viewer.info.memory.geometries+=t.memory.geometries,this.viewer.info.memory.geometryBytes+=t.memory.geometryBytes,this.viewer.info.memory.textures+=t.memory.textures,this.viewer.info.memory.textureBytes+=t.memory.textureBytes,this.viewer.info.memory.materials+=t.memory.materials,this.viewer.info.memory.totalEstimatedGpuBytes+=t.memory.totalEstimatedGpuBytes;const e=performance.memory;e&&(this.viewer.info.memory.usedJSHeapSize=e.usedJSHeapSize),this.viewer.info.performance.loadTime+=performance.now()-this.startTime,console.log("Number of objects:",t.scene.objects),console.log("Number of objects after optimization:",t.optimizedScene.objects),console.log("Total geometry size:",t.memory.totalEstimatedGpuBytes/1048576,"MB"),console.log("File load time:",this.viewer.info.performance.loadTime,"ms")},this.resize=()=>{const t=this.viewer.renderer.getSize(new $e);this.viewer.info.render.viewport.width=t.x,this.viewer.info.render.viewport.height=t.y},this.render=()=>{this.viewer.info.render.drawCalls=this.viewer.renderer.info.render.calls,this.viewer.info.render.triangles=this.viewer.renderer.info.render.triangles,this.viewer.info.render.points=this.viewer.renderer.info.render.points,this.viewer.info.render.lines=this.viewer.renderer.info.render.lines},this.animate=()=>{const t=performance.now();this.viewer.info.performance.frameTime=Math.round(t-this.beginTime),this.beginTime=t,this.frames++,t-this.prevTime>=1e3&&(this.viewer.info.performance.fps=Math.round(1e3*this.frames/(t-this.prevTime)),this.prevTime=t,this.frames=0)},this.viewer=t,this.startTime=0,this.beginTime=performance.now(),this.prevTime=performance.now(),this.frames=0,this.viewer.addEventListener("initialize",this.initialize),this.viewer.addEventListener("clear",this.clear),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("geometrystart",this.geometryStart),this.viewer.addEventListener("databasechunk",this.databaseChunk),this.viewer.addEventListener("geometryend",this.geometryEnd),this.viewer.addEventListener("resize",this.resize),this.viewer.addEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}dispose(){this.viewer.removeEventListener("initialize",this.initialize),this.viewer.removeEventListener("clear",this.clear),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("geometrystart",this.geometryStart),this.viewer.removeEventListener("databasechunk",this.databaseChunk),this.viewer.removeEventListener("geometryend",this.geometryEnd),this.viewer.removeEventListener("resize",this.resize),this.viewer.removeEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}}class Mf{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Ef{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this.viewer.setSize(e,i)},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}const Tf=new Li,Af=new ei;class Cf extends Rl{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new dr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new dr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new mc(e,6,1);return this.setAttribute("instanceStart",new is(i,3,0)),this.setAttribute("instanceEnd",new is(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new mc(e,6,1);return this.setAttribute("instanceColorStart",new is(i,3,0)),this.setAttribute("instanceColorEnd",new is(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new vh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Li);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),Tf.setFromBufferAttribute(e),this.boundingBox.union(Tf))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Zi),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let r=0,s=t.count;r<s;r++)Af.fromBufferAttribute(t,r),n=Math.max(n,i.distanceToSquared(Af)),Af.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(Af));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}td.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new $e(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ed.line={uniforms:Fr.merge([td.common,td.fog,td.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class Rf extends zr{constructor(t){super({type:"LineMaterial",uniforms:Fr.clone(ed.line.uniforms),vertexShader:ed.line.vertexShader,fragmentShader:ed.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Pf=new ei,Lf=new ei,If=new Ti;class Df extends Lr{constructor(t=new Cf,e=new Rf({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,r=0,s=e.count;t<s;t++,r+=2)Pf.fromBufferAttribute(e,t),Lf.fromBufferAttribute(i,t),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+Pf.distanceTo(Lf);const r=new mc(n,2,1);return t.setAttribute("instanceDistanceStart",new is(r,1,0)),t.setAttribute("instanceDistanceEnd",new is(r,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(If),this.material.uniforms.resolution.value.set(If.z,If.w))}}class Of{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new Cf,n=[];for(let i=0;i<e.length;i+=2){const r=3*e[i],s=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[r],t[r+1],t[r+2],t[s],t[s+1],t[s+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new Cf,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)Of.isBreak(t,e)||Of.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)Of.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class Nf{constructor(t){this.geometryEnd=()=>{this.facesMaterial=new Mh({transparent:!0,specular:2236962,shininess:10,reflectivity:.05,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.edgesMaterial=new Rf({linewidth:1.5,resolution:new $e(window.innerWidth,window.innerHeight)}),this.lineMaterial=new wa({transparent:!0,depthTest:!0,depthWrite:!0}),this.lineGlowMaterial=new Rf({linewidth:1.5,transparent:!0,opacity:.8,resolution:new $e(window.innerWidth,window.innerHeight)}),this.syncHighlightColors()},this.optionsChange=()=>{this.syncHighlightColors(),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new $e);this.renderTarget=new Ci(e.x,e.y,{format:Rt,stencilBuffer:!1,samples:4,type:mt})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){const{edgesVisibility:e}=this.viewer.options;Array.isArray(t)||(t=[t]),t.length&&t.filter(t=>!t.userData.isEdge).forEach(t=>{if(!t.isHighlighted)if(t.isLine||t.isLineSegments){const i=t.geometry.attributes.position.array,n=t.geometry.index?t.geometry.index.array:null,r=n?Of.fromIndexedLine(i,n):Of.fromNonIndexedLine(i,t.isLineSegments),s=new Df(r,this.lineGlowMaterial);s.position.copy(t.position),s.rotation.copy(t.rotation),s.scale.copy(t.scale),s.visible=e,t.parent.add(s),t.userData.highlightWireframe=s,t.userData.originalMaterial=t.material,t.material=this.lineMaterial,t.isHighlighted=!0}else if(t.isMesh){const i=new no(t.geometry,89),n=(new Cf).fromEdgesGeometry(i),r=new Df(n,this.edgesMaterial);r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.visible=e,t.parent.add(r),t.userData.highlightWireframe=r,t.userData.originalMaterial=t.material,t.material=this.facesMaterial,t.isHighlighted=!0}})}unhighlight(t){Array.isArray(t)||(t=[t]),t.length&&t.forEach(t=>{t.isHighlighted&&(t.isHighlighted=!1,t.material=t.userData.originalMaterial,t.userData.highlightWireframe.removeFromParent(),delete t.userData.originalMaterial,delete t.userData.highlightWireframe)})}syncHighlightColors(){const t=this.viewer.options.enableCustomHighlight?this.viewer.options:f.defaults(),{facesColor:e,facesTransparancy:i,facesOverlap:n}=t,{edgesColor:r,edgesVisibility:s,edgesOverlap:a}=t;this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-i)/255,this.facesMaterial.depthTest=!n,this.facesMaterial.depthWrite=!n,this.edgesMaterial.color.setRGB(r.r/255,r.g/255,r.b/255),this.edgesMaterial.depthTest=!a,this.edgesMaterial.depthWrite=!a,this.lineMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.lineGlowMaterial.color.setRGB(r.r/255,r.g/255,r.b/255),this.lineGlowMaterial.depthTest=!a,this.lineGlowMaterial.depthWrite=!a,this.viewer.selected.forEach(t=>{const e=t.userData.highlightWireframe;e&&(e.visible=s)})}viewerResize(t){var e,i,n;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.edgesMaterial)||void 0===i||i.resolution.set(t.width,t.height),null===(n=this.lineGlowMaterial)||void 0===n||n.resolution.set(t.width,t.height)}}class Uf{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new $e);if(0!==e.distanceTo(this.downPosition))return;const i=new Hm(this.viewer.camera,this.viewer.renderer,this.viewer.canvas);let n=[];if(this.viewer.models.forEach(t=>{const r=t.getVisibleObjects(),s=i.getPointerIntersects(e,r);s.length>0&&n.push({...s[0],model:t})}),n=n.sort((t,e)=>t.distance-e.distance),t.shiftKey||this.clearSelection(),n.length>0){const e=n[0].model,i=e.getHandlesByObjects(n[0].object),r=e.getObjectsByHandles(i);t.shiftKey?this.toggleSelection(r,e):this.select(r,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()}),this.viewer.emitEvent({type:"select2",data:void 0,handles:this.viewer.getSelected2()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.downPosition=new $e,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}select(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(e.showOriginalObjects(t),this.highlighter.highlight(t),t.forEach(t=>this.viewer.selected.push(t)),t.forEach(t=>t.isSelected=!0))):this.viewer.models.forEach(e=>this.select(t,e))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(this.highlighter.unhighlight(t),e.hideOriginalObjects(t),this.viewer.selected=this.viewer.selected.filter(e=>!t.includes(e)),t.forEach(t=>t.isSelected=!1))):this.viewer.models.forEach(e=>this.select(t,e))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),t.length&&(t[0].isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){this.viewer.selected.length&&(this.highlighter.unhighlight(this.viewer.selected),this.viewer.models.forEach(t=>t.hideOriginalObjects(this.viewer.selected)),this.viewer.selected.forEach(t=>t.isSelected=!1),this.viewer.selected.length=0)}}class Ff extends In{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new xl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new er({toneMapped:!1,color:"#dd0000"}),i=new er({toneMapped:!1,color:"#00dd00"}),n=new er({toneMapped:!1,color:"#0000dd"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new Za(.01,.01,1,3);o.translate(0,.5,0);const h=new Za(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Lr(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(o,e),[0,0,0],[0,0,-Math.PI/2]],[new vs(r),[1.55,0,0]]],Y:[[new Lr(h,i),[0,.5,0],null],[new Lr(o,i),null,null],[new vs(s),[0,1.55,0]]],Z:[[new Lr(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Lr(o,n),null,[Math.PI/2,0,0]],[new vs(a),[0,0,1.55]]]};Object.keys(l).forEach(t=>{l[t].forEach(e=>{const i=e[0],n=e[1],r=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),r&&i.rotation.set(r[0],r[1],r[2]),i.updateMatrixWorld(),this.add(i)})})}dispose(){this.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const r=new Wa(i);return r.colorSpace=Me,new ns({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.autoClear,i=t.clippingPlanes,n=t.getViewport(new Ti);t.autoClear=!1,t.clippingPlanes=[],t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=i,t.autoClear=e}}class zf{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new Ff(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new Ff(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}class kf{constructor(t){this.savedCameraPosition=null,this.onDatabaseChunk=()=>{this.savedCameraPosition={position:this.viewer.camera.position.clone(),up:this.viewer.camera.up.clone(),direction:this.viewer.camera.getWorldDirection(new ei)}},this.resetCameraPosition=()=>{this.savedCameraPosition&&(this.viewer.camera.position.copy(this.savedCameraPosition.position),this.viewer.camera.up.copy(this.savedCameraPosition.up),this.viewer.camera.lookAt(this.savedCameraPosition.position.clone().add(this.savedCameraPosition.direction)),this.viewer.camera.updateProjectionMatrix())},this.viewer=t,this.viewer.addEventListener("databasechunk",this.onDatabaseChunk),this.viewer.on("resetview",this.resetCameraPosition)}dispose(){this.viewer.off("resetview",this.resetCameraPosition),this.viewer.removeEventListener("databasechunk",this.onDatabaseChunk)}}const Bf=l("threejs");Bf.registerComponent("ExtentsComponent",t=>new wf(t)),Bf.registerComponent("CameraComponent",t=>new xf(t)),Bf.registerComponent("BackgroundComponent",t=>new _f(t)),Bf.registerComponent("LightComponent",t=>new bf(t)),Bf.registerComponent("InfoComponent",t=>new Sf(t)),Bf.registerComponent("ResizeCanvasComponent",t=>new Ef(t)),Bf.registerComponent("RenderLoopComponent",t=>new Mf(t)),Bf.registerComponent("HighlighterComponent",t=>new Nf(t)),Bf.registerComponent("SelectionComponent",t=>new Uf(t)),Bf.registerComponent("WCSHelperComponent",t=>new zf(t)),Bf.registerComponent("ResetComponent",t=>new kf(t));class Gf{constructor(t){this.scene=t}dispose(){this.scene.traverse(function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach(t=>function(t){t.dispose()}(t)))}),this.scene.clear()}getUnits(){return"Meters"}getUnitScale(){return Dm(this.getUnits(),"Meters",1)}getUnitString(){return t=this.getUnits(),(Im[t]||Im.Default).type;var t}getPrecision(){return 2}getInfo(){const t=new Set,e=new Set,i=new Set;let n=0,r=0,s=0,a=0,o=0,h=0,l=0;function c(t){if(!t.image)return 0;return(t.image.width||0)*(t.image.height||0)*4*(t.generateMipmaps?1.33:1)}this.scene.traverse(d=>{if(n++,d.geometry){const e=d.geometry;if(!t.has(e)){if(t.add(e),e.attributes)for(const t in e.attributes){const i=e.attributes[t];i&&i.array&&(h+=i.array.byteLength)}e.index&&e.index.array&&(h+=e.index.array.byteLength)}if(e.index){const t=e.index.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?s+=t:r+=t/3}else if(e.attributes&&e.attributes.position){const t=e.attributes.position.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?s+=t:r+=t/3}d.isLineSegments&&e.attributes.position&&(o+=e.attributes.position.count/2)}if(d.material){(Array.isArray(d.material)?d.material:[d.material]).forEach(t=>{e.add(t),t.map&&!i.has(t.map)&&(i.add(t.map),l+=c(t.map));["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","iridescenceMap","sheenColorMap","sheenRoughnessMap","thicknessMap","transmissionMap","anisotropyMap","gradientMap"].forEach(e=>{const n=t[e];n&&!i.has(n)&&(i.add(n),l+=c(n))})})}});const d=new y;return d.scene.objects=n,d.scene.triangles=Math.floor(r),d.scene.points=Math.floor(s),d.scene.lines=Math.floor(a),d.scene.edges=Math.floor(o),d.memory.geometries=t.size,d.memory.geometryBytes=h,d.memory.textures=i.size,d.memory.textureBytes=Math.floor(l),d.memory.materials=e.size,d.memory.totalEstimatedGpuBytes=h+Math.floor(l),d.optimizedScene.objects=d.scene.objects,d.optimizedScene.triangles=d.scene.triangles,d.optimizedScene.points=d.scene.points,d.optimizedScene.lines=d.scene.lines,d.optimizedScene.edges=d.scene.edges,d}getExtents(t){return this.scene.traverseVisible(e=>!e.children.length&&t.expandByObject(e)),t}getObjects(){const t=[];return this.scene.traverse(e=>t.push(e)),t}getVisibleObjects(){const t=[];return this.scene.traverseVisible(e=>t.push(e)),t}hasObject(t){for(;t;){if(t===this.scene)return!0;t=t.parent}return!1}hasHandle(t){return!t.includes(":")||t.split(":",1)[0]===this.id+""}getOwnObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.hasObject(t))}getOwnHandles(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.hasHandle(t))}getObjectsByHandles(t){const e=this.getOwnHandles(t);if(0===e.length)return[];const i=new Set(e.map(t=>t.slice(t.indexOf(":")+1))),n=[];return this.scene.traverse(t=>{const e=t.userData.handle;e&&i.has(e)&&n.push(t)}),n}getHandlesByObjects(t){const e=this.getOwnObjects(t);if(0===e.length)return[];const i=new Set;return e.forEach(t=>{const e=t.userData.handle;e&&i.add(`${this.id}:${e}`)}),Array.from(i)}hideObjects(t){return this.getOwnObjects(t).forEach(t=>t.visible=!1),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return this.getOwnObjects(t).forEach(t=>t.traverseAncestors(t=>e.add(t))),this.scene.traverse(t=>t.visible=e.has(t)),this}showObjects(t){return this.getOwnObjects(t).forEach(t=>{t.visible=!0,t.traverseAncestors(t=>t.visible=!0)}),this}showAllObjects(){return this.scene.traverse(t=>t.visible=!0),this}showOriginalObjects(t){return this}hideOriginalObjects(t){return this}explode(t=0,e=4){t/=100,this.scene.userData.explodeDepth||(this.scene.userData.explodeDepth=function t(e,i){let n=i;return e.children.forEach(e=>{const r=t(e,i+1);n<r&&(n=r)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=(new Li).setFromObject(e).getCenter(new ei),e.userData.isExplodeLocked=i>2&&0===e.children.length,n}(this.scene,1));const i=this.scene.userData.explodeDepth,n=t*i+1,r=0|n,s=n-r;return function i(n,a){if(n.position.copy(n.userData.originalPosition),a>0&&a<=r&&!n.userData.isExplodeLocked){let i=t*e;a===r&&(i*=s);const o=n.parent.userData.originalCenter,h=n.userData.originalCenter.clone().sub(o).multiplyScalar(i);n.position.add(h)}n.children.forEach(t=>i(t,a+1))}(this.scene,0),this.scene.updateMatrixWorld(),this}}class Hf extends Gf{getInfo(){const t=this.gltfLoader.getStats(),e=new y;return e.scene.objects=t.scene.beforeOptimization.objects,e.scene.triangles=t.scene.beforeOptimization.triangles,e.scene.lines=t.scene.beforeOptimization.lines,e.scene.edges=t.scene.beforeOptimization.edges,e.optimizedScene.objects=t.scene.afterOptimization.objects,e.optimizedScene.triangles=t.scene.afterOptimization.triangles,e.optimizedScene.lines=t.scene.afterOptimization.lines,e.optimizedScene.edges=t.scene.afterOptimization.edges,e.memory.geometries=t.memory.geometries.count,e.memory.geometryBytes=t.memory.geometries.bytes,e.memory.textures=t.memory.textures.count,e.memory.materials=t.memory.materials.count,e.memory.totalEstimatedGpuBytes=t.memory.totalEstimatedGpuBytes,e}getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach(e=>{t.push(e)}),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}hasObject(t){return this.gltfLoader.originalObjects.has(t)}getObjectsByHandles(t){const e=this.getOwnHandles(t);if(0===e.length)return[];const i=new Set(e),n=[];return i.forEach(t=>{n.push(...this.gltfLoader.getObjectsByHandle(t))}),n}getHandlesByObjects(t){const e=this.getOwnObjects(t);if(0===e.length)return[];const i=new Set;return e.forEach(t=>{const e=t.userData.handle;e&&i.add(e)}),Array.from(i)}hideObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.hideObjects(e),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.showObjects(e),this}showAllObjects(){return this.gltfLoader.showAllHiddenObjects(),this}showOriginalObjects(t){return this.gltfLoader.showOriginalObjects(t),this}hideOriginalObjects(t){return this.gltfLoader.hideOriginalObjects(t),this}}const Vf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wf=0,jf=1,Xf=2,Yf=3,qf=4,Zf=5,Kf=6,Jf=31457280;class Qf{constructor(t,e){this.id=`${t}`,this.json=null,this.loadController=e,this.loader=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new al,this.materials=new Map,this.textureCache=new Map,this.materialCache=new Map,this.uri="",this._nextObjectId=0,this.loadingAborted=!1,this.criticalError=null}async initialize(t){this.json=await this.loadController.loadJson(),this.loader=t,this.uri=this.json.buffers[0].uri||""}clear(){this.json=null,this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear(),this.activeChunkLoads=0,this.chunkQueue=[],this.loadingAborted=!1,this.criticalError=null}getJson(){return this.json}scheduleRequest(t){return new Promise((e,i)=>{this.loadingAborted?i(this.criticalError||new Error("Structure loading has been aborted due to critical error")):this.pendingRequests.push({...t,_resolve:e,_reject:i})})}isCriticalHttpError(t){if(!t)return!1;const e=t.status||t.statusCode||t.code;if("number"==typeof e)return e>=400&&e<600;if(t.message){const e=t.message.match(/HTTP\s+(\d{3})/i);if(e){const t=parseInt(e[1],10);return t>=400&&t<600}}return!1}abortLoading(t){if(this.loadingAborted)return;this.loadingAborted=!0,this.criticalError=t;const e=[...this.pendingRequests];this.pendingRequests=[];for(const i of e)i._reject&&i._reject(t);throw console.error(`❌ Critical error for structure "${this.id}". All further loading aborted.`,`\n Error: ${t.message||t}`,`\n Rejected ${e.length} pending chunk requests.`),t}async flushBufferRequests(){if(!this.pendingRequests||0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],t.sort((t,e)=>t.offset-e.offset);const e=[];let i={start:t[0].offset,end:t[0].offset+t[0].length,requests:[t[0]]};for(let n=1;n<t.length;n++){const r=t[n],s=r.offset-i.end,a=Math.max(i.end,r.offset+r.length),o=a-i.start;s<=131072&&o<=Jf?(i.end=a,i.requests.push(r)):(e.push(i),i={start:r.offset,end:r.offset+r.length,requests:[r]})}e.push(i);const n=[];for(const t of e){let{start:e,end:i,requests:r}=t;for(;i-e>Jf;){let t=0;for(let i=0;i<r.length&&!(r[i].offset+r[i].length-e>Jf);i++)t=i;const s=r.slice(0,t+1),a=s[s.length-1].offset+s[s.length-1].length;if(n.push({start:e,end:a,requests:s}),r=r.slice(t+1),r.length>0){e=r[0].offset,i=r[0].offset+r[0].length;for(let t=1;t<r.length;t++)i=Math.max(i,r[t].offset+r[t].length)}}r.length>0&&n.push({start:e,end:i,requests:r})}const r=n.map(async(t,e)=>{if(this.loadingAborted)for(const e of t.requests)e._reject(this.criticalError||new Error("Structure loading aborted"));else{await this.loader.waitForChunkSlot();try{const e=t.end-t.start,i=await this.loadController.loadBinaryData([{offset:t.start,length:e}],this.uri);for(const e of t.requests){const n=e.offset-t.start;try{e._resolve({buffer:i,relOffset:n,length:e.length})}catch(t){e._reject(t)}}}catch(i){for(const e of t.requests)e._reject(i);this.isCriticalHttpError(i)?this.abortLoading(i):console.warn(`Failed to load chunk ${e+1}/${n.length} (${t.start}-${t.end}):`,i)}finally{this.loader.releaseChunkSlot()}}});await Promise.all(r),this.pendingRequests=[]}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let r;switch(n){case 5120:case 5121:r=1;break;case 5122:case 5123:r=2;break;case 5125:case 5126:r=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const s=i/r;if(!Number.isInteger(s))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,Vf[n])(t,e,s)}catch(r){throw"AbortError"!==r.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:r}),r}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),r=i.count*e*this.getComponentSize(i.componentType),s=await this.getBufferView(t,r,i.componentType),a=new hr(s,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){const t=await this.loadController.resolveURL(e.uri);return this.textureLoader.loadAsync(t)}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),r=URL.createObjectURL(n),s=await this.textureLoader.loadAsync(r);return URL.revokeObjectURL(r),s.flipY=!1,s}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then(t=>this.textureCache.set(i,t)));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=`material_${t}`;this.materialCache.set(i,{mesh:this.createMaterial(e,qf),points:this.createMaterial(e,Wf),lines:this.createMaterial(e,jf)}),this.materialCache.get(i).mesh.name=e.name,this.materialCache.get(i).points.name=e.name,this.materialCache.get(i).lines.name=e.name,this.materials.set(t,this.materialCache.get(i).mesh)}return this.materials}createMaterial(t,e=void 0){const i={};if(t.pbrMetallicRoughness){const e=t.pbrMetallicRoughness;e.baseColorFactor&&(i.color=(new Jn).fromArray(e.baseColorFactor),i.opacity=e.baseColorFactor[3],i.opacity<1&&(i.transparent=!0)),e.baseColorTexture&&(i.map=this.textureCache.get(e.baseColorTexture.index))}let n;return t.emissiveFactor&&(i.emissive=(new Jn).fromArray(t.emissiveFactor)),"BLEND"===t.alphaMode&&(i.transparent=!0),t.doubleSided&&(i.side=2),e===Wf?(i.sizeAttenuation=!1,n=new Na(i),n.sizeAttenuation=!1):e===jf||e===Yf||e===Xf?n=new wa(i):(i.specular=2236962,i.shininess=10,i.reflectivity=.05,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=1,t.normalTexture&&(i.normalMap=this.textureCache.get(t.normalTexture.index)),n=new Mh(i)),n}getCachedMaterial(t,e){const i=`material_${t}`,n=this.materialCache.get(i);return n?e===Wf?n.points:e===jf||e===Yf||e===Xf?n.lines:n.mesh:null}disposeMaterials(){this.textureCache.forEach(t=>t.dispose()),this.textureCache.clear(),this.materials.forEach(t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()}),this.materials.clear(),this.materialCache.forEach(t=>{t.mesh&&(t.mesh.map&&t.mesh.map.dispose(),t.mesh.lightMap&&t.mesh.lightMap.dispose(),t.mesh.bumpMap&&t.mesh.bumpMap.dispose(),t.mesh.normalMap&&t.mesh.normalMap.dispose(),t.mesh.specularMap&&t.mesh.specularMap.dispose(),t.mesh.envMap&&t.mesh.envMap.dispose(),t.mesh.aoMap&&t.mesh.aoMap.dispose(),t.mesh.metalnessMap&&t.mesh.metalnessMap.dispose(),t.mesh.roughnessMap&&t.mesh.roughnessMap.dispose(),t.mesh.emissiveMap&&t.mesh.emissiveMap.dispose(),t.mesh.dispose()),t.points&&(t.points.map&&t.points.map.dispose(),t.points.dispose()),t.lines&&(t.lines.map&&t.lines.map.dispose(),t.lines.dispose())}),this.materialCache.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),r=this.getComponentSize(t.componentType);i+=t.count*n*r}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}function $f(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,h=new _r;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[t]&&(s[t]=[]),s[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const r=t[n].index;for(let t=0;t<r.count;++t)i.push(r.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in s){const e=tg(s[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=tg(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function tg(t){let e,i,n,r=-1,s=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.count*i}const a=new e(s),o=new hr(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,r=n.count;e<r;e++)for(let r=0;r<i;r++){const i=n.getComponent(e,r);o.setComponent(e+t,r,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==r&&(o.gpuType=r),o}class eg{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[],optimizationprogress:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.lastUpdateTime=0,this.updateInterval=1e3,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],
|
|
35
|
+
function Jc(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Qc(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_);const $c={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 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( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\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}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\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 = inverseTransformDirection( 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 * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\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\t\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 = inverseTransformDirection( 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, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( 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 = inverseTransformDirection( 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 = inverseTransformDirection( 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",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 * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), 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.07, 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:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\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#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\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\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.specularColor;\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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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}\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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\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\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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 );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\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 )\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#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\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\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",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#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\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#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\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\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#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\treturn depth * ( near - far ) - near;\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\treturn ( near * far ) / ( ( far - near ) * depth - far );\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\tuniform sampler2D directionalShadowMap[ 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\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\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 sampler2D pointShadowMap[ 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\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D 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\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\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\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\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\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 = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, 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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), 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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},td={common:{diffuse:{value:new Jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ri},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ri}},envmap:{envMap:{value:null},envMapRotation:{value:new ri},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ri}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ri}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ri},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ri},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ri},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ri}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ri}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ri}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Jn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0},uvTransform:{value:new ri}},sprite:{diffuse:{value:new Jn(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ri},alphaMap:{value:null},alphaMapTransform:{value:new ri},alphaTest:{value:0}}},ed={basic:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.fog]),vertexShader:$c.meshbasic_vert,fragmentShader:$c.meshbasic_frag},lambert:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.fog,td.lights,{emissive:{value:new Jn(0)}}]),vertexShader:$c.meshlambert_vert,fragmentShader:$c.meshlambert_frag},phong:{uniforms:Nr([td.common,td.specularmap,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.fog,td.lights,{emissive:{value:new Jn(0)},specular:{value:new Jn(1118481)},shininess:{value:30}}]),vertexShader:$c.meshphong_vert,fragmentShader:$c.meshphong_frag},standard:{uniforms:Nr([td.common,td.envmap,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.roughnessmap,td.metalnessmap,td.fog,td.lights,{emissive:{value:new Jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$c.meshphysical_vert,fragmentShader:$c.meshphysical_frag},toon:{uniforms:Nr([td.common,td.aomap,td.lightmap,td.emissivemap,td.bumpmap,td.normalmap,td.displacementmap,td.gradientmap,td.fog,td.lights,{emissive:{value:new Jn(0)}}]),vertexShader:$c.meshtoon_vert,fragmentShader:$c.meshtoon_frag},matcap:{uniforms:Nr([td.common,td.bumpmap,td.normalmap,td.displacementmap,td.fog,{matcap:{value:null}}]),vertexShader:$c.meshmatcap_vert,fragmentShader:$c.meshmatcap_frag},points:{uniforms:Nr([td.points,td.fog]),vertexShader:$c.points_vert,fragmentShader:$c.points_frag},dashed:{uniforms:Nr([td.common,td.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$c.linedashed_vert,fragmentShader:$c.linedashed_frag},depth:{uniforms:Nr([td.common,td.displacementmap]),vertexShader:$c.depth_vert,fragmentShader:$c.depth_frag},normal:{uniforms:Nr([td.common,td.bumpmap,td.normalmap,td.displacementmap,{opacity:{value:1}}]),vertexShader:$c.meshnormal_vert,fragmentShader:$c.meshnormal_frag},sprite:{uniforms:Nr([td.sprite,td.fog]),vertexShader:$c.sprite_vert,fragmentShader:$c.sprite_frag},background:{uniforms:{uvTransform:{value:new ri},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$c.background_vert,fragmentShader:$c.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ri}},vertexShader:$c.backgroundCube_vert,fragmentShader:$c.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$c.cube_vert,fragmentShader:$c.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$c.equirect_vert,fragmentShader:$c.equirect_frag},distanceRGBA:{uniforms:Nr([td.common,td.displacementmap,{referencePosition:{value:new ei},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$c.distanceRGBA_vert,fragmentShader:$c.distanceRGBA_frag},shadow:{uniforms:Nr([td.lights,td.fog,{color:{value:new Jn(0)},opacity:{value:1}}]),vertexShader:$c.shadow_vert,fragmentShader:$c.shadow_frag}};ed.physical={uniforms:Nr([ed.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ri},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ri},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ri},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ri},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ri},sheen:{value:0},sheenColor:{value:new Jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ri},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ri},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ri},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ri},attenuationDistance:{value:0},attenuationColor:{value:new Jn(0)},specularColor:{value:new Jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ri},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ri},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ri}}]),vertexShader:$c.meshphysical_vert,fragmentShader:$c.meshphysical_frag};const id={r:0,b:0,g:0},nd=new fn,rd=new sn;function sd(t,e,i,n,r,s,a){const o=new Jn(0);let h,l,c=!0===s?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(id,Ur(t)),n.buffers.color.setClear(id.r,id.g,id.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const r=m(e);null===r?f(o,c):r&&r.isColor&&(f(r,1),i=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===rt)?(void 0===l&&(l=new Lr(new Dr(1,1,1),new zr({name:"BackgroundCubeMaterial",uniforms:Or(ed.backgroundCube.uniforms),vertexShader:ed.backgroundCube.vertexShader,fragmentShader:ed.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),nd.copy(i.backgroundRotation),nd.x*=-1,nd.y*=-1,nd.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(nd.y*=-1,nd.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(rd.makeRotationFromEuler(nd)),l.material.toneMapped=fi.getTransfer(n.colorSpace)!==Ae,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Lr(new lh(2,2),new zr({name:"BackgroundMaterial",uniforms:Or(ed.background.uniforms),vertexShader:ed.background.vertexShader,fragmentShader:ed.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=fi.getTransfer(n.colorSpace)!==Ae,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function ad(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=l(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function f(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,h,f,g){let v=!1;const y=function(e,i,r){const s=!0===r.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[s];void 0===h&&(h=l(t.createVertexArray()),o[s]=h);return h}(f,h,r);s!==y&&(s=y,o(s.object)),v=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,f,h,g),v&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===yt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,h*p,(g+a/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)h(r[t].object),delete r[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function od(t,e,i){let n;function r(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))}this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];i.update(e,n,1)}}}function hd(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=!0===i.logarithmicDepthBuffer,l=!0===i.reversedDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===Rt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===wt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==mt&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==xt&&!r)},precision:a,logarithmicDepthBuffer:h,reversedDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function ld(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Zs,o=new ri,h={value:null,needsUpdate:!1};function l(t,i,n,r){const s=null!==t?t.length:0;let l=null;if(0!==s){if(l=h.value,!0!==r||null===l){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;h.value=r,r=l(d,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function cd(t){let e=new WeakMap;function i(t,e){return e===it?t.mapping=tt:e===nt&&(t.mapping=et),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===it||s===nt){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Yr(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const dd=[.125,.215,.35,.446,.526,.582],ud=20,pd=new xl,md=new Jn;let fd=null,gd=0,vd=0,yd=!1;const _d=(1+Math.sqrt(5))/2,xd=1/_d,wd=[new ei(-_d,xd,0),new ei(_d,xd,0),new ei(-xd,0,_d),new ei(xd,0,_d),new ei(0,_d,-xd),new ei(0,_d,xd),new ei(-1,1,-1),new ei(1,1,-1),new ei(-1,1,1),new ei(1,1,1)],bd=new ei;class Sd{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100,r={}){const{size:s=256,position:a=bd}=r;fd=this._renderer.getRenderTarget(),gd=this._renderer.getActiveCubeFace(),vd=this._renderer.getActiveMipmapLevel(),yd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ad(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Td(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(fd,gd,vd),this._renderer.xr.enabled=yd,t.scissorTest=!1,Ed(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===tt||t.mapping===et?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),fd=this._renderer.getRenderTarget(),gd=this._renderer.getActiveCubeFace(),vd=this._renderer.getActiveMipmapLevel(),yd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:dt,minFilter:dt,generateMipmaps:!1,type:wt,format:Rt,colorSpace:Ee,depthBuffer:!1},n=Md(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Md(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+dd.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);i.push(s);let o=1/s;a>t-4?o=dd[a-t+4-1]:0===a&&(o=0),n.push(o);const h=1/(s-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),y=new Float32Array(f*p*u),_=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),y.set(d,f*p*t);const r=[t,t,t,t,t,t];_.set(r,g*p*t)}const x=new _r;x.setAttribute("position",new hr(v,m)),x.setAttribute("uv",new hr(y,f)),x.setAttribute("faceIndex",new hr(_,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(ud),r=new ei(0,1,0),s=new zr({name:"SphericalGaussianBlur",defines:{n:ud,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Cd(),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 <cube_uv_reflection_fragment>\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:0,depthTest:!1,depthWrite:!1});return s}(n,t,e)}return n}_compileMaterial(t){const e=new Lr(this._lodPlanes[0],t);this._renderer.compile(e,pd)}_sceneToCubeUV(t,e,i,n,r){const s=new Vr(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],h=this._renderer,l=h.autoClear,c=h.toneMapping;h.getClearColor(md),h.toneMapping=0,h.autoClear=!1;h.state.buffers.depth.getReversed()&&(h.setRenderTarget(n),h.clearDepth(),h.setRenderTarget(null));const d=new er({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Lr(new Dr,d);let p=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,p=!0):(d.color.copy(md),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[e],r.y,r.z)):1===i?(s.up.set(0,0,a[e]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[e],r.z)):(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[e]));const l=this._cubeSize;Ed(n,i*l,e>2?l:0,l,l),h.setRenderTarget(n),p&&h.render(u,s),h.render(t,s)}u.geometry.dispose(),u.material.dispose(),h.toneMapping=c,h.autoClear=l,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===tt||t.mapping===et;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ad()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Td());const r=n?this._cubemapMaterial:this._equirectMaterial,s=new Lr(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;Ed(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,pd)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodPlanes.length;for(let e=1;e<n;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=wd[(n-e-1)%wd.length];this._blur(t,e-1,e,i,r)}e.autoClear=i}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new Lr(this._lodPlanes[n],h),c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):ud;m>ud&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<ud;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const y=this._sizeLods[n];Ed(e,3*y*(n>v-4?n-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(e),o.render(l,pd)}}function Md(t,e,i){const n=new Ci(t,e,i);return n.texture.mapping=rt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ed(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function Td(){return new zr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cd(),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 <common>\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:0,depthTest:!1,depthWrite:!1})}function Ad(){return new zr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cd(),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:0,depthTest:!1,depthWrite:!1})}function Cd(){return"\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"}function Rd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===it||s===nt,o=s===tt||s===et;if(a||o){let s=e.get(r);const h=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==h)return null===i&&(i=new Sd(t)),s=a?i.fromEquirectangular(r,s):i.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const h=r.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new Sd(t)),s=a?i.fromEquirectangular(r):i.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",n),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Pd(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&ui("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ld(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(e.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}}const o=new(ai(i)?cr:lr)(i,1);o.version=a;const h=s.get(t);h&&e.remove(h),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function Id(t,e,i){let n,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,r,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function Dd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Od(t,e,i){const n=new WeakMap,r=new Ti;return{update:function(s,a,o){const h=s.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let y=0;!0===u&&(y=1),!0===p&&(y=2),!0===m&&(y=3);let _=a.attributes.position.count*y,x=1;_>e.maxTextureSize&&(x=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const w=new Float32Array(_*x*4*c),b=new Ri(w,_,x,c);b.type=xt,b.needsUpdate=!0;const S=4*y;for(let E=0;E<c;E++){const T=f[E],A=g[E],C=v[E],R=_*x*4*E;for(let P=0;P<T.count;P++){const L=P*S;!0===u&&(r.fromBufferAttribute(T,P),w[R+L+0]=r.x,w[R+L+1]=r.y,w[R+L+2]=r.z,w[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),w[R+L+4]=r.x,w[R+L+5]=r.y,w[R+L+6]=r.z,w[R+L+7]=0),!0===m&&(r.fromBufferAttribute(C,P),w[R+L+8]=r.x,w[R+L+9]=r.y,w[R+L+10]=r.z,w[R+L+11]=4===C.itemSize?r.w:1)}}function M(){b.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:b,size:new $e(_,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let I=0;for(let O=0;O<h.length;O++)I+=h[O];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Nd(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(r.get(l)!==o&&(e.update(l),r.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return l},dispose:function(){r=new WeakMap}}}const Ud=new Ei,Fd=new ja(1,1),zd=new Ri,kd=new Pi,Bd=new Xr,Gd=[],Hd=[],Vd=new Float32Array(16),Wd=new Float32Array(9),jd=new Float32Array(4);function Xd(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=Gd[r];if(void 0===s&&(s=new Float32Array(r),Gd[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Yd(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function qd(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Zd(t,e){let i=Hd[e];void 0===i&&(i=new Int32Array(e),Hd[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Kd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Jd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2fv(this.addr,e),qd(i,e)}}function Qd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Yd(i,e))return;t.uniform3fv(this.addr,e),qd(i,e)}}function $d(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4fv(this.addr,e),qd(i,e)}}function tu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;jd.set(n),t.uniformMatrix2fv(this.addr,!1,jd),qd(i,n)}}function eu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;Wd.set(n),t.uniformMatrix3fv(this.addr,!1,Wd),qd(i,n)}}function iu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Yd(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),qd(i,e)}else{if(Yd(i,n))return;Vd.set(n),t.uniformMatrix4fv(this.addr,!1,Vd),qd(i,n)}}function nu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function ru(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2iv(this.addr,e),qd(i,e)}}function su(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Yd(i,e))return;t.uniform3iv(this.addr,e),qd(i,e)}}function au(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4iv(this.addr,e),qd(i,e)}}function ou(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function hu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yd(i,e))return;t.uniform2uiv(this.addr,e),qd(i,e)}}function lu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Yd(i,e))return;t.uniform3uiv(this.addr,e),qd(i,e)}}function cu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yd(i,e))return;t.uniform4uiv(this.addr,e),qd(i,e)}}function du(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Fd.compareFunction=515,s=Fd):s=Ud,i.setTexture2D(e||s,r)}function uu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||kd,r)}function pu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Bd,r)}function mu(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||zd,r)}function fu(t,e){t.uniform1fv(this.addr,e)}function gu(t,e){const i=Xd(e,this.size,2);t.uniform2fv(this.addr,i)}function vu(t,e){const i=Xd(e,this.size,3);t.uniform3fv(this.addr,i)}function yu(t,e){const i=Xd(e,this.size,4);t.uniform4fv(this.addr,i)}function _u(t,e){const i=Xd(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function xu(t,e){const i=Xd(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function wu(t,e){const i=Xd(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function bu(t,e){t.uniform1iv(this.addr,e)}function Su(t,e){t.uniform2iv(this.addr,e)}function Mu(t,e){t.uniform3iv(this.addr,e)}function Eu(t,e){t.uniform4iv(this.addr,e)}function Tu(t,e){t.uniform1uiv(this.addr,e)}function Au(t,e){t.uniform2uiv(this.addr,e)}function Cu(t,e){t.uniform3uiv(this.addr,e)}function Ru(t,e){t.uniform4uiv(this.addr,e)}function Pu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||Ud,s[t])}function Lu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||kd,s[t])}function Iu(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Bd,s[t])}function Du(t,e,i){const n=this.cache,r=e.length,s=Zd(i,r);Yd(n,s)||(t.uniform1iv(this.addr,s),qd(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||zd,s[t])}class Ou{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Kd;case 35664:return Jd;case 35665:return Qd;case 35666:return $d;case 35674:return tu;case 35675:return eu;case 35676:return iu;case 5124:case 35670:return nu;case 35667:case 35671:return ru;case 35668:case 35672:return su;case 35669:case 35673:return au;case 5125:return ou;case 36294:return hu;case 36295:return lu;case 36296:return cu;case 35678:case 36198:case 36298:case 36306:case 35682:return du;case 35679:case 36299:case 36307:return uu;case 35680:case 36300:case 36308:case 36293:return pu;case 36289:case 36303:case 36311:case 36292:return mu}}(e.type)}}class Nu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return fu;case 35664:return gu;case 35665:return vu;case 35666:return yu;case 35674:return _u;case 35675:return xu;case 35676:return wu;case 5124:case 35670:return bu;case 35667:case 35671:return Su;case 35668:case 35672:return Mu;case 35669:case 35673:return Eu;case 5125:return Tu;case 36294:return Au;case 36295:return Cu;case 36296:return Ru;case 35678:case 36198:case 36298:case 36306:case 35682:return Pu;case 35679:case 36299:case 36307:return Lu;case 35680:case 36300:case 36308:case 36293:return Iu;case 36289:case 36303:case 36311:case 36292:return Du}}(e.type)}}class Uu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const Fu=/(\w+)(\])?(\[|\.)?/g;function zu(t,e){t.seq.push(e),t.map[e.id]=e}function ku(t,e,i){const n=t.name,r=n.length;for(Fu.lastIndex=0;;){const s=Fu.exec(n),a=Fu.lastIndex;let o=s[1];const h="]"===s[2],l=s[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===r){zu(i,void 0===l?new Ou(o,t,e):new Nu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new Uu(o),zu(i,t)),i=t}}}class Bu{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);ku(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Gu(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Hu=0;const Vu=new ri;function Wu(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function ju(t,e){const i=function(t){fi._getMatrix(Vu,fi.workingColorSpace,t);const e=`mat3( ${Vu.elements.map(t=>t.toFixed(4))} )`;switch(fi.getTransfer(t)){case Te:return[e,"LinearTransferOETF"];case Ae:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}function Xu(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Cineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 7:i="Neutral";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const Yu=new ei;function qu(){fi.getLuminanceCoefficients(Yu);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Yu.x.toFixed(4)}, ${Yu.y.toFixed(4)}, ${Yu.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Zu(t){return""!==t}function Ku(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ju(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Qu=/^[ \t]*#include +<([\w\d./]+)>/gm;function $u(t){return t.replace(Qu,ep)}const tp=new Map;function ep(t,e){let i=$c[e];if(void 0===i){const t=tp.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=$c[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return $u(i)}const ip=/#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 np(t){return t.replace(ip,rp)}function rp(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function sp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function ap(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case tt:case et:e="ENVMAP_TYPE_CUBE";break;case rt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===et&&(e="ENVMAP_MODE_REFRACTION");return e}(i),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zu).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),f=r.createProgram();let g,v,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Zu).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Zu).join("\n"),v.length>0&&(v+="\n")):(g=[sp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.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(Zu).join("\n"),v=[sp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?$c.tonemapping_pars_fragment:"",0!==i.toneMapping?Xu("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",$c.colorspace_pars_fragment,ju("linearToOutputTexel",i.outputColorSpace),qu(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Zu).join("\n")),a=$u(a),a=Ku(a,i),a=Ju(a,i),o=$u(o),o=Ku(o,i),o=Ju(o,i),a=np(a),o=np(o),!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ze?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ze?"":"#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"+v);const _=y+g+a,x=y+v+o,w=Gu(r,r.VERTEX_SHADER,_),b=Gu(r,r.FRAGMENT_SHADER,x);function S(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(f)||"",n=r.getShaderInfoLog(w)||"",s=r.getShaderInfoLog(b)||"",a=i.trim(),o=n.trim(),h=s.trim();let l=!0,c=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(l=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,w,b);else{const t=Wu(r,w,"vertex"),i=Wu(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?console.warn("THREE.WebGLProgram: Program Info Log:",a):""!==o&&""!==h||(c=!1);c&&(e.diagnostics={runnable:l,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:h,prefix:v}})}r.deleteShader(w),r.deleteShader(b),M=new Bu(r,f),E=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,f)}let M,E;r.attachShader(f,w),r.attachShader(f,b),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===M&&S(this),M},this.getAttributes=function(){return void 0===E&&S(this),E};let T=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===T&&(T=r.getProgramParameter(f,37297)),T},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Hu++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=w,this.fragmentShader=b,this}let op=0;class hp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new lp(t),e.set(t,i)),i}}class lp{constructor(t){this.id=op++,this.code=t,this.usedTimes=0}}function cp(t,e,i,n,r,s,a){const o=new gn,h=new hp,l=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,v){const y=g.fog,_=v.geometry,x=s.isMeshStandardMaterial?g.environment:null,w=(s.isMeshStandardMaterial?i:e).get(s.envMap||x),b=w&&w.mapping===rt?w.image.height:null,S=m[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const M=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,E=void 0!==M?M.length:0;let T,A,C,R,P=0;if(void 0!==_.morphAttributes.position&&(P=1),void 0!==_.morphAttributes.normal&&(P=2),void 0!==_.morphAttributes.color&&(P=3),S){const t=ed[S];T=t.vertexShader,A=t.fragmentShader}else T=s.vertexShader,A=s.fragmentShader,h.update(s),C=h.getVertexShaderID(s),R=h.getFragmentShaderID(s);const L=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),D=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,N=!!s.map,U=!!s.matcap,F=!!w,z=!!s.aoMap,k=!!s.lightMap,B=!!s.bumpMap,G=!!s.normalMap,H=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,j=!!s.roughnessMap,X=s.anisotropy>0,Y=s.clearcoat>0,q=s.dispersion>0,Z=s.iridescence>0,K=s.sheen>0,J=s.transmission>0,Q=X&&!!s.anisotropyMap,$=Y&&!!s.clearcoatMap,tt=Y&&!!s.clearcoatNormalMap,et=Y&&!!s.clearcoatRoughnessMap,it=Z&&!!s.iridescenceMap,nt=Z&&!!s.iridescenceThicknessMap,st=K&&!!s.sheenColorMap,at=K&&!!s.sheenRoughnessMap,ot=!!s.specularMap,ht=!!s.specularColorMap,lt=!!s.specularIntensityMap,ct=J&&!!s.transmissionMap,dt=J&&!!s.thicknessMap,ut=!!s.gradientMap,pt=!!s.alphaMap,mt=s.alphaTest>0,ft=!!s.alphaHash,gt=!!s.extensions;let vt=0;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping));const yt={shaderID:S,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:A,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:D,instancingColor:D&&null!==v.instanceColor,instancingMorph:D&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ee,alphaToCoverage:!!s.alphaToCoverage,map:N,matcap:U,envMap:F,envMapMode:F&&w.mapping,envMapCubeUVHeight:b,aoMap:z,lightMap:k,bumpMap:B,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:Q,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:Z,iridescenceMap:it,iridescenceThicknessMap:nt,sheen:K,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:ht,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:dt,gradientMap:ut,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:s.combine,mapUv:N&&f(s.map.channel),aoMapUv:z&&f(s.aoMap.channel),lightMapUv:k&&f(s.lightMap.channel),bumpMapUv:B&&f(s.bumpMap.channel),normalMapUv:G&&f(s.normalMap.channel),displacementMapUv:H&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:W&&f(s.metalnessMap.channel),roughnessMapUv:j&&f(s.roughnessMap.channel),anisotropyMapUv:Q&&f(s.anisotropyMap.channel),clearcoatMapUv:$&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:nt&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&f(s.sheenRoughnessMap.channel),specularMapUv:ot&&f(s.specularMap.channel),specularColorMapUv:ht&&f(s.specularColorMap.channel),specularIntensityMapUv:lt&&f(s.specularIntensityMap.channel),transmissionMapUv:ct&&f(s.transmissionMap.channel),thicknessMapUv:dt&&f(s.thicknessMap.channel),alphaMapUv:pt&&f(s.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(G||X),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!_.attributes.uv&&(N||pt),fog:!!y,useFog:!0===s.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===s.flatShading&&!1===s.wireframe,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:E,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,decodeVideoTexture:N&&!0===s.map.isVideoTexture&&fi.getTransfer(s.map.colorSpace)===Ae,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&fi.getTransfer(s.emissiveMap.colorSpace)===Ae,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:gt&&!0===s.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===s.extensions.multiDraw||O)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return yt.vertexUv1s=l.has(1),yt.vertexUv2s=l.has(2),yt.vertexUv3s=l.has(3),l.clear(),yt},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&o.enable(21);e.gradientMap&&o.enable(22);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reversedDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=ed[e];i=Fr.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new ap(t,i,e,s),c.push(n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function dp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function up(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function pp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function mp(){const t=[];let e=0;const i=[],n=[],r=[];function s(i,n,r,s,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,groupOrder:s,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?r.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||up),n.length>1&&n.sort(e||pp),r.length>1&&r.sort(e||pp)}}}function fp(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new mp,t.set(e,[r])):i>=n.length?(r=new mp,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function gp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new ei,color:new Jn};break;case"SpotLight":i={position:new ei,direction:new ei,color:new Jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ei,color:new Jn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ei,skyColor:new Jn,groundColor:new Jn};break;case"RectAreaLight":i={color:new Jn,position:new ei,halfWidth:new ei,halfHeight:new ei}}return t[e.id]=i,i}}}let vp=0;function yp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function _p(t){const e=new gp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)n.probe.push(new ei);const r=new ei,s=new sn,a=new sn;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,y=0;r.sort(yp);for(let t=0,_=r.length;t<_;t++){const _=r[t],x=_.color,w=_.intensity,b=_.distance,S=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)s+=x.r*w,a+=x.g*w,o+=x.b*w;else if(_.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(_.sh.coefficients[t],w);y++}else if(_.isDirectionalLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){const t=_.shadow,e=i.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=S,n.directionalShadowMatrix[h]=_.shadow.matrix,p++}n.directional[h]=t,h++}else if(_.isSpotLight){const t=e.get(_);t.position.setFromMatrixPosition(_.matrixWorld),t.color.copy(x).multiplyScalar(w),t.distance=b,t.coneCos=Math.cos(_.angle),t.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),t.decay=_.decay,n.spot[c]=t;const r=_.shadow;if(_.map&&(n.spotLightMap[g]=_.map,g++,r.updateMatrices(_),_.castShadow&&v++),n.spotLightMatrix[c]=r.matrix,_.castShadow){const t=i.get(_);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=S,f++}c++}else if(_.isRectAreaLight){const t=e.get(_);t.color.copy(x).multiplyScalar(w),t.halfWidth.set(.5*_.width,0,0),t.halfHeight.set(0,.5*_.height,0),n.rectArea[d]=t,d++}else if(_.isPointLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),t.distance=_.distance,t.decay=_.decay,_.castShadow){const t=_.shadow,e=i.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=S,n.pointShadowMatrix[l]=_.shadow.matrix,m++}n.point[l]=t,l++}else if(_.isHemisphereLight){const t=e.get(_);t.skyColor.copy(_.color).multiplyScalar(w),t.groundColor.copy(_.groundColor).multiplyScalar(w),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=td.LTC_FLOAT_1,n.rectAreaLTC2=td.LTC_FLOAT_2):(n.rectAreaLTC1=td.LTC_HALF_1,n.rectAreaLTC2=td.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const _=n.hash;_.directionalLength===h&&_.pointLength===l&&_.spotLength===c&&_.rectAreaLength===d&&_.hemiLength===u&&_.numDirectionalShadows===p&&_.numPointShadows===m&&_.numSpotShadows===f&&_.numSpotMaps===g&&_.numLightProbes===y||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=y,_.directionalLength=h,_.pointLength=l,_.spotLength=c,_.rectAreaLength=d,_.hemiLength=u,_.numDirectionalShadows=p,_.numPointShadows=m,_.numSpotShadows=f,_.numSpotMaps=g,_.numLightProbes=y,n.version=vp++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function xp(t){const e=new _p(t),i=[],n=[];const r={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,i.length=0,n.length=0},state:r,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function wp(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new xp(t),e.set(i,[s])):n>=r.length?(s=new xp(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}function bp(t,e,i){let n=new $s;const r=new $e,s=new $e,a=new Ti,o=new Ch({depthPacking:3201}),h=new Rh,l={},c=i.maxTextureSize,d={[b]:1,[S]:0,[M]:2},u=new zr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},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;\n#include <packing>\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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new _r;m.setAttribute("position",new hr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Lr(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(i,n){const s=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Ci(r.x,r.y)),u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,p,f,null)}function _(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=s.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",w)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],s.alphaMap=i.alphaMap,s.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function x(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=_(i,d,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(h.visible){const e=_(i,h,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],r,s,a,o)}function w(t){t.target.removeEventListener("dispose",w);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=3!==v&&3===this.type,m=3===v&&3!==this.type;for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const f=d.getFrameExtents();if(r.multiply(f),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/f.x),r.x=s.x*f.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/f.y),r.y=s.y*f.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ht,magFilter:ht}:{};null!==d.map&&d.map.dispose(),d.map=new Ci(r.x,r.y,t),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(l,t),n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&y(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const Sp={[V]:1,[j]:6,[Y]:7,[X]:5,[W]:0,[Z]:2,[K]:4,[q]:3};function Mp(t,e){const i=new function(){let e=!1;const i=new Ti;let n=null;const r=new Ti(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const r=a;a=null,this.setClear(r)}},getReversed:function(){return n},setTest:function(e){e?rt(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=Sp[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?rt(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null}}},s=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,y=null,_=null,x=new Jn(0,0,0),w=0,b=!1,S=null,M=null,V=null,W=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new Ti).fromArray(Q),et=(new Ti).fromArray($);function it(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const nt={};function rt(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function st(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),rt(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),rt(t.CULL_FACE),ht(0);const at={[E]:t.FUNC_ADD,[T]:t.FUNC_SUBTRACT,[A]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[C]:t.ZERO,[R]:t.ONE,[P]:t.SRC_COLOR,[I]:t.SRC_ALPHA,[z]:t.SRC_ALPHA_SATURATE,[U]:t.DST_COLOR,[O]:t.DST_ALPHA,[L]:t.ONE_MINUS_SRC_COLOR,[D]:t.ONE_MINUS_SRC_ALPHA,[F]:t.ONE_MINUS_DST_COLOR,[N]:t.ONE_MINUS_DST_ALPHA,[k]:t.CONSTANT_COLOR,[B]:t.ONE_MINUS_CONSTANT_COLOR,[G]:t.CONSTANT_ALPHA,[H]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,h,l,c){if(0!==e){if(!1===u&&(rt(t.BLEND),u=!0),5===e)s=s||i,a=a||n,o=o||r,i===m&&s===v||(t.blendEquationSeparate(at[i],at[s]),m=i,v=s),n===f&&r===g&&a===y&&o===_||(t.blendFuncSeparate(ot[n],ot[r],ot[a],ot[o]),f=n,g=r,y=a,_=o),!1!==h.equals(x)&&l===w||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),w=l),p=e,b=!1;else if(e!==p||c!==b){if(m===E&&v===E||(t.blendEquation(t.FUNC_ADD),m=E,v=E),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,g=null,y=null,_=null,x.set(0,0,0),w=0,p=e,b=c}}else!0===u&&(st(t.BLEND),u=!1)}function lt(e){S!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),S=e)}function ct(e){0!==e?(rt(t.CULL_FACE),e!==M&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),M=e}function dt(e,i,n){e?(rt(t.POLYGON_OFFSET_FILL),W===i&&j===n||(t.polygonOffset(i,n),W=i,j=n)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:rt,disable:st,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,r=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?st(t.CULL_FACE):rt(t.CULL_FACE);let a=1===e.side;s&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?rt(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==V&&(Y&&t.lineWidth(e),V=e)},setPolygonOffset:dt,setScissorTest:function(e){e?rt(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),K!==e&&(t.activeTexture(e),K=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===K?t.TEXTURE0+X-1:K);let r=J[n];void 0===r&&(r={type:void 0,texture:void 0},J[n]=r),r.type===e&&r.texture===i||(K!==n&&(t.activeTexture(n),K=n),t.bindTexture(e,i||nt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=J[K];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},K=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,y=null,_=null,x=new Jn(0,0,0),w=0,b=!1,S=null,M=null,V=null,W=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function Ep(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new $e,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):li("canvas")}function f(t,e,i){let n=1;const r=V(t);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=m(i,s));const a=e?m(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function y(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function _(i,n,r,s,a=!1){if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),n===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),n===t.RGB&&(r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),n===t.RGBA){const e=a?Te:fi.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ae?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===_t||i===Mt?n=t.DEPTH24_STENCIL8:i===xt?n=t.DEPTH32F_STENCIL8:i===vt&&(n=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===_t||i===Mt?n=t.DEPTH_COMPONENT24:i===xt?n=t.DEPTH_COMPONENT32F:i===vt&&(n=t.DEPTH_COMPONENT16),n}function w(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==ht&&t.minFilter!==dt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=u.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(r).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete u.get(r)[i.__cacheKey],a.memory.textures--}let E=0;function T(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[st]:t.REPEAT,[at]:t.CLAMP_TO_EDGE,[ot]:t.MIRRORED_REPEAT},C={[ht]:t.NEAREST,[lt]:t.NEAREST_MIPMAP_NEAREST,[ct]:t.NEAREST_MIPMAP_LINEAR,[dt]:t.LINEAR,[ut]:t.LINEAR_MIPMAP_NEAREST,[pt]:t.LINEAR_MIPMAP_LINEAR},R={[Re]:t.NEVER,[Ue]:t.ALWAYS,[Pe]:t.LESS,[Ie]:t.LEQUAL,[Le]:t.EQUAL,[Ne]:t.GEQUAL,[De]:t.GREATER,[Oe]:t.NOTEQUAL};function P(i,s){if(s.type!==xt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==dt&&s.magFilter!==ut&&s.magFilter!==ct&&s.magFilter!==pt&&s.minFilter!==dt&&s.minFilter!==ut&&s.minFilter!==ct&&s.minFilter!==pt||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===ht)return;if(s.minFilter!==ct&&s.minFilter!==pt)return;if(s.type===xt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b));const r=i.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function I(t,e,i){return Math.floor(Math.floor(t/i)/e)}function D(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=L(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),n=a.colorSpace===Se?null:fi.getPrimaries(a.colorSpace),u=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,r.maxTextureSize);p=H(a,p);const m=s.convert(a.format,a.colorSpace),y=s.convert(a.type);let b,S=_(a.internalFormat,m,y,a.colorSpace,a.isVideoTexture);P(h,a);const M=a.mipmaps,E=!0!==a.isVideoTexture,T=void 0===d.__version||!0===l,A=c.dataReady,C=w(a,p);if(a.isDepthTexture)S=x(a.format===Lt,a.type),T&&(E?i.texStorage2D(t.TEXTURE_2D,1,S,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,y,null));else if(a.isDataTexture)if(M.length>0){E&&T&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)b=M[e],E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,y,b.data):i.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,m,y,b.data);a.generateMipmaps=!1}else E?(T&&i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height),A&&function(e,n,r,s){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,r,s,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],r=e.start+e.count,s=I(i.start,n.width,4),h=I(e.start,n.width,4);i.start<=r+1&&s===h&&I(i.start+i.count-1,n.width,4)===s?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const h=t.getParameter(t.UNPACK_ROW_LENGTH),l=t.getParameter(t.UNPACK_SKIP_PIXELS),c=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],h=Math.floor(o.start/4),l=Math.ceil(o.count/4),c=h%n.width,d=Math.floor(h/n.width),u=l,p=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,c),t.pixelStorei(t.UNPACK_SKIP_ROWS,d),i.texSubImage2D(t.TEXTURE_2D,0,c,d,u,p,r,s,n.data)}e.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,h),t.pixelStorei(t.UNPACK_SKIP_PIXELS,l),t.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,p,m,y)):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,y,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){E&&T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(b=M[e],a.format!==Rt)if(null!==m)if(E){if(A)if(a.layerUpdates.size>0){const n=Kc(b.width,b.height,a.format,a.type);for(const r of a.layerUpdates){const s=b.data.subarray(r*n/b.data.BYTES_PER_ELEMENT,(r+1)*n/b.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,b.width,b.height,1,m,s)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,b.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,y,b.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,m,y,b.data)}else{E&&T&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)b=M[e],a.format!==Rt?null!==m?E?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,b.data):i.compressedTexImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,y,b.data):i.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,m,y,b.data)}else if(a.isDataArrayTexture)if(E){if(T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Kc(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const r=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,y,r)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,y,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,S,p.width,p.height,p.depth,0,m,y,p.data);else if(a.isData3DTexture)E?(T&&i.texStorage3D(t.TEXTURE_3D,C,S,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,y,p.data)):i.texImage3D(t.TEXTURE_3D,0,S,p.width,p.height,p.depth,0,m,y,p.data);else if(a.isFramebufferTexture){if(T)if(E)i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height);else{let e=p.width,n=p.height;for(let r=0;r<C;r++)i.texImage2D(t.TEXTURE_2D,r,S,e,n,0,m,y,null),e>>=1,n>>=1}}else if(M.length>0){if(E&&T){const e=V(M[0]);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)b=M[e],E?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,y,b):i.texImage2D(t.TEXTURE_2D,e,S,m,y,b);a.generateMipmaps=!1}else if(E){if(T){const e=V(p);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,y,p)}else i.texImage2D(t.TEXTURE_2D,0,S,m,y,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function O(e,r,a,h,l,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=_(a.internalFormat,d,u,a.colorSpace),m=n.get(r),f=n.get(a);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>c),n=Math.max(1,r.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,r.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,B(r)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(i.stencilBuffer,s),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,l=B(i);G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,l,a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,l,a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r<e.length;r++){const a=e[r],h=s.convert(a.format,a.colorSpace),l=s.convert(a.type),c=_(a.internalFormat,h,l,a.colorSpace),d=B(i);n&&!1===G(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,i.width,i.height):G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=n.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const a=s.__webglTexture,h=B(r);if(r.depthTexture.format===Pt)G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Lt)throw new Error("Unknown depthTexture format");G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}function F(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");const t=e.texture.mipmaps;t&&t.length>0?U(r.__webglFramebuffer[0],e):U(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),N(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),N(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const z=[],k=[];function B(t){return Math.min(r.maxSamples,t.samples)}function G(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Ee&&i!==Se&&(fi.getTransfer(i)===Ae?n===Rt&&r===mt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),e}function V(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=T,this.setTexture2DArray=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=L(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),n=a.colorSpace===Se?null:fi.getPrimaries(a.colorSpace),d=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,r.maxCubemapSize),m[t]=H(a,m[t]);const y=m[0],x=s.convert(a.format,a.colorSpace),b=s.convert(a.type),S=_(a.internalFormat,x,b,a.colorSpace),M=!0!==a.isVideoTexture,E=void 0===c.__version||!0===h,T=l.dataReady;let A,C=w(a,y);if(P(t.TEXTURE_CUBE_MAP,a),u){M&&E&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,y.width,y.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const r=A[n];a.format!==Rt?null!==x?M?T&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,x,b,r.data)}}}else{if(A=a.mipmaps,M&&E){A.length>0&&C++;const e=V(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,b,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,m[e].width,m[e].height,0,x,b,m[e].data);for(let n=0;n<A.length;n++){const r=A[n].image[e].image;M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,x,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,r.width,r.height,0,x,b,r.data)}}else{M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,b,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,x,b,m[e]);for(let n=0;n<A.length;n++){const r=A[n];M?T&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,b,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,x,b,r.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&O(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&F(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),h=n.get(r);e.addEventListener("dispose",S);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),h=_(n.internalFormat,r,a,n.colorSpace,!0===e.isXRRenderTarget),c=B(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(r)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let r=0,s=l.length;r<s;r++){const s=l[r],a=n.get(s);let h=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(h=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(h,a.__webglTexture),P(h,s),O(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,h,0),g(s)&&v(h)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),P(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);g(r)&&v(n),i.unbindTexture()}e.depthBuffer&&F(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=y(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===G(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===h&&(z.length=0,k.length=0,z.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(z.push(l),k.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,k)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G}function Tp(t,e){return{convert:function(i,n=""){let r;const s=fi.getTransfer(n);if(i===mt)return t.UNSIGNED_BYTE;if(i===bt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===St)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Et)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===Tt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===ft)return t.BYTE;if(i===gt)return t.SHORT;if(i===vt)return t.UNSIGNED_SHORT;if(i===yt)return t.INT;if(i===_t)return t.UNSIGNED_INT;if(i===xt)return t.FLOAT;if(i===wt)return t.HALF_FLOAT;if(i===At)return t.ALPHA;if(i===Ct)return t.RGB;if(i===Rt)return t.RGBA;if(i===Pt)return t.DEPTH_COMPONENT;if(i===Lt)return t.DEPTH_STENCIL;if(i===It)return t.RED;if(i===Dt)return t.RED_INTEGER;if(i===Ot)return t.RG;if(i===Nt)return t.RG_INTEGER;if(i===Ut)return t.RGBA_INTEGER;if(i===Ft||i===zt||i===kt||i===Bt)if(s===Ae){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ft)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ft)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Gt||i===Ht||i===Vt||i===Wt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===jt||i===Xt||i===Yt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===jt||i===Xt)return s===Ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Yt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===qt||i===Zt||i===Kt||i===Jt||i===Qt||i===$t||i===te||i===ee||i===ie||i===ne||i===re||i===se||i===ae||i===oe){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Zt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Kt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===te)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ee)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ie)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ne)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===re)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ae)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===oe)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===he||i===le||i===ce){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===he)return s===Ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===de||i===ue||i===pe||i===me){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===de)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pe)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===me)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Mt?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class Ap{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new Xa(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new zr({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:e.z},depthHeight:{value:e.w}}});this.mesh=new Lr(new lh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Cp extends Ge{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new Ap,g={},v=e.getContextAttributes();let y=null,_=null;const x=[],w=[],b=new $e;let S=null;const M=new Vr;M.viewport=new Ti;const E=new Vr;E.viewport=new Ti;const T=[M,E],A=new Bl;let C=null,R=null;function P(t){const e=w.indexOf(t.inputSource);if(-1===e)return;const i=x[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function L(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",L),n.removeEventListener("inputsourceschange",I);for(let t=0;t<x.length;t++){const e=w[t];null!==e&&(w[t]=null,x[t].disconnect(e))}C=null,R=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(y),u=null,d=null,c=null,n=null,_=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(S),t.setSize(b.width,b.height,!1),i.dispatchEvent({type:"sessionend"})}function I(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=w.indexOf(i);n>=0&&(w[n]=null,x[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=w.indexOf(i);if(-1===n){for(let t=0;t<x.length;t++){if(t>=w.length){w.push(i),n=t;break}if(null===w[t]){w[t]=i,n=t;break}}if(-1===n)break}const r=x[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new Kr,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){y=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",L),n.addEventListener("inputsourceschange",I),!0!==v.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(b);if(m&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;v.depth&&(a=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=v.stencil?Lt:Pt,s=v.stencil?Mt:_t);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=this.getBinding(),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new Ci(d.textureWidth,d.textureHeight,{format:Rt,type:mt,depthTexture:new ja(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),_=new Ci(u.framebufferWidth,u.framebufferHeight,{format:Rt,type:mt,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}_.isXRRenderTarget=!0,this.setFoveation(o),h=null,s=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new ei,O=new ei;function N(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(i=f.depthFar)),A.near=E.near=M.near=e,A.far=E.far=M.far=i,C===A.near&&R===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,M.layers.mask=3&A.layers.mask,E.layers.mask=5&A.layers.mask;const r=t.parent,s=A.cameras;N(A,r);for(let t=0;t<s.length;t++)N(s[t],r);2===s.length?function(t,e,i){D.setFromMatrixPosition(e.matrixWorld),O.setFromMatrixPosition(i.matrixWorld);const n=D.distanceTo(O),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,r=u-f,s=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(r,s,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,M,E):A.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*je*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new Jc;F.setAnimationLoop(function(e,r){if(l=r.getViewerPose(h||s),p=r,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(_,u.framebuffer),t.setRenderTarget(_));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let i=0;i<e.length;i++){const n=e[i];let s=null;if(null!==u)s=u.getViewport(n);else{const e=c.getViewSubImage(d,n);s=e.viewport,0===i&&(t.setRenderTargetTextures(_,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(_))}let a=T[i];void 0===a&&(a=new Vr,a.layers.enable(i),a.viewport=new Ti,T[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(a)}const s=n.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&m){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,n.renderState)}if(s&&s.includes("camera-access")&&m){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new Xa,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=w[t],i=x[t];null!==e&&void 0!==i&&i.update(e,r,h||s)}U&&U(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const Rp=new fn,Pp=new sn;function Lp(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,Rp.copy(a),Rp.x*=-1,Rp.y*=-1,Rp.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(Rp.y*=-1,Rp.z*=-1),t.envMapRotation.value.setFromMatrix4(Pp.makeRotationFromEuler(Rp)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,Ur(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ip(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return n[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=r[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=l(s[t]),a=i%n,o=a%r.boundary,h=a+o;i+=o,0!==h&&n-h<r.storage&&(i+=n-h),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===h(r,e,n,s)){const e=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const a=i[s],o=l(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class Dp{constructor(t={}){const{canvas:e=ci(),context:i=null,depth:n=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:d=!1}=t;let u;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=s;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const v=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const x=this;let w=!1;this._outputColorSpace=Me;let b=0,S=0,M=null,E=-1,T=null;const A=new Ti,C=new Ti;let R=null;const P=new Jn(0);let L=0,I=e.width,D=e.height,O=1,N=null,U=null;const F=new Ti(0,0,I,D),z=new Ti(0,0,I,D);let k=!1;const B=new $s;let G=!1,H=!1;const V=new sn,W=new ei,j=new Ti,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function q(){return null===M?O:1}let Z,K,J,Q,$,tt,et,it,nt,rt,st,at,ot,ht,lt,ct,dt,ut,ft,gt,yt,xt,Et,Tt,At=i;function Ct(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_}`),e.addEventListener("webglcontextlost",Lt,!1),e.addEventListener("webglcontextrestored",It,!1),e.addEventListener("webglcontextcreationerror",Ot,!1),null===At){const e="webgl2";if(At=Ct(e,t),null===At)throw Ct(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Rt(){Z=new Pd(At),Z.init(),xt=new Tp(At,Z),K=new hd(At,Z,t,xt),J=new Mp(At,Z),K.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),Q=new Dd(At),$=new dp,tt=new Ep(At,Z,J,$,K,xt,Q),et=new cd(x),it=new Rd(x),nt=new Qc(At),Et=new ad(At,nt),rt=new Ld(At,nt,Q,Et),st=new Nd(At,rt,nt,Q),ft=new Od(At,K,tt),ct=new ld($),at=new cp(x,et,it,Z,K,Et,ct),ot=new Lp(x,$),ht=new fp,lt=new wp(Z),ut=new sd(x,et,it,J,st,u,o),dt=new bp(x,st,K),Tt=new Ip(At,Q,K,J),gt=new od(At,Z,Q),yt=new Id(At,Z,Q),Q.programs=at.programs,x.capabilities=K,x.extensions=Z,x.properties=$,x.renderLists=ht,x.shadowMap=dt,x.state=J,x.info=Q}Rt();const Pt=new Cp(x,At);function Lt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function It(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;const t=Q.autoReset,e=dt.enabled,i=dt.autoUpdate,n=dt.needsUpdate,r=dt.type;Rt(),Q.autoReset=t,dt.enabled=e,dt.autoUpdate=i,dt.needsUpdate=n,dt.type=r}function Ot(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Ft(t){const e=t.target;e.removeEventListener("dispose",Ft),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach(function(t){at.releaseProgram(t)}),t.isShaderMaterial&&at.releaseShaderCache(t))})(t),$.remove(t)}(e)}function zt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,qt(t,e,i),t.side=0,t.needsUpdate=!0,qt(t,e,i),t.side=2):qt(t,e,i)}this.xr=Pt,this.getContext=function(){return At},this.getContextAttributes=function(){return At.getContextAttributes()},this.forceContextLoss=function(){const t=Z.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Z.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(I,D,!1))},this.getSize=function(t){return t.set(I,D)},this.setSize=function(t,i,n=!0){Pt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(I=t,D=i,e.width=Math.floor(t*O),e.height=Math.floor(i*O),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(I*O,D*O).floor()},this.setDrawingBufferSize=function(t,i,n){I=t,D=i,O=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(F)},this.setViewport=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),J.viewport(A.copy(F).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(z)},this.setScissor=function(t,e,i,n){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,i,n),J.scissor(C.copy(z).multiplyScalar(O).round())},this.getScissorTest=function(){return k},this.setScissorTest=function(t){J.setScissorTest(k=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.copy(ut.getClearColor())},this.setClearColor=function(){ut.setClearColor(...arguments)},this.getClearAlpha=function(){return ut.getClearAlpha()},this.setClearAlpha=function(){ut.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==M){const e=M.texture.format;t=e===Ut||e===Nt||e===Dt}if(t){const t=M.texture.type,e=t===mt||t===_t||t===vt||t===Mt||t===bt||t===St,i=ut.getClearColor(),n=ut.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(p[0]=r,p[1]=s,p[2]=a,p[3]=n,At.clearBufferuiv(At.COLOR,0,p)):(m[0]=r,m[1]=s,m[2]=a,m[3]=n,At.clearBufferiv(At.COLOR,0,m))}else n|=At.COLOR_BUFFER_BIT}e&&(n|=At.DEPTH_BUFFER_BIT),i&&(n|=At.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),At.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Lt,!1),e.removeEventListener("webglcontextrestored",It,!1),e.removeEventListener("webglcontextcreationerror",Ot,!1),ut.dispose(),ht.dispose(),lt.dispose(),$.dispose(),et.dispose(),it.dispose(),st.dispose(),Et.dispose(),Tt.dispose(),at.dispose(),Pt.dispose(),Pt.removeEventListener("sessionstart",Bt),Pt.removeEventListener("sessionend",Gt),Ht.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=X);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=X);tt.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===M?x.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:Ee,h=(n.isMeshStandardMaterial?it:et).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=x.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==f?f.length:0,y=$.get(n),_=g.state.lights;if(!0===G&&(!0===H||t!==T)){const e=t===T&&n.id===E;ct.setState(n,t,e)}let w=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==_.state.version||y.outputColorSpace!==o||r.isBatchedMesh&&!1===y.batching?w=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?w=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?w=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==h||!0===n.fog&&y.fog!==s?w=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ct.numPlanes&&y.numIntersection===ct.numIntersection?(y.vertexAlphas!==l||y.vertexTangents!==c||y.morphTargets!==d||y.morphNormals!==u||y.morphColors!==p||y.toneMapping!==m||y.morphTargetsCount!==v)&&(w=!0):w=!0:w=!0:w=!0:w=!0:(w=!0,y.__version=n.version);let b=y.currentProgram;!0===w&&(b=qt(n,e,r));let S=!1,A=!1,C=!1;const R=b.getUniforms(),P=y.uniforms;J.useProgram(b.program)&&(S=!0,A=!0,C=!0);n.id!==E&&(E=n.id,A=!0);if(S||T!==t){J.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),R.setValue(At,"projectionMatrix",t.projectionMatrix),R.setValue(At,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(At,W.setFromMatrixPosition(t.matrixWorld)),K.logarithmicDepthBuffer&&R.setValue(At,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(At,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,A=!0,C=!0)}if(r.isSkinnedMesh){R.setOptional(At,r,"bindMatrix"),R.setOptional(At,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(At,"boneTexture",t.boneTexture,tt))}r.isBatchedMesh&&(R.setOptional(At,r,"batchingTexture"),R.setValue(At,"batchingTexture",r._matricesTexture,tt),R.setOptional(At,r,"batchingIdTexture"),R.setValue(At,"batchingIdTexture",r._indirectTexture,tt),R.setOptional(At,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(At,"batchingColorTexture",r._colorsTexture,tt));const L=i.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||ft.update(r,i,b);(A||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,R.setValue(At,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=h,P.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);A&&(R.setValue(At,"toneMappingExposure",x.toneMappingExposure),y.needsLights&&(N=C,(I=P).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),s&&!0===n.fog&&ot.refreshFogUniforms(P,s),ot.refreshMaterialUniforms(P,n,O,D,g.state.transmissionRenderTarget[t.id]),Bu.upload(At,Zt(y),P,tt));var I,N;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Bu.upload(At,Zt(y),P,tt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(At,"center",r.center);if(R.setValue(At,"modelViewMatrix",r.modelViewMatrix),R.setValue(At,"normalMatrix",r.normalMatrix),R.setValue(At,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];Tt.update(i,b),Tt.bind(i,b)}}return b}(t,e,i,n,r);J.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=rt.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==s&&(u=Math.max(u,s.start*l),p=Math.min(p,(s.start+s.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Et.setup(r,n,o,i,h);let v=gt;if(null!==h&&(f=nt.get(h),v=yt,v.setIndex(f)),r.isMesh)!0===n.wireframe?(J.setLineWidth(n.wireframeLinewidth*q()),v.setMode(At.LINES)):v.setMode(At.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),J.setLineWidth(t*q()),r.isLineSegments?v.setMode(At.LINES):r.isLineLoop?v.setMode(At.LINE_LOOP):v.setMode(At.LINE_STRIP)}else r.isPoints?v.setMode(At.POINTS):r.isSprite&&v.setMode(At.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)ui("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),v.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))v.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=h?nt.get(h).bytesPerElement:1,a=$.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(At,"_gl_DrawID",n),v.render(t[n]/s,e[n])}else if(r.isInstancedMesh)v.renderInstances(u,m,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);v.renderInstances(u,m,e)}else v.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),g=lt.get(i),g.init(e),y.push(g),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),g.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];zt(s,i,t),n.add(s)}else zt(e,i,t),n.add(e)}),g=y.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){$.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==Z.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let kt=null;function Bt(){Ht.stop()}function Gt(){Ht.start()}const Ht=new Jc;function Vt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||B.intersectsSprite(t)){n&&j.setFromMatrixPosition(t.matrixWorld).applyMatrix4(V);const e=st.update(t),r=t.material;r.visible&&f.push(t,e,r,i,j.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||B.intersectsObject(t))){const e=st.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),j.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),j.copy(e.boundingSphere.center)),j.applyMatrix4(t.matrixWorld).applyMatrix4(V)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&f.push(t,e,o,i,j.z,a)}}else r.visible&&f.push(t,e,r,i,j.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Vt(r[t],e,i,n)}function Wt(t,e,i,n){const r=t.opaque,s=t.transmissive,a=t.transparent;g.setupLightsView(i),!0===G&&ct.setGlobalState(x.clippingPlanes,i),n&&J.viewport(A.copy(n)),r.length>0&&Xt(r,e,i),s.length>0&&Xt(s,e,i),a.length>0&&Xt(a,e,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function jt(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[n.id]&&(g.state.transmissionRenderTarget[n.id]=new Ci(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?wt:mt,minFilter:pt,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fi.workingColorSpace}));const s=g.state.transmissionRenderTarget[n.id],a=n.viewport||A;s.setSize(a.z*x.transmissionResolutionScale,a.w*x.transmissionResolutionScale);const o=x.getRenderTarget(),h=x.getActiveCubeFace(),l=x.getActiveMipmapLevel();x.setRenderTarget(s),x.getClearColor(P),L=x.getClearAlpha(),L<1&&x.setClearColor(16777215,.5),x.clear(),Y&&ut.render(i);const c=x.toneMapping;x.toneMapping=0;const d=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),g.setupLightsView(n),!0===G&&ct.setGlobalState(x.clippingPlanes,n),Xt(t,i,n),tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s),!1===Z.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=s.material,l=s.group;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,Yt(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s))}x.setRenderTarget(o,h,l),x.setClearColor(P,L),void 0!==d&&(n.viewport=d),x.toneMapping=c}function Xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,h=s.group;let l=s.material;!0===l.allowOverride&&null!==n&&(l=n),a.layers.test(i.layers)&&Yt(a,e,i,o,l,h)}}function Yt(t,e,i,n,r,s){t.onBeforeRender(x,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(x,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=2):x.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(x,e,i,n,r,s)}function qt(t,e,i){!0!==e.isScene&&(e=X);const n=$.get(t),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=at.getParameters(t,r.state,s,e,i),h=at.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?it:et).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",Ft),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Kt(t,o),c}else o.uniforms=at.getUniforms(t),t.onBeforeCompile(o,x),c=at.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ct.uniform),Kt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Bu.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Kt(t,e){const i=$.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Ht.setAnimationLoop(function(t){kt&&kt(t)}),"undefined"!=typeof self&&Ht.setContext(self),this.setAnimationLoop=function(t){kt=t,Pt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Pt.addEventListener("sessionstart",Bt),Pt.addEventListener("sessionend",Gt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===w)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Pt.enabled&&!0===Pt.isPresenting&&(!0===Pt.cameraAutoUpdate&&Pt.updateCamera(e),e=Pt.getCamera()),!0===t.isScene&&t.onBeforeRender(x,t,e,M),g=lt.get(t,y.length),g.init(e),y.push(g),V.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),B.setFromProjectionMatrix(V,ke,e.reversedDepth),H=this.localClippingEnabled,G=ct.init(this.clippingPlanes,H),f=ht.get(t,v.length),f.init(),v.push(f),!0===Pt.enabled&&!0===Pt.isPresenting){const t=x.xr.getDepthSensingMesh();null!==t&&Vt(t,e,-1/0,x.sortObjects)}Vt(t,e,0,x.sortObjects),f.finish(),!0===x.sortObjects&&f.sort(N,U),Y=!1===Pt.enabled||!1===Pt.isPresenting||!1===Pt.hasDepthSensing(),Y&&ut.addToRenderList(f,t),this.info.render.frame++,!0===G&&ct.beginShadows();const i=g.state.shadowsArray;dt.render(i,t,e),!0===G&&ct.endShadows(),!0===this.info.autoReset&&this.info.reset();const n=f.opaque,r=f.transmissive;if(g.setupLights(),e.isArrayCamera){const i=e.cameras;if(r.length>0)for(let e=0,s=i.length;e<s;e++){jt(n,r,t,i[e])}Y&&ut.render(t);for(let e=0,n=i.length;e<n;e++){const n=i[e];Wt(f,t,n,n.viewport)}}else r.length>0&&jt(n,r,t,e),Y&&ut.render(t),Wt(f,t,e);null!==M&&0===S&&(tt.updateMultisampleRenderTarget(M),tt.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(x,t,e),Et.resetDefaultState(),E=-1,T=null,y.pop(),y.length>0?(g=y[y.length-1],!0===G&&ct.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,v.pop(),f=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,i){const n=$.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),$.get(t.texture).__webglTexture=e,$.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=$.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const Jt=At.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){M=t,b=e,S=i;let n=!0,r=null,s=!1,a=!1;if(t){const o=$.get(t);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(At.FRAMEBUFFER,null),n=!1;else if(void 0===o.__webglFramebuffer)tt.setupRenderTarget(t);else if(o.__hasExternalTextures)tt.rebindTextures(t,$.get(t.texture).__webglTexture,$.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&$.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(t)}}const h=t.texture;(h.isData3DTexture||h.isDataArrayTexture||h.isCompressedArrayTexture)&&(a=!0);const l=$.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(l[e])?l[e][i]:l[e],s=!0):r=t.samples>0&&!1===tt.useMultisampledRTT(t)?$.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,A.copy(t.viewport),C.copy(t.scissor),R=t.scissorTest}else A.copy(F).multiplyScalar(O).floor(),C.copy(z).multiplyScalar(O).floor(),R=k;0!==i&&(r=Jt);if(J.bindFramebuffer(At.FRAMEBUFFER,r)&&n&&J.drawBuffers(t,r),J.viewport(A),J.scissor(C),J.setScissorTest(R),s){const n=$.get(t.texture);At.framebufferTexture2D(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=e;for(let e=0;e<t.textures.length;e++){const r=$.get(t.textures[e]);At.framebufferTextureLayer(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0+e,r.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=$.get(t.texture);At.framebufferTexture2D(At.FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,e.__webglTexture,i)}E=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){J.bindFramebuffer(At.FRAMEBUFFER,h);try{const a=t.textures[o],h=a.format,l=a.type;if(!K.textureFormatReadable(h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&(t.textures.length>1&&At.readBuffer(At.COLOR_ATTACHMENT0+o),At.readPixels(e,i,n,r,xt.convert(h),xt.convert(l),s))}finally{const t=null!==M?$.get(M).__webglFramebuffer:null;J.bindFramebuffer(At.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){J.bindFramebuffer(At.FRAMEBUFFER,h);const a=t.textures[o],l=a.format,c=a.type;if(!K.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=At.createBuffer();At.bindBuffer(At.PIXEL_PACK_BUFFER,d),At.bufferData(At.PIXEL_PACK_BUFFER,s.byteLength,At.STREAM_READ),t.textures.length>1&&At.readBuffer(At.COLOR_ATTACHMENT0+o),At.readPixels(e,i,n,r,xt.convert(l),xt.convert(c),0);const u=null!==M?$.get(M).__webglFramebuffer:null;J.bindFramebuffer(At.FRAMEBUFFER,u);const p=At.fenceSync(At.SYNC_GPU_COMMANDS_COMPLETE,0);return At.flush(),await function(t,e,i){return new Promise(function(n,r){setTimeout(function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}},i)})}(At,p,4),At.bindBuffer(At.PIXEL_PACK_BUFFER,d),At.getBufferSubData(At.PIXEL_PACK_BUFFER,0,s),At.deleteBuffer(d),At.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;tt.setTexture2D(t,0),At.copyTexSubImage2D(At.TEXTURE_2D,i,0,0,a,o,r,s),J.unbindTexture()};const Qt=At.createFramebuffer(),$t=At.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=null){let a,o,h,l,c,d,u,p,m;null===s&&(0!==r?(ui("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const f=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=xt.convert(e.format),v=xt.convert(e.type);let y;e.isData3DTexture?(tt.setTexture3D(e,0),y=At.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(tt.setTexture2DArray(e,0),y=At.TEXTURE_2D_ARRAY):(tt.setTexture2D(e,0),y=At.TEXTURE_2D),At.pixelStorei(At.UNPACK_FLIP_Y_WEBGL,e.flipY),At.pixelStorei(At.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),At.pixelStorei(At.UNPACK_ALIGNMENT,e.unpackAlignment);const _=At.getParameter(At.UNPACK_ROW_LENGTH),x=At.getParameter(At.UNPACK_IMAGE_HEIGHT),w=At.getParameter(At.UNPACK_SKIP_PIXELS),b=At.getParameter(At.UNPACK_SKIP_ROWS),S=At.getParameter(At.UNPACK_SKIP_IMAGES);At.pixelStorei(At.UNPACK_ROW_LENGTH,f.width),At.pixelStorei(At.UNPACK_IMAGE_HEIGHT,f.height),At.pixelStorei(At.UNPACK_SKIP_PIXELS,l),At.pixelStorei(At.UNPACK_SKIP_ROWS,c),At.pixelStorei(At.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=$.get(t),n=$.get(e),f=$.get(i.__renderTarget),g=$.get(n.__renderTarget);J.bindFramebuffer(At.READ_FRAMEBUFFER,f.__webglFramebuffer),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(At.framebufferTextureLayer(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,$.get(t).__webglTexture,r,d+i),At.framebufferTextureLayer(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,$.get(e).__webglTexture,s,m+i)),At.blitFramebuffer(l,c,a,o,u,p,a,o,At.DEPTH_BUFFER_BIT,At.NEAREST);J.bindFramebuffer(At.READ_FRAMEBUFFER,null),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||$.has(t)){const i=$.get(t),n=$.get(e);J.bindFramebuffer(At.READ_FRAMEBUFFER,Qt),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,$t);for(let t=0;t<h;t++)M?At.framebufferTextureLayer(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,i.__webglTexture,r,d+t):At.framebufferTexture2D(At.READ_FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,i.__webglTexture,r),E?At.framebufferTextureLayer(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,n.__webglTexture,s,m+t):At.framebufferTexture2D(At.DRAW_FRAMEBUFFER,At.COLOR_ATTACHMENT0,At.TEXTURE_2D,n.__webglTexture,s),0!==r?At.blitFramebuffer(l,c,a,o,u,p,a,o,At.COLOR_BUFFER_BIT,At.NEAREST):E?At.copyTexSubImage3D(y,s,u,p,m+t,l,c,a,o):At.copyTexSubImage2D(y,s,u,p,l,c,a,o);J.bindFramebuffer(At.READ_FRAMEBUFFER,null),J.bindFramebuffer(At.DRAW_FRAMEBUFFER,null)}else E?t.isDataTexture||t.isData3DTexture?At.texSubImage3D(y,s,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?At.compressedTexSubImage3D(y,s,u,p,m,a,o,h,g,f.data):At.texSubImage3D(y,s,u,p,m,a,o,h,g,v,f):t.isDataTexture?At.texSubImage2D(At.TEXTURE_2D,s,u,p,a,o,g,v,f.data):t.isCompressedTexture?At.compressedTexSubImage2D(At.TEXTURE_2D,s,u,p,f.width,f.height,g,f.data):At.texSubImage2D(At.TEXTURE_2D,s,u,p,a,o,g,v,f);At.pixelStorei(At.UNPACK_ROW_LENGTH,_),At.pixelStorei(At.UNPACK_IMAGE_HEIGHT,x),At.pixelStorei(At.UNPACK_SKIP_PIXELS,w),At.pixelStorei(At.UNPACK_SKIP_ROWS,b),At.pixelStorei(At.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&At.generateMipmap(y),J.unbindTexture()},this.initRenderTarget=function(t){void 0===$.get(t).__webglFramebuffer&&tt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?tt.setTextureCube(t,0):t.isData3DTexture?tt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?tt.setTexture2DArray(t,0):tt.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){b=0,S=0,M=null,J.reset(),Et.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ke}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=fi._getDrawingBufferColorSpace(t),e.unpackColorSpace=fi._getUnpackColorSpace()}}var Op=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:E,AddOperation:2,AdditiveAnimationBlendMode:be,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:At,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Sl,AnimationAction:cc,AnimationClip:Zh,AnimationLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new nl(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=Zh.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends Ge{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=n[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Ql(lc.create(i,h,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),s[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new kh(new Float32Array(2),new Float32Array(2),1,dc),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?Zh.findByName(n,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:we),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const l=new cc(this,s,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,r),l}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?Zh.findByName(i,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Xe(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new lc(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[u];e[u]=s,void 0===a&&(a=new lc(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,h=e[o];if(void 0!==h&&h>=r){const s=r++,l=t[s];e[l.uuid]=h,t[h]=l,e[o]=s,t[s]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[h];e[h]=n,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<r){const a=--r,o=t[a],l=--s,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],r=e[l];e[h]=n,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=r.length,i[t]=n,s.push(t),a.push(e),r.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new lc(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=i,s[i]=o,s.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:class{static convertArray(t,e){return Ih(t,e)}static isTypedArray(t){return Dh(t)}static getKeyframeOrder(t){return Oh(t)}static sortedArray(t,e,i){return Nh(t,e,i)}static flattenJSON(t,e,i,n){Uh(t,e,i,n)}static subclip(t,e,i,n,r=30){return function(t,e,i,n,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],o=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<i||s>=n)){h.push(e.times[t]);for(let i=0;i<o;++i)l.push(e.values[t*o+i])}}0!==h.length&&(e.times=Ih(h,e.times.constructor),e.values=Ih(l,e.values.constructor),a.push(e))}s.tracks=a;let o=1/0;for(let t=0;t<s.tracks.length;++t)o>s.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*o);return s.resetDuration(),s}(t,e,i,n,r)}static makeClipAdditive(t,e=0,i=t,n=30){return function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,s=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const a=t.tracks.find(function(t){return t.name===n.name&&t.ValueTypeName===r});if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let l=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const d=n.times.length-1;let u;if(s<=n.times[0]){const t=o,e=h-o;u=n.values.slice(t,e)}else if(s>=n.times[d]){const t=d*h+o,e=t+h-o;u=n.values.slice(t,e)}else{const t=n.createInterpolant(),e=o,i=h-o;t.evaluate(s),u=t.resultBuffer.slice(e,i)}"quaternion"===r&&(new ti).fromArray(u).normalize().conjugate().toArray(u);const p=a.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===r)ti.multiplyQuaternionsFlat(a.values,e,u,0,a.values,e);else{const t=c-2*l;for(let i=0;i<t;++i)a.values[e+i]-=u[i]}}}return t.blendMode=be,t}(t,e,i,n)}},ArcCurve:ao,ArrayCamera:Bl,ArrowHelper:class extends In{constructor(t=new ei(0,0,1),e=new ei(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===Yc&&(Yc=new _r,Yc.setAttribute("position",new dr([0,0,0,0,1,0],3)),qc=new Ka(.5,1,5,1),qc.translate(0,-.5,0)),this.position.copy(e),this.line=new Ra(Yc,new wa({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Lr(qc,new er({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Xc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Xc,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:J,Audio:Yl,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:Ul,AudioListener:class extends In{constructor(){super(),this.type="AudioListener",this.context=Ul.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Gl}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Hl,Vl,Wl),jl.set(0,0,-1).applyQuaternion(Vl),Xl.set(0,1,0).applyQuaternion(Vl),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Hl.x,t),e.positionY.linearRampToValueAtTime(Hl.y,t),e.positionZ.linearRampToValueAtTime(Hl.z,t),e.forwardX.linearRampToValueAtTime(jl.x,t),e.forwardY.linearRampToValueAtTime(jl.y,t),e.forwardZ.linearRampToValueAtTime(jl.z,t),e.upX.linearRampToValueAtTime(Xl.x,t),e.upY.linearRampToValueAtTime(Xl.y,t),e.upZ.linearRampToValueAtTime(Xl.z,t)}else e.setPosition(Hl.x,Hl.y,Hl.z),e.setOrientation(jl.x,jl.y,jl.z,Xl.x,Xl.y,Xl.z)}},AudioLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new nl(this.manager);function a(e){n?n(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(t){try{const i=t.slice(0);Ul.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,n)}},AxesHelper:class extends Da{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new _r;i.setAttribute("position",new dr(e,3)),i.setAttribute("color",new dr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new wa({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new Jn,r=this.geometry.attributes.color.array;return n.set(t),n.toArray(r,0),n.toArray(r,3),n.set(e),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:xa,Bone:Is,BooleanKeyframeTrack:Hh,Box2:class{constructor(t=new $e(1/0,1/0),e=new $e(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=bc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,bc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Li,Box3Helper:class extends Da{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new _r;n.setIndex(new hr(i,1)),n.setAttribute("position",new dr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new wa({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Dr,BoxHelper:class extends Da{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new _r;r.setIndex(new hr(i,1)),r.setAttribute("position",new hr(n,3)),super(r,new wa({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&jc.setFromObject(this.object),jc.isEmpty())return;const t=jc.min,e=jc.max,i=this.geometry.attributes.position,n=i.array;n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=t.x,n[4]=e.y,n[5]=e.z,n[6]=t.x,n[7]=t.y,n[8]=e.z,n[9]=e.x,n[10]=t.y,n[11]=e.z,n[12]=e.x,n[13]=e.y,n[14]=t.z,n[15]=t.x,n[16]=e.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=e.x,n[22]=t.y,n[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:hr,BufferGeometry:_r,BufferGeometryLoader:Pl,ByteType:ft,Cache:Jh,Camera:kr,CameraHelper:class extends Da{constructor(t){const e=new _r,i=new wa({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new dr(n,3)),e.setAttribute("color",new dr(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const h=new Jn(16755200),l=new Jn(16711680),c=new Jn(43775),d=new Jn(16777215),u=new Jn(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let i,n;if(Vc.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===ke)i=-1,n=1;else{if(this.camera.coordinateSystem!==Be)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}Wc("c",e,t,Vc,0,0,i),Wc("t",e,t,Vc,0,0,n),Wc("n1",e,t,Vc,-1,-1,i),Wc("n2",e,t,Vc,1,-1,i),Wc("n3",e,t,Vc,-1,1,i),Wc("n4",e,t,Vc,1,1,i),Wc("f1",e,t,Vc,-1,-1,n),Wc("f2",e,t,Vc,1,-1,n),Wc("f3",e,t,Vc,-1,1,n),Wc("f4",e,t,Vc,1,1,n),Wc("u1",e,t,Vc,.7,1.1,i),Wc("u2",e,t,Vc,-.7,1.1,i),Wc("u3",e,t,Vc,0,2,i),Wc("cf1",e,t,Vc,-1,0,n),Wc("cf2",e,t,Vc,1,0,n),Wc("cf3",e,t,Vc,0,-1,n),Wc("cf4",e,t,Vc,0,1,n),Wc("cn1",e,t,Vc,-1,0,i),Wc("cn2",e,t,Vc,1,0,i),Wc("cn3",e,t,Vc,0,-1,i),Wc("cn4",e,t,Vc,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:Wa,CapsuleGeometry:Ya,CatmullRomCurve3:po,CineonToneMapping:3,CircleGeometry:qa,ClampToEdgeWrapping:at,Clock:Gl,Color:Jn,ColorKeyframeTrack:Vh,ColorManagement:fi,CompressedArrayTexture:class extends Va{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=at,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Va{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,tt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Va,CompressedTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=[],a=new Va,o=new nl(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let h=0;function l(l){o.load(t[l],function(t){const i=r.parse(t,!0);s[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=dt),a.image=s,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}a.image=s}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=dt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Ka,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:Zc,CubeCamera:jr,CubeReflectionMapping:tt,CubeRefractionMapping:et,CubeTexture:Xr,CubeTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=new Xr;r.colorSpace=Me;const s=new sl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,n)}for(let e=0;e<t.length;++e)o(e);return r}},CubeUVReflectionMapping:rt,CubicBezierCurve:vo,CubicBezierCurve3:yo,CubicInterpolant:zh,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:ro,CurvePath:Eo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:Za,Cylindrical:class{constructor(t=1,e=0,i=0){this.radius=t,this.theta=e,this.y=i}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Pi,DataArrayTexture:Ri,DataTexture:Ds,DataTextureLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Ds,a=new nl(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(t){let i;try{i=r.parse(t)}catch(t){if(void 0===n)return void console.error(t);n(t)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:at,s.wrapT=void 0!==i.wrapT?i.wrapT:at,s.magFilter=void 0!==i.magFilter?i.magFilter:dt,s.minFilter=void 0!==i.minFilter?i.minFilter:dt,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=pt),1===i.mipmapCount&&(s.minFilter=dt),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)},i,n),s}},DataUtils:class{static toHalfFloat(t){return nr(t)}static fromHalfFloat(t){return rr(t)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:$h,DepthFormat:Pt,DepthStencilFormat:Lt,DepthTexture:ja,DetachedBindMode:Q,DirectionalLight:bl,DirectionalLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new _r;n.setAttribute("position",new dr([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new wa({fog:!1,toneMapped:!1});this.lightPlane=new Ra(n,r),this.add(this.lightPlane),n=new _r,n.setAttribute("position",new dr([0,0,0,0,0,1],3)),this.targetLine=new Ra(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),kc.setFromMatrixPosition(this.light.matrixWorld),Bc.setFromMatrixPosition(this.light.target.matrixWorld),Gc.subVectors(Bc,kc),this.lightPlane.lookAt(Bc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Bc),this.targetLine.scale.z=Gc.length()}},DiscreteInterpolant:Bh,DodecahedronGeometry:Qa,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:no,EllipseCurve:so,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:it,EquirectangularRefractionMapping:nt,Euler:fn,EventDispatcher:Ge,ExternalTexture:Xa,ExtrudeGeometry:rh,FileLoader:nl,Float16BufferAttribute:class extends hr{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=rr(this.array[t*this.itemSize]);return this.normalized&&(e=Ke(e,this.array)),e}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize]=nr(e),this}getY(t){let e=rr(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ke(e,this.array)),e}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+1]=nr(e),this}getZ(t){let e=rr(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ke(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+2]=nr(e),this}getW(t){let e=rr(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ke(e,this.array)),e}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+3]=nr(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this.array[t+2]=nr(n),this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array),r=Je(r,this.array)),this.array[t+0]=nr(e),this.array[t+1]=nr(i),this.array[t+2]=nr(n),this.array[t+3]=nr(r),this}},Float32BufferAttribute:dr,FloatType:xt,Fog:Qr,FogExp2:Jr,FramebufferTexture:class extends Ei{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ht,this.minFilter=ht,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:$s,FrustumArray:ia,GLBufferAttribute:class{constructor(t,e,i,n,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.normalized=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ze,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends Da{constructor(t=10,e=10,i=4473924,n=8947848){i=new Jn(i),n=new Jn(n);const r=e/2,s=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=s){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new _r;l.setAttribute("position",new dr(o,3)),l.setAttribute("color",new dr(h,3));super(l,new wa({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:qr,HalfFloatType:wt,HemisphereLight:hl,HemisphereLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new hh(e);n.rotateY(.5*Math.PI),this.material=new er({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new hr(s,3)),this.add(new Lr(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Fc.copy(this.light.color),zc.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?Fc:zc;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Uc.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:ah,ImageBitmapLoader:class extends tl{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Jh.get(`image-bitmap:${t}`);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then(i=>{if(!0!==Ol.has(s))return e&&e(i),r.manager.itemEnd(t),i;n&&n(Ol.get(s)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){return Jh.add(`image-bitmap:${t}`,i),e&&e(i),r.manager.itemEnd(t),i}).catch(function(e){n&&n(e),Ol.set(o,e),Jh.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Jh.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ImageLoader:sl,ImageUtils:_i,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Fs,InstancedBufferGeometry:Rl,InstancedInterleavedBuffer:mc,InstancedMesh:js,Int16BufferAttribute:class extends hr{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends hr{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends hr{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:yt,InterleavedBuffer:ts,InterleavedBufferAttribute:is,Interpolant:Fh,InterpolateDiscrete:fe,InterpolateLinear:ge,InterpolateSmooth:ve,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:Ce,KeyframeTrack:Gh,LOD:ws,LatheGeometry:oh,Layers:gn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:ol,LightProbe:Tl,Line:Ra,Line3:Pc,LineBasicMaterial:wa,LineCurve:_o,LineCurve3:xo,LineDashedMaterial:Lh,LineLoop:Oa,LineSegments:Da,LinearFilter:dt,LinearInterpolant:kh,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:pt,LinearMipmapNearestFilter:ut,LinearSRGBColorSpace:Ee,LinearToneMapping:1,LinearTransfer:Te,Loader:tl,LoaderUtils:Cl,LoadingManager:Qh,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:x,Material:tr,MaterialLoader:Al,MathUtils:Qe,Matrix2:wc,Matrix3:ri,Matrix4:sn,MaxEquation:104,Mesh:Lr,MeshBasicMaterial:er,MeshDepthMaterial:Ch,MeshDistanceMaterial:Rh,MeshLambertMaterial:Ah,MeshMatcapMaterial:Ph,MeshNormalMaterial:Th,MeshPhongMaterial:Mh,MeshPhysicalMaterial:Sh,MeshStandardMaterial:bh,MeshToonMaterial:Eh,MinEquation:103,MirroredRepeatWrapping:ot,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ht,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:ct,NearestMipmapNearestFilter:lt,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:Se,NoToneMapping:0,NormalAnimationBlendMode:we,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:Wh,Object3D:In,ObjectLoader:class extends tl{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?Cl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new nl(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(s,e)},i,n)}async loadAsync(t,e){const i=""===this.path?Cl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new nl(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),s=this.parseImages(t.images,function(){void 0!==e&&e(h)}),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,r,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,n,a,s,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new Ao).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Us).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Pl;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(a);break;default:a.type in _h?s=_h[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new Al;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=Zh.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:hi(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new Qh(e);r=new sl(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=s(r[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ds(i.data,i.width,i.height)))}n[i.uuid]=new wi(t)}else{const t=s(i.url);n[i.uuid]=new wi(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function r(t){if("string"==typeof t){const i=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(r)}return t.data?{data:hi(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new sl(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=s[e],n=await r(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Ds(n.data,n.width,n.height)))}i[n.uuid]=new wi(t)}else{const t=await r(n.url);i[n.uuid]=new wi(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let h;Array.isArray(o)?(h=new Xr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new Ds:new Ei,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.mapping&&(h.mapping=i(s.mapping,Ll)),void 0!==s.channel&&(h.channel=s.channel),void 0!==s.offset&&h.offset.fromArray(s.offset),void 0!==s.repeat&&h.repeat.fromArray(s.repeat),void 0!==s.center&&h.center.fromArray(s.center),void 0!==s.rotation&&(h.rotation=s.rotation),void 0!==s.wrap&&(h.wrapS=i(s.wrap[0],Il),h.wrapT=i(s.wrap[1],Il)),void 0!==s.format&&(h.format=s.format),void 0!==s.internalFormat&&(h.internalFormat=s.internalFormat),void 0!==s.type&&(h.type=s.type),void 0!==s.colorSpace&&(h.colorSpace=s.colorSpace),void 0!==s.minFilter&&(h.minFilter=i(s.minFilter,Dl)),void 0!==s.magFilter&&(h.magFilter=i(s.magFilter,Dl)),void 0!==s.anisotropy&&(h.anisotropy=s.anisotropy),void 0!==s.flipY&&(h.flipY=s.flipY),void 0!==s.generateMipmaps&&(h.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(h.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(h.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(h.compareFunction=s.compareFunction),void 0!==s.userData&&(h.userData=s.userData),n[s.uuid]=h}return n}parseObject(t,e,i,n,r){let s,a,o;function h(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":s=new $r,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new Jn(t.background):s.background=c(t.background)),void 0!==t.environment&&(s.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new Qr(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new Jr(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new Vr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new xl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new Sl(t.color,t.intensity);break;case"DirectionalLight":s=new bl(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new _l(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new Ml(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new ml(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new hl(t.color,t.groundColor,t.intensity);break;case"LightProbe":s=(new Tl).fromJSON(t);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),s=new Ls(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),s=new Lr(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;s=new js(a,o,e),s.instanceMatrix=new Fs(new Float32Array(i.array),16),void 0!==n&&(s.instanceColor=new Fs(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),s=new xa(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._geometryInfo=t.geometryInfo.map(t=>{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Li).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new Zi).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),s._instanceInfo=t.instanceInfo,s._availableInstanceIds=t._availableInstanceIds,s._availableGeometryIds=t._availableGeometryIds,s._nextIndexStart=t.nextIndexStart,s._nextVertexStart=t.nextVertexStart,s._geometryCount=t.geometryCount,s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._matricesTexture=c(t.matricesTexture.uuid),s._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(s.boundingSphere=(new Zi).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(s.boundingBox=(new Li).fromJSON(t.boundingBox));break;case"LOD":s=new ws;break;case"Line":s=new Ra(h(t.geometry),l(t.material));break;case"LineLoop":s=new Oa(h(t.geometry),l(t.material));break;case"LineSegments":s=new Da(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":s=new Ba(h(t.geometry),l(t.material));break;case"Sprite":s=new vs(l(t.material));break;case"Group":s=new qr;break;case"Bone":s=new Is;break;default:s=new In}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,i,n,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];s.animations.push(r[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new In}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:hh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:D,OneMinusSrcColorFactor:203,OrthographicCamera:xl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Sd,Path:To,PerspectiveCamera:Vr,Plane:Zs,PlaneGeometry:lh,PlaneHelper:class extends Ra{constructor(t,e=1,i=16776960){const n=i,r=new _r;r.setAttribute("position",new dr([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new wa({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new _r;s.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Lr(s,new er({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:_l,PointLightHelper:class extends Lr{constructor(t,e,i){super(new uh(e,4,2),new er({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:Ba,PointsMaterial:Na,PolarGridHelper:class extends Da{constructor(t=10,e=16,i=8,n=64,r=4473924,s=8947848){r=new Jn(r),s=new Jn(s);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?r:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?r:s,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l;a.push(i,0,r),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l,a.push(i,0,r),o.push(h.r,h.g,h.b)}}const h=new _r;h.setAttribute("position",new dr(a,3)),h.setAttribute("color",new dr(o,3));super(h,new wa({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Ja,PositionalAudio:class extends Yl{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(ql,Zl,Kl),Jl.set(0,0,1).applyQuaternion(Zl);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(ql.x,t),e.positionY.linearRampToValueAtTime(ql.y,t),e.positionZ.linearRampToValueAtTime(ql.z,t),e.orientationX.linearRampToValueAtTime(Jl.x,t),e.orientationY.linearRampToValueAtTime(Jl.y,t),e.orientationZ.linearRampToValueAtTime(Jl.z,t)}else e.setPosition(ql.x,ql.y,ql.z),e.setOrientation(Jl.x,Jl.y,Jl.z)}},PropertyBinding:lc,PropertyMixer:Ql,QuadraticBezierCurve:wo,QuadraticBezierCurve3:bo,Quaternion:ti,QuaternionKeyframeTrack:Xh,QuaternionLinearInterpolant:jh,RED_GREEN_RGTC2_Format:pe,RED_RGTC1_Format:de,REVISION:_,RGBADepthPacking:3201,RGBAFormat:Rt,RGBAIntegerFormat:Ut,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ie,RGBA_ASTC_10x6_Format:ne,RGBA_ASTC_10x8_Format:re,RGBA_ASTC_12x10_Format:ae,RGBA_ASTC_12x12_Format:oe,RGBA_ASTC_4x4_Format:qt,RGBA_ASTC_5x4_Format:Zt,RGBA_ASTC_5x5_Format:Kt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Qt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:te,RGBA_ASTC_8x8_Format:ee,RGBA_BPTC_Format:he,RGBA_ETC2_EAC_Format:Yt,RGBA_PVRTC_2BPPV1_Format:Wt,RGBA_PVRTC_4BPPV1_Format:Vt,RGBA_S3TC_DXT1_Format:zt,RGBA_S3TC_DXT3_Format:kt,RGBA_S3TC_DXT5_Format:Bt,RGBDepthPacking:3202,RGBFormat:Ct,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:ce,RGB_ETC1_Format:jt,RGB_ETC2_Format:Xt,RGB_PVRTC_2BPPV1_Format:Ht,RGB_PVRTC_4BPPV1_Format:Gt,RGB_S3TC_DXT1_Format:Ft,RGDepthPacking:3203,RGFormat:Ot,RGIntegerFormat:Nt,RawShaderMaterial:wh,Ray:rn,Raycaster:gc,RectAreaLight:Ml,RedFormat:It,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Ai,RenderTarget3D:class extends Ai{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Pi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:st,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:ch,SIGNED_RED_GREEN_RGTC2_Format:me,SIGNED_RED_RGTC1_Format:ue,SRGBColorSpace:Me,SRGBTransfer:Ae,Scene:$r,ShaderChunk:$c,ShaderLib:ed,ShaderMaterial:zr,ShadowMaterial:xh,Shape:Ao,ShapeGeometry:dh,ShapePath:class{constructor(){this.type="ShapePath",this.color=new Jn,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new To,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],a=e[s],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[s],o=-o,a=e[r],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=eh.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,a;const o=[];if(1===n.length)return s=n[0],a=new Ao,a.curves=s.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)s=n[e],d=s.getPoints(),r=i(d),r=t?!r:r,r?(!h&&c[m]&&m++,c[m]={s:new Ao,p:d},c[m].s.curves=s.curves,h&&m++,p[m]=[]):p[m].push({h:s,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new Ao;r.curves=n.curves,e.push(r)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,r=c.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(n!==r&&i++,o?(o=!1,l[r].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:eh,ShortType:gt,Skeleton:Us,SkeletonHelper:class extends Da{constructor(t){const e=Nc(t),i=new _r,n=[],r=[];for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new dr(n,3)),i.setAttribute("color",new dr(r,3));super(i,new wa({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const s=new Jn(255),a=new Jn(65280);this.setColors(s,a)}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Oc.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(Dc.multiplyMatrices(Oc,r.matrixWorld),Ic.setFromMatrixPosition(Dc),n.setXYZ(i,Ic.x,Ic.y,Ic.z),Dc.multiplyMatrices(Oc,r.parent.matrixWorld),Ic.setFromMatrixPosition(Dc),n.setXYZ(i+1,Ic.x,Ic.y,Ic.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,t.r,t.g,t.b),i.setXYZ(n+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ls,Source:wi,Sphere:Zi,SphereGeometry:uh,Spherical:xc,SphericalHarmonics3:El,SplineCurve:So,SpotLight:ml,SpotLightHelper:class extends In{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new _r,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new dr(n,3));const r=new wa({fog:!1,toneMapped:!1});this.cone=new Da(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Lc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:vs,SpriteMaterial:ns,SrcAlphaFactor:I,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Fe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Vr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Vr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,kl.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,r=e.near*Math.tan(We*e.fov*.5)/e.zoom;let s,a;zl.elements[12]=-i,Fl.elements[12]=i,s=-r*e.aspect+n,a=r*e.aspect+n,kl.elements[0]=2*e.near/(a-s),kl.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(kl),s=-r*e.aspect-n,a=r*e.aspect-n,kl.elements[0]=2*e.near/(a-s),kl.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(kl)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(zl),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Fl)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Yh,SubtractEquation:101,SubtractiveBlending:3,TOUCH:w,TangentSpaceNormalMap:0,TetrahedronGeometry:ph,Texture:Ei,TextureLoader:al,TextureUtils:class{static contain(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,n){return Kc(t,e,i,n)}},Timer:class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=_c.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}},TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:mh,TorusKnotGeometry:fh,Triangle:Xn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:gh,UVMapping:$,Uint16BufferAttribute:lr,Uint32BufferAttribute:cr,Uint8BufferAttribute:class extends hr{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends hr{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:uc,UniformsGroup:class extends Ge{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:pc++}),this.name="",this.usage=Fe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:td,UniformsUtils:Fr,UnsignedByteType:mt,UnsignedInt101111Type:Tt,UnsignedInt248Type:Mt,UnsignedInt5999Type:Et,UnsignedIntType:_t,UnsignedShort4444Type:bt,UnsignedShort5551Type:St,UnsignedShortType:vt,VSMShadowMap:3,Vector2:$e,Vector3:ei,Vector4:Ti,VectorKeyframeTrack:qh,VideoFrameTexture:class extends Ha{constructor(t,e,i,n,r,s,a,o){super({},t,e,i,n,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:Ha,WebGL3DRenderTarget:class extends Ci{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Pi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Ci{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ri(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:ke,WebGLCubeRenderTarget:Yr,WebGLRenderTarget:Ci,WebGLRenderer:Dp,WebGLUtils:Tp,WebGPUCoordinateSystem:Be,WebXRController:Kr,WireframeGeometry:vh,WrapAroundEnding:xe,ZeroCurvatureEnding:ye,ZeroFactor:200,ZeroSlopeEnding:_e,ZeroStencilOp:0,createCanvasElement:ci});const Np=new gc,Up=new ei,Fp=new ei,zp=new ti,kp={X:new ei(1,0,0),Y:new ei(0,1,0),Z:new ei(0,0,1)},Bp={type:"change"},Gp={type:"mouseDown",mode:null},Hp={type:"mouseUp",mode:null},Vp={type:"objectChange"};class Wp extends Zc{constructor(t,e=null){super(void 0,e);const i=new dm(this);this._root=i;const n=new um;this._gizmo=n,i.add(n);const r=new pm;this._plane=r,i.add(r);const s=this;function a(t,e){let i=e;Object.defineProperty(s,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,r[t]=e,n[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Bp))}}),s[t]=e,r[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new ei,h=new ei,l=new ti,c=new ti,d=new ei,u=new ti,p=new ei,m=new ei,f=new ei,g=new ei;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new ei,this._startNorm=new ei,this._endNorm=new ei,this._cameraScale=new ei,this._parentPosition=new ei,this._parentQuaternion=new ti,this._parentQuaternionInv=new ti,this._parentScale=new ei,this._worldScaleStart=new ei,this._worldQuaternionInv=new ti,this._worldScale=new ei,this._positionStart=new ei,this._quaternionStart=new ti,this._scaleStart=new ei,this._getPointer=jp.bind(this),this._onPointerDown=Yp.bind(this),this._onPointerHover=Xp.bind(this),this._onPointerMove=qp.bind(this),this._onPointerUp=Zp.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&Np.setFromCamera(t,this.camera);const e=Kp(this._gizmo.picker[this.mode],Np);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&Np.setFromCamera(t,this.camera);const e=Kp(this._plane,Np,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,Gp.mode=this.mode,this.dispatchEvent(Gp)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&Np.setFromCamera(t,this.camera);const s=Kp(this._plane,Np,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(zp.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(Up.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Up.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),Fp.set(t,t,t)}else Up.copy(this.pointStart),Fp.copy(this.pointEnd),Up.applyQuaternion(this._worldQuaternionInv),Fp.applyQuaternion(this._worldQuaternionInv),Fp.divide(Up),-1===e.search("X")&&(Fp.x=1),-1===e.search("Y")&&(Fp.y=1),-1===e.search("Z")&&(Fp.z=1);n.scale.copy(this._scaleStart).multiply(Fp),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(Up.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Up.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(kp[e]),Up.copy(kp[e]),"local"===r&&Up.applyQuaternion(this.worldQuaternion),Up.cross(this.eye),0===Up.length()?i=!0:this.rotationAngle=this._offset.dot(Up.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(zp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(zp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Bp),this.dispatchEvent(Vp)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(Hp.mode=this.mode,this.dispatchEvent(Hp)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Bp),this.dispatchEvent(Vp),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Np}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,i,n){const r=this._gizmo.materialLib;r.xAxis.color.set(t),r.yAxis.color.set(e),r.zAxis.color.set(i),r.active.color.set(n),r.xAxisTransparent.color.set(t),r.yAxisTransparent.color.set(e),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(n),r.xAxis._color&&r.xAxis._color.set(t),r.yAxis._color&&r.yAxis._color.set(e),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(n),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(t),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(e),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(n)}}function jp(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Xp(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Yp(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function qp(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Zp(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Kp(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Jp=new fn,Qp=new ei(0,1,0),$p=new ei(0,0,0),tm=new sn,em=new ti,im=new ti,nm=new ei,rm=new sn,sm=new ei(1,0,0),am=new ei(0,1,0),om=new ei(0,0,1),hm=new ei,lm=new ei,cm=new ei;class dm extends In{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class um extends In{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new er({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new wa({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;const u=t.clone();u.color.setHex(16776960);const p=t.clone();p.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:s,zAxis:a,active:u,xAxisTransparent:o,yAxisTransparent:h,zAxisTransparent:l,activeTransparent:d};const m=new Za(0,.04,.1,12);m.translate(0,.05,0);const f=new Dr(.08,.08,.08);f.translate(0,.04,0);const g=new _r;g.setAttribute("position",new dr([0,0,0,1,0,0],3));const v=new Za(.0075,.0075,.5,3);function y(t,e){const i=new mh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}v.translate(0,.25,0);const _={X:[[new Lr(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(m,r),[-.5,0,0],[0,0,Math.PI/2]],[new Lr(v,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Lr(m,s),[0,.5,0]],[new Lr(m,s),[0,-.5,0],[Math.PI,0,0]],[new Lr(v,s)]],Z:[[new Lr(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Lr(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Lr(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new Lr(new hh(.1,0),c),[0,0,0]]],XY:[[new Lr(new Dr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Lr(new Dr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new Lr(new Za(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Lr(new Za(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(new Za(.2,0,.6,4),i),[0,.3,0]],[new Lr(new Za(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Lr(new Za(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Lr(new Za(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new hh(.2,0),i)]],XY:[[new Lr(new Dr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Lr(new Dr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new Lr(new hh(.01,2),n),null,null,null,"helper"]],END:[[new Lr(new hh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Ra(function(){const t=new _r;return t.setAttribute("position",new dr([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ra(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ra(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},b={XYZE:[[new Lr(y(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new Lr(y(.5,.5),r)]],Y:[[new Lr(y(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Lr(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Lr(y(.75,1),d),null,[0,Math.PI/2,0]]]},S={AXIS:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Lr(new uh(.25,10,8),i)]],X:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Lr(new mh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Lr(new mh(.75,.1,2,24),i)]]},E={X:[[new Lr(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(v,r),[0,0,0],[0,0,-Math.PI/2]],[new Lr(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(f,s),[0,.5,0]],[new Lr(v,s)],[new Lr(f,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Lr(f,a),[0,0,.5],[Math.PI/2,0,0]],[new Lr(v,a),[0,0,0],[Math.PI/2,0,0]],[new Lr(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Lr(new Dr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Lr(new Dr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new Dr(.1,.1,.1),c)]]},T={X:[[new Lr(new Za(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Lr(new Za(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Lr(new Za(.2,0,.6,4),i),[0,.3,0]],[new Lr(new Za(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Lr(new Za(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Lr(new Za(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Lr(new Dr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Lr(new Dr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Lr(new Dr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Lr(new Dr(.2,.2,.2),i),[0,0,0]]]},A={X:[[new Ra(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ra(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ra(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new In;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];r.name=i,r.tag=h,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const l=r.geometry.clone();l.applyMatrix4(r.matrix),r.geometry=l,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(_)),this.add(this.gizmo.rotate=C(b)),this.add(this.gizmo.scale=C(E)),this.add(this.picker.translate=C(x)),this.add(this.picker.rotate=C(M)),this.add(this.picker.scale=C(T)),this.add(this.helper.translate=C(w)),this.add(this.helper.rotate=C(S)),this.add(this.helper.scale=C(A)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:im;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(em.copy(e),Qp.copy(this.eye).applyQuaternion(zp.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(tm.lookAt(this.eye,$p,am)),"X"===n.name&&(zp.setFromAxisAngle(sm,Math.atan2(-Qp.y,Qp.z)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)),"Y"===n.name&&(zp.setFromAxisAngle(am,Math.atan2(Qp.x,Qp.z)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)),"Z"===n.name&&(zp.setFromAxisAngle(om,Math.atan2(Qp.y,Qp.x)),zp.multiplyQuaternions(em,zp),n.quaternion.copy(zp)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(t){return n.name===t}))&&(n.material.color.copy(this.materialLib.active.color),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(zp.setFromEuler(Jp.set(0,0,0)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(sm).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(zp.setFromEuler(Jp.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(am).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(zp.setFromEuler(Jp.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(zp),Math.abs(Qp.copy(om).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(zp.setFromEuler(Jp.set(0,Math.PI/2,0)),Qp.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(tm.lookAt($p,Qp,am)),n.quaternion.multiply(zp),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),Up.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Up.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(Up),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class pm extends Lr{constructor(){super(new lh(1e5,1e5,2,2),new er({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),hm.copy(sm).applyQuaternion("local"===e?this.worldQuaternion:im),lm.copy(am).applyQuaternion("local"===e?this.worldQuaternion:im),cm.copy(om).applyQuaternion("local"===e?this.worldQuaternion:im),Qp.copy(lm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Qp.copy(this.eye).cross(hm),nm.copy(hm).cross(Qp);break;case"Y":Qp.copy(this.eye).cross(lm),nm.copy(lm).cross(Qp);break;case"Z":Qp.copy(this.eye).cross(cm),nm.copy(cm).cross(Qp);break;case"XY":nm.copy(cm);break;case"YZ":nm.copy(hm);break;case"XZ":Qp.copy(cm),nm.copy(lm);break;case"XYZ":case"E":nm.set(0,0,0)}break;default:nm.set(0,0,0)}0===nm.length()?this.quaternion.copy(this.cameraQuaternion):(rm.lookAt(Up.set(0,0,0),nm,Qp),this.quaternion.setFromRotationMatrix(rm)),super.updateMatrixWorld(t)}}class mm extends Ra{constructor(t,e=1,i=16776960,n=new ei){const r=new _r;r.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new wa({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const s=new _r;s.setAttribute("position",new dr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Lr(s,new er({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const fm={type:"change"},gm={type:"start"},vm={type:"end"},ym=-1,_m=0,xm=1,wm=2,bm=3,Sm=4,Mm=5,Em=6;class Tm extends Ge{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new ei,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.DOLLY,RIGHT:x.PAN},this.touches={ONE:w.ROTATE,TWO:w.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(fm),i.update(),i.state=ym},this.update=function(){const e=new ei,a=(new ti).setFromUnitVectors(t.up,new ei(0,1,0)),h=a.clone().invert(),l=new ei,c=new ti,d=new ei,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),r.setFromVector3(e),i.autoRotate&&i.state===ym&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(r.theta+=s.theta*i.dampingFactor,r.phi+=s.phi*i.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),r.theta=p<=m?Math.max(p,Math.min(m,r.theta)):r.theta>(p+m)/2?Math.max(p,r.theta):Math.min(m,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=i.scale,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(r),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(s.theta*=1-i.dampingFactor,s.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(s.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent(fm),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",R),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",T),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",E),i.domElement.removeEventListener("pointerup",T),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=ym;const n=1e-6,r=new xc,s=new xc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){s.theta-=t}function h(t){s.phi-=t}i.scale=1,i.panOffset=new ei,i.zoomChanged=!1,i.rotateStart=new $e,i.rotateEnd=new $e,i.rotateDelta=new $e,i.panStart=new $e,i.panEnd=new $e,i.panDelta=new $e,i.dollyStart=new $e,i.dollyEnd=new $e,i.dollyDelta=new $e,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new ei;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new ei;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new ei;return function(e,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const s=i.object.position;t.copy(s).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/r.clientHeight,i.object.matrix),c(2*n*a/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function y(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function _(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.rotateEnd.set(n,r)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function b(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.panEnd.set(n,r)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function S(t){const e=L(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);i.dollyEnd.set(0,s),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",E),i.domElement.addEventListener("pointerup",T)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(P(t),i.pointers.length){case 1:switch(i.touches.ONE){case w.ROTATE:if(!1===i.enableRotate)return;g(),i.state=bm;break;case w.PAN:if(!1===i.enablePan)return;v(),i.state=Sm;break;default:i.state=ym}break;case 2:switch(i.touches.TWO){case w.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&y(),i.enablePan&&v(),i.state=Mm;break;case w.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&y(),i.enableRotate&&g(),i.state=Em;break;default:i.state=ym}break;default:i.state=ym}i.state!==ym&&i.dispatchEvent(gm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case x.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=xm;break;case x.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=wm}else{if(!1===i.enableRotate)return;m(t),i.state=_m}break;case x.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=_m}else{if(!1===i.enablePan)return;f(t),i.state=wm}break;default:i.state=ym}i.state!==ym&&i.dispatchEvent(gm)}(t))}function E(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(P(t),i.state){case bm:if(!1===i.enableRotate)return;_(t),i.update();break;case Sm:if(!1===i.enablePan)return;b(t),i.update();break;case Mm:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&S(t),i.enablePan&&b(t)}(t),i.update();break;case Em:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&S(t),i.enableRotate&&_(t)}(t),i.update();break;default:i.state=ym}}(t):function(t){switch(i.state){case _m:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case xm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case wm:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function T(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",E),i.domElement.removeEventListener("pointerup",T)),i.dispatchEvent(vm),i.state=ym}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===ym&&(t.preventDefault(),i.dispatchEvent(gm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=xm,i.dispatchEvent(fm),i.state=ym)}(t),i.dispatchEvent(vm))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function R(t){!1!==i.enabled&&t.preventDefault()}function P(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new $e,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function L(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",R),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",T),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class Am{constructor(t){this.updateControls=()=>{this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.updateControlsCamera=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.update()},this.optionsChange=({data:t})=>{this.orbit.zoomSpeed=Math.abs(this.orbit.zoomSpeed)*(t.reverseZoomWheel?-1:1)},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case _m:case bm:this.viewer.emitEvent({type:"orbit"});break;case wm:case Sm:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case xm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.viewer.emitEvent({type:"changecamera"}),this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new Tm(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.PAN,RIGHT:x.PAN},this.orbit.touches={ONE:w.ROTATE,TWO:w.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.addEventListener("clear",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls()}initialize(){}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.removeEventListener("clear",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class Cm extends Am{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new ei).length(),this.viewer.update()},this.updateTransformCamera=()=>{this.transform.camera=this.viewer.camera},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new ei).length(),r=t.extents.getCenter(new ei),s=-r.dot(e);this.plane=new Zs(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new mm(this.plane,n,i,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new In,this.planeCenter.position.copy(t.extents.getCenter(new ei)),this.viewer.helpers.add(this.planeCenter),this.transform=new Wp(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.addEventListener("explode",this.updatePlaneSize),this.viewer.addEventListener("show",this.updatePlaneSize),this.viewer.addEventListener("showall",this.updatePlaneSize),this.viewer.addEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.removeEventListener("explode",this.updatePlaneSize),this.viewer.removeEventListener("show",this.updatePlaneSize),this.viewer.removeEventListener("showall",this.updatePlaneSize),this.viewer.removeEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class Rm extends Cm{constructor(t){super(t,new ei(1,0,0),16711680)}}class Pm extends Cm{constructor(t){super(t,new ei(0,1,0),65280)}}class Lm extends Cm{constructor(t){super(t,new ei(0,0,1),255)}}const Im={Meters:{name:"Meters",symbol:"m",scale:1},Centimeters:{name:"Centimeters",symbol:"cm",scale:.01},Millimeters:{name:"Millimeters",symbol:"mm",scale:.001},Feet:{name:"Feet",symbol:"ft",scale:.3048},Inches:{name:"Inches",symbol:"in",scale:.0254},Yards:{name:"Yards",symbol:"yd",scale:.9144},Kilometers:{name:"Kilometers",symbol:"km",scale:1e3},Miles:{name:"Miles",symbol:"mi",scale:1609.344},Micrometers:{name:"Micrometers",symbol:"µm",scale:1e-6},Mils:{name:"Mils",symbol:"mil",scale:254e-7},MicroInches:{name:"Micro-inches",symbol:"µin",scale:2.54e-8},Default:{name:"File units",symbol:"",scale:1}},Dm={Default:{name:"",symbol:"",scale:1}};function Om(t,e,i){return i*(1/(Dm[t]||Dm.Default).scale)*((Dm[e]||Dm.Default).scale||1)}function Nm(t,e,i){let n=t.toFixed(e);return"Auto"===i&&(n=n.replace(/\.0+$/,"").replace(/\.$/,"")),+n!==t&&(n="~ "+n),n}function Um(t,e,i=2){let n;return n="Auto"===i?function(t){const e=Math.abs(t);return e>=1e3?0:e>=10?1:e>=.1?2:e>=.001?3:e>0?Math.floor(-Math.log10(e))+1:2}(t):Number.isFinite(i)?i:parseFloat(i),Number.isFinite(n)?n<0?n=0:n>10&&(n=10):n=2,Dm[e]?Nm(t,n,i)+" "+Dm[e].symbol:e?Nm(t,n,i)+" "+e:Nm(t,n,i)}Object.keys(Im).forEach(t=>Dm[t]=Im[t]),Object.keys(Im).forEach(t=>Dm[Im[t].symbol]=Im[t]);const Fm=new ei,zm=new ei,km=new ei,Bm=new Pc,Gm=new ei,Hm=new ei;class Vm{constructor(t,e,i){this.camera=t,this.renderer=e,this.canvas=i,this.threshold=1e-4,this.raycaster=new gc,this.detectRadiusInPixels=this.isMobile()?50:10,this.edgesCache=new WeakMap}isMobile(){return"undefined"!=typeof navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,r=-(t.y-i.top)/i.height*2+1,s=new $e(n,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:this.threshold},Line2:{threshold:this.threshold},LOD:{},Points:{threshold:this.threshold},Sprite:{}};let a=this.raycaster.intersectObjects(e,!1);return(this.renderer.clippingPlanes||[]).forEach(t=>{a=a.filter(e=>t.distanceToPoint(e.point)>=0)}),a}getDetectRadius(t){const e=this.camera;if(e.isOrthographicCamera){const t=(e.top-e.bottom)/e.zoom/this.canvas.height;return this.detectRadiusInPixels*t}if(e.isPerspectiveCamera){const i=e.position.distanceTo(t),n=2*Math.tan(Qe.degToRad(.5*e.fov))*i/this.canvas.height;return this.detectRadiusInPixels*n}return.1}getSnapPoint(t,e){const i=this.getPointerIntersects(t,e);if(0===i.length)return;const n=i[0].object,r=i[0].point,s=n.worldToLocal(r.clone());let a,o=this.getDetectRadius(r);const h=n.geometry,l=h.attributes.position.array;for(let t=0;t<l.length;t+=3){Fm.set(l[t],l[t+1],l[t+2]);const e=Fm.distanceTo(s);e<o&&(o=e,a=Fm.clone())}if(a)return n.localToWorld(a);let c=this.edgesCache.get(h);c||(c=new no(h),this.edgesCache.set(h,c));const d=c.attributes.position.array;for(let t=0;t<d.length;t+=6){zm.set(d[t],d[t+1],d[t+2]),km.set(d[t+3],d[t+4],d[t+5]),Bm.set(zm,km),Bm.getCenter(Gm);const e=Gm.distanceTo(s);if(e<o){o=e,a=Gm.clone();continue}Bm.closestPointToPoint(s,!0,Hm);const i=Hm.distanceTo(s);i<o&&(o=i,a=Hm.clone())}return a?n.localToWorld(a):r.clone()}}const Wm=new $e;class jm extends Am{constructor(t){super(t),this.scale=1,this.units="",this.precision=2,this.onPointerDown=t=>{if(0!==t.button)return;const e=this.snapper.getMousePosition(t,Wm);this.line.startPoint=this.snapper.getSnapPoint(e,this.objects),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint},this.onPointerMove=t=>{if(this.orbit.enabled&&-1!==this.orbit.state)return;const e=this.snapper.getMousePosition(t,Wm),i=this.snapper.getSnapPoint(e,this.objects);i&&this.line.endPoint&&i.equals(this.line.endPoint)||(this.line.endPoint=i,this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>0?(this.line=new qm(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.clearOverlay=()=>{this.overlay.clear(),this.line=new qm(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)},this.renderOverlay=()=>{this.overlay.render()},this.updateObjects=()=>{this.objects.length=0,this.viewer.models.forEach(t=>{t.getVisibleObjects().forEach(t=>this.objects.push(t))})},this.updateSnapperCamera=()=>{this.snapper.camera=this.viewer.camera,this.overlay.camera=this.viewer.camera},this.updateUnits=()=>{var t,e;const i=this.viewer.models[0],n=null!==(t=this.viewer.options.rulerUnit)&&void 0!==t?t:"Default",r=null!==(e=this.viewer.options.rulerPrecision)&&void 0!==e?e:"Default";"Default"===n?(this.scale=i.getUnitScale(),this.units=i.getUnitString()):(this.scale=Om(i.getUnits(),n,1),this.units=n),this.precision="Default"===r?i.getPrecision():r,this.overlay.updateLineUnits(this.scale,this.units,this.precision)},this.overlay=new Xm(t.camera,t.canvas),this.overlay.attach(),this.line=new qm(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line),this.snapper=new Vm(t.camera,t.renderer,t.canvas),this.snapper.threshold=t.extents.getSize(new ei).length()/1e4,this.objects=[],this.updateObjects(),this.updateUnits(),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateObjects),this.viewer.addEventListener("isolate",this.updateObjects),this.viewer.addEventListener("show",this.updateObjects),this.viewer.addEventListener("showall",this.updateObjects),this.viewer.addEventListener("changecameramode",this.updateSnapperCamera),this.viewer.addEventListener("optionschange",this.updateUnits)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateObjects),this.viewer.removeEventListener("isolate",this.updateObjects),this.viewer.removeEventListener("show",this.updateObjects),this.viewer.removeEventListener("showall",this.updateObjects),this.viewer.removeEventListener("changecameramode",this.updateSnapperCamera),this.viewer.removeEventListener("optionschange",this.updateUnits),this.objects.length=0,this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class Xm{constructor(t,e){this.lines=[],this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this.canvas;i&&n&&(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.width=`${i}px`,this.container.style.height=`${n}px`)},this.camera=t,this.canvas=e,this.projector=new af(t,e),this.resizeObserver=new ResizeObserver(this.resizeContainer)}dispose(){this.clear()}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.position="absolute",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement&&(this.canvas.parentElement.appendChild(this.container),this.resizeObserver.observe(this.canvas))}detach(){this.resizeObserver.disconnect(),this.container.remove(),this.container=void 0}clear(){this.lines.forEach(t=>t.dispose()),this.lines.length=0}render(){this.projector.setFromCamera(this.camera),this.lines.forEach(t=>t.render())}update(){this.lines.forEach(t=>t.update())}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter(e=>e!==t)}updateLineUnits(t,e,i){this.lines.forEach(n=>{n.scale=t,n.units=e,n.precision=i})}}const Ym=new ei;class qm{constructor(t,e,i,n){this.id=Qe.generateUUID(),this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.scale=e,this.units=i,this.precision=n,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove(),this.elementStartPoint=void 0,this.elementEndPoint=void 0,this.elementLine=void 0,this.elementLabel=void 0}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const r=i.angle(),s=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){Ym.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(Ym),n=this.getDistance();this.elementLabel.style.display=i&&n>0?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=Um(n,this.units,this.precision)}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let Zm,Km;const Jm=new sn,Qm=new sn,$m=new ei,tf=new Ti,ef=new Ti,nf=new $e,rf=new $e,sf=new $e;class af{constructor(t,e){this.camera=t,this.canvas=e}setFromCamera(t){this.camera=t,this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();Zm=t.width/2,Km=t.height/2,Jm.copy(this.camera.matrixWorldInverse),Qm.multiplyMatrices(this.camera.projectionMatrix,Jm)}projectPoint(t){$m.copy(t).applyMatrix4(Qm);const e=$m.z>=-1&&$m.z<=1;return nf.x=($m.x+1)*Zm,nf.y=(1-$m.y)*Km,{point:nf,visible:e}}projectLine(t,e){let i;tf.copy(t).applyMatrix4(Qm),ef.copy(e).applyMatrix4(Qm);const n=tf.z+tf.w,r=ef.z+ef.w,s=-tf.z+tf.w,a=-ef.z+ef.w;if(n>=0&&r>=0&&s>=0&&a>=0)i=!0;else if(n<0&&r<0||s<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-r)):r<0&&(e=Math.min(e,n/(n-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),i=e>=t,i&&(tf.lerp(ef,t),ef.lerp(tf,1-e))}return tf.multiplyScalar(1/tf.w),ef.multiplyScalar(1/ef.w),rf.x=(tf.x+1)*Zm,rf.y=(1-tf.y)*Km,sf.x=(ef.x+1)*Zm,sf.y=(1-ef.y)*Km,{point1:rf,point2:sf,visible:i}}}class of extends Am{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.PAN,MIDDLE:x.PAN,RIGHT:x.PAN}}}class hf extends Zc{constructor(t,e,i){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.LOOK_SPEED=.1,this.WALK_SPEED_DELIMITER=4,this.WHEEL_SPEED_DELIMITER=15e3,this.movementSpeed=.1,this.multiplier=3,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.camera=t,this.groundObjects=i,this.raycaster=new gc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.moveKeys=new Set,this.moveClock=new Gl,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}updateGroundFollowing(){const t=(new ei).copy(this.camera.up);this.raycaster.set(this.object.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.object.position.y=Qe.lerp(this.object.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){let t=!1,e=!1;const i=new ei,n=new ei;if(this.moveKeys.size>0){e=!0;const r=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),n.setFromMatrixColumn(this.object.matrix,0),n.y=0,n.normalize(),this.moveKeys.has("KeyW")&&this.object.position.addScaledVector(i,r),this.moveKeys.has("KeyS")&&this.object.position.addScaledVector(i,-r),this.moveKeys.has("KeyA")&&this.object.position.addScaledVector(n,-r),this.moveKeys.has("KeyD")&&this.object.position.addScaledVector(n,r),this.moveKeys.has("KeyQ")&&(this.object.translateY(r),e=!1),this.moveKeys.has("KeyE")&&(this.object.translateY(-r),e=!1);const s=this.LOOK_SPEED+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-s/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,s/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(s,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-s,0))),this.moveWheel=0,t=!0}if(0!==this.moveWheel){const e=this.moveWheel*this.multiplier*this.movementSpeed/this.WHEEL_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),this.object.position.addScaledVector(i,-e),this.moveWheel+=-1*Math.sign(this.moveWheel),t=!0}e&&this.updateGroundFollowing(),t&&this.dispatchEvent({type:"change"}),0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new ti;n.setFromAxisAngle(this.object.up,e);const r=new ti;r.setFromAxisAngle(new ei(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class lf extends Zc{constructor(t,e,i,n){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.WALK_SPEED_DELIMITER=4,this.movementSpeed=.1,this.multiplier=3,this.isActive=!1,this.MAX_JOYSTICK_DISTANCE=100,this.INTERNAL_RADIUS=35,this.MAX_MOVE_STICK=40,this.EXTERNAL_RADIUS=65,this.CANVAS_SIZE=200,this.pressed=!1,this.onPointerDown=t=>{t.preventDefault(),this.pressed=!0},this.onPointerMove=t=>{if(t.preventDefault(),!this.pressed)return;let e=t.pageX,i=t.pageY;this.joyStickCanvas.offsetParent&&"BODY"===this.joyStickCanvas.offsetParent.tagName.toUpperCase()?(e-=this.joyStickCanvas.offsetLeft,i-=this.joyStickCanvas.offsetTop):this.joyStickCanvas.offsetParent&&(e-=this.joyStickCanvas.offsetParent.offsetLeft,i-=this.joyStickCanvas.offsetParent.offsetTop);const n=(e-this.centerX)/this.MAX_MOVE_STICK*100,r=(i-this.centerY)/this.MAX_MOVE_STICK*100*-1;Math.sqrt(n*n+r*r)>20?(this.joyStickPosition.set(n,r),this.isActive=!0):(this.joyStickPosition.set(0,0),this.isActive=!1),this.draw(),this.moveClock.start(),this.update()},this.onPointerUp=t=>{t.preventDefault(),this.pressed=!1,this.joyStickPosition.set(0,0),this.isActive=!1,this.moveClock.stop(),this.draw()},this.onResize=()=>{this.updateVisibility(),this.updatePosition()},this.camera=t,this.canvas=i,this.moveClock=new Gl(!1),this.joyStickPosition=new $e(0,0),this.groundObjects=n,this.raycaster=new gc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.centerX=this.CANVAS_SIZE/2,this.centerY=this.CANVAS_SIZE/2,this.overlayElement=document.createElement("div"),this.overlayElement.id="joyStickDiv",this.overlayElement.style.background="rgba(0,0,0,0)",this.overlayElement.style.position="fixed",this.overlayElement.style.zIndex="0",this.overlayElement.style.touchAction="none",i.parentElement.appendChild(this.overlayElement),this.joyStickCanvas=document.createElement("canvas"),this.joyStickCanvas.id="joyStickCanvas",this.joyStickCanvas.width=this.CANVAS_SIZE,this.joyStickCanvas.height=this.CANVAS_SIZE,this.overlayElement.appendChild(this.joyStickCanvas),this.context=this.joyStickCanvas.getContext("2d"),this.joyStickCanvas.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),window.addEventListener("resize",this.onResize),document.addEventListener("fullscreenchange",this.onResize),this.updateVisibility(),this.updatePosition(),this.draw()}dispose(){this.joyStickCanvas.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onResize),document.removeEventListener("fullscreenchange",this.onResize),this.overlayElement.remove(),super.dispose()}updateVisibility(){const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),e=window.innerWidth<1024;this.overlayElement.style.display=t||e?"block":"none"}updatePosition(){const t=this.canvas.getBoundingClientRect();this.overlayElement.style.top=t.height-this.CANVAS_SIZE+"px",this.overlayElement.style.left=`${t.left}px`,this.overlayElement.style.width=`${this.CANVAS_SIZE}px`,this.overlayElement.style.height=`${this.CANVAS_SIZE}px`}draw(){this.context.clearRect(0,0,this.CANVAS_SIZE,this.CANVAS_SIZE),this.context.beginPath(),this.context.arc(this.centerX,this.centerY,this.EXTERNAL_RADIUS,0,2*Math.PI,!1),this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.stroke();let t=this.centerX+this.joyStickPosition.x*this.MAX_MOVE_STICK/100,e=this.centerY-this.joyStickPosition.y*this.MAX_MOVE_STICK/100;t=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,t)),e=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,e)),this.context.beginPath(),this.context.arc(t,e,this.INTERNAL_RADIUS,0,2*Math.PI,!1),this.context.fillStyle="#35436E",this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.fill(),this.context.stroke()}updateGroundFollowing(){const t=(new ei).copy(this.camera.up);this.raycaster.set(this.camera.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.camera.position.y=Qe.lerp(this.camera.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){if(!this.isActive)return;const t=this.joyStickPosition.y/this.MAX_JOYSTICK_DISTANCE,e=this.joyStickPosition.x/this.MAX_JOYSTICK_DISTANCE,i=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER,n=new ei,r=new ei;this.camera.getWorldDirection(n),this.groundObjects.length>0&&(n.y=0),n.normalize(),r.setFromMatrixColumn(this.camera.matrix,0),this.groundObjects.length>0&&(r.y=0),r.normalize(),0!==t&&this.camera.position.addScaledVector(n,i*t),0!==e&&this.camera.position.addScaledVector(r,i*e),0===t&&0===e||(this.groundObjects.length>0&&this.updateGroundFollowing(),this.dispatchEvent({type:"change"}))}}class cf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new ei);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.walkspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update(),this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)};const e=[];t.models.forEach(t=>t.getVisibleObjects().forEach(t=>{t instanceof Lr&&e.push(t)})),this.controls=new hf(t.camera,t.canvas,e),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.joyStickControls=new lf(t.camera,t.canvas,t.canvas,e),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class df extends Zc{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new Gl,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new ti;n.setFromAxisAngle(this.object.up,e);const r=new ti;r.setFromAxisAngle(new ei(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class uf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new ei);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.flyspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update(),this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new df(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("flyspeedchange",this.flyspeedChange),this.joyStickControls=new lf(t.camera,t.canvas,t.canvas,[]),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("flyspeedchange",this.flyspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class pf extends Am{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.DOLLY,MIDDLE:x.PAN,RIGHT:x.PAN}}}const mf=a("threejs");function ff(t,e=0){t.models.forEach(t=>t.explode(e)),t.update(),t.emitEvent({type:"explode",data:e})}function gf(t,e){if(e.isEmpty())return;const i=e.getCenter(new ei),n=e.getBoundingSphere(new Zi).radius,r=t.renderer.getSize(new $e),s=r.x/r.y,a=t.camera;if(a.isPerspectiveCamera){const t=new ei(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(n/Math.tan(Qe.degToRad(.5*a.fov)));a.position.copy(t).add(i),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n,a.bottom=-n,a.left=a.bottom*s,a.right=a.top*s,a.zoom=1,a.updateProjectionMatrix();const e=new ei(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(3*t.extents.getBoundingSphere(new Zi).radius);a.position.copy(e).add(i),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}mf.registerDragger("Pan",t=>new of(t)),mf.registerDragger("Orbit",t=>new Am(t)),mf.registerDragger("Zoom",t=>new pf(t)),mf.registerDragger("MeasureLine",t=>new jm(t)),mf.registerDragger("CuttingPlaneXAxis",t=>new Rm(t)),mf.registerDragger("CuttingPlaneYAxis",t=>new Pm(t)),mf.registerDragger("CuttingPlaneZAxis",t=>new Lm(t)),mf.registerDragger("Walk",t=>new cf(t)),mf.registerDragger("Fly",t=>new uf(t));const vf={front:new ei(0,0,-1),back:new ei(0,0,1),left:new ei(1,0,0),right:new ei(-1,0,0),bottom:new ei(0,-1,0),top:new ei(0,1,0),se:new ei(-1,1,-1).normalize(),sw:new ei(1,1,-1).normalize(),ne:new ei(-1,1,1).normalize(),nw:new ei(1,1,1).normalize()};function yf(t,e){const i=t.extents.getCenter(new ei),n=2*t.extents.getBoundingSphere(new Zi).radius,r=new ei(0,1,0),s=vf[e]||vf.sw,a=(new ei).copy(t.camera.up),o=(new ti).setFromUnitVectors(r,a),h=(new ei).copy(s).applyQuaternion(o),l=t.camera;l.position.copy(h).multiplyScalar(n).add(i),l.lookAt(i),l.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),gf(t,t.extents)}const _f=n("threejs");_f.registerCommand("applyModelTransform",function(t,e){console.warn("applyModelTransform not implemented")}),_f.registerCommand("clearMarkup",function(t){t.clearOverlay()}),_f.registerCommand("clearSelected",function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),_f.registerCommand("clearSlices",function(t){t.clearSlices()}),_f.registerCommand("collect",function(t){ff(t,0)}),_f.registerCommand("createPreview",function(t,e="image/jpeg",i=.25){return t.update(!0),t.canvas.toDataURL(e,i)}),_f.registerCommand("explode",ff),_f.registerCommand("getDefaultViewPositions",function(){return Object.keys(vf)}),_f.registerCommand("getModels",function(t){return t.models.map(t=>t.id)}),_f.registerCommand("getSelected",function(t){return t.executeCommand("getSelected2").map(t=>t.slice(t.indexOf(":")+1))}),_f.registerCommand("getSelected2",function(t){const e=[];return t.models.forEach(i=>{e.push(i.getHandlesByObjects(t.selected))}),e.flat()}),_f.registerCommand("hideSelected",function(t){t.models.forEach(e=>e.hideObjects(t.selected)),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),_f.registerCommand("isolateSelected",function(t){t.models.forEach(e=>e.isolateObjects(t.selected)),t.update(),t.emitEvent({type:"isolate"})}),_f.registerCommand("regenerateAll",function(t){t.emit({type:"regenerateall"})}),_f.registerCommand("resetView",function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.emit({type:"resetview"})}),_f.registerCommand("selectModel",function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter(t=>t.id===e).forEach(t=>i.select(t.getObjects(),t)),t.update(),t.emitEvent({type:"select",handles:t.getSelected()}),t.emitEvent({type:"select2",handles:t.getSelected2()})}),_f.registerCommand("setActiveDragger",function(t,e=""){t.setActiveDragger(e)}),_f.registerCommand("setDefaultViewPosition",yf),_f.registerCommand("setMarkupColor",function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)}),_f.registerCommand("setSelected",function(t,e=[]){const i=[];e.forEach(e=>{e.includes(":")?i.push(e):t.models.forEach(t=>{i.push(`${t.id}:${e}`)})}),t.executeCommand("setSelected2",i)}),_f.registerCommand("setSelected2",function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach(t=>{const n=t.getObjectsByHandles(e);t.showObjects(n),i.select(n,t)}),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:t.getSelected()}),t.emitEvent({type:"select2",data:void 0,handles:e})}),_f.registerCommand("showAll",function(t){t.models.forEach(t=>t.showAllObjects()),t.update(),t.emitEvent({type:"showall"})}),_f.registerCommand("zoomToExtents",function(t){gf(t,t.extents)}),_f.registerCommand("zoomToObjects",function(t,e=[]){const i=new Li;t.models.forEach(t=>{t.getObjectsByHandles(e).forEach(t=>i.expandByObject(t))}),i.isEmpty()&&i.copy(t.extents),gf(t,i)}),_f.registerCommand("zoomToSelected",function(t){const e=new Li;t.selected.forEach(t=>e.expandByObject(t)),e.isEmpty()&&e.copy(t.extents),gf(t,e)}),_f.registerCommand("top",t=>yf(t,"top")),_f.registerCommand("bottom",t=>yf(t,"bottom")),_f.registerCommand("left",t=>yf(t,"left")),_f.registerCommand("right",t=>yf(t,"right")),_f.registerCommand("front",t=>yf(t,"front")),_f.registerCommand("back",t=>yf(t,"back")),_f.registerCommand("sw",t=>yf(t,"sw")),_f.registerCommand("se",t=>yf(t,"se")),_f.registerCommand("ne",t=>yf(t,"ne")),_f.registerCommand("nw",t=>yf(t,"nw")),_f.registerCommandAlias("clearMarkup","clearOverlay"),_f.registerCommandAlias("clearSelected","unselect"),_f.registerCommandAlias("zoomToExtents","zoomExtents"),_f.registerCommandAlias("top","k3DViewTop"),_f.registerCommandAlias("bottom","k3DViewBottom"),_f.registerCommandAlias("left","k3DViewLeft"),_f.registerCommandAlias("right","k3DViewRight"),_f.registerCommandAlias("front","k3DViewFront"),_f.registerCommandAlias("back","k3DViewBack"),_f.registerCommandAlias("se","k3DViewSE"),_f.registerCommandAlias("sw","k3DViewSW"),_f.registerCommandAlias("ne","k3DViewNE"),_f.registerCommandAlias("nw","k3DViewNW");class xf{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new Jn(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class wf{constructor(t){this.optionsChange=()=>{this.switchCameraMode(this.viewer.options.cameraMode)},this.geometryEnd=()=>{if(this.viewer.models.length>1)return void this.switchCamera(this.viewer.camera);let t;if(this.viewer.scene.traverse(e=>{e.isCamera&&(t?e.isPerspectiveCamera&&t.isOrthographicCamera&&(t=e):t=e)}),t){t.isDefaultCamera=!0,t.scale.set(1,1,1),this.switchCamera(t);const e=this.getCameraMode(t);this.viewer.options.cameraMode=e,this.viewer.emitEvent({type:"changecameramode",mode:e})}else this.switchCamera(this.viewer.camera),this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("initialize",this.optionsChange)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("initialize",this.optionsChange)}getCameraMode(t){return t.isOrthographicCamera?"orthographic":"perspective"}switchCamera(t){const e=2*this.viewer.extents.getBoundingSphere(new Zi).radius||1,i=this.viewer.renderer.getSize(new $e),n=i.x/i.y;t.isPerspectiveCamera&&(t.aspect=n,t.near=e/1e3,t.far=1e3*e),t.isOrthographicCamera&&(t.left=t.bottom*n,t.right=t.top*n,t.near=0,t.far=1e3*e),t.updateProjectionMatrix(),this.viewer.camera=t,this.viewer.renderPass.camera=t,this.viewer.helpersPass.camera=t,this.viewer.ssaaRenderPass.camera=t,this.viewer.update()}switchCameraMode(t){if(!t)return;const e=this.viewer.camera;if(t===this.getCameraMode(e))return;const i=this.viewer.target.clone();let n;if(e.isOrthographicCamera){const t=e.userData.fov||45,r=(e.top-e.bottom)/e.zoom/(2*Math.tan(Qe.degToRad(t)/2)),s=(new ei).subVectors(e.position,i).normalize();n=new Vr(t),n.position.copy(s).multiplyScalar(r).add(i)}if(e.isPerspectiveCamera){const t=e.fov,r=e.position.distanceTo(i),s=2*Math.tan(Qe.degToRad(t)/2)*r;n=new xl,n.top=s/2,n.bottom=-s/2,n.position.copy(e.position),n.userData.fov=t}n&&(n.up.copy(e.up),n.quaternion.copy(e.quaternion),this.switchCamera(n),this.viewer.emitEvent({type:"changecameramode",mode:t}))}}class bf{constructor(t){this.syncExtents=t=>{const e=new Li;this.viewer.models.forEach(t=>t.getExtents(e)),this.viewer.extents.copy(e),"databasechunk"!==t.type&&"clear"!==t.target||this.viewer.models.length>1||this.viewer.extents.getCenter(this.viewer.target)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class Sf{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new ei),e=this.viewer.extents.getBoundingSphere(new Zi).radius,i=new ei(0,1,0),n=new ei(0,0,-1),r=(new ei).copy(this.viewer.camera.up),s=(new ti).setFromUnitVectors(i,r),a=(new ei).copy(n).applyQuaternion(s).negate();this.directionalLight.position.copy(r).applyAxisAngle(a,30*-Math.PI/180).multiplyScalar(2*e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.copy(a).multiplyScalar(2*e).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.copy(a).multiplyScalar(3*e).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new Sl(16777215,1.5),this.directionalLight=new bl(16777215,1),this.frontLight=new bl(16777215,1.25),this.hemisphereLight=new hl(16777215,4473924,1.25),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class Mf{constructor(t){this.initialize=()=>{try{const t=this.viewer.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.viewer.info.system.webglRenderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.viewer.info.system.webglVendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}catch(t){console.error("Error reading WebGL info.",t)}console.log("THREE.WebGLRenderer:",_),console.log("WebGL Renderer:",this.viewer.info.system.webglRenderer),console.log("WebGL Vendor:",this.viewer.info.system.webglVendor),this.resize(),this.optionsChange({data:this.viewer.options})},this.clear=()=>{this.viewer.info.performance.timeToFirstRender=0,this.viewer.info.performance.loadTime=0,this.viewer.info.scene.objects=0,this.viewer.info.scene.triangles=0,this.viewer.info.scene.points=0,this.viewer.info.scene.lines=0,this.viewer.info.scene.edges=0,this.viewer.info.optimizedScene.objects=0,this.viewer.info.optimizedScene.triangles=0,this.viewer.info.optimizedScene.points=0,this.viewer.info.optimizedScene.lines=0,this.viewer.info.optimizedScene.edges=0,this.viewer.info.memory.geometries=0,this.viewer.info.memory.geometryBytes=0,this.viewer.info.memory.textures=0,this.viewer.info.memory.textureBytes=0,this.viewer.info.memory.materials=0,this.viewer.info.memory.totalEstimatedGpuBytes=0,this.viewer.info.memory.usedJSHeapSize=0},this.optionsChange=({data:t})=>{!1===t.antialiasing?this.viewer.info.render.antialiasing="":!0===t.antialiasing?this.viewer.info.render.antialiasing="mxaa":this.viewer.info.render.antialiasing=t.antialiasing},this.geometryStart=()=>{this.startTime=performance.now()},this.databaseChunk=()=>{this.viewer.info.performance.timeToFirstRender+=performance.now()-this.startTime,console.log("Time to first render:",this.viewer.info.performance.timeToFirstRender,"ms")},this.geometryEnd=()=>{const t=this.viewer.models[this.viewer.models.length-1].getInfo();this.viewer.info.scene.objects+=t.scene.objects,this.viewer.info.scene.triangles+=t.scene.triangles,this.viewer.info.scene.points+=t.scene.points,this.viewer.info.scene.lines+=t.scene.lines,this.viewer.info.scene.edges+=t.scene.edges,this.viewer.info.optimizedScene.objects+=t.optimizedScene.objects,this.viewer.info.optimizedScene.triangles+=t.optimizedScene.triangles,this.viewer.info.optimizedScene.points+=t.optimizedScene.points,this.viewer.info.optimizedScene.lines+=t.optimizedScene.lines,this.viewer.info.optimizedScene.edges+=t.optimizedScene.edges,this.viewer.info.memory.geometries+=t.memory.geometries,this.viewer.info.memory.geometryBytes+=t.memory.geometryBytes,this.viewer.info.memory.textures+=t.memory.textures,this.viewer.info.memory.textureBytes+=t.memory.textureBytes,this.viewer.info.memory.materials+=t.memory.materials,this.viewer.info.memory.totalEstimatedGpuBytes+=t.memory.totalEstimatedGpuBytes;const e=performance.memory;e&&(this.viewer.info.memory.usedJSHeapSize=e.usedJSHeapSize),this.viewer.info.performance.loadTime+=performance.now()-this.startTime,console.log("Number of objects:",t.scene.objects),console.log("Number of objects after optimization:",t.optimizedScene.objects),console.log("Total geometry size:",t.memory.totalEstimatedGpuBytes/1048576,"MB"),console.log("File load time:",this.viewer.info.performance.loadTime,"ms")},this.resize=()=>{const t=this.viewer.renderer.getSize(new $e);this.viewer.info.render.viewport.width=t.x,this.viewer.info.render.viewport.height=t.y},this.render=()=>{this.viewer.info.render.drawCalls=this.viewer.renderer.info.render.calls,this.viewer.info.render.triangles=this.viewer.renderer.info.render.triangles,this.viewer.info.render.points=this.viewer.renderer.info.render.points,this.viewer.info.render.lines=this.viewer.renderer.info.render.lines},this.animate=()=>{const t=performance.now();this.viewer.info.performance.frameTime=Math.round(t-this.beginTime),this.beginTime=t,this.frames++,t-this.prevTime>=1e3&&(this.viewer.info.performance.fps=Math.round(1e3*this.frames/(t-this.prevTime)),this.prevTime=t,this.frames=0)},this.viewer=t,this.startTime=0,this.beginTime=performance.now(),this.prevTime=performance.now(),this.frames=0,this.viewer.addEventListener("initialize",this.initialize),this.viewer.addEventListener("clear",this.clear),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("geometrystart",this.geometryStart),this.viewer.addEventListener("databasechunk",this.databaseChunk),this.viewer.addEventListener("geometryend",this.geometryEnd),this.viewer.addEventListener("resize",this.resize),this.viewer.addEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}dispose(){this.viewer.removeEventListener("initialize",this.initialize),this.viewer.removeEventListener("clear",this.clear),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("geometrystart",this.geometryStart),this.viewer.removeEventListener("databasechunk",this.databaseChunk),this.viewer.removeEventListener("geometryend",this.geometryEnd),this.viewer.removeEventListener("resize",this.resize),this.viewer.removeEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}}class Ef{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Tf{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this.viewer.setSize(e,i)},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}const Af=new Li,Cf=new ei;class Rf extends Rl{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new dr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new dr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new mc(e,6,1);return this.setAttribute("instanceStart",new is(i,3,0)),this.setAttribute("instanceEnd",new is(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new mc(e,6,1);return this.setAttribute("instanceColorStart",new is(i,3,0)),this.setAttribute("instanceColorEnd",new is(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new vh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Li);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),Af.setFromBufferAttribute(e),this.boundingBox.union(Af))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Zi),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let r=0,s=t.count;r<s;r++)Cf.fromBufferAttribute(t,r),n=Math.max(n,i.distanceToSquared(Cf)),Cf.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(Cf));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}td.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new $e(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ed.line={uniforms:Fr.merge([td.common,td.fog,td.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class Pf extends zr{constructor(t){super({type:"LineMaterial",uniforms:Fr.clone(ed.line.uniforms),vertexShader:ed.line.vertexShader,fragmentShader:ed.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Lf=new ei,If=new ei,Df=new Ti;class Of extends Lr{constructor(t=new Rf,e=new Pf({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,r=0,s=e.count;t<s;t++,r+=2)Lf.fromBufferAttribute(e,t),If.fromBufferAttribute(i,t),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+Lf.distanceTo(If);const r=new mc(n,2,1);return t.setAttribute("instanceDistanceStart",new is(r,1,0)),t.setAttribute("instanceDistanceEnd",new is(r,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Df),this.material.uniforms.resolution.value.set(Df.z,Df.w))}}class Nf{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new Rf,n=[];for(let i=0;i<e.length;i+=2){const r=3*e[i],s=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[r],t[r+1],t[r+2],t[s],t[s+1],t[s+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new Rf,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)Nf.isBreak(t,e)||Nf.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)Nf.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class Uf{constructor(t){this.geometryEnd=()=>{this.facesMaterial=new Mh({transparent:!0,specular:2236962,shininess:10,reflectivity:.05,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.edgesMaterial=new Pf({linewidth:1.5,resolution:new $e(window.innerWidth,window.innerHeight)}),this.lineMaterial=new wa({transparent:!0,depthTest:!0,depthWrite:!0}),this.lineGlowMaterial=new Pf({linewidth:1.5,transparent:!0,opacity:.8,resolution:new $e(window.innerWidth,window.innerHeight)}),this.syncHighlightColors()},this.optionsChange=()=>{this.syncHighlightColors(),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new $e);this.renderTarget=new Ci(e.x,e.y,{format:Rt,stencilBuffer:!1,samples:4,type:mt})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){const{edgesVisibility:e}=this.viewer.options;Array.isArray(t)||(t=[t]),0!==t.length&&t.filter(t=>!t.userData.isEdge).forEach(t=>{if(!t.userData.isHighlighted)if(t.isLine||t.isLineSegments){const i=t.geometry.attributes.position.array,n=t.geometry.index?t.geometry.index.array:null,r=n?Nf.fromIndexedLine(i,n):Nf.fromNonIndexedLine(i,t.isLineSegments),s=new Of(r,this.lineGlowMaterial);s.visible=e,s.userData.isHighlightWireframe=!0,t.add(s),t.userData.highlightWireframe=s,t.userData.originalMaterial=t.material,t.material=this.lineMaterial,t.userData.isHighlighted=!0}else if(t.isMesh){const i=new no(t.geometry,89),n=(new Rf).fromEdgesGeometry(i),r=new Of(n,this.edgesMaterial);r.visible=e,r.userData.isHighlightWireframe=!0,t.add(r),t.userData.highlightWireframe=r,t.userData.originalMaterial=t.material,t.material=this.facesMaterial,t.userData.isHighlighted=!0}})}unhighlight(t){Array.isArray(t)||(t=[t]),0!==t.length&&t.forEach(t=>{t.userData.isHighlighted&&(t.material=t.userData.originalMaterial,t.userData.highlightWireframe.removeFromParent(),delete t.userData.isHighlighted,delete t.userData.originalMaterial,delete t.userData.highlightWireframe)})}syncHighlightColors(){const t=this.viewer.options.enableCustomHighlight?this.viewer.options:f.defaults(),{facesColor:e,facesTransparancy:i,facesOverlap:n}=t,{edgesColor:r,edgesVisibility:s,edgesOverlap:a}=t;this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-i)/255,this.facesMaterial.depthTest=!n,this.facesMaterial.depthWrite=!n,this.edgesMaterial.color.setRGB(r.r/255,r.g/255,r.b/255),this.edgesMaterial.depthTest=!a,this.edgesMaterial.depthWrite=!a,this.lineMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.lineGlowMaterial.color.setRGB(r.r/255,r.g/255,r.b/255),this.lineGlowMaterial.depthTest=!a,this.lineGlowMaterial.depthWrite=!a,this.viewer.selected.forEach(t=>{const e=t.userData.highlightWireframe;e&&(e.visible=s)})}viewerResize(t){var e,i,n;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.edgesMaterial)||void 0===i||i.resolution.set(t.width,t.height),null===(n=this.lineGlowMaterial)||void 0===n||n.resolution.set(t.width,t.height)}}class Ff{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new $e);if(0!==e.distanceTo(this.downPosition))return;const i=new Vm(this.viewer.camera,this.viewer.renderer,this.viewer.canvas);i.threshold=this.viewer.extents.getSize(new ei).length()/1e4;let n=[];if(this.viewer.models.forEach(t=>{const r=t.getVisibleObjects(),s=i.getPointerIntersects(e,r);s.length>0&&n.push({...s[0],model:t})}),n=n.sort((t,e)=>t.distance-e.distance),t.shiftKey||this.clearSelection(),n.length>0){const e=n[0].model,i=e.getHandlesByObjects(n[0].object),r=e.getObjectsByHandles(i);t.shiftKey?this.toggleSelection(r,e):this.select(r,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()}),this.viewer.emitEvent({type:"select2",data:void 0,handles:this.viewer.getSelected2()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.downPosition=new $e,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}select(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.highlightObjects(t),this.highlighter.highlight(t),t.forEach(t=>this.viewer.selected.push(t)),t.forEach(t=>t.userData.isSelected=!0))):this.viewer.models.forEach(e=>this.select(t,e))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.unhighlightObjects(t),this.highlighter.unhighlight(t),this.viewer.selected=this.viewer.selected.filter(e=>!t.includes(e)),t.forEach(t=>t.userData.isSelected=!1))):this.viewer.models.forEach(e=>this.select(t,e))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),0!==t.length&&(t[0].userData.isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){0!==this.viewer.selected.length&&(this.viewer.models.forEach(t=>t.unhighlightObjects(this.viewer.selected)),this.highlighter.unhighlight(this.viewer.selected),this.viewer.selected.forEach(t=>t.userData.isSelected=!1),this.viewer.selected.length=0)}}class zf extends In{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new xl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new er({toneMapped:!1,color:"#dd0000"}),i=new er({toneMapped:!1,color:"#00dd00"}),n=new er({toneMapped:!1,color:"#0000dd"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new Za(.01,.01,1,3);o.translate(0,.5,0);const h=new Za(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Lr(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Lr(o,e),[0,0,0],[0,0,-Math.PI/2]],[new vs(r),[1.55,0,0]]],Y:[[new Lr(h,i),[0,.5,0],null],[new Lr(o,i),null,null],[new vs(s),[0,1.55,0]]],Z:[[new Lr(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Lr(o,n),null,[Math.PI/2,0,0]],[new vs(a),[0,0,1.55]]]};Object.keys(l).forEach(t=>{l[t].forEach(e=>{const i=e[0],n=e[1],r=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),r&&i.rotation.set(r[0],r[1],r[2]),i.updateMatrixWorld(),this.add(i)})})}dispose(){this.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const r=new Wa(i);return r.colorSpace=Me,new ns({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.autoClear,i=t.clippingPlanes,n=t.getViewport(new Ti);t.autoClear=!1,t.clippingPlanes=[],t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=i,t.autoClear=e}}class kf{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new zf(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new zf(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}class Bf{constructor(t){this.savedCameraPosition=null,this.onDatabaseChunk=()=>{this.savedCameraPosition={position:this.viewer.camera.position.clone(),up:this.viewer.camera.up.clone(),direction:this.viewer.camera.getWorldDirection(new ei)}},this.resetCameraPosition=()=>{this.savedCameraPosition&&(this.viewer.camera.position.copy(this.savedCameraPosition.position),this.viewer.camera.up.copy(this.savedCameraPosition.up),this.viewer.camera.lookAt(this.savedCameraPosition.position.clone().add(this.savedCameraPosition.direction)),this.viewer.camera.updateProjectionMatrix())},this.viewer=t,this.viewer.addEventListener("databasechunk",this.onDatabaseChunk),this.viewer.on("resetview",this.resetCameraPosition)}dispose(){this.viewer.off("resetview",this.resetCameraPosition),this.viewer.removeEventListener("databasechunk",this.onDatabaseChunk)}}const Gf=l("threejs");Gf.registerComponent("ExtentsComponent",t=>new bf(t)),Gf.registerComponent("CameraComponent",t=>new wf(t)),Gf.registerComponent("BackgroundComponent",t=>new xf(t)),Gf.registerComponent("LightComponent",t=>new Sf(t)),Gf.registerComponent("InfoComponent",t=>new Mf(t)),Gf.registerComponent("ResizeCanvasComponent",t=>new Tf(t)),Gf.registerComponent("RenderLoopComponent",t=>new Ef(t)),Gf.registerComponent("HighlighterComponent",t=>new Uf(t)),Gf.registerComponent("SelectionComponent",t=>new Ff(t)),Gf.registerComponent("WCSHelperComponent",t=>new kf(t)),Gf.registerComponent("ResetComponent",t=>new Bf(t));class Hf{constructor(t){this.scene=t,this.handleToObjects=new Map,this.originalObjects=new Set,this.scene.traverse(t=>{this.originalObjects.add(t);const e=t.userData.handle;if(!e)return;let i=this.handleToObjects.get(e);i||(i=new Set,this.handleToObjects.set(e,i)),i.add(t)})}dispose(){this.handleToObjects=void 0,this.originalObjects=void 0,this.scene.traverse(function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach(t=>function(t){t.dispose()}(t)))}),this.scene.clear()}getUnits(){return"Meters"}getUnitScale(){return Om(this.getUnits(),"Meters",1)}getUnitString(){return t=this.getUnits(),(Dm[t]||Dm.Default).symbol;var t}getPrecision(){return 2}getInfo(){const t=new Set,e=new Set,i=new Set;let n=0,r=0,s=0,a=0,o=0,h=0,l=0;function c(t){if(!t.image)return 0;return(t.image.width||0)*(t.image.height||0)*4*(t.generateMipmaps?1.33:1)}this.scene.traverse(d=>{if(n++,d.geometry){const e=d.geometry;if(!t.has(e)){if(t.add(e),e.attributes)for(const t in e.attributes){const i=e.attributes[t];i&&i.array&&(h+=i.array.byteLength)}e.index&&e.index.array&&(h+=e.index.array.byteLength)}if(e.index){const t=e.index.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?s+=t:r+=t/3}else if(e.attributes&&e.attributes.position){const t=e.attributes.position.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?s+=t:r+=t/3}d.isLineSegments&&e.attributes.position&&(o+=e.attributes.position.count/2)}if(d.material){(Array.isArray(d.material)?d.material:[d.material]).forEach(t=>{e.add(t),t.map&&!i.has(t.map)&&(i.add(t.map),l+=c(t.map));["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","iridescenceMap","sheenColorMap","sheenRoughnessMap","thicknessMap","transmissionMap","anisotropyMap","gradientMap"].forEach(e=>{const n=t[e];n&&!i.has(n)&&(i.add(n),l+=c(n))})})}});const d=new y;return d.scene.objects=n,d.scene.triangles=Math.floor(r),d.scene.points=Math.floor(s),d.scene.lines=Math.floor(a),d.scene.edges=Math.floor(o),d.memory.geometries=t.size,d.memory.geometryBytes=h,d.memory.textures=i.size,d.memory.textureBytes=Math.floor(l),d.memory.materials=e.size,d.memory.totalEstimatedGpuBytes=h+Math.floor(l),d.optimizedScene.objects=d.scene.objects,d.optimizedScene.triangles=d.scene.triangles,d.optimizedScene.points=d.scene.points,d.optimizedScene.lines=d.scene.lines,d.optimizedScene.edges=d.scene.edges,d}getExtents(t){return this.scene.traverseVisible(e=>t.expandByObject(e)),t}getObjects(){return Array.from(this.originalObjects)}getVisibleObjects(){const t=[];return this.scene.traverseVisible(e=>t.push(e)),t.filter(t=>t.userData.handle)}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(t=>{const i=t.indexOf(":");if(-1!==i){if(t.slice(0,i)!==this.id)return;t=t.slice(i+1)}e.push(t)});const i=new Set(e),n=[];return i.forEach(t=>{n.push(Array.from(this.handleToObjects.get(t)||[]))}),n.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{e.add(`${this.id}:${t.userData.handle}`)}),Array.from(e)}hideObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!1}),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.traverseAncestors(t=>e.add(t))}),this.scene.traverse(t=>t.visible=e.has(t)),this}showObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!0,t.traverseAncestors(t=>t.visible=!0)}),this}showAllObjects(){return this.scene.traverse(t=>t.visible=!0),this}highlightObjects(t){return this}unhighlightObjects(t){return this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Li).setFromObject(t),r=t.userData.handle;if(!r)return n.getCenter(e);const s=i.get(r);if(s)return e.copy(s);return this.getObjectsByHandles(r).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(r,e.clone()),e};const r=t/100,s=this.scene;s.userData.explodeDepth||(s.userData.explodeDepth=function t(e,i){let r=i;return e.children.forEach(e=>{const n=t(e,i+1);r<n&&(r=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new ei),r}(s,1));const a=s.userData.explodeDepth,o=r*a+1,h=0|o,l=o-h;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h){let t=r*e;n===h&&(t*=l);const s=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(s).multiplyScalar(t);i.position.add(a)}i.children.forEach(e=>t(e,n+1))}}(s,0),this.scene.updateMatrixWorld(),this}}class Vf extends Hf{getInfo(){const t=this.gltfLoader.getStats(),e=new y;return e.scene.objects=t.scene.beforeOptimization.objects,e.scene.triangles=t.scene.beforeOptimization.triangles,e.scene.lines=t.scene.beforeOptimization.lines,e.scene.edges=t.scene.beforeOptimization.edges,e.optimizedScene.objects=t.scene.afterOptimization.objects,e.optimizedScene.triangles=t.scene.afterOptimization.triangles,e.optimizedScene.lines=t.scene.afterOptimization.lines,e.optimizedScene.edges=t.scene.afterOptimization.edges,e.memory.geometries=t.memory.geometries.count,e.memory.geometryBytes=t.memory.geometries.bytes,e.memory.textures=t.memory.textures.count,e.memory.materials=t.memory.materials.count,e.memory.totalEstimatedGpuBytes=t.memory.totalEstimatedGpuBytes,e}getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach(e=>{t.push(e)}),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=new Set(t),i=[];return e.forEach(t=>{i.push(this.gltfLoader.getObjectsByHandle(t))}),i.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.gltfLoader.originalObjects.has(t)).forEach(t=>{e.add(t.userData.handle)}),Array.from(e)}hideObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.hideObjects(e),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.showObjects(e),this}showAllObjects(){return this.gltfLoader.showAllHiddenObjects(),this}highlightObjects(t){return this.gltfLoader.showOriginalObjects(t),this}unhighlightObjects(t){return this.gltfLoader.hideOriginalObjects(t),this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Li).setFromObject(t),r=t.userData.handle;if(!r)return n.getCenter(e);const s=i.get(r);if(s)return e.copy(s);return this.getObjectsByHandles(r).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(r,e.clone()),e};const r=t/100,s=this.scene.children[0];s.userData.explodeDepth||(s.userData.explodeDepth=function t(e,i){let r=i;return e.children.filter(t=>!t.userData.isOptimized).forEach(e=>{const n=t(e,i+1);r<n&&(r=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new ei),r}(s,1));const a=s.userData.explodeDepth,o=r*a+1,h=0|o,l=o-h,c=new Map;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h&&!i.userData.isExplodeLocked){let t=r*e;n===h&&(t*=l);const s=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(s).multiplyScalar(t);i.position.add(a);const o=(new sn).makeTranslation(a.x,a.y,a.z);c.set(i,o)}i.children.filter(t=>!t.userData.isOptimized).forEach(e=>t(e,n+1))}}(s,0),this.scene.updateMatrixWorld(),this.gltfLoader.applyObjectTransforms(c),this}}const Wf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jf=0,Xf=1,Yf=2,qf=3,Zf=4,Kf=5,Jf=6,Qf=31457280;class $f{constructor(t,e){this.id=`${t}`,this.json=null,this.loadController=e,this.loader=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new al,this.materials=new Map,this.textureCache=new Map,this.materialCache=new Map,this.uri="",this._nextObjectId=1,this.loadingAborted=!1,this.criticalError=null}async initialize(t){this.json=await this.loadController.loadJson(),this.loader=t,this.uri=this.json.buffers[0].uri||""}clear(){this.json=null,this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear(),this.activeChunkLoads=0,this.chunkQueue=[],this.loadingAborted=!1,this.criticalError=null}getJson(){return this.json}scheduleRequest(t){return new Promise((e,i)=>{this.loadingAborted?i(this.criticalError||new Error("Structure loading has been aborted due to critical error")):this.pendingRequests.push({...t,_resolve:e,_reject:i})})}isCriticalHttpError(t){if(!t)return!1;const e=t.status||t.statusCode||t.code;if("number"==typeof e)return e>=400&&e<600;if(t.message){const e=t.message.match(/HTTP\s+(\d{3})/i);if(e){const t=parseInt(e[1],10);return t>=400&&t<600}}return!1}abortLoading(t){if(this.loadingAborted)return;this.loadingAborted=!0,this.criticalError=t;const e=[...this.pendingRequests];this.pendingRequests=[];for(const i of e)i._reject&&i._reject(t);throw console.error(`❌ Critical error for structure "${this.id}". All further loading aborted.`,`\n Error: ${t.message||t}`,`\n Rejected ${e.length} pending chunk requests.`),t}async flushBufferRequests(){if(!this.pendingRequests||0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],t.sort((t,e)=>t.offset-e.offset);const e=[];let i={start:t[0].offset,end:t[0].offset+t[0].length,requests:[t[0]]};for(let n=1;n<t.length;n++){const r=t[n],s=r.offset-i.end,a=Math.max(i.end,r.offset+r.length),o=a-i.start;s<=131072&&o<=Qf?(i.end=a,i.requests.push(r)):(e.push(i),i={start:r.offset,end:r.offset+r.length,requests:[r]})}e.push(i);const n=[];for(const t of e){let{start:e,end:i,requests:r}=t;for(;i-e>Qf;){let t=0;for(let i=0;i<r.length&&!(r[i].offset+r[i].length-e>Qf);i++)t=i;const s=r.slice(0,t+1),a=s[s.length-1].offset+s[s.length-1].length;if(n.push({start:e,end:a,requests:s}),r=r.slice(t+1),r.length>0){e=r[0].offset,i=r[0].offset+r[0].length;for(let t=1;t<r.length;t++)i=Math.max(i,r[t].offset+r[t].length)}}r.length>0&&n.push({start:e,end:i,requests:r})}const r=n.map(async(t,e)=>{if(this.loadingAborted)for(const e of t.requests)e._reject(this.criticalError||new Error("Structure loading aborted"));else{await this.loader.waitForChunkSlot();try{const e=t.end-t.start,i=await this.loadController.loadBinaryData([{offset:t.start,length:e}],this.uri);for(const e of t.requests){const n=e.offset-t.start;try{e._resolve({buffer:i,relOffset:n,length:e.length})}catch(t){e._reject(t)}}}catch(i){for(const e of t.requests)e._reject(i);this.isCriticalHttpError(i)?this.abortLoading(i):console.warn(`Failed to load chunk ${e+1}/${n.length} (${t.start}-${t.end}):`,i)}finally{this.loader.releaseChunkSlot()}}});await Promise.all(r),this.pendingRequests=[]}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let r;switch(n){case 5120:case 5121:r=1;break;case 5122:case 5123:r=2;break;case 5125:case 5126:r=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const s=i/r;if(!Number.isInteger(s))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,Wf[n])(t,e,s)}catch(r){throw"AbortError"!==r.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:r}),r}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),r=i.count*e*this.getComponentSize(i.componentType),s=await this.getBufferView(t,r,i.componentType),a=new hr(s,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){const t=await this.loadController.resolveURL(e.uri);return this.textureLoader.loadAsync(t)}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),r=URL.createObjectURL(n),s=await this.textureLoader.loadAsync(r);return URL.revokeObjectURL(r),s.flipY=!1,s}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then(t=>this.textureCache.set(i,t)));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=`material_${t}`;this.materialCache.set(i,{mesh:this.createMaterial(e,Zf),points:this.createMaterial(e,jf),lines:this.createMaterial(e,Xf)}),this.materialCache.get(i).mesh.name=e.name,this.materialCache.get(i).points.name=e.name,this.materialCache.get(i).lines.name=e.name,this.materials.set(t,this.materialCache.get(i).mesh)}return this.materials}createMaterial(t,e=void 0){const i={};if(t.pbrMetallicRoughness){const e=t.pbrMetallicRoughness;e.baseColorFactor&&(i.color=(new Jn).fromArray(e.baseColorFactor),i.opacity=e.baseColorFactor[3],i.opacity<1&&(i.transparent=!0)),e.baseColorTexture&&(i.map=this.textureCache.get(e.baseColorTexture.index))}let n;return t.emissiveFactor&&(i.emissive=(new Jn).fromArray(t.emissiveFactor)),"BLEND"===t.alphaMode&&(i.transparent=!0),t.doubleSided&&(i.side=2),e===jf?(i.sizeAttenuation=!1,n=new Na(i),n.sizeAttenuation=!1):e===Xf||e===qf||e===Yf?n=new wa(i):(i.specular=2236962,i.shininess=10,i.reflectivity=.05,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=1,t.normalTexture&&(i.normalMap=this.textureCache.get(t.normalTexture.index)),n=new Mh(i)),n}getCachedMaterial(t,e){const i=`material_${t}`,n=this.materialCache.get(i);return n?e===jf?n.points:e===Xf||e===qf||e===Yf?n.lines:n.mesh:null}disposeMaterials(){this.textureCache.forEach(t=>t.dispose()),this.textureCache.clear(),this.materials.forEach(t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()}),this.materials.clear(),this.materialCache.forEach(t=>{t.mesh&&(t.mesh.map&&t.mesh.map.dispose(),t.mesh.lightMap&&t.mesh.lightMap.dispose(),t.mesh.bumpMap&&t.mesh.bumpMap.dispose(),t.mesh.normalMap&&t.mesh.normalMap.dispose(),t.mesh.specularMap&&t.mesh.specularMap.dispose(),t.mesh.envMap&&t.mesh.envMap.dispose(),t.mesh.aoMap&&t.mesh.aoMap.dispose(),t.mesh.metalnessMap&&t.mesh.metalnessMap.dispose(),t.mesh.roughnessMap&&t.mesh.roughnessMap.dispose(),t.mesh.emissiveMap&&t.mesh.emissiveMap.dispose(),t.mesh.dispose()),t.points&&(t.points.map&&t.points.map.dispose(),t.points.dispose()),t.lines&&(t.lines.map&&t.lines.map.dispose(),t.lines.dispose())}),this.materialCache.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),r=this.getComponentSize(t.componentType);i+=t.count*n*r}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}function tg(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,h=new _r;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[t]&&(s[t]=[]),s[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const r=t[n].index;for(let t=0;t<r.count;++t)i.push(r.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in s){const e=eg(s[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=eg(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function eg(t){let e,i,n,r=-1,s=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.count*i}const a=new e(s),o=new hr(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,r=n.count;e<r;e++)for(let r=0;r<i;r++){const i=n.getComponent(e,r);o.setComponent(e+t,r,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==r&&(o.gpuType=r),o}class ig{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[],optimizationprogress:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],
|
|
36
36
|
//!!window.WebGL2RenderingContext && this.renderer.getContext() instanceof WebGL2RenderingContext
|
|
37
|
-
this.useVAO=!1,this.visibleEdges=!0,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set,this.activeChunkLoads=0,this.chunkQueue=[],this.objectIdToIndex=new Map,this.maxObjectId=0,this.objectVisibility=new Float32Array,this.maxConcurrentChunks=6,this.mergedObjectMap=new Map,this.mergedGeometryVisibility=new Map,this._webglInfoCache=null}setVisibleEdges(t){this.visibleEdges=t}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t/3}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}updateMemoryIndicator(){this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse(t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach(t=>{t&&t.array&&(e+=t.array.byteLength)}),i.index&&i.index.array&&(e+=i.index.array.byteLength)}}),e}recalculateScene(){const t=[];if(this.scene.traverse(e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}}),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort((t,e)=>e.distance-t.distance);let e=0;for(const i of t)e+=i.size;if(e>this.memoryLimit){console.log(`Memory usage (${Math.round(e/1048576)}MB) exceeds limit`);for(const i of t){if(e<=this.memoryLimit)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=i.object;t.geometry&&(e-=i.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}getStats(){let t=0,e=0,i=0,n=0,r=0,s=0,a=0,o=0;this.scene.traverse(h=>{t++;const l=h.geometry;if(!l)return;let c=0;l.index?c=Math.floor(l.index.count/3):l.attributes&&l.attributes.position&&(c=Math.floor(l.attributes.position.count/3)),i+=c;let d=0;l.index?d=Math.floor(l.index.count/2):l.attributes&&l.attributes.position&&(d=Math.floor(l.attributes.position.count/2)),"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?a+=d:r+=d),!1!==h.visible&&(h.isMesh||h.isLine||h.isPoints)&&(e++,h.isMesh?n+=c:"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?o+=d:s+=d))});const h=this.geometryCache?this.geometryCache.size:0,l=Array.from(this.geometryCache?.values?.()||[]).reduce((t,e)=>t+e,0),c=new Set,d=new Set;if(Array.isArray(this.structures))for(const t of this.structures)try{for(const e of t.materialCache.values())e?.mesh?.uuid&&c.add(e.mesh.uuid),e?.points?.uuid&&c.add(e.points.uuid),e?.lines?.uuid&&c.add(e.lines.uuid)}catch(t){console.error("Error adding material to uniqueMaterialIds",t)}const u=c.size,p=d.size,m=l;if(!this._webglInfoCache)try{const t=this.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");if(e){const i=t.getParameter(e.UNMASKED_RENDERER_WEBGL),n=t.getParameter(e.UNMASKED_VENDOR_WEBGL);this._webglInfoCache={renderer:i,vendor:n}}else this._webglInfoCache={renderer:null,vendor:null}}catch(t){console.error("Error getting webgl info",t),this._webglInfoCache={renderer:null,vendor:null}}const f=new $e;return this.renderer&&this.renderer.getSize&&this.renderer.getSize(f),{scene:{beforeOptimization:{objects:t-e,triangles:i-n,lines:r-s,edges:a-o},afterOptimization:{objects:e,triangles:n,lines:s,edges:o}},memory:{geometries:{count:h,bytes:l},textures:{count:p},materials:{count:u},totalEstimatedGpuBytes:m},system:{webglRenderer:this._webglInfoCache?.renderer||"",webglVendor:this._webglInfoCache?.vendor||"",viewport:{width:f.x||0,height:f.y||0}}}}async loadNode(t,e){const i=this.nodes.get(t);if(!i||i.loaded||i.loading)return;i.loading=!0;const n=i.structure.getJson().meshes[i.meshIndex];try{const t=[],r=new Map;for(let e=0;e<n.primitives.length;e++){const s=n.primitives[e],a=[];if(void 0!==s.attributes.POSITION){const t=s.attributes.POSITION,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"position",primIdx:e})}if(void 0!==s.attributes.NORMAL){const t=s.attributes.NORMAL,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"normal",primIdx:e})}if(void 0!==s.attributes.TEXCOORD_0){const t=s.attributes.TEXCOORD_0,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"uv",primIdx:e})}if(void 0!==s.indices){const t=s.indices,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"index",primIdx:e})}r.set(e,a),t.push(...a)}if(0===t.length)return i.loaded=!0,void(i.loading=!1);t.sort((t,e)=>t.offset-e.offset);const s=t[0].offset,a=Math.max(...t.map(t=>t.offset+t.length))-s,{buffer:o,relOffset:h}=await i.structure.scheduleRequest({offset:s,length:a,componentType:null});for(const e of t){const t=e.offset-s;e.data=i.structure.createTypedArray(o,h+t,e.length,e.componentType)}for(let t=0;t<n.primitives.length;t++){const e=n.primitives[t],s=new _r,a=r.get(t);if(void 0!==e.attributes.POSITION){const t=a.find(t=>"position"===t.type&&t.accessorIndex===e.attributes.POSITION),n=i.structure.json.accessors[e.attributes.POSITION],r=i.structure.getNumComponents(n.type);s.setAttribute("position",new hr(t.data,r))}if(void 0!==e.attributes.NORMAL){const t=a.find(t=>"normal"===t.type&&t.accessorIndex===e.attributes.NORMAL),n=i.structure.json.accessors[e.attributes.NORMAL],r=i.structure.getNumComponents(n.type);s.setAttribute("normal",new hr(t.data,r))}if(void 0!==e.attributes.TEXCOORD_0){const t=a.find(t=>"uv"===t.type&&t.accessorIndex===e.attributes.TEXCOORD_0),n=i.structure.json.accessors[e.attributes.TEXCOORD_0],r=i.structure.getNumComponents(n.type);s.setAttribute("uv",new hr(t.data,r))}if(void 0!==e.indices){const t=a.find(t=>"index"===t.type&&t.accessorIndex===e.indices);s.setIndex(new hr(t.data,1))}let o,h;if(void 0!==e.material){if(o=i.structure.getCachedMaterial(e.material,e.mode),!o){const t=i.structure.json.materials[e.material];o=i.structure.createMaterial(t,e.mode)}}else o=this.createDefaultMaterial(e.mode);e.mode===Wf?h=new Ba(s,o):e.mode===qf||e.mode===Zf||e.mode===Kf||void 0===e.mode?(h=new Lr(s,o),e.mode===Zf?h.drawMode=1:e.mode===Kf&&(h.drawMode=2)):e.mode===jf?h=new Da(s,o):e.mode===Yf?h=new Ra(s,o):e.mode===Xf&&(h=new Oa(s,o)),i.extras&&(h.userData={...h.userData,...i.extras}),n.extras&&(h.userData={...h.userData,...n.extras}),e.extras&&(h.userData={...h.userData,...e.extras}),i.handle?h.userData.handle=i.handle:h.userData.handle=this.getFullHandle(i.structure.id,h.userData.handle),"edges"===h.material.name?h.userData.isEdge=!0:h.userData.isEdge=!1,this.registerObjectWithHandle(h,h.userData.handle),h.position.copy(i.position),s.attributes.normal||s.computeVertexNormals(),o.aoMap&&s.attributes.uv&&s.setAttribute("uv2",s.attributes.uv),i.group?i.group.add(h):this.scene.add(h),i.object=h,this.totalLoadedObjects++,h.visible=this.totalLoadedObjects<this.graphicsObjectLimit}i.loaded=!0,i.loading=!1;const l=this.estimateGeometrySize(i.object);this.geometryCache.set(i.object.uuid,l),this.currentMemoryUsage+=l,e&&e()}catch(e){if(i.loading=!1,"AbortError"===e.name)return;if(i.structure&&i.structure.loadingAborted)return;console.error(`Error loading node ${t}:`,e)}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse(t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}}),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)})}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)await t.initialize(this),this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new qr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const r=i.scenes[i.scene||0];for(const t of r.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const r=i.geometryExtents.getSize(new ei),s=n.geometryExtents.getSize(new ei),a=r.x*r.y*r.z;return s.x*s.y*s.z-a}),!e&&this.visibleEdges&&this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map(t=>({id:t.id,nodeCount:this.nodesToLoad.filter(e=>e.startsWith(t.id)).length}))})}getFullHandle(t,e){return`${t}:${e}`}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let r=null,s=null;if(n.extras?.handle&&(s=this.getFullHandle(t.id,n.extras.handle)),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(r=new qr,r.name=n.name||`node_${e}`,n.extras&&(r.userData={...n.extras},r.userData.handle&&(r.userData.handle=this.getFullHandle(t.id,r.userData.handle))),n.matrix)r.matrix.fromArray(n.matrix),r.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new ei).fromArray(n.translation):new ei,e=n.rotation?(new ti).fromArray(n.rotation):new ti,i=n.scale?(new ei).fromArray(n.scale):new ei(1,1,1);r.matrix.compose(t,e,i),r.matrixAutoUpdate=!1}i&&i.add(r)}if(void 0!==n.mesh){const a=new sn,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Li;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Li((new ei).fromArray(i.min),(new ei).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),h.extras&&h.extras.handle&&(s=this.getFullHandle(t.id,h.extras.handle)),this.nodes.set(o,{position:r?r.position.clone():(new ei).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:r||i,structure:t,extras:n.extras,geometryExtents:l,handle:s||this.getFullHandle(t.id,t._nextObjectId++)})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,r||i);return r}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0,i=0;const n=t.length,r=async()=>{if(e++,e-i>1e3){i=e,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:Math.round(e/n*100),loaded:e,total:n});const t=Date.now();t-this.lastUpdateTime>=this.updateInterval&&(this.dispatchEvent("update"),this.lastUpdateTime=t),await new Promise(t=>{setTimeout(t,0)})}};try{const i=[];for(const n of t){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=await this.estimateNodeSize(n);if(this.currentMemoryUsage+t>this.memoryLimit)return console.log(`Memory limit reached after loading ${e} nodes`),this.dispatchEvent("geometryerror",{message:"Memory limit reached"}),this.dispatchEvent("update"),e;i.push(this.loadNode(n,r))}for(const t of this.structures)i.push(t.flushBufferRequests());return await Promise.all(i),this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:n}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("Process nodes"),await this.processNodes(),console.timeEnd("Process nodes"),console.time("Optimize scene"),await this.optimizeScene(),console.timeEnd("Optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach(t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)})}createDefaultMaterial(t=void 0){return t===Wf?new Na({color:new Jn(8421504),size:.05,sizeAttenuation:!1,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):t===jf||t===Yf||t===Xf?new wa({color:8421504,linewidth:1,alphaTest:.1,depthTest:!0,depthWrite:!0,transparent:!0,opacity:1}):new Mh({color:8421504,specular:2236962,shininess:10,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Li;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone();e.group&&e.group.matrix&&(i.applyMatrix4(e.group.matrix),e.group.parent&&e.group.parent.matrix&&i.applyMatrix4(e.group.parent.matrix)),t.union(i)}return t}loadCamera(t,e,i){const n=t.getJson().cameras[e],r=n[n.type];let s;return"perspective"===n.type?s=new Vr(Qe.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new xl(r.xmag/-2,r.xmag/2,r.ymag/2,r.ymag/-2,r.znear,r.zfar)),i.matrix?(s.matrix.fromArray(i.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale)):(i.translation&&s.position.fromArray(i.translation),i.rotation&&s.quaternion.fromArray(i.rotation),i.scale&&s.scale.fromArray(i.scale)),s}clearNodesToLoad(){this.nodesToLoad=[]}removeOptimization(){this.originalObjects.forEach(t=>t.visible=!0);const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}initializeObjectVisibility(){if(this.maxObjectId>0){this.objectVisibility=new Float32Array(this.maxObjectId);for(let t=0;t<this.maxObjectId;t++)this.objectVisibility[t]=1;console.log(`Initialized object visibility array: ${this.maxObjectId} objects`)}}createVisibilityMaterial(t){return t.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include <common>","\n #include <common>\n attribute float visibility;\n varying float vVisibility;\n "),t.fragmentShader=t.fragmentShader.replace("#include <common>","\n #include <common>\n varying float vVisibility;\n "),t.vertexShader=t.vertexShader.replace("void main() {","\n void main() {\n vVisibility = visibility;\n "),t.fragmentShader=t.fragmentShader.replace("void main() {","\n void main() {\n if (vVisibility < 0.5) discard;\n ")},t.needsUpdate=!0,t}clear(){this.chunkQueue=[],this.structures.forEach(t=>{t&&t.clear()}),this.structures=[],this.nodes.forEach(t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach(t=>t.dispose()):t.object.material.dispose()))}),this.nodes.clear(),this.loadedMeshes.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),this.loadedMeshes.clear(),this.structureRoots.forEach(t=>{t&&(t.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),t.parent&&t.parent.remove(t))}),this.structureRoots.clear(),this.mergedMesh.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose()),t.parent&&t.parent.remove(t)}),this.mergedMesh.clear(),this.mergedLines.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLines.clear(),this.mergedLineSegments.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLineSegments.clear(),this.mergedPoints.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.totalLoadedObjects=0,this.lastUpdateTime=0,this.currentMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator(),this.objectIdToIndex.clear(),this.maxObjectId=0,this.objectVisibility=new Float32Array}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter(t=>t!==e))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach(t=>t(e))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split(":")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach(t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)}),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,r=t.geometry.index?t.geometry.index.count:0,s=t.material;let a,o=this.getMaterialId(s,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+r>1e5){const a={material:s,objects:[t],totalVertices:n,totalIndices:r};o=this.getMaterialId(s,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=r;else a={material:s,objects:[t],totalVertices:n,totalIndices:r},e.set(o,a),i.push(a);this.originalObjects.add(t)}yieldToUI(){return new Promise(t=>{requestAnimationFrame(()=>{setTimeout(t,0)})})}async optimizeScene(){console.log("Starting scene optimization..."),this.dispatchEvent("optimizationprogress",{phase:"start",progress:0,message:"Starting optimization..."}),this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.dispatchEvent("optimizationprogress",{phase:"collecting",progress:5,message:"Collecting scene objects..."}),this.scene.traverse(e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Lr?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof Da?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Ra?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof Ba&&this.addToMaterialGroup(e,n.mapPoints,n.points)}});let e=0;const i=t.size;this.dispatchEvent("optimizationprogress",{phase:"merging",progress:10,message:`Merging ${i} structure groups...`,current:0,total:i});for(const n of t.values()){n.mapMeshes.clear(),n.mapLines.clear(),n.mapLineSegments.clear(),n.mapPoints.clear(),await this.mergeMeshGroups(n.meshes,n.rootGroup),await this.yieldToUI(),await this.mergeLineGroups(n.lines,n.rootGroup),await this.yieldToUI(),await this.mergeLineSegmentGroups(n.lineSegments,n.rootGroup),await this.yieldToUI(),await this.mergePointsGroups(n.points,n.rootGroup),e++;const t=10+Math.round(e/i*80);this.dispatchEvent("optimizationprogress",{phase:"merging",progress:t,message:`Processing structure ${e}/${i}...`,current:e,total:i}),console.log(`Optimization progress: ${e}/${i} structure groups processed (${t}%)`),await this.yieldToUI()}this.dispatchEvent("optimizationprogress",{phase:"finalizing",progress:95,message:"Finalizing optimization..."}),this.originalObjects.forEach(t=>{t.visible=!1,t instanceof Ba||t.userData.isEdge||this.originalObjectsToSelection.add(t)}),this.initializeObjectVisibility(),console.log(`Optimization complete. Total objects: ${this.maxObjectId}`),this.dispatchEvent("optimizationprogress",{phase:"complete",progress:100,message:`Optimization complete! ${this.maxObjectId} objects processed.`}),this.dispatchEvent("update")}async mergeMeshGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=new Set,s=[],a=new Map;let o=0;for(const e of n.objects){const i=e.geometry.clone(),n=e.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++);const h=this.objectIdToIndex.get(n),l=i.attributes.position.count,c=new Float32Array(l);for(let t=0;t<l;t++)c[t]=h;i.setAttribute("objectId",new hr(c,1)),a.set(e,{geometry:i,startVertexIndex:o,vertexCount:i.attributes.position.count}),o+=i.attributes.position.count,t.push(i),s.push(e),r.add(e.userData.handle)}const h=[];if(t.length>0){const i=$f(t),r=i.attributes.position.count,o=new Float32Array(r);for(let t=0;t<r;t++)o[t]=1;i.setAttribute("visibility",new hr(o,1)),this.useVAO&&this.createVAO(i);const l=this.createVisibilityMaterial(n.material),c=new Lr(i,l);c.userData.isOptimized=!0,e.add(c),this.mergedMesh.add(c),this.optimizedOriginalMap.set(c,s),this.mergedObjectMap.set(c.uuid,{objectMapping:a,visibilityArray:o,totalVertices:r}),this.mergedGeometryVisibility.set(c,o),h.push(c),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...h),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,h)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.error("Failed to merge meshes for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping mesh group with null material")}async mergeLineGroups(t,e){let i=0;for(const n of t){if(0===n.objects.length)continue;if(!n.material){console.warn("Skipping line group with null material");continue}const t=new Set;let r=0;const s=new Map;let a=0;n.objects.map(e=>{t.add(e.userData.handle),r+=e.geometry.attributes.position.count});const o=new Float32Array(3*r);let h=0;const l=[];let c=0,d=!1;n.objects.forEach(t=>{d=t.userData.isEdge;const e=t.geometry.attributes.position,i=e.count,n=t.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++),s.set(t,{startVertexIndex:a,vertexCount:i}),a+=i;const r=new ei;for(let t=0;t<i;t++)r.fromBufferAttribute(e,t),o[h++]=r.x,o[h++]=r.y,o[h++]=r.z;for(let t=0;t<i-1;t++)l.push(c+t,c+t+1);c+=i});const u=new _r;u.setAttribute("position",new hr(o,3)),u.setIndex(l),u.computeBoundingSphere(),u.computeBoundingBox();const p=new Float32Array(r);let m=0;n.objects.forEach(t=>{const e=t.geometry.attributes.position.count,i=t.userData.handle,n=this.objectIdToIndex.get(i);for(let t=0;t<e;t++)p[m++]=n}),u.setAttribute("objectId",new hr(p,1));const f=new Float32Array(r);for(let t=0;t<r;t++)f[t]=1;u.setAttribute("visibility",new hr(f,1));const g=this.createVisibilityMaterial(n.material),v=new Da(u,g);v.userData.isEdge=d,v.userData.isOptimized=!0;const y=[v];this.useVAO&&this.createVAO(v),e.add(v),this.mergedLines.add(v),this.optimizedOriginalMap.set(v,n.objects),this.mergedObjectMap.set(v.uuid,{objectMapping:s,visibilityArray:f,totalVertices:r}),this.mergedGeometryVisibility.set(v,f),t.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...y),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,y)}),i++,i%5==0&&await this.yieldToUI()}}async mergeLineSegmentGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=[],s=new Set,a=new Map;let o=0,h=!1;for(const e of n.objects){h=e.userData.isEdge;const i=e.geometry.clone(),n=e.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++);const l=this.objectIdToIndex.get(n),c=i.attributes.position.count,d=new Float32Array(c);for(let t=0;t<c;t++)d[t]=l;i.setAttribute("objectId",new hr(d,1)),a.set(e,{geometry:i,startVertexIndex:o,vertexCount:i.attributes.position.count}),o+=i.attributes.position.count,t.push(i),r.push(e),s.add(e.userData.handle)}const l=[];if(t.length>0){const i=$f(t,!1),s=i.attributes.position.count,o=new Float32Array(s);for(let t=0;t<s;t++)o[t]=1;i.setAttribute("visibility",new hr(o,1));const c=this.createVisibilityMaterial(n.material),d=new Da(i,c);d.userData.isEdge=h,d.userData.isOptimized=!0,this.useVAO&&this.createVAO(d),e.add(d),this.mergedLineSegments.add(d),this.optimizedOriginalMap.set(d,r),this.mergedObjectMap.set(d.uuid,{objectMapping:a,visibilityArray:o,totalVertices:s}),this.mergedGeometryVisibility.set(d,o),l.push(d),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...l),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,l)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge line segments for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping line segment group with null material")}async mergePointsGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=[],s=new Set;for(const e of n.objects){const i=e.geometry.clone();t.push(i),r.push(e),s.add(e.userData.handle)}const a=[];if(t.length>0){const i=$f(t,!1),s=new Ba(i,n.material);s.userData.isOptimized=!0,this.useVAO&&this.createVAO(s),e.add(s),this.mergedPoints.add(s),this.optimizedOriginalMap.set(s,r),a.push(s),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...a),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,a)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge points for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping points group with null material")}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter(e=>e.userData.structureId===t);if(0!==i.length)try{const n=[],r=i.some(t=>void 0!==t.geometry.attributes.normal);i.forEach(t=>{const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld),r&&!e.attributes.normal&&e.computeVertexNormals(),!r&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new hr(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)});const s=$f(n,!1),a=new wa({vertexColors:!0});this.useVAO&&this.createVAO(s);const o=new Da(s,a);o.userData.structureId=t,o.userData.isOptimized=!0,e.add(o),this.mergedLineSegments.add(o),i.forEach(t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()})}catch(t){console.error("Failed to merge geometries:",t),i.forEach(t=>{t.visible=!0,e.add(t)})}}showOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!0)})}hideOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!1)})}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],r=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,r),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach(t=>{this.hiddenHandles.add(t)}),this.syncHiddenObjects()}showObjects(t){t.forEach(t=>{this.hiddenHandles.delete(t)}),this.syncHiddenObjects()}_updateVisibilityAttribute(t){if(t.geometry&&t.geometry.attributes.visibility&&t.geometry.attributes.objectId){const e=t.geometry.attributes.visibility.array,i=t.geometry.attributes.objectId.array;for(let t=0;t<e.length;t++){const n=i[t];n<this.objectVisibility.length&&(e[t]=this.objectVisibility[n])}t.geometry.attributes.visibility.needsUpdate=!0}}syncHiddenObjects(){if(0!==this.mergedObjectMap.size){if(this.objectVisibility.length>0){for(let t=0;t<this.objectVisibility.length;t++)this.objectVisibility[t]=1;this.hiddenHandles.forEach(t=>{const e=this.objectIdToIndex.get(t);void 0!==e&&e<this.objectVisibility.length&&(this.objectVisibility[e]=0)})}for(const t of this.mergedMesh)this._updateVisibilityAttribute(t);for(const t of this.mergedLines)this._updateVisibilityAttribute(t);for(const t of this.mergedLineSegments)this._updateVisibilityAttribute(t);for(const t of this.mergedPoints)this._updateVisibilityAttribute(t)}else console.log("No merged objects to sync")}getStructureGeometryExtent(t){const e=new Li;for(const[i,n]of this.nodes.entries()){if(!n.geometryExtents)continue;if(!i.startsWith(t+"_"))continue;if(n.object&&this.hiddenHandles&&this.hiddenHandles.has(n.object.userData.handle))continue;const r=n.geometryExtents.clone();n.group&&n.group.matrix&&(r.applyMatrix4(n.group.matrix),n.group.parent&&n.group.parent.matrix&&r.applyMatrix4(n.group.parent.matrix)),e.union(r)}return e}setMaxConcurrentChunks(t){t<1?console.warn("Max concurrent chunks must be at least 1"):this.maxConcurrentChunks=t}waitForChunkSlot(){return this.activeChunkLoads<this.maxConcurrentChunks?(this.activeChunkLoads++,Promise.resolve()):new Promise(t=>{this.chunkQueue.push(t)})}releaseChunkSlot(){if(this.activeChunkLoads--,this.chunkQueue.length>0){const t=this.chunkQueue.shift();this.activeChunkLoads++,t()}}}class ig extends Qh{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Cl.extractUrlBase(t)):(i.forEach((e,i)=>this.fileURL=e===t?i:this.fileURL),i.set(this.fileURL,t)),i.forEach((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)}),this.setURLModifier(t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t})}dispose(){this.dataURLs.forEach(t=>URL.revokeObjectURL(t))}}const ng="glTF",rg=1313821514,sg=5128258;class ag{constructor(t){const e=new DataView(t,0,12),i=new TextDecoder,n=i.decode(new Uint8Array(t.slice(0,4)));if(n!==ng)return void(this.content=i.decode(t));const r=n,s=e.getUint32(4,!0),a=e.getUint32(8,!0);if(r!==ng)throw new Error("Unsupported glTF-Binary header.");if(s<2)throw new Error("Legacy binary file detected.");const o=a-12,h=new DataView(t,12);let l=0;for(;l<o;){const e=h.getUint32(l,!0);l+=4;const n=h.getUint32(l,!0);if(l+=4,n===rg){const n=new Uint8Array(t,12+l,e);this.content=i.decode(n)}else if(n===sg){const i=12+l;this.body=t.slice(i,i+e)}l+=e}if(void 0===this.content)throw new Error("JSON content not found.")}}class og extends Error{constructor(t,e){super(e),this.name="FetchError",this.status=t}}class hg{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}async load(t,e){const i={headers:{...this.requestHeader,Range:"bytes="+e.map(t=>`${t.offset}-${t.offset+t.length-1}`).join(",")},credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal},n=await fetch(t,i);if(!n.ok)throw new og(n.status,`Failed to fetch "${t}", status ${n.status}`);if(206!==n.status){const t=await n.arrayBuffer();return this.extractRanges(t,e)}return n.arrayBuffer()}extractRanges(t,e){const i=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(i);let r=0;for(const i of e){const e=new Uint8Array(t,i.offset,i.length);n.set(e,r),r+=i.length}return n.buffer}}class lg extends c{constructor(t){super(),this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear(),this.manager&&this.manager.dispose()}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){this.manager=new ig(t,i);const n=new qr;this.gltfLoader=new eg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.visibleEdges=this.viewer.options.edgeModel;const r=new Hf(n);r.id=i.modelId||this.extractFileName(t),r.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",()=>{this.viewer.scene.add(n),this.viewer.models.push(r),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t})}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t})}),this.gltfLoader.addEventListener("update",t=>{this.viewer.update()});const s={loadJson:async()=>{const e=new nl(this.manager);e.setPath(this.manager.path),e.setRequestHeader(i.requestHeader||{}),e.setWithCredentials(i.withCredentials||e.withCredentials),e.setResponseType("arraybuffer");const n=await e.loadAsync(this.manager.fileURL,e=>{const{lengthComputable:i,loaded:n,total:r}=e,s=i?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:s,file:t})}),r=new ag(n);if(this.gltf=JSON.parse(r.content),this.glb=r.body,/\.glb$/i.test(this.manager.fileURL)&&!this.glb)throw new Error("GLTFFileDynamicLoader: Binary buffer chunk not found or type not supported.");return this.gltf},loadBinaryData:(t,e="")=>{const n=new hg;if(n.setRequestHeader(i.requestHeader||{}),n.setWithCredentials(i.withCredentials||!1),n.setAbortSignal(this.gltfLoader.abortController.signal),this.glb)return n.extractRanges(this.glb,t);const r=this.manager.path||this.manager.resourcePath,s=Cl.resolveURL(e,r);return n.load(this.manager.resolveURL(s),t)},resolveURL:t=>{const e=this.manager.path||this.manager.resourcePath,i=Cl.resolveURL(t,e);return Promise.resolve(this.manager.resolveURL(i))}},a=new Qf(r.id,s);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}class cg extends c{constructor(t){super(),this.requestId=0,this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i={}){const n=new qr;this.gltfLoader=new eg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);const r=new Hf(n);r.id=t.file.id,r.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",e=>{this.viewer.scene.add(n),this.viewer.models.push(r),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t})}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}),this.gltfLoader.addEventListener("update",t=>{this.viewer.update()});const s={loadJson:async()=>{const e=await t.downloadResource(t.database,e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t})},this.gltfLoader.getAbortController().signal),i=(new TextDecoder).decode(e);return JSON.parse(i)},loadBinaryData:e=>{const i=e.map(t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++}));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},resolveURL:e=>{const i=`${t.httpClient.serverUrl}${t.path}/`,n=Cl.resolveURL(e,i);return Promise.resolve(n)}},a=new Qf(r.id,s);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const dg=p("threejs");dg.registerLoader("gltf-file",t=>new lg(t)),dg.registerLoader("gltf-cloud",t=>new cg(t));const ug={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\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}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class pg{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const mg=new xl(-1,1,1,-1,0,1);const fg=new class extends _r{constructor(){super(),this.setAttribute("position",new dr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new dr([0,2,0,0,2,0],2))}};class gg{constructor(t){this._mesh=new Lr(fg,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,mg)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class vg extends pg{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof zr?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Fr.clone(t.uniforms),this.material=new zr({name:void 0!==t.name?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new gg(this.material)}render(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class yg extends pg{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const n=t.getContext(),r=t.state;let s,a;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),r.buffers.stencil.setFunc(n.ALWAYS,s,4294967295),r.buffers.stencil.setClear(a),r.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(n.EQUAL,1,4294967295),r.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),r.buffers.stencil.setLocked(!0)}}class _g extends pg{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class xg{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),void 0===e){const i=t.getSize(new $e);this._width=i.width,this._height=i.height,(e=new Ci(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wt})).texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new vg(ug),this.copyPass.material.blending=0,this.clock=new Gl}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let i=!1;for(let e=0,n=this.passes.length;e<n;e++){const n=this.passes[e];if(!1!==n.enabled){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),n.render(this.renderer,this.writeBuffer,this.readBuffer,t,i),n.needsSwap){if(i){const e=this.renderer.getContext(),i=this.renderer.state.buffers.stencil;i.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),i.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==yg&&(n instanceof yg?i=!0:n instanceof _g&&(i=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new $e);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(i,n)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class wg extends pg{constructor(t,e,i=null,n=null,r=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Jn}render(t,e,i){const n=t.autoClear;let r,s;t.autoClear=!1,null!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),null!==this.clearAlpha&&(r=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),!0===this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),null!==this.clearColor&&t.setClearColor(this._oldClearColor),null!==this.clearAlpha&&t.setClearAlpha(r),null!==this.overrideMaterial&&(this.scene.overrideMaterial=s),t.autoClear=n}}const bg={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\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}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n\t\t}"};class Sg extends vg{constructor(){super(bg)}setSize(t,e){this.material.uniforms.resolution.value.set(1/t,1/e)}}const Mg={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvoid SMAAEdgeDetectionVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAAEdgeDetectionVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n\t\t\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n\t\t\t// Calculate color deltas:\n\t\t\tvec4 delta;\n\t\t\tvec3 C = texture2D( colorTex, texcoord ).rgb;\n\n\t\t\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n\t\t\tvec3 t = abs( C - Cleft );\n\t\t\tdelta.x = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n\t\t\tt = abs( C - Ctop );\n\t\t\tdelta.y = max( max( t.r, t.g ), t.b );\n\n\t\t\t// We do the usual threshold:\n\t\t\tvec2 edges = step( threshold, delta.xy );\n\n\t\t\t// Then discard if there is no edge:\n\t\t\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n\t\t\t\tdiscard;\n\n\t\t\t// Calculate right and bottom deltas:\n\t\t\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n\t\t\tt = abs( C - Cright );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n\t\t\tt = abs( C - Cbottom );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the maximum delta in the direct neighborhood:\n\t\t\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n\t\t\t// Calculate left-left and top-top deltas:\n\t\t\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n\t\t\tt = abs( C - Cleftleft );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n\t\t\tt = abs( C - Ctoptop );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the final maximum delta:\n\t\t\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n\t\t\t// Local contrast adaptation in action:\n\t\t\tedges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n\t\t\treturn vec4( edges, 0.0, 0.0 );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n\t\t}"},Eg={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\t\tvarying vec2 vPixcoord;\n\n\t\tvoid SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n\t\t\tvPixcoord = texcoord / resolution;\n\n\t\t\t// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n\t\t\t// And these for the searches, they indicate the ends of the loops:\n\t\t\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAABlendingWeightCalculationVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tArea;\n\t\tuniform sampler2D tSearch;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[3];\n\t\tvarying vec2 vPixcoord;\n\n\t\t#if __VERSION__ == 100\n\t\tvec2 round( vec2 x ) {\n\t\t\treturn sign( x ) * floor( abs( x ) + 0.5 );\n\t\t}\n\t\t#endif\n\n\t\tfloat SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n\t\t\t// Not required if searchTex accesses are set to point:\n\t\t\t// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n\t\t\t// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n\t\t\t// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n\t\t\te.r = bias + e.r * scale;\n\t\t\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;\n\t\t}\n\n\t\tfloat SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\t/**\n\t\t\t\t* @PSEUDO_GATHER4\n\t\t\t\t* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n\t\t\t\t* sample between edge, thus fetching four edges in a row.\n\t\t\t\t* Sampling with different offsets in each direction allows to disambiguate\n\t\t\t\t* which edges are active from the four fetched ones.\n\t\t\t\t*/\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\t// We correct the previous (-0.25, -0.125) offset we applied:\n\t\t\ttexcoord.x += 0.25 * resolution.x;\n\n\t\t\t// The searches are bias by 1, so adjust the coords accordingly:\n\t\t\ttexcoord.x += resolution.x;\n\n\t\t\t// Disambiguate the length added by the last step:\n\t\t\ttexcoord.x += 2.0 * resolution.x; // Undo last step\n\t\t\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.x -= 0.25 * resolution.x;\n\t\t\ttexcoord.x -= resolution.x;\n\t\t\ttexcoord.x -= 2.0 * resolution.x;\n\t\t\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tfloat SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tvec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n\t\t\t// Rounding prevents precision errors of bilinear filtering:\n\t\t\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n\t\t\t// We do a scale and bias for mapping to texel space:\n\t\t\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n\t\t\t// Move to proper place, according to the subpixel offset:\n\t\t\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n\t\t\treturn texture2D( areaTex, texcoord, 0.0 ).rg;\n\t\t}\n\n\t\tvec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n\t\t\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n\t\t\tvec2 e = texture2D( edgesTex, texcoord ).rg;\n\n\t\t\tif ( e.g > 0.0 ) { // Edge at north\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the left:\n\t\t\t\tvec2 coords;\n\t\t\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n\t\t\t\tcoords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n\t\t\t\td.x = coords.x;\n\n\t\t\t\t// Now fetch the left crossing edges, two at a time using bilinear\n\t\t\t\t// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n\t\t\t\t// discern what value each edge has:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n\t\t\t\t// Find the distance to the right:\n\t\t\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n\t\t\t\td.y = coords.x;\n\n\t\t\t\t// We want the distances to be in pixel units (doing this here allow to\n\t\t\t\t// better interleave arithmetic and memory accesses):\n\t\t\t\td = d / resolution.x - pixcoord.x;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the right crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n\t\t\t\t// Ok, we know how this pattern looks like, now it is time for getting\n\t\t\t\t// the actual area:\n\t\t\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n\t\t\t}\n\n\t\t\tif ( e.r > 0.0 ) { // Edge at west\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the top:\n\t\t\t\tvec2 coords;\n\n\t\t\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n\t\t\t\tcoords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n\t\t\t\td.x = coords.y;\n\n\t\t\t\t// Fetch the top crossing edges:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n\t\t\t\t// Find the distance to the bottom:\n\t\t\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n\t\t\t\td.y = coords.y;\n\n\t\t\t\t// We want the distances to be in pixel units:\n\t\t\t\td = d / resolution.y - pixcoord.y;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the bottom crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n\t\t\t\t// Get the area for this direction:\n\t\t\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n\t\t\t}\n\n\t\t\treturn weights;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n\t\t}"},Tg={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvoid SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAANeighborhoodBlendingVS( vUv );\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 sampler2D tColor;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n\t\t\t// Fetch the blending weights for current pixel:\n\t\t\tvec4 a;\n\t\t\ta.xz = texture2D( blendTex, texcoord ).xz;\n\t\t\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n\t\t\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n\t\t\t// Is there any blending weight with a value greater than 0.0?\n\t\t\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n\t\t\t\treturn texture2D( colorTex, texcoord, 0.0 );\n\t\t\t} else {\n\t\t\t\t// Up to 4 lines can be crossing a pixel (one through each edge). We\n\t\t\t\t// favor blending by choosing the line with the maximum weight for each\n\t\t\t\t// direction:\n\t\t\t\tvec2 offset;\n\t\t\t\toffset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n\t\t\t\toffset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n\t\t\t\t// Then we go in the direction that has the maximum weight:\n\t\t\t\tif ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n\t\t\t\t\toffset.y = 0.0;\n\t\t\t\t} else {\n\t\t\t\t\toffset.x = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Fetch the opposite color and lerp by hand:\n\t\t\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\ttexcoord += sign( offset ) * resolution;\n\t\t\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n\t\t\t\t// WebGL port note: Added gamma correction\n\t\t\t\tC.xyz = pow(C.xyz, vec3(2.2));\n\t\t\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));\n\t\t\t\tvec4 mixed = mix(C, Cop, s);\n\t\t\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n\t\t\t\treturn mixed;\n\t\t\t}\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n\t\t}"};class Ag extends pg{constructor(){super(),this._edgesRT=new Ci(1,1,{depthBuffer:!1,type:wt}),this._edgesRT.texture.name="SMAAPass.edges",this._weightsRT=new Ci(1,1,{depthBuffer:!1,type:wt}),this._weightsRT.texture.name="SMAAPass.weights";const t=this,e=new Image;e.src=this._getAreaTexture(),e.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Ei,this._areaTexture.name="SMAAPass.area",this._areaTexture.image=e,this._areaTexture.minFilter=dt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;const i=new Image;i.src=this._getSearchTexture(),i.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Ei,this._searchTexture.name="SMAAPass.search",this._searchTexture.image=i,this._searchTexture.magFilter=ht,this._searchTexture.minFilter=ht,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=Fr.clone(Mg.uniforms),this._materialEdges=new zr({defines:Object.assign({},Mg.defines),uniforms:this._uniformsEdges,vertexShader:Mg.vertexShader,fragmentShader:Mg.fragmentShader}),this._uniformsWeights=Fr.clone(Eg.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new zr({defines:Object.assign({},Eg.defines),uniforms:this._uniformsWeights,vertexShader:Eg.vertexShader,fragmentShader:Eg.fragmentShader}),this._uniformsBlend=Fr.clone(Tg.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new zr({uniforms:this._uniformsBlend,vertexShader:Tg.vertexShader,fragmentShader:Tg.fragmentShader}),this._fsQuad=new gg(null)}render(t,e,i){this._uniformsEdges.tDiffuse.value=i.texture,this._fsQuad.material=this._materialEdges,t.setRenderTarget(this._edgesRT),this.clear&&t.clear(),this._fsQuad.render(t),this._fsQuad.material=this._materialWeights,t.setRenderTarget(this._weightsRT),this.clear&&t.clear(),this._fsQuad.render(t),this._uniformsBlend.tColor.value=i.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(),this._fsQuad.render(t))}setSize(t,e){this._edgesRT.setSize(t,e),this._weightsRT.setSize(t,e),this._materialEdges.uniforms.resolution.value.set(1/t,1/e),this._materialWeights.uniforms.resolution.value.set(1/t,1/e),this._materialBlend.uniforms.resolution.value.set(1/t,1/e)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return"data:image/png;base64,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"}_getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}}class Cg extends pg{constructor(t,e,i=0,n=0){super(),this.scenes=Array.isArray(t)?t:[t],this.camera=e,this.sampleLevel=2,this.unbiased=!0,this.stencilBuffer=!1,this.clearColor=i,this.clearAlpha=n,this._sampleRenderTarget=null,this._oldClearColor=new Jn,this._copyUniforms=Fr.clone(ug.uniforms),this._copyMaterial=new zr({uniforms:this._copyUniforms,vertexShader:ug.vertexShader,fragmentShader:ug.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:2}),this._fsQuad=new gg(this._copyMaterial)}dispose(){this._sampleRenderTarget&&(this._sampleRenderTarget.dispose(),this._sampleRenderTarget=null),this._copyMaterial.dispose(),this._fsQuad.dispose()}setSize(t,e){this._sampleRenderTarget&&this._sampleRenderTarget.setSize(t,e)}render(t,e,i,n,r){this._sampleRenderTarget||(this._sampleRenderTarget=new Ci(i.width,i.height,{type:wt,stencilBuffer:this.stencilBuffer}),this._sampleRenderTarget.texture.name="SSAAMultiRenderPass.sample");const s=Rg[Math.max(0,Math.min(this.sampleLevel,5))],a=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const o=t.getClearAlpha(),h=1/s.length;this._copyUniforms.tDiffuse.value=this._sampleRenderTarget.texture;const l={fullWidth:i.width,fullHeight:i.height,offsetX:0,offsetY:0,width:i.width,height:i.height},c=Object.assign({},this.camera.view);c.enabled&&Object.assign(l,c);for(let i=0;i<s.length;i++){const n=s[i];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*n[0],l.offsetY+.0625*n[1],l.width,l.height);let r=h;if(this.unbiased){r+=.03125*((i+.5)/s.length-.5)}this._copyUniforms.opacity.value=r,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this._sampleRenderTarget),t.clear(),this.scenes.forEach(e=>t.render(e,this.camera)),t.setRenderTarget(this.renderToScreen?null:e),0===i&&(t.setClearColor(0,0),t.clear()),this._fsQuad.render(t)}this.camera.setViewOffset&&c.enabled?this.camera.setViewOffset(c.fullWidth,c.fullHeight,c.offsetX,c.offsetY,c.width,c.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=a,t.setClearColor(this._oldClearColor,o)}}const Rg=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Pg={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:"\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}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\t#include <tonemapping_pars_fragment>\n\t\t#include <colorspace_pars_fragment>\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 Lg extends pg{constructor(){super(),this.uniforms=Fr.clone(Pg.uniforms),this.material=new wh({name:Pg.name,uniforms:this.uniforms,vertexShader:Pg.vertexShader,fragmentShader:Pg.fragmentShader}),this._fsQuad=new gg(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,this._outputColorSpace===t.outputColorSpace&&this._toneMapping===t.toneMapping||(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},fi.getTransfer(this._outputColorSpace)===Ae&&(this.material.defines.SRGB_TRANSFER=""),1===this._toneMapping?this.material.defines.LINEAR_TONE_MAPPING="":2===this._toneMapping?this.material.defines.REINHARD_TONE_MAPPING="":3===this._toneMapping?this.material.defines.CINEON_TONE_MAPPING="":4===this._toneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":6===this._toneMapping?this.material.defines.AGX_TONE_MAPPING="":7===this._toneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":5===this._toneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),!0===this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Ig{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter(t=>t!==e);return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach(e=>e.call(this,t)),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}const Dg=Math.PI/180;const Og="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Ng={_global:Og,version:"10.0.12",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>Ng.angleDeg?t*Dg:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Ng.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=Ng.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!Ng.DD.node,releaseCanvasOnDestroy:!0,document:Og.document,_injectGlobal(t){void 0!==Og.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),Og.Konva=t}},Ug=t=>{Ng[t.prototype.getClassName()]=t};Ng._injectGlobal(Ng);const Fg=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class zg{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new zg(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],r=t*n-e*i,s={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);s.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),s.scaleX=a,s.scaleY=r/a,s.skewX=(t*i+e*n)/r,s.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);s.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),s.scaleX=r/a,s.scaleY=a,s.skewX=0,s.skewY=(t*i+e*n)/r}return s.rotation=qg._getRotation(s.rotation),s}}const kg=Math.PI/180,Bg=180/Math.PI,Gg="#",Hg="Konva error: ",Vg={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},Wg=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let jg=[],Xg=null;const Yg="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)},qg={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){jg.push(t),1===jg.length&&Yg(function(){const t=jg;jg=[],t.forEach(function(t){t()})})},createCanvasElement(){Fg();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(Fg(),document.createElement("img")),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=qg.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace(Gg,"");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return Gg+t},isCanvasFarblingActive(){if(null!==Xg)return Xg;if("undefined"==typeof document)return Xg=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return Xg=n,this.releaseCanvas(t),Xg},getHitColor(){const t=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(t):t},getHitColorKey(t,e,i){return this.isCanvasFarblingActive()&&(t=5*Math.round(t/5),e=5*Math.round(e/5),i=5*Math.round(i/5)),Gg+this._rgbToHex(t,e,i)},getSnappedHexColor(t){const e=this._hexToRgb(t);return Gg+this._rgbToHex(5*Math.round(e.r/5),5*Math.round(e.g/5),5*Math.round(e.b/5))},getRGB(t){let e;return t in Vg?(e=Vg[t],{r:e[0],g:e[1],b:e[2]}):t[0]===Gg?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=Wg.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",qg._namedColorToRBA(t)||qg._hex3ColorToRGBA(t)||qg._hex4ColorToRGBA(t)||qg._hex6ColorToRGBA(t)||qg._hex8ColorToRGBA(t)||qg._rgbColorToRGBA(t)||qg._rgbaColorToRGBA(t)||qg._hslColorToRGBA(t)),_namedColorToRBA(t){const e=Vg[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,r=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===r)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+r):s+r-s*r;const l=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*kg,radToDeg:t=>t*Bg,_degToRad:t=>(qg.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),qg.degToRad(t)),_radToDeg:t=>(qg.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),qg.radToDeg(t)),_getRotation:t=>Ng.angleDeg?qg.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(Hg+t)},error(t){console.error(Hg+t)},warn(t){Ng.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,r,s){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(r-i)*(r-i)+(s-n)*(s-n);else{const c=((r-t)*(i-t)+(s-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=i,o=n,h=(i-r)*(i-r)+(n-s)*(n-s)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=qg.cloneObject(t);let r=Number.MAX_VALUE;return e.forEach(function(s,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=qg._getProjectionToSegment(s.x,s.y,o.x,o.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<r&&(n.x=l,n.y=c,r=d)}),n},_prepareArrayForTween(t,e,i){const n=[],r=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});const s=[];return r.forEach(function(t){const e=qg._getProjectionToLine(t,n,i);s.push(e.x),s.push(e.y)}),s},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||qg._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===qg._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){Ng.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let r=e<0?e:0,s=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let a=0,o=0,h=0,l=0;"number"==typeof n?a=o=h=l=Math.min(n,e/2,i/2):(a=Math.min(n[0]||0,e/2,i/2),o=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r+a,s),t.lineTo(r+e-o,s),t.arc(r+e-o,s+o,o,3*Math.PI/2,0,!1),t.lineTo(r+e,s+i-l),t.arc(r+e-l,s+i-l,l,0,Math.PI/2,!1),t.lineTo(r+h,s+i),t.arc(r+h,s+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(r,s+a),t.arc(r+a,s+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,r){n=Math.abs(n);for(let s=0;s<i;s++){const a=e[(s-1+i)%i],o=e[s],h=e[(s+1)%i],l={x:o.x-a.x,y:o.y-a.y},c={x:h.x-o.x,y:h.y-o.y},d=Math.hypot(l.x,l.y),u=Math.hypot(c.x,c.y);let p;p="number"==typeof r?r:s<r.length?r[s]:0;p=n*Math.cos(Math.PI/i)*Math.min(1,p/n*2);const m={x:l.x/d,y:l.y/d},f={x:c.x/u,y:c.y/u},g={x:o.x-m.x*p,y:o.y-m.y*p},v={x:o.x+f.x*p,y:o.y+f.y*p};0===s?t.moveTo(g.x,g.y):t.lineTo(g.x,g.y),t.arcTo(o.x,o.y,v.x,v.y,p)}}};const Zg=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let Kg,Jg=null;function Qg(){if(null!==Jg)return Jg;try{const t=qg.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(Jg=!1,!1)}catch(t){return Jg=!1,!1}}class $g{constructor(t){this.canvas=t,Ng.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,r,s,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],r=n.method,r?(s=n.args,h+=r,t?h+="()":qg._isArray(s[0])?h+="(["+s.join(",")+"])":(e&&(s=s.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+s.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,r,s){this._context.arc(t,e,i,n,r,s)}arcTo(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,r,s){this._context.bezierCurveTo(t,e,i,n,r,s)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,r,s){return this._context.createRadialGradient(t,e,i,n,r,s)}drawImage(t,e,i,n,r,s,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,r):9===l.length&&c.drawImage(t,e,i,n,r,s,a,o,h)}ellipse(t,e,i,n,r,s,a,o){this._context.ellipse(t,e,i,n,r,s,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,r){this._context.roundRect(t,e,i,n,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,r,s){this._context.setTransform(t,e,i,n,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,r,s){this._context.transform(t,e,i,n,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=Zg.length,r=this.setAttr;const s=function(t){let n,r=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=qg;for(let r=0;r<i;r++){let i=t[r];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=r.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)s(Zg[t]);i.setAttr=function(){r.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty($g.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class tv extends $g{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)r.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}}class ev extends $g{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class iv{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||Ng.pixelRatio||function(){if(Kg)return Kg;const t=qg.createCanvasElement(),e=t.getContext("2d");return Kg=(Ng._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),qg.releaseCanvas(t),Kg}();this.pixelRatio=e,this._canvas=qg.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return qg.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class nv extends iv{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new tv(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class rv extends iv{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new ev(this),this.setSize(t.width,t.height)}}const sv={get isDragging(){let t=!1;return sv._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return sv._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const e=[];sv._dragElements.forEach((i,n)=>{const{node:r}=i,s=r.getStage();s.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=qg._getFirstPointerId(t));const a=s._changedPointerPositions.find(t=>t.id===i.pointerId);if(a){if("dragging"!==i.dragStatus){const e=r.dragDistance();if(Math.max(Math.abs(a.x-i.startPointerPos.x),Math.abs(a.y-i.startPointerPos.y))<e)return;if(r.startDrag({evt:t}),!r.isDragging())return}r._setDragPosition(t,i),e.push(r)}}),e.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const e=[];sv._dragElements.forEach(i=>{const{node:n}=i,r=n.getStage();t&&r.setPointersPositions(t);if(!r._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(sv.justDragged=!0,Ng._mouseListenClick=!1,Ng._touchListenClick=!1,Ng._pointerListenClick=!1,i.dragStatus="stopped");const s=i.node.getLayer()||i.node instanceof Ng.Stage&&i.node;s&&-1===e.indexOf(s)&&e.push(s)}),e.forEach(t=>{t.draw()})},_endDragAfter(t){sv._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&sv._dragElements.delete(i)})}};function av(t){return qg._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||qg._isBoolean(t)?t:Object.prototype.toString.call(t)}function ov(t){return t>255?255:t<0?0:Math.round(t)}function hv(){if(Ng.isUnminified)return function(t,e){return qg._isNumber(t)||qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function lv(t){if(Ng.isUnminified)return function(e,i){let n=qg._isNumber(e),r=qg._isArray(e)&&e.length==t;return n||r||qg.warn(av(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function cv(){if(Ng.isUnminified)return function(t,e){return qg._isNumber(t)||"auto"===t||qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function dv(){if(Ng.isUnminified)return function(t,e){return qg._isString(t)||qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function uv(){if(Ng.isUnminified)return function(t,e){const i=qg._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function pv(){if(Ng.isUnminified)return function(t,e){return!0===t||!1===t||qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}Ng.isBrowser&&(window.addEventListener("mouseup",sv._endDragBefore,!0),window.addEventListener("touchend",sv._endDragBefore,!0),window.addEventListener("touchcancel",sv._endDragBefore,!0),window.addEventListener("mousemove",sv._drag),window.addEventListener("touchmove",sv._drag),window.addEventListener("mouseup",sv._endDragAfter,!1),window.addEventListener("touchend",sv._endDragAfter,!1),window.addEventListener("touchcancel",sv._endDragAfter,!1));const mv="get",fv="set",gv={addGetterSetter(t,e,i,n,r){gv.addGetter(t,e,i),gv.addSetter(t,e,n,r),gv.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=mv+qg._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const r=fv+qg._capitalize(e);t.prototype[r]||gv.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const r=fv+qg._capitalize(e);t.prototype[r]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,i,n,r){const s=i.length,a=qg._capitalize,o=mv+a(e),h=fv+a(e);t.prototype[o]=function(){const t={};for(let n=0;n<s;n++){const r=i[n];t[r]=this.getAttr(e+a(r))}return t};const l=function(t){if(Ng.isUnminified)return function(e,i){return null==e||qg.isObject(e)||qg.warn(av(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[h]=function(t){const s=this.attrs[e];n&&(t=n.call(this,t,e)),l&&l.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+a(i),t[i]);return t||i.forEach(t=>{this._setAttr(e+a(t),void 0)}),this._fireChangeEvent(e,s,t),r&&r.call(this),this},gv.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=qg._capitalize(e),n=fv+i,r=mv+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(t,e,i,n){qg.error("Adding deprecated "+e);const r=mv+qg._capitalize(e),s=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[r]=function(){qg.error(s);const t=this.attrs[e];return void 0===t?i:t},gv.addSetter(t,e,n,function(){qg.error(s)}),gv.addOverloadedGetterSetter(t,e)},backCompat(t,e){qg.each(e,function(e,i){const n=t.prototype[i],r=mv+qg._capitalize(e),s=fv+qg._capitalize(e);function a(){n.apply(this,arguments),qg.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[r]=a,t.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function vv(t){const e=/(\w+)\(([^)]+)\)/g;let i;for(;null!==(i=e.exec(t));){const[,t,e]=i;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const i=Ng.Filters;i&&i.Blur&&i.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const i=Ng.Filters;i&&i.Brightness&&i.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const i=100*(Math.sqrt(t)-1);this.contrast(i);const n=Ng.Filters;n&&n.Contrast&&n.Contrast.call(this,e)}}case"grayscale":return function(t){const e=Ng.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=Ng.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=Ng.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:qg.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const yv="absoluteOpacity",_v="allEventListeners",xv="absoluteTransform",wv="absoluteScale",bv="canvas",Sv="listening",Mv="Shape",Ev=" ",Tv="stage",Av="transform",Cv="visible",Rv=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Ev);let Pv=1;class Lv{constructor(t){this._id=Pv++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==Av&&t!==xv||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===Av||t===xv)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(Ev);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(bv)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===xv&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(bv)){const{scene:t,filter:e,hit:i,buffer:n}=this._cache.get(bv);qg.releaseCanvas(t,e,i,n),this._cache.delete(bv)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),r=Math.ceil(e.height||i.height),s=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!r)return void qg.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),r+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const d=new nv({pixelRatio:s,width:n,height:r}),u=new nv({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=new rv({pixelRatio:c,width:n,height:r}),m=d.getContext(),f=p.getContext(),g=new nv({width:d.width/d.pixelRatio+Math.abs(a),height:d.height/d.pixelRatio+Math.abs(o),pixelRatio:d.pixelRatio}),v=g.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(bv),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),m.save(),f.save(),v.save(),m.translate(-a,-o),f.translate(-a,-o),v.translate(-a,-o),g.x=a,g.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(yv),this._clearSelfAndDescendantCache(wv),this.drawScene(d,this,g),this.drawHit(p,this),this._isUnderCache=!1,m.restore(),f.restore(),l&&(m.save(),m.beginPath(),m.rect(0,0,n,r),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),this._cache.set(bv,{scene:d,filter:u,hit:p,buffer:g,x:a,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(bv)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);void 0===n&&(n=s=e.x,r=a=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)}),{x:n,y:r,width:s-n,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,r=this.filters(),s=this._getCanvasCache(),a=s.scene,o=s.filter,h=o.getContext();if(!r||0===r.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<r.length;t++)if("string"==typeof r[t]&&Qg(),"string"!=typeof r[t]||!Qg()){l=!1;break}const c=a.pixelRatio;if(o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),l){const t=r.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),h.restore(),this._filterUpToDate=!0,o}try{for(t=r.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=r[i],"string"==typeof n&&(n=vv(n)),n.call(this,e),h.putImageData(e,0,0)}catch(t){qg.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(t,e){if(this._cache&&this._cache.delete(_v),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(Ev);for(let t=0;t<i.length;t++){const n=i[t].split("."),r=n[0],s=n[1]||"";this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:s,handler:e})}return this}off(t,e){let i,n,r,s,a,o,h=(t||"").split(Ev),l=h.length;if(this._cache&&this._cache.delete(_v),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(r=h[i],s=r.split("."),a=s[0],o=s[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;this.on(t,function(t){const r=t.target.findAncestors(e,!0,n);for(let e=0;e<r.length;e++)(t=qg.cloneObject(t)).currentTarget=r[e],i.call(r[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),sv._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(xv),this._clearSelfAndDescendantCache(yv),this._clearSelfAndDescendantCache(wv),this._clearSelfAndDescendantCache(Tv),this._clearSelfAndDescendantCache(Cv),this._clearSelfAndDescendantCache(Sv)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+qg._capitalize(t);return qg._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+qg._capitalize(e),qg._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(Sv,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(Cv,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;sv._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)});const r=!e&&!Ng.hitOnDragEnabled&&(n||Ng.isTransforming());return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==Mv&&(t=t.concat(n.getChildren().slice())),n._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Av),this._clearSelfAndDescendantCache(xv)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),r=new zg,s=this.offset();return r.m=n.slice(),r.translate(s.x,s.y),r.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(Av);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(Av),this._clearSelfAndDescendantCache(xv),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}_eachAncestorReverse(t,e){let i,n,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return qg.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return qg.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return qg.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return qg.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return qg.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&qg.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(yv,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,r,s=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in s)e=s[t],r=qg.isObject(e)&&!qg._isPlainObject(e)&&!qg._isArray(e),r||(i="function"==typeof this[t]&&this[t],delete s[t],n=i?i.call(this):null,s[t]=e,n!==e&&(a.attrs[t]=e));return qg._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let r=this.parent;for(;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),r=n.length;for(e=0;e<r;e++)if(i=n[e],qg.isValidSelector(i)||(qg.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),qg.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),qg.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Tv,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(xv,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new zg,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(xv)||new zg,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,r=this.attrs.offsetY||0;e.translate(t-n,i-r)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Av,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(Av)||new zg;i.reset();const n=this.x(),r=this.y(),s=Ng.getAngle(this.rotation()),a=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===r||i.translate(n,r),0!==s&&i.rotate(s),0===h&&0===l||i.skew(h,l),1===a&&1===o||i.scale(a,o),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){let e,i,n,r,s,a=qg.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,r=0;r<n;r++)s=i[r],s.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(s));return o}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),r=void 0!==t.y?t.y:Math.floor(e.y),s=t.pixelRatio||1,a=new nv({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:s}),o=a.getContext(),h=new nv({width:a.width/a.pixelRatio+Math.abs(n),height:a.height/a.pixelRatio+Math.abs(r),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||r)&&o.translate(-1*n,-1*r),this.drawScene(a,void 0,h),o.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,qg._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Ng.dragDistance}_off(t,e,i){let n,r,s,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(r=a[n].name,s=a[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==s)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+qg._capitalize(t)];return qg._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Ng.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||qg.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===Mv&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const r=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const r=null!==(e=this._cache.get(_v))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(_v,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const r=i._getPointerById(e)||i._changedPointerPositions[0]||n;sv._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-n.x,y:r.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){sv._dragElements.has(this._id)||this._createDragElement(t);sv._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const r=this.dragBoundFunc();if(void 0!==r){const e=r.call(this,n,t);e?n=e:qg.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=sv._dragElements.get(this._id);e&&(e.dragStatus="stopped"),sv._endDragBefore(t),sv._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=sv._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||Ng.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;sv._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=sv._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&sv._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return qg.haveIntersection(i,this.getClientRect())}static create(t,e){return qg._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let i,n,r,s=Lv.prototype.getClassName.call(t),a=t.children;e&&(t.attrs.container=e),Ng[s]||(qg.warn('Can not find a node with class name "'+s+'". Fallback to "Shape".'),s="Shape");if(i=new(0,Ng[s])(t.attrs),a)for(n=a.length,r=0;r<n;r++)i.add(Lv._createNode(a[r]));return i}}Lv.prototype.nodeType="Node",Lv.prototype._attrsAffectingSize=[],Lv.prototype.eventListeners={},Lv.prototype.on.call(Lv.prototype,Rv,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Av),this._clearSelfAndDescendantCache(xv))}),Lv.prototype.on.call(Lv.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(Cv)}),Lv.prototype.on.call(Lv.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(Sv)}),Lv.prototype.on.call(Lv.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(yv)});const Iv=gv.addGetterSetter;Iv(Lv,"zIndex"),Iv(Lv,"absolutePosition"),Iv(Lv,"position"),Iv(Lv,"x",0,hv()),Iv(Lv,"y",0,hv()),Iv(Lv,"globalCompositeOperation","source-over",dv()),Iv(Lv,"opacity",1,hv()),Iv(Lv,"name","",dv()),Iv(Lv,"id","",dv()),Iv(Lv,"rotation",0,hv()),gv.addComponentsGetterSetter(Lv,"scale",["x","y"]),Iv(Lv,"scaleX",1,hv()),Iv(Lv,"scaleY",1,hv()),gv.addComponentsGetterSetter(Lv,"skew",["x","y"]),Iv(Lv,"skewX",0,hv()),Iv(Lv,"skewY",0,hv()),gv.addComponentsGetterSetter(Lv,"offset",["x","y"]),Iv(Lv,"offsetX",0,hv()),Iv(Lv,"offsetY",0,hv()),Iv(Lv,"dragDistance",void 0,hv()),Iv(Lv,"width",0,hv()),Iv(Lv,"height",0,hv()),Iv(Lv,"listening",!0,pv()),Iv(Lv,"preventDefault",!0,pv()),Iv(Lv,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),Iv(Lv,"visible",!0,pv()),Iv(Lv,"transformsEnabled","all",dv()),Iv(Lv,"size"),Iv(Lv,"dragBoundFunc"),Iv(Lv,"draggable",!1,pv()),gv.backCompat(Lv,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Dv extends Lv{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const r=n._isMatch(t);return r&&i.push(n),!(!r||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=Lv.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=Lv.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){s.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),s.beginPath(),h)e=h.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),n=t.copy().invert().getMatrix(),s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach(function(r){r[t](e,i,n)}),d&&s.restore(),l&&s.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let r,s,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,s=i.y,a=i.x+i.width,o=i.y+i.height):(r=Math.min(r,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))});const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}gv.addComponentsGetterSetter(Dv,"clip",["x","y","width","height"]),gv.addGetterSetter(Dv,"clipX",void 0,hv()),gv.addGetterSetter(Dv,"clipY",void 0,hv()),gv.addGetterSetter(Dv,"clipWidth",void 0,hv()),gv.addGetterSetter(Dv,"clipHeight",void 0,hv()),gv.addGetterSetter(Dv,"clipFunc");const Ov=new Map,Nv=void 0!==Ng._global.PointerEvent;function Uv(t){return Ov.get(t)}function Fv(t){return{evt:t,pointerId:t.pointerId}}function zv(t,e){return Ov.get(t)===e}function kv(t,e){Bv(t);e.getStage()&&(Ov.set(t,e),Nv&&e._fire("gotpointercapture",Fv(new PointerEvent("gotpointercapture"))))}function Bv(t,e){const i=Ov.get(t);if(!i)return;const n=i.getStage();n&&n.content,Ov.delete(t),Nv&&i._fire("lostpointercapture",Fv(new PointerEvent("lostpointercapture")))}const Gv="mouseleave",Hv="mouseover",Vv="mouseenter",Wv="mousemove",jv="mousedown",Xv="mouseup",Yv="pointermove",qv="pointerdown",Zv="pointerup",Kv="pointercancel",Jv="pointerout",Qv="pointerleave",$v="pointerover",ty="pointerenter",ey="contextmenu",iy="touchstart",ny="touchend",ry="touchmove",sy="touchcancel",ay="wheel",oy=[[Vv,"_pointerenter"],[jv,"_pointerdown"],[Wv,"_pointermove"],[Xv,"_pointerup"],[Gv,"_pointerleave"],[iy,"_pointerdown"],[ry,"_pointermove"],[ny,"_pointerup"],[sy,"_pointercancel"],[Hv,"_pointerover"],[ay,"_wheel"],[ey,"_contextmenu"],[qv,"_pointerdown"],[Yv,"_pointermove"],[Zv,"_pointerup"],[Kv,"_pointercancel"],[Qv,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],hy={mouse:{[Jv]:"mouseout",[Qv]:Gv,[$v]:Hv,[ty]:Vv,[Yv]:Wv,[qv]:jv,[Zv]:Xv,[Kv]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Jv]:"touchout",[Qv]:"touchleave",[$v]:"touchover",[ty]:"touchenter",[Yv]:ry,[qv]:iy,[Zv]:ny,[Kv]:sy,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Jv]:Jv,[Qv]:Qv,[$v]:$v,[ty]:ty,[Yv]:Yv,[qv]:qv,[Zv]:Zv,[Kv]:Kv,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},ly=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",cy=t=>{const e=ly(t);return"pointer"===e?Ng.pointerEventsEnabled&&hy.pointer:"touch"===e?hy.touch:"mouse"===e?hy.mouse:void 0};function dy(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&qg.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const uy=[];class py extends Dv{constructor(t){super(dy(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),uy.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{dy(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||qg.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),Dv.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&qg._isInDocument(t)&&this.container().removeChild(t);const e=uy.indexOf(this);return e>-1&&uy.splice(e,1),qg.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(qg.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new nv({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const i=this.children.length;return i>5&&qg.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),Ng.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return zv(t,this)}setPointerCapture(t){kv(t,this)}releaseCapture(t){Bv(t)}getLayers(){return this.children}_bindContentEvents(){Ng.isBrowser&&oy.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=cy(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=cy(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=cy(t.type),i=ly(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),r=!(Ng.isDragging()||Ng.isTransforming())||Ng.hitOnDragEnabled;n&&r?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=cy(t.type),i=ly(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach(r=>{const s=this.getIntersection(r);if(sv.justDragged=!1,Ng["_"+i+"ListenClick"]=!0,!s||!s.isListening())return void(this[i+"ClickStartShape"]=void 0);Ng.capturePointerEventsEnabled&&s.setPointerCapture(r.id),this[i+"ClickStartShape"]=s,s._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),n=!0;const a=t.type.indexOf("touch")>=0;s.preventDefault()&&t.cancelable&&a&&t.preventDefault()}),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=cy(t.type),i=ly(t.type);if(!e)return;const n=t.type.indexOf("touch")>=0||"touch"===t.pointerType;Ng.isDragging()&&sv.node.preventDefault()&&t.cancelable&&n&&t.preventDefault(),this.setPointersPositions(t);if(!(!(Ng.isDragging()||Ng.isTransforming())||Ng.hitOnDragEnabled))return;const r={};let s=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(n=>{const o=Uv(n.id)||this.getIntersection(n),h=n.id,l={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...l},o),a._fireAndBubble(e.pointerleave,{...l},o)),o){if(r[o._id])return;r[o._id]=!0}o&&o.isListening()?(s=!0,c&&(o._fireAndBubble(e.pointerover,{...l},a),o._fireAndBubble(e.pointerenter,{...l},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=cy(t.type),i=ly(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],r=this[i+"ClickEndShape"],s={};let a=!1;this._changedPointerPositions.forEach(o=>{const h=Uv(o.id)||this.getIntersection(o);if(h){if(h.releaseCapture(o.id),s[h._id])return;s[h._id]=!0}const l=o.id,c={evt:t,pointerId:l};let d=!1;Ng["_"+i+"InDblClickWindow"]?(d=!0,clearTimeout(this[i+"DblTimeout"])):sv.justDragged||(Ng["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){Ng["_"+i+"InDblClickWindow"]=!1},Ng.dblClickWindow),h&&h.isListening()?(a=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...c}),Ng["_"+i+"ListenClick"]&&n&&n===h&&(h._fireAndBubble(e.pointerclick,{...c}),d&&r&&r===h&&h._fireAndBubble(e.pointerdblclick,{...c}))):(this[i+"ClickEndShape"]=null,a||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a=!0),Ng["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:l}),d&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:l}))}),a||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Ng["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(ey,{evt:t}):this._fire(ey,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(ay,{evt:t}):this._fire(ay,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=Uv(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(Zv,Fv(t)),Bv(t.pointerId)}_lostpointercapture(t){Bv(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:qg._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:qg._getFirstPointerId(t)}])}_setPointerPosition(t){qg.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new nv({width:this.width(),height:this.height()}),this.bufferHitCanvas=new rv({pixelRatio:1,width:this.width(),height:this.height()}),!Ng.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return qg.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}py.prototype.nodeType="Stage",Ug(py),gv.addGetterSetter(py,"container"),Ng.isBrowser&&document.addEventListener("visibilitychange",()=>{uy.forEach(t=>{t.batchDraw()})});const my="hasShadow",fy="shadowRGBA",gy="patternImage",vy="linearGradient",yy="radialGradient";let _y;function xy(){return _y||(_y=qg.createCanvasElement().getContext("2d"),_y)}const wy={};class by extends Lv{constructor(t){let e;super(t);let i=0;for(;e=qg.getHitColor(),!e||e in wy;)if(i++,i>=1e4){qg.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=qg.getRandomColor();break}this.colorKey=e,wy[e]=this}getContext(){return qg.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return qg.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(my,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(gy,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=xy().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new zg;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(Ng.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(vy,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=xy(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(yy,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=xy(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(fy,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=qg.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return Lv.prototype.destroy.call(this),delete wy[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&s&&a)}setStrokeHitEnabled(t){qg.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+s.x,y:-(a/2+m)+Math.min(d,0)+s.y};return n?f:this._transformedRect(f,r)}drawScene(t,e,i){const n=this.getLayer(),r=(t||n.getCanvas()).getContext(),s=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(s){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore(),this}if(!a)return this;if(r.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();n.clear(),n.save(),n._applyLineJoin(this),n._applyMiterLimit(this);const s=this.getAbsoluteTransform(e).getMatrix();n.transform(s[0],s[1],s[2],s[3],s[4],s[5]),a.call(this,n,this),n.restore();const c=t.pixelRatio;o&&r._applyShadow(this),l||(r._applyOpacity(this),r._applyGlobalCompositeOperation(this)),r.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(r._applyLineJoin(this),r._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r._applyOpacity(this),r._applyGlobalCompositeOperation(this)}o&&r._applyShadow(this),a.call(this,r,this)}return r.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),r=t||n.hitCanvas,s=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCanvasCache(),h=o&&o.hit;if(this.colorKey||qg.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore(),this}if(!a)return this;s.save(),s._applyLineJoin(this),s._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,s,this),s.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,r=n.getContext(),s=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(i._canvas,0,0,s,a);try{const e=r.getImageData(0,0,s,a),i=e.data,n=i.length,o=qg._hexToRgb(this.colorKey);for(let e=0;e<n;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}r.putImageData(e,0,0)}catch(t){qg.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return zv(t,this)}setPointerCapture(t){kv(t,this)}releaseCapture(t){Bv(t)}}by.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},by.prototype._strokeFunc=function(t){t.stroke()},by.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},by.prototype._strokeFuncHit=function(t){t.stroke()},by.prototype._centroid=!1,by.prototype.nodeType="Shape",Ug(by),by.prototype.eventListeners={},by.prototype.on.call(by.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(my)}),by.prototype.on.call(by.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(fy)}),by.prototype.on.call(by.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(gy)}),by.prototype.on.call(by.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(vy)}),by.prototype.on.call(by.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(yy)}),gv.addGetterSetter(by,"stroke",void 0,uv()),gv.addGetterSetter(by,"strokeWidth",2,hv()),gv.addGetterSetter(by,"fillAfterStrokeEnabled",!1),gv.addGetterSetter(by,"hitStrokeWidth","auto",cv()),gv.addGetterSetter(by,"strokeHitEnabled",!0,pv()),gv.addGetterSetter(by,"perfectDrawEnabled",!0,pv()),gv.addGetterSetter(by,"shadowForStrokeEnabled",!0,pv()),gv.addGetterSetter(by,"lineJoin"),gv.addGetterSetter(by,"lineCap"),gv.addGetterSetter(by,"miterLimit"),gv.addGetterSetter(by,"sceneFunc"),gv.addGetterSetter(by,"hitFunc"),gv.addGetterSetter(by,"dash"),gv.addGetterSetter(by,"dashOffset",0,hv()),gv.addGetterSetter(by,"shadowColor",void 0,dv()),gv.addGetterSetter(by,"shadowBlur",0,hv()),gv.addGetterSetter(by,"shadowOpacity",1,hv()),gv.addComponentsGetterSetter(by,"shadowOffset",["x","y"]),gv.addGetterSetter(by,"shadowOffsetX",0,hv()),gv.addGetterSetter(by,"shadowOffsetY",0,hv()),gv.addGetterSetter(by,"fillPatternImage"),gv.addGetterSetter(by,"fill",void 0,uv()),gv.addGetterSetter(by,"fillPatternX",0,hv()),gv.addGetterSetter(by,"fillPatternY",0,hv()),gv.addGetterSetter(by,"fillLinearGradientColorStops"),gv.addGetterSetter(by,"strokeLinearGradientColorStops"),gv.addGetterSetter(by,"fillRadialGradientStartRadius",0),gv.addGetterSetter(by,"fillRadialGradientEndRadius",0),gv.addGetterSetter(by,"fillRadialGradientColorStops"),gv.addGetterSetter(by,"fillPatternRepeat","repeat"),gv.addGetterSetter(by,"fillEnabled",!0),gv.addGetterSetter(by,"strokeEnabled",!0),gv.addGetterSetter(by,"shadowEnabled",!0),gv.addGetterSetter(by,"dashEnabled",!0),gv.addGetterSetter(by,"strokeScaleEnabled",!0),gv.addGetterSetter(by,"fillPriority","color"),gv.addComponentsGetterSetter(by,"fillPatternOffset",["x","y"]),gv.addGetterSetter(by,"fillPatternOffsetX",0,hv()),gv.addGetterSetter(by,"fillPatternOffsetY",0,hv()),gv.addComponentsGetterSetter(by,"fillPatternScale",["x","y"]),gv.addGetterSetter(by,"fillPatternScaleX",1,hv()),gv.addGetterSetter(by,"fillPatternScaleY",1,hv()),gv.addComponentsGetterSetter(by,"fillLinearGradientStartPoint",["x","y"]),gv.addComponentsGetterSetter(by,"strokeLinearGradientStartPoint",["x","y"]),gv.addGetterSetter(by,"fillLinearGradientStartPointX",0),gv.addGetterSetter(by,"strokeLinearGradientStartPointX",0),gv.addGetterSetter(by,"fillLinearGradientStartPointY",0),gv.addGetterSetter(by,"strokeLinearGradientStartPointY",0),gv.addComponentsGetterSetter(by,"fillLinearGradientEndPoint",["x","y"]),gv.addComponentsGetterSetter(by,"strokeLinearGradientEndPoint",["x","y"]),gv.addGetterSetter(by,"fillLinearGradientEndPointX",0),gv.addGetterSetter(by,"strokeLinearGradientEndPointX",0),gv.addGetterSetter(by,"fillLinearGradientEndPointY",0),gv.addGetterSetter(by,"strokeLinearGradientEndPointY",0),gv.addComponentsGetterSetter(by,"fillRadialGradientStartPoint",["x","y"]),gv.addGetterSetter(by,"fillRadialGradientStartPointX",0),gv.addGetterSetter(by,"fillRadialGradientStartPointY",0),gv.addComponentsGetterSetter(by,"fillRadialGradientEndPoint",["x","y"]),gv.addGetterSetter(by,"fillRadialGradientEndPointX",0),gv.addGetterSetter(by,"fillRadialGradientEndPointY",0),gv.addGetterSetter(by,"fillPatternRotation",0),gv.addGetterSetter(by,"fillRule",void 0,dv()),gv.backCompat(by,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const Sy=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],My=Sy.length;class Ey extends Dv{constructor(t){super(t),this.canvas=new nv,this.hitCanvas=new rv({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Lv.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Lv.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Lv.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Lv.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return Lv.prototype.remove.call(this),t&&t.parentNode&&qg._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&qg.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),Lv.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){qg.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){qg.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,qg.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<My;n++){const r=Sy[n],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(i=!!s.antialiased,!s.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=qg.getHitColorKey(i[0],i[1],i[2]),e=wy[t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Dv.prototype.drawScene.call(this,r,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),Dv.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){qg.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return qg.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return qg.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Ey.prototype.nodeType="Layer",Ug(Ey),gv.addGetterSetter(Ey,"imageSmoothingEnabled",!0),gv.addGetterSetter(Ey,"clearBeforeDraw",!0),gv.addGetterSetter(Ey,"hitGraphEnabled",!0,pv());class Ty extends Ey{constructor(t){super(t),this.listening(!1),qg.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Ty.prototype.nodeType="FastLayer",Ug(Ty);class Ay extends Dv{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&qg.throw("You may only add groups and shapes to groups.")}}Ay.prototype.nodeType="Group",Ug(Ay);const Cy=Og.performance&&Og.performance.now?function(){return Og.performance.now()}:function(){return(new Date).getTime()};class Ry{constructor(t,e){this.id=Ry.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Cy(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Ry.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Cy(),Ry._addAnimation(this),this}stop(){return Ry._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],r=n.layers,s=n.func;n._updateFrameObject(Cy());const a=r.length;let o;if(o=!s||!1!==s.call(n,n.frame),o)for(let e=0;e<a;e++){const i=r[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=Ry;t.animations.length?(t._runFrames(),qg.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,qg.requestAnimFrame(this._animationLoop))}}Ry.animations=[],Ry.animIdCounter=0,Ry.animRunning=!1;const Py={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Ly=["fill","stroke","shadowColor"];let Iy=0;class Dy{constructor(t,e,i,n,r,s,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Oy{constructor(t){const e=this,i=t.node,n=i._id,r=t.easing||Ny.Linear,s=!!t.yoyo;let a,o;a=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=i,this._id=Iy++;const h=i.getLayer()||(i instanceof Ng.Stage?i.getLayers():null);for(o in h||qg.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Ry(function(){e.tween.onEnterFrame()},h),this.tween=new Dy(o,function(t){e._tweenFunc(t)},r,0,1,1e3*a,s),this._addListeners(),Oy.attrs[n]||(Oy.attrs[n]={}),Oy.attrs[n][this._id]||(Oy.attrs[n][this._id]={}),Oy.tweens[n]||(Oy.tweens[n]={}),t)void 0===Py[o]&&this._addAttr(o,t[o]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let r,s,a,o,h;const l=Oy.tweens[n][t];l&&delete Oy.attrs[n][l][t];let c=i.getAttr(t);if(qg._isArray(e))if(r=[],s=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(o=c,c=qg._prepareArrayForTween(c,e,i.closed())):(a=e,e=qg._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<s;t++)if(t%2==0)r.push(e[t]-c[t]);else{const i=qg.colorToRGBA(c[t]);h=qg.colorToRGBA(e[t]),c[t]=i,r.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<s;t++)r.push(e[t]-c[t]);else-1!==Ly.indexOf(t)?(c=qg.colorToRGBA(c),h=qg.colorToRGBA(e),r={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):r=e-c;Oy.attrs[n][this._id][t]={start:c,diff:r,end:e,trueEnd:a,trueStart:o},Oy.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=Oy.attrs[e._id][this._id];let n,r,s,a,o,h,l,c;for(n in i){if(r=i[n],s=r.start,a=r.diff,c=r.end,qg._isArray(s))if(o=[],l=Math.max(s.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((s[h]||0)+a[h]*t):o.push("rgba("+Math.round(s[h].r+a[h].r*t)+","+Math.round(s[h].g+a[h].g*t)+","+Math.round(s[h].b+a[h].b*t)+","+(s[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((s[h]||0)+a[h]*t);else o=-1!==Ly.indexOf(n)?"rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":s+a*t;e.setAttr(n,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=Oy.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=Oy.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=Oy.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete Oy.tweens[t][e];delete Oy.attrs[t][e],Oy.tweens[t]&&(0===Object.keys(Oy.tweens[t]).length&&delete Oy.tweens[t],0===Object.keys(Oy.attrs[t]).length&&delete Oy.attrs[t])}}Oy.attrs={},Oy.tweens={},Lv.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new Oy(t).play()};const Ny={BackEaseIn(t,e,i,n){const r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,n){const r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,n){let r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,n,r,s){let a=0;return 0===t?e:1===(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,i,n,r,s){let a=0;return 0===t?e:1===(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/s)+i+e)},ElasticEaseInOut(t,e,i,n,r,s){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(s||(s=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-Ny.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*Ny.BounceEaseIn(2*t,0,i,n)+e:.5*Ny.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},Uy=qg._assign(Ng,{Util:qg,Transform:zg,Node:Lv,Container:Dv,Stage:py,stages:uy,Layer:Ey,FastLayer:Ty,Group:Ay,DD:sv,Shape:by,shapes:wy,Animation:Ry,Tween:Oy,Easings:Ny,Context:$g,Canvas:iv});class Fy extends by{_sceneFunc(t){const e=Ng.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=Ng.getAngle(i?360-this.angle():this.angle()),r=Math.cos(Math.min(n,Math.PI)),s=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),a=Math.sin(Math.min(n,Math.PI/2)),o=r*(r>0?t:e),h=s*(s>0?t:e),l=a*(a>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}function zy(t,e,i,n,r,s,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(s-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(r-t),n-l*(s-e),i+c*(r-t),n+c*(s-e)]}function ky(t,e){const i=t.length,n=[];for(let r=2;r<i-2;r+=2){const i=zy(t[r-2],t[r-1],t[r],t[r+1],t[r+2],t[r+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[r]),n.push(t[r+1]),n.push(i[2]),n.push(i[3]))}return n}Fy.prototype._centroid=!0,Fy.prototype.className="Arc",Fy.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Ug(Fy),gv.addGetterSetter(Fy,"innerRadius",0,hv()),gv.addGetterSetter(Fy,"outerRadius",0,hv()),gv.addGetterSetter(Fy,"angle",0,hv()),gv.addGetterSetter(Fy,"clockwise",!1,pv());class By extends by{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,n=this.tension(),r=this.closed(),s=this.bezier();if(!i)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==n&&i>4){const n=this.getTensionPoints(),s=n.length;for(a=r?0:4,r||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);a<s-2;)t.bezierCurveTo(n[a++],n[a++],n[a++],n[a++],n[a++],n[a++]);r||t.quadraticCurveTo(n[s-2],n[s-1],e[i-2],e[i-1])}else if(s)for(a=2;a<i;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<i;a+=2)t.lineTo(e[a],e[a+1]);r?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():ky(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=zy(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),r=zy(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),s=ky(t,i);return[n[2],n[3]].concat(s).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);return{x:n,y:s,width:r-n,height:a-s}}}By.prototype.className="Line",By.prototype._attrsAffectingSize=["points","bezier","tension"],Ug(By),gv.addGetterSetter(By,"closed",!1),gv.addGetterSetter(By,"bezier",!1),gv.addGetterSetter(By,"tension",0,hv()),gv.addGetterSetter(By,"points",[],function(){if(Ng.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(qg._isArray(t)?t.forEach(function(t){qg._isNumber(t)||qg.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):qg.warn(av(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const Gy=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Hy=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],Vy=[[1],[1,1],[1,2,1],[1,3,3,1]],Wy=(t,e,i)=>{let n,r;const s=i/2;n=0;for(let i=0;i<20;i++)r=s*Gy[20][i]+s,n+=Hy[20][i]*Xy(t,e,r);return s*n},jy=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+r*r),h=4*(n*s+r*a),l=s*s+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};function Xy(t,e,i){const n=Yy(1,i,t),r=Yy(1,i,e),s=n*n+r*r;return Math.sqrt(s)}const Yy=(t,e,i)=>{const n=i.length-1;let r,s;if(0===n)return 0;if(0===t){s=0;for(let t=0;t<=n;t++)s+=Vy[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return s}r=new Array(n);for(let t=0;t<n;t++)r[t]=n*(i[t+1]-i[t]);return Yy(t-1,e,r)},qy=(t,e,i)=>{let n=1,r=t/e,s=(t-i(r))/e,a=0;for(;n>.001;){const o=i(r+s),h=Math.abs(t-o)/e;if(h<n)n=h,r+=s;else{const a=i(r-s),o=Math.abs(t-a)/e;o<n?(n=o,r-=s):s/=2}if(a++,a>500)break}return r};class Zy extends by{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Zy.parsePathData(this.data()),this.pathLength=Zy.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const r=e[n].command,s=e[n].points;switch(r){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const e=s[0],n=s[1],r=s[2],a=s[3],o=s[4],h=s[5],l=s[6],c=s[7],d=r>a?r:a,u=r>a?1:r/a,p=r>a?a/r:1;t.translate(e,n),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],r=e.points[4]+n;let s=Math.PI/180;if(Math.abs(i-r)<s&&(s=Math.abs(i-r)),n<0)for(let n=i-s;n>r;n-=s){const i=Zy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+s;n<r;n+=s){const i=Zy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=Zy.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)});let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),r=Math.max(r,e)),isNaN(i)||(s=Math.min(s,i),a=Math.max(a,i));return{x:n,y:s,width:r-n,height:a-s}}getLength(){return this.pathLength}getPointAtLength(t){return Zy.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,r=e.length;if(!r)return null;for(;n<r&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===r)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const s=e[n],a=s.points;switch(s.command){case"L":return Zy.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Zy.getPointOnCubicBezier(qy(t,Zy.getPathLength(e),t=>Wy([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],t)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Zy.getPointOnQuadraticBezier(qy(t,Zy.getPathLength(e),t=>jy([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],t)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],r=a[2],o=a[3],h=a[5],l=a[6];let c=a[4];return c+=h*t/s.pathLength,Zy.getPointOnEllipticalArc(i,n,r,o,c,l)}return null}static getPointOnLine(t,e,i,n,r,s,a){s=null!=s?s:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,r);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:s,y:a+(r>i?t:-t)};const h=(r-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(s-e))<1e-10)return{x:s+l,y:a+c};const d=((s-e)*(n-e)+(a-i)*(r-i))/(o*o),u=e+d*(n-e),p=i+d*(r-i),m=this.getLineLength(s,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,r,s,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+s*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+r*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,r,s,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:s*o(t)+n*h(t)+e*l(t),y:a*o(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,r,s){const a=Math.cos(s),o=Math.sin(s),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),r=[],s=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),s.length=0;l=h.exec(e);)s.push(l[0]);let c=[],d="A"===i||"a"===i?0:-1;for(let t=0,e=s.length;t<e;t++){const e=s[t];if("00"!==e)if(d>=0){if(3===d){if(/^[01]{2}\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),c.push(parseFloat(e.slice(2))),d+=3,d>=7&&(d-=7);continue}if("11"===e||"10"===e||"01"===e){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}else if(4===d){if(/^[01]\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseFloat(e.slice(1))),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t),d+=1,d>=7&&(d-=7)}else{const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t)}else c.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7))}for(;c.length>0&&!isNaN(c[0]);){let t="",e=[];const n=a,s=o;let h,l,d,u,p,m,f,g,v,y;switch(i){case"l":a+=c.shift(),o+=c.shift(),t="L",e.push(a,o);break;case"L":a=c.shift(),o=c.shift(),e.push(a,o);break;case"m":const n=c.shift(),s=c.shift();if(a+=n,o+=s,t="M",r.length>2&&"z"===r[r.length-1].command)for(let t=r.length-2;t>=0;t--)if("M"===r[t].command){a=r[t].points[0]+n,o=r[t].points[1]+s;break}e.push(a,o),i="l";break;case"M":a=c.shift(),o=c.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=c.shift(),t="L",e.push(a,o);break;case"H":a=c.shift(),t="L",e.push(a,o);break;case"v":o+=c.shift(),t="L",e.push(a,o);break;case"V":o=c.shift(),t="L",e.push(a,o);break;case"C":e.push(c.shift(),c.shift(),c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"c":e.push(a+c.shift(),o+c.shift(),a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"S":l=a,d=o,h=r[r.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,c.shift(),c.shift()),a=c.shift(),o=c.shift(),t="C",e.push(a,o);break;case"s":l=a,d=o,h=r[r.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"Q":e.push(c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"q":e.push(a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="Q",e.push(a,o);break;case"T":l=a,d=o,h=r[r.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a=c.shift(),o=c.shift(),t="Q",e.push(l,d,a,o);break;case"t":l=a,d=o,h=r[r.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a+=c.shift(),o+=c.shift(),t="Q",e.push(l,d,a,o);break;case"A":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,y=o,a=c.shift(),o=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,y,a,o,f,g,u,p,m);break;case"a":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,y=o,a+=c.shift(),o+=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,y,a,o,f,g,u,p,m)}r.push({command:t||i,points:e,start:{x:n,y:s},pathLength:this.calcLength(n,s,t||i,e)})}"z"!==i&&"Z"!==i||r.push({command:"z",points:[],start:void 0,pathLength:0})}return r}static calcLength(t,e,i,n){let r,s,a,o;const h=Zy;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return Wy([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return jy([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":r=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),s=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-d;o>c;o-=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(o=i+d;o<c;o+=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),r}return 0}static convertEndpointToCenterParameterization(t,e,i,n,r,s,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));r===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},w=x([1,0],[(c-m)/a,(d-f)/o]),b=[(c-m)/a,(d-f)/o],S=[(-1*c-m)/a,(-1*d-f)/o];let M=x(b,S);return _(b,S)<=-1&&(M=Math.PI),_(b,S)>=1&&(M=0),0===s&&M>0&&(M-=2*Math.PI),1===s&&M<0&&(M+=2*Math.PI),[g,v,a,o,w,M,l,s]}}Zy.prototype.className="Path",Zy.prototype._attrsAffectingSize=["data"],Ug(Zy),gv.addGetterSetter(Zy,"data");class Ky extends By{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const r=0!==this.tension()&&i.length>4;r&&(n=this.getTensionPoints());const s=this.pointerLength(),a=i.length;let o,h;if(r){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=Zy.calcLength(n[n.length-4],n[n.length-3],"C",t),r=Zy.getPointOnQuadraticBezier(Math.min(1,1-s/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-r.x,h=i[a-1]-r.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-s,c/2),t.lineTo(-s,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),r?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-s,c/2),t.lineTo(-s,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Ky.prototype.className="Arrow",Ug(Ky),gv.addGetterSetter(Ky,"pointerLength",10,hv()),gv.addGetterSetter(Ky,"pointerWidth",10,hv()),gv.addGetterSetter(Ky,"pointerAtBeginning",!1),gv.addGetterSetter(Ky,"pointerAtEnding",!0);class Jy extends by{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}Jy.prototype._centroid=!0,Jy.prototype.className="Circle",Jy.prototype._attrsAffectingSize=["radius"],Ug(Jy),gv.addGetterSetter(Jy,"radius",0,hv());class Qy extends by{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}Qy.prototype.className="Ellipse",Qy.prototype._centroid=!0,Qy.prototype._attrsAffectingSize=["radiusX","radiusY"],Ug(Qy),gv.addComponentsGetterSetter(Qy,"radius",["x","y"]),gv.addGetterSetter(Qy,"radiusX",0,hv()),gv.addGetterSetter(Qy,"radiusY",0,hv());let $y=class t extends by{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),r=this.attrs.image;let s;if(r){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;s=t&&n?[r,this.cropX(),this.cropY(),t,n,0,0,e,i]:[r,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?qg.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),r&&(n&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?qg.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(e,i,n=null){const r=qg.createImageElement();r.onload=function(){const e=new t({image:r});i(e)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}};$y.prototype.className="Image",$y.prototype._attrsAffectingSize=["image"],Ug($y),gv.addGetterSetter($y,"cornerRadius",0,lv(4)),gv.addGetterSetter($y,"image"),gv.addComponentsGetterSetter($y,"crop",["x","y","width","height"]),gv.addGetterSetter($y,"cropX",0,hv()),gv.addGetterSetter($y,"cropY",0,hv()),gv.addGetterSetter($y,"cropWidth",0,hv()),gv.addGetterSetter($y,"cropHeight",0,hv());const t_=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],e_="up",i_="right",n_="down",r_="left",s_=t_.length;class a_ extends Ay{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<s_;e++)t.on(t_[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,r,s,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),r=0,s=0,i){case e_:r=t/2,s=-1*a;break;case i_:r=t+n,s=e/2;break;case n_:r=t/2,s=e+a;break;case r_:r=-1*n,s=e/2}h.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),o.setAttrs({x:-1*r,y:-1*s})}}}a_.prototype.className="Label",Ug(a_);class o_ extends by{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),a=this.cornerRadius();let o=0,h=0,l=0,c=0;"number"==typeof a?o=h=l=c=Math.min(a,e/2,i/2):(o=Math.min(a[0]||0,e/2,i/2),h=Math.min(a[1]||0,e/2,i/2),c=Math.min(a[2]||0,e/2,i/2),l=Math.min(a[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===e_&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===i_&&(t.lineTo(e,(i-s)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+s)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===n_&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+s),t.lineTo((e-r)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===r_&&(t.lineTo(0,(i+s)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-s)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),a=this.height();return r===e_?(e-=n,a+=n):r===n_?a+=n:r===r_?(t-=1.5*i,s+=i):r===i_&&(s+=1.5*i),{x:t,y:e,width:s,height:a}}}o_.prototype.className="Tag",Ug(o_),gv.addGetterSetter(o_,"pointerDirection","none"),gv.addGetterSetter(o_,"pointerWidth",0,hv()),gv.addGetterSetter(o_,"pointerHeight",0,hv()),gv.addGetterSetter(o_,"cornerRadius",0,lv(4));class h_ extends by{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?qg.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}h_.prototype.className="Rect",Ug(h_),gv.addGetterSetter(h_,"cornerRadius",0,lv(4));class l_ extends by{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),r=this.cornerRadius();if(t.beginPath(),r)qg.drawRoundedPolygonPath(t,e,n,i,r);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].x,n=t[0].y,r=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),{x:e,y:n,width:i-e,height:r-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}l_.prototype.className="RegularPolygon",l_.prototype._centroid=!0,l_.prototype._attrsAffectingSize=["radius"],Ug(l_),gv.addGetterSetter(l_,"radius",0,hv()),gv.addGetterSetter(l_,"sides",0,hv()),gv.addGetterSetter(l_,"cornerRadius",0,lv(4));const c_=2*Math.PI;class d_ extends by{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,c_,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),c_,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}d_.prototype.className="Ring",d_.prototype._centroid=!0,d_.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ug(d_),gv.addGetterSetter(d_,"innerRadius",0,hv()),gv.addGetterSetter(d_,"outerRadius",0,hv());class u_ extends by{constructor(t){super(t),this._updated=!0,this.anim=new Ry(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+0],o=r[n+1],h=r[n+2],l=r[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(s){const n=s[e],r=2*i;t.drawImage(c,a,o,h,l,n[r+0],n[r+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+2],o=r[n+3];if(t.beginPath(),s){const n=s[e],r=2*i;t.rect(n[r+0],n[r+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}u_.prototype.className="Sprite",Ug(u_),gv.addGetterSetter(u_,"animation"),gv.addGetterSetter(u_,"animations"),gv.addGetterSetter(u_,"frameOffsets"),gv.addGetterSetter(u_,"image"),gv.addGetterSetter(u_,"frameIndex",0,hv()),gv.addGetterSetter(u_,"frameRate",17,hv()),gv.backCompat(u_,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class p_ extends by{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*n;r++){const s=r%2==0?i:e,a=s*Math.sin(r*Math.PI/n),o=-1*s*Math.cos(r*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function m_(t){return[...t].reduce((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const r=n[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}p_.prototype.className="Star",p_.prototype._centroid=!0,p_.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ug(p_),gv.addGetterSetter(p_,"numPoints",5,hv()),gv.addGetterSetter(p_,"innerRadius",0,hv()),gv.addGetterSetter(p_,"outerRadius",0,hv());const f_="auto",g_="inherit",v_="justify",y_="left",__="middle",x_="normal",w_=" ",b_="none",S_=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],M_=S_.length;let E_;function T_(){return E_||(E_=qg.createCanvasElement().getContext("2d"),E_)}class A_ extends by{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<M_;t++)this.on(S_[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,i;const n=this.textArr,r=n.length;if(!this.text())return;let s,a=this.padding(),o=this.fontSize(),h=this.lineHeight()*o,l=this.verticalAlign(),c=this.direction(),d=0,u=this.align(),p=this.getWidth(),m=this.letterSpacing(),f=this.charRenderFunc(),g=this.fill(),v=this.textDecoration(),y=-1!==v.indexOf("underline"),_=-1!==v.indexOf("line-through");c=c===g_?t.direction:c;let x=h/2,w=__;if(!Ng.legacyTextRendering){const t=this.measureSize("M");w="alphabetic";x=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(i=t.fontBoundingBoxDescent)&&void 0!==i?i:t.actualBoundingBoxDescent))/2+h/2}for("rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",y_),l===__?d=(this.getHeight()-r*h-2*a)/2:"bottom"===l&&(d=this.getHeight()-r*h-2*a),t.translate(a,d+a),s=0;s<r;s++){let e=0,i=0;const l=n[s],d=l.text,v=l.width,w=l.lastInParagraph;if(t.save(),"right"===u?e+=p-v-2*a:"center"===u&&(e+=(p-v-2*a)/2),y){t.save(),t.beginPath();const n=e,r=x+i+(Ng.legacyTextRendering?Math.round(o/2):Math.round(o/4));t.moveTo(n,r);const s=u!==v_||w?v:p-2*a;t.lineTo(n+Math.round(s),r),t.lineWidth=o/15;const h=this._getLinearGradient();t.strokeStyle=h||g,t.stroke(),t.restore()}const b=e;if("rtl"===c||0===m&&u!==v_&&!f)0!==m&&t.setAttr("letterSpacing",`${m}px`),this._partialTextX=e,this._partialTextY=x+i,this._partialText=d,t.fillStrokeShape(this);else{const r=d.split(" ").length-1,o=m_(d);for(let h=0;h<o.length;h++){const l=o[h];if(" "!==l||w||u!==v_||(e+=(p-2*a-v)/r),this._partialTextX=e,this._partialTextY=x+i,this._partialText=l,f){t.save();f({char:l,index:h+n.slice(0,s).reduce((t,e)=>t+m_(e.text).length,0),x:e,y:x+i,lineIndex:s,column:h,isLastInLine:w,width:this.measureSize(l).width,context:t})}t.fillStrokeShape(this),f&&t.restore(),e+=this.measureSize(l).width+m}}if(_){t.save(),t.beginPath();const e=Ng.legacyTextRendering?0:-Math.round(o/4),n=b;t.moveTo(n,x+i+e);const r=u!==v_||w?v:p-2*a;t.lineTo(n+Math.round(r),x+i+e),t.lineWidth=o/15;const s=this._getLinearGradient();t.strokeStyle=s||g,t.stroke(),t.restore()}t.restore(),r>1&&(x+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=qg._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===f_||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===f_||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return qg.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,r,s,a,o,h,l,c,d;let u,p=T_(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*f,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+w_+this.fontVariant()+w_+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===v_&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return T_().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,a=r!==f_&&void 0!==r,o=s!==f_&&void 0!==s,h=this.padding(),l=r-2*h,c=s-2*h,d=0,u=this.wrap(),p="char"!==u&&u!==b_,m=this.ellipsis();this.textArr=[],T_().font=this._getContextFont();const f=m?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],h=this._getTextWidth(s);if(a&&h>l)for(;s.length>0;){let t=0,e=m_(s).length,r="",a=0;for(;t<e;){const i=t+e>>>1,h=m_(s).slice(0,i+1).join(""),u=this._getTextWidth(h);(m&&o&&d+n>c?u+f:u)<=l?(t=i+1,r=h,a=u):e=i}if(!r)break;if(p){const e=m_(s),i=m_(r),n=e[i.length];let o;if((n===w_||"-"===n)&&a<=l)o=i.length;else{const t=i.lastIndexOf(w_),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,r=e.slice(0,t).join(""),a=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,a),d+=n;if(this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(s=m_(s).slice(t).join("").trimLeft(),s.length>0&&(h=this._getTextWidth(s),h<=l)){this._addTextLine(s),d+=n,i=Math.max(i,h);break}}else this._addTextLine(s),d+=n,i=Math.max(i,h),this._shouldHandleEllipsis(d)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==f_&&void 0!==n,s=n-2*this.padding();return!(this.wrap()!==b_)||r&&t+i>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==f_&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}A_.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},A_.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},A_.prototype.className="Text",A_.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ug(A_),gv.overWriteSetter(A_,"width",cv()),gv.overWriteSetter(A_,"height",cv()),gv.addGetterSetter(A_,"direction",g_),gv.addGetterSetter(A_,"fontFamily","Arial"),gv.addGetterSetter(A_,"fontSize",12,hv()),gv.addGetterSetter(A_,"fontStyle",x_),gv.addGetterSetter(A_,"fontVariant",x_),gv.addGetterSetter(A_,"padding",0,hv()),gv.addGetterSetter(A_,"align",y_),gv.addGetterSetter(A_,"verticalAlign","top"),gv.addGetterSetter(A_,"lineHeight",1,hv()),gv.addGetterSetter(A_,"wrap","word"),gv.addGetterSetter(A_,"ellipsis",!1,pv()),gv.addGetterSetter(A_,"letterSpacing",0,hv()),gv.addGetterSetter(A_,"text","",dv()),gv.addGetterSetter(A_,"textDecoration",""),gv.addGetterSetter(A_,"charRenderFunc",void 0);const C_="normal";function R_(t){t.fillText(this.partialText,0,0)}function P_(t){t.strokeText(this.partialText,0,0)}class L_ extends by{constructor(t){super(t),this.dummyCanvas=qg.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Zy.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:Zy.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Zy.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo,s=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");s&&t.beginPath();for(let e=0;e<r.length;e++){t.save();const i=r[e].p0;t.translate(i.x,i.y),t.rotate(r[e].rotation),this.partialText=r[e].text,t.fillStrokeShape(this),s&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(r[e].width,n/2+1)),t.restore()}if(s&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),a){t.beginPath();for(let e=0;e<r.length;e++){t.save();const i=r[e].p0;t.translate(i.x,i.y),t.rotate(r[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(r[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=n/20,t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return qg.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return A_.prototype.setText.call(this,t)}_getContextFont(){return A_.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=m_(this.text()),e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const r=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);let h=0;"center"===s&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(h=Math.max(0,this.pathLength-o));let l=h;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(l);if(!n)return;const h=e[i].char;let c=e[i].width+r;if(" "===h&&"justify"===s){const t=this.text().split(" ").length-1;c+=(this.pathLength-o)/t}const d=this._getPointAtLength(l+c);if(!d)return;const u=Zy.getLineLength(n.x,n.y,d.x,d.y);let p=0;if(a)try{p=a(e[i-1].char,h)*this.fontSize()}catch(t){p=0}n.x+=p,d.x+=p,this.textWidth+=p;const m=Zy.getPointOnLine(p+u/2,n.x,n.y,d.x,d.y),f=Math.atan2(d.y-n.y,d.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:f,p0:n,p1:d,width:u}),l+=c}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:s-o/2,width:r-n+o,height:a-s+o}}destroy(){return qg.releaseCanvas(this.dummyCanvas),super.destroy()}}L_.prototype._fillFunc=R_,L_.prototype._strokeFunc=P_,L_.prototype._fillFuncHit=R_,L_.prototype._strokeFuncHit=P_,L_.prototype.className="TextPath",L_.prototype._attrsAffectingSize=["text","fontSize","data"],Ug(L_),gv.addGetterSetter(L_,"data"),gv.addGetterSetter(L_,"fontFamily","Arial"),gv.addGetterSetter(L_,"fontSize",12,hv()),gv.addGetterSetter(L_,"fontStyle",C_),gv.addGetterSetter(L_,"align","left"),gv.addGetterSetter(L_,"letterSpacing",0,hv()),gv.addGetterSetter(L_,"textBaseline","middle"),gv.addGetterSetter(L_,"fontVariant",C_),gv.addGetterSetter(L_,"text",""),gv.addGetterSetter(L_,"textDecoration",""),gv.addGetterSetter(L_,"kerningFunc",void 0);const I_="tr-konva",D_=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${I_}`).join(" "),O_="nodesRect",N_=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],U_={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},F_="ontouchstart"in Ng._global;const z_=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function k_(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:r}}function B_(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return k_(t,e,i)}let G_=0;class H_ extends Ay{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(D_,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return qg.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return I_+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(qg.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(N_.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),r=n.x-e.x,s=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+r,y:n.y+s}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(O_),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(O_,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),s=t.getAbsolutePosition(i),a=n.x*r.x-t.offsetX()*r.x,o=n.y*r.y-t.offsetY()*r.y,h=(Ng.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return k_({x:s.x+a*Math.cos(h)+o*Math.sin(-h),y:s.y+o*Math.cos(h)+a*Math.sin(h),width:n.width*r.x,height:n.height*r.y,rotation:h},-Ng.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=e.getAbsoluteTransform();n.forEach(function(e){const i=r.point(e);t.push(i)})});const e=new zg;e.rotate(-Ng.getAngle(this.rotation()));let i=1/0,n=1/0,r=-1/0,s=-1/0;t.forEach(function(t){const a=e.point(t);void 0===i&&(i=r=a.x,n=s=a.y),i=Math.min(i,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),s=Math.max(s,a.y)}),e.invert();const a=e.point({x:i,y:n});return{x:a.x,y:a.y,width:r-i,height:s-n,rotation:Ng.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),z_.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new h_({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:F_?10:"auto"}),i=this;e.on("mousedown touchstart",function(t){i._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const i=Ng.getAngle(this.rotation()),n=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=qg.degToRad(U_[t]||0);const n=(qg.radToDeg(e)%360+360)%360;return qg._inRange(n,337.5,360)||qg._inRange(n,0,22.5)?"ns-resize":qg._inRange(n,22.5,67.5)?"nesw-resize":qg._inRange(n,67.5,112.5)?"ew-resize":qg._inRange(n,112.5,157.5)?"nwse-resize":qg._inRange(n,157.5,202.5)?"ns-resize":qg._inRange(n,202.5,247.5)?"nesw-resize":qg._inRange(n,247.5,292.5)?"ew-resize":qg._inRange(n,292.5,337.5)?"nwse-resize":(qg.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new by({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.moveTo(e.width()/2,-n),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*qg._sign(e.height())-n),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},G_++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,i,n;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const a=s.getPointerPosition();let o={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),r.setAbsolutePosition(o);const l=r.getAbsolutePosition();if(h.x===l.x&&h.y===l.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=r.x()-n.width/2,i=-r.y()+n.height/2;let s=Math.atan2(-i,e)+Math.PI/2;n.height<0&&(s-=Math.PI);const a=Ng.getAngle(this.rotation())+s,o=Ng.getAngle(this.rotationSnapTolerance()),h=function(t,e,i){let n=e;for(let r=0;r<t.length;r++){const s=Ng.getAngle(t[r]),a=Math.abs(s-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(n=s)}return n}(this.rotationSnaps(),a,o),l=B_(n,h-n.rotation);return void this._fitNodesInto(l,t)}const c=this.shiftBehavior();let d;d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(t.y-r.y(),2));const s=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const s=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var p=r.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const s=t.x<r.x()?-1:1,a=r.y()<t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,r.x(t.x-e),r.y(t.y+i)}p=r.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(r.y()-t.y,2));const s=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:r,y:s})}const m=this.findOne(".top-left").getAbsolutePosition();e=m.x,i=m.y;const f=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:f,height:g,rotation:Ng.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();G_--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const i=this._getNodeRect();if(qg._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(qg._inRange(t.height,2*-this.padding()-1,1))return void this.update();const n=new zg;if(n.rotate(Ng.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:qg.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const r=1e7,s=new zg;s.translate(i.x,i.y),s.rotate(i.rotation),s.scale(i.width/r,i.height/r);const a=new zg,o=t.width/r,h=t.height/r;!1===this.flipEnabled()?(a.translate(t.x,t.y),a.rotate(t.rotation),a.translate(t.width<0?t.width:0,t.height<0?t.height:0),a.scale(Math.abs(o),Math.abs(h))):(a.translate(t.x,t.y),a.rotate(t.rotation),a.scale(o,h));const l=a.multiply(s.invert());this._nodes.forEach(t=>{var e;if(!t.getStage())return;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const r=new zg;r.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const s=r.decompose();t.setAttrs(s),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(qg._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(qg._getRotation(e.rotation));const i=e.width,n=e.height,r=this.enabledAnchors(),s=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:s&&r.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:s&&r.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:s&&r.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:s&&r.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:s&&r.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:s&&r.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:s&&r.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:s&&r.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*qg._sign(n)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach(t=>{l(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Ay.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Lv.prototype.toObject.call(this)}clone(t){return Lv.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}H_.isTransforming=()=>G_>0,H_.prototype.className="Transformer",Ug(H_),gv.addGetterSetter(H_,"enabledAnchors",z_,function(t){return t instanceof Array||qg.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===z_.indexOf(t)&&qg.warn("Unknown anchor name: "+t+". Available names are: "+z_.join(", "))}),t||[]}),gv.addGetterSetter(H_,"flipEnabled",!0,pv()),gv.addGetterSetter(H_,"resizeEnabled",!0),gv.addGetterSetter(H_,"anchorSize",10,hv()),gv.addGetterSetter(H_,"rotateEnabled",!0),gv.addGetterSetter(H_,"rotateLineVisible",!0),gv.addGetterSetter(H_,"rotationSnaps",[]),gv.addGetterSetter(H_,"rotateAnchorOffset",50,hv()),gv.addGetterSetter(H_,"rotateAnchorCursor","crosshair"),gv.addGetterSetter(H_,"rotationSnapTolerance",5,hv()),gv.addGetterSetter(H_,"borderEnabled",!0),gv.addGetterSetter(H_,"anchorStroke","rgb(0, 161, 255)"),gv.addGetterSetter(H_,"anchorStrokeWidth",1,hv()),gv.addGetterSetter(H_,"anchorFill","white"),gv.addGetterSetter(H_,"anchorCornerRadius",0,hv()),gv.addGetterSetter(H_,"borderStroke","rgb(0, 161, 255)"),gv.addGetterSetter(H_,"borderStrokeWidth",1,hv()),gv.addGetterSetter(H_,"borderDash"),gv.addGetterSetter(H_,"keepRatio",!0),gv.addGetterSetter(H_,"shiftBehavior","default"),gv.addGetterSetter(H_,"centeredScaling",!1),gv.addGetterSetter(H_,"ignoreStroke",!1),gv.addGetterSetter(H_,"padding",0,hv()),gv.addGetterSetter(H_,"nodes"),gv.addGetterSetter(H_,"node"),gv.addGetterSetter(H_,"boundBoxFunc"),gv.addGetterSetter(H_,"anchorDragBoundFunc"),gv.addGetterSetter(H_,"anchorStyleFunc"),gv.addGetterSetter(H_,"shouldOverdrawWholeArea",!1),gv.addGetterSetter(H_,"useSingleNodeRotation",!0),gv.backCompat(H_,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class V_ extends by{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Ng.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function W_(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}V_.prototype.className="Wedge",V_.prototype._centroid=!0,V_.prototype._attrsAffectingSize=["radius"],Ug(V_),gv.addGetterSetter(V_,"radius",0,hv()),gv.addGetterSetter(V_,"angle",0,hv()),gv.addGetterSetter(V_,"clockwise",!1),gv.backCompat(V_,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const j_=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],X_=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];gv.addGetterSetter(Lv,"blurRadius",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"brightness",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"contrast",0,hv(),gv.afterSetFilter);function Y_(t,e,i,n,r){const s=i-e,a=r-n;if(0===s)return n+a/2;if(0===a)return n;let o=(t-e)/s;return o=a*o+n,o}gv.addGetterSetter(Lv,"embossStrength",.5,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"embossWhiteLevel",.5,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"embossDirection","top-left",void 0,gv.afterSetFilter),gv.addGetterSetter(Lv,"embossBlend",!1,void 0,gv.afterSetFilter);gv.addGetterSetter(Lv,"enhance",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"hue",0,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"saturation",0,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"luminance",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"hue",0,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"saturation",0,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"value",0,hv(),gv.afterSetFilter);function q_(t,e,i){let n=4*(i*t.width+e);const r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function Z_(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}gv.addGetterSetter(Lv,"kaleidoscopePower",2,hv(),gv.afterSetFilter),gv.addGetterSetter(Lv,"kaleidoscopeAngle",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"threshold",0,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"noise",.2,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"pixelSize",8,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"levels",.5,hv(),gv.afterSetFilter);gv.addGetterSetter(Lv,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),gv.addGetterSetter(Lv,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),gv.addGetterSetter(Lv,"blue",0,ov,gv.afterSetFilter);gv.addGetterSetter(Lv,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),gv.addGetterSetter(Lv,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),gv.addGetterSetter(Lv,"blue",0,ov,gv.afterSetFilter),gv.addGetterSetter(Lv,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});gv.addGetterSetter(Lv,"threshold",.5,hv(),gv.afterSetFilter);const K_=Uy.Util._assign(Uy,{Arc:Fy,Arrow:Ky,Circle:Jy,Ellipse:Qy,Image:$y,Label:a_,Tag:o_,Line:By,Path:Zy,Rect:h_,RegularPolygon:l_,Ring:d_,Sprite:u_,Star:p_,Text:A_,TextPath:L_,Transformer:H_,Wedge:V_,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,r=t.height;let s,a,o,h,l,c,d,u,p,m,f,g,v,y,_,x,w,b,S,M;const E=e+e+1,T=n-1,A=r-1,C=e+1,R=C*(C+1)/2,P=new W_,L=j_[e],I=X_[e];let D=null,O=P,N=null,U=null;for(let t=1;t<E;t++)O=O.next=new W_,t===C&&(D=O);O.next=P,o=a=0;for(let t=0;t<r;t++){g=v=y=_=h=l=c=d=0,u=C*(x=i[a]),p=C*(w=i[a+1]),m=C*(b=i[a+2]),f=C*(S=i[a+3]),h+=R*x,l+=R*w,c+=R*b,d+=R*S,O=P;for(let t=0;t<C;t++)O.r=x,O.g=w,O.b=b,O.a=S,O=O.next;for(let t=1;t<C;t++)s=a+((T<t?T:t)<<2),h+=(O.r=x=i[s])*(M=C-t),l+=(O.g=w=i[s+1])*M,c+=(O.b=b=i[s+2])*M,d+=(O.a=S=i[s+3])*M,g+=x,v+=w,y+=b,_+=S,O=O.next;N=P,U=D;for(let t=0;t<n;t++)i[a+3]=S=d*L>>I,0!==S?(S=255/S,i[a]=(h*L>>I)*S,i[a+1]=(l*L>>I)*S,i[a+2]=(c*L>>I)*S):i[a]=i[a+1]=i[a+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,s=o+((s=t+e+1)<T?s:T)<<2,g+=N.r=i[s],v+=N.g=i[s+1],y+=N.b=i[s+2],_+=N.a=i[s+3],h+=g,l+=v,c+=y,d+=_,N=N.next,u+=x=U.r,p+=w=U.g,m+=b=U.b,f+=S=U.a,g-=x,v-=w,y-=b,_-=S,U=U.next,a+=4;o+=n}for(let t=0;t<n;t++){v=y=_=g=l=c=d=h=0,a=t<<2,u=C*(x=i[a]),p=C*(w=i[a+1]),m=C*(b=i[a+2]),f=C*(S=i[a+3]),h+=R*x,l+=R*w,c+=R*b,d+=R*S,O=P;for(let t=0;t<C;t++)O.r=x,O.g=w,O.b=b,O.a=S,O=O.next;let o=n;for(let r=1;r<=e;r++)a=o+t<<2,h+=(O.r=x=i[a])*(M=C-r),l+=(O.g=w=i[a+1])*M,c+=(O.b=b=i[a+2])*M,d+=(O.a=S=i[a+3])*M,g+=x,v+=w,y+=b,_+=S,O=O.next,r<A&&(o+=n);a=t,N=P,U=D;for(let e=0;e<r;e++)s=a<<2,i[s+3]=S=d*L>>I,S>0?(S=255/S,i[s]=(h*L>>I)*S,i[s+1]=(l*L>>I)*S,i[s+2]=(c*L>>I)*S):i[s]=i[s+1]=i[s+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,s=t+((s=e+C)<A?s:A)*n<<2,h+=g+=N.r=i[s],l+=v+=N.g=i[s+1],c+=y+=N.b=i[s+2],d+=_+=N.a=i[s+3],N=N.next,u+=x=U.r,p+=w=U.g,m+=b=U.b,f+=S=U.a,g-=x,v-=w,y-=b,_-=S,U=U.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let r=150,s=150,a=150;for(let t=0;t<n;t+=4)r=i[t],s=i[t+1],a=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,i[t]=r,i[t+1]=s,i[t+2]=a},Emboss:function(t){var e,i,n,r,s,a,o,h,l;const c=t.data,d=t.width,u=t.height,p=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),m=Math.min(1,Math.max(0,null!==(r=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==r?r:.5)),f=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(s=this.embossDirection)||void 0===s?void 0:s.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,g=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),v=10*p,y=255*m,_=f*Math.PI/180,x=Math.cos(_),w=Math.sin(_),b=128/1020*v,S=new Uint8ClampedArray(c),M=new Float32Array(d*u);for(let t=0,e=0;e<c.length;e+=4,t++)M[t]=.2126*S[e]+.7152*S[e+1]+.0722*S[e+2];const E=[-1,0,1,-2,0,2,-1,0,1],T=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],C=t=>t<0?0:t>255?255:t;for(let t=1;t<u-1;t++)for(let e=1;e<d-1;e++){const i=t*d+e;let n=0,r=0;n+=M[i+A[0]]*E[0],r+=M[i+A[0]]*T[0],n+=M[i+A[1]]*E[1],r+=M[i+A[1]]*T[1],n+=M[i+A[2]]*E[2],r+=M[i+A[2]]*T[2],n+=M[i+A[3]]*E[3],r+=M[i+A[3]]*T[3],n+=M[i+A[5]]*E[5],r+=M[i+A[5]]*T[5],n+=M[i+A[6]]*E[6],r+=M[i+A[6]]*T[6],n+=M[i+A[7]]*E[7],r+=M[i+A[7]]*T[7],n+=M[i+A[8]]*E[8],r+=M[i+A[8]]*T[8];const s=C(y+(x*n+w*r)*b),a=4*i;if(g){const t=s-y;c[a]=C(S[a]+t),c[a+1]=C(S[a+1]+t),c[a+2]=C(S[a+2]+t),c[a+3]=S[a+3]}else c[a]=c[a+1]=c[a+2]=s,c[a+3]=S[a+3]}for(let t=0;t<d;t++){let e=4*t,i=4*((u-1)*d+t);c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3],c[i]=S[i],c[i+1]=S[i+1],c[i+2]=S[i+2],c[i+3]=S[i+3]}for(let t=1;t<u-1;t++){let e=t*d*4,i=4*(t*d+(d-1));c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3],c[i]=S[i],c[i+1]=S[i+1],c[i+2]=S[i+2],c[i+3]=S[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,r,s,a=e[0],o=a,h=e[1],l=h,c=e[2],d=c;const u=this.enhance();if(0===u)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),r=e[t+1],r<h?h=r:r>l&&(l=r),s=e[t+2],s<c?c=s:s>d&&(d=s);let p,m,f,g,v,y;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),u>0)p=o+u*(255-o),m=a-u*(a-0),f=l+u*(255-l),g=h-u*(h-0),v=d+u*(255-d),y=c-u*(c-0);else{const t=.5*(o+a);p=o+u*(o-t),m=a+u*(a-t);const e=.5*(l+h);f=l+u*(l-e),g=h+u*(h-e);const i=.5*(d+c);v=d+u*(d-i),y=c+u*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=Y_(e[t+0],a,o,m,p),e[t+1]=Y_(e[t+1],h,l,g,f),e[t+2]=Y_(e[t+2],c,d,y,v)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,s=127*this.luminance(),a=1*n*Math.cos(r*Math.PI/180),o=1*n*Math.sin(r*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,y,_,x;for(let t=0;t<i;t+=4)v=e[t+0],y=e[t+1],_=e[t+2],x=e[t+3],e[t+0]=h*v+l*y+c*_+s,e[t+1]=d*v+u*y+p*_+s,e[t+2]=m*v+f*y+g*_+s,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=n*r*Math.cos(s*Math.PI/180),o=n*r*Math.sin(s*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2],s=e[t+3];e[t+0]=h*i+l*n+c*r,e[t+1]=d*i+u*n+p*r,e[t+2]=m*i+f*n+g*r,e[t+3]=s}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,r,s,a,o,h,l,c,d,u,p=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),f=Math.floor(e*(m%360)/360);if(p<1)return;const g=qg.createCanvasElement();g.width=e,g.height=i;const v=g.getContext("2d").getImageData(0,0,e,i);qg.releaseCanvas(g),function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*s+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*s),r[u+0]=m,r[u+1]=f,r[u+2]=g,r[u+3]=v}}}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let y=e/Math.pow(2,p);for(;y<=8;)y*=2,p-=1;y=Math.ceil(y);let _=y,x=0,w=_,b=1;for(f+y>e&&(x=_,w=0,b=-1),r=0;r<i;r+=1)for(n=x;n!==w;n+=b)s=Math.round(n+f)%e,d=4*(e*r+s),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*r+n),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;for(r=0;r<i;r+=1)for(_=Math.floor(y),a=0;a<p;a+=1){for(n=0;n<_+1;n+=1)d=4*(e*r+n),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*r+2*_-n-1),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;_*=2}!function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s;let f,g;for(c=0;c<s;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*s+f);const v=n[u+0],y=n[u+1],_=n[u+2],x=n[u+3];u=4*(d*s+c),r[u+0]=v,r[u+1]=y,r[u+2]=_,r[u+3]=x}}(v,t,{})},Mask:function(t){let e=function(t,e){const i=q_(t,0,0),n=q_(t,t.width-1,0),r=q_(t,0,t.height-1),s=q_(t,t.width-1,t.height-1),a=e||10;if(Z_(i,n)<a&&Z_(n,s)<a&&Z_(s,r)<a&&Z_(r,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,s,r]),o=[];for(let i=0;i<t.width*t.height;i++){const n=Z_(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,r=e/2;for(let t=0;t<n;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,r=Math.ceil(i/e),s=Math.ceil(n/e),a=t.data;if(e<=0)qg.error("pixelSize value can not be <= 0");else for(let t=0;t<r;t+=1)for(let r=0;r<s;r+=1){let s=0,o=0,h=0,l=0;const c=t*e,d=c+e,u=r*e,p=u+e;let m=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const r=4*(i*e+t);s+=a[r+0],o+=a[r+1],h+=a[r+2],l+=a[r+3],m+=1}s/=m,o/=m,h/=m,l/=m;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const r=4*(i*e+t);a[r+0]=s,a[r+1]=o,a[r+2]=h,a[r+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,r=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/r)*r},RGB:function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*r,e[t+2]=i*s,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=r*a+e[t+1]*i,e[t+2]=s*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*r),e[t+1]=Math.min(255,.349*i+.686*n+.168*r),e[t+2]=Math.min(255,.272*i+.534*n+.131*r)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],r=e[t+2];.2126*i+.7152*n+.0722*r>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-r)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}});class J_{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class Q_{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const $_=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class tx{constructor(t,e=null,i=new J_){var n,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const s=[],a=[];t.points.forEach(t=>{s.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})}),this._ref=new K_.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:$_.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case $_.get("dot"):t="dot";break;case $_.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=$_.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class ex{constructor(t,e=null,i=new J_){var n,r,s;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new K_.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class ix{constructor(t,e=null,i=new J_){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new K_.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}function nx(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class rx{constructor(t,e=null,i=new J_){var n,r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=nx(t.position,t.position2),t.position3?t.radius.y=nx(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new K_.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let s=this._ref.radiusY();n&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const r=n.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(n.point(e).x-r.x),y:Math.abs(n.point(i).y-r.y)})}}class sx{constructor(t,e=null,i=new J_){var n,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new K_.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),r=n.point({x:i[0],y:i[1]}),s=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,r.x,r.y])}}class ax{constructor(t,e=null,i=new J_){var n,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new K_.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),t.position2&&this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(i&&this._ref.width(r),n&&this._ref.height(s)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}class ox{constructor(t,e=null,i=new J_){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new K_.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function s(s,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=a;const n=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=r[e].x+n/c/2,u=r[e].y+h/c/2;const p=r[e+1].x,m=r[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,s,f,g):t.arc(d,u,s,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?s(8,15):i>=25||n>=25?s(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}const hx={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new tx(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new ex(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new ix(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new rx(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new sx(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new ax(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new ox(e,t,...i)}};class lx{constructor(){this._markupIsActive=!1,this._markupColor=new Q_(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this._container;i&&n&&(this._markupContainer.style.left=`${t}px`,this._markupContainer.style.top=`${e}px`,this._konvaStage.width(i),this._konvaStage.height(n),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.updateScreenCoordinatesForAll()},this.zoomAt=()=>{this.updateScreenCoordinatesForAll()},this.changeCameraMode=()=>{this.clearOverlay()},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){this._viewer=i,this._worldTransformer=null!=n?n:new J_,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(t),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt),this._viewer.addEventListener("changecameramode",this.changeCameraMode))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("changecameramode",this.changeCameraMode),this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,this.destroyKonva(),null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new Q_(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}colorizeSelectedMarkups(t,e,i){const n=new Q_(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}setViewpoint(t){var e,i,n,r,s,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(n=t.texts)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(r=t.rectangles)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(s=t.ellipses)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)}),null===(a=t.arrows)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(o=t.clouds)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&hx[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=hx[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(hx).forEach(e=>{const i=hx[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map(t=>{const e=t.className,i=Object.values(hx).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=hx[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}updateScreenCoordinatesForAll(){this.getObjects().forEach(t=>{t.updateScreenCoordinates()})}initializeKonva(){const t=new K_.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new K_.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new K_.Group,e.add(this._groupImages),this._groupGeometry=new K_.Group,e.add(this._groupGeometry),this._groupTexts=new K_.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new K_.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,r,s,a=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(n=this.addLine([s.x,s.y,s.x,s.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,n=i?r.x:Math.min(r.x,e.x),s=i?r.y:Math.min(r.y,e.y),a=i?200:Math.abs(r.x-e.x),o=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:s},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:s},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:s},null,Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!a)return;const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,o=i?r.x:Math.min(r.x,e.x),h=i?r.y:Math.min(r.y,e.y),l=i?200:Math.abs(r.x-e.x),c=i?200:Math.abs(r.y-e.y);"Line"===this._markupMode?n.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(e.x,e.y):s=this.addArrow({x:r.x,y:r.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?s?(s.setPosition(o,h),s.setWidth(l),s.setHeight(c)):s=this.addRectangle({x:o,y:h},null,l,c):"Ellipse"===this._markupMode?s?(s.setPosition(o,h),s.setRadiusX(l),s.setRadiusY(c)):s=this.addEllipse({x:o,y:h},null,null,{x:l,y:c}):"Cloud"===this._markupMode&&(s?(s.setPosition(o,h),s.setWidth(Math.max(100,l)),s.setHeight(Math.max(100,c))):s=this.addCloud({x:o,y:h},null,l,c))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(n||r){if(n&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new tx(null,e,this._worldTransformer),r={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(r)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),s=new ex(null,e,this._worldTransformer),a={id:s.id(),position:n,text:s.getText(),text_size:.02*i.y,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()*r.getMatrix()[0]};t.push(a)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new ix(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new rx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:r,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=new sx(null,e,this._worldTransformer),s={id:r.id(),start:i,end:n,color:r.getColor()};t.push(s)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],s=new ax(null,e,this._worldTransformer),a={id:s.id(),position:i,position2:n,src:s.getSrc(),width:s.getWidth()*r,height:s.getHeight()*r};t.push(a)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new ox(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,n,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new tx({points:s,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!s||s<h)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const l=new ex({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:s||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,r,s,a){if(!t)return;const o=new ix({position:t,position2:e,width:i,height:n,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,r,s,a){if(!t)return;const o=new rx({position:t,position2:e,position3:i,radius:n,lineWidth:r,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const r=new sx({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,n,r,s,a){if(!t||!i||!n)return;const o=new ox({position:t,position2:e,width:i,height:n,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,r,s){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new ax({position:t,position2:e,src:i,width:n,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s},null,this._worldTransformer);return this.addObject(o),o}}class cx extends $r{constructor(){super(...arguments),this.oldAutoClear=!1,this.oldClippingPlanes=[]}onBeforeRender(t){this.oldAutoClear=t.autoClear,this.oldClippingPlanes=t.clippingPlanes,t.autoClear=!1,t.clippingPlanes=[]}onAfterRender(t){t.clippingPlanes=this.oldClippingPlanes,t.autoClear=this.oldAutoClear}}"undefined"!=typeof window&&(window.THREE=Op),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=ig,t.Info=y,t.Loader=c,t.Markup=lx,t.ModelImpl=Gf,t.Options=f,t.Viewer=class extends Ig{constructor(t){super(),this.client=t,this.options=new f(this),this.loaders=[],this.models=[],this.info=new y,this.canvasEvents=v.slice(),this.canvaseventlistener=t=>this.emit(t),this.selected=[],this.extents=new Li,this.target=new ei(0,0,0),this._activeDragger=null,this._components=[],this._renderNeeded=!1,this._renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new lx}get markup(){return this._markup}get draggers(){return[...pf.getDraggers().keys()]}get components(){return[...Bf.getComponents().keys()]}initialize(t,e){this.addEventListener("optionschange",t=>this.syncOptions(t.data)),this.scene=new $r,this.helpers=new cx;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),r=n.width||1,s=n.height||1,a=r/s;this.camera=new Vr(45,a,.001,1e3),this.camera.up.set(0,1,0),this.camera.position.set(0,0,1),this.camera.lookAt(this.target),this.camera.updateProjectionMatrix(),this.renderer=new Dp({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.renderer.setPixelRatio(i),this.renderer.setSize(r,s),this.renderer.outputColorSpace=Ee,this.renderPass=new wg(this.scene,this.camera),this.helpersPass=new wg(this.helpers,this.camera),this.helpersPass.clear=!1,this.fxaaPass=new Sg,this.smaaPass=new Ag,this.ssaaRenderPass=new Cg([this.scene,this.helpers],this.camera),this.ssaaRenderPass.unbiased=!0,this.outputPass=new Lg,this.composer=new xg(this.renderer),this.composer.addPass(this.renderPass),this.composer.addPass(this.helpersPass),this.composer.addPass(this.smaaPass),this.composer.addPass(this.fxaaPass),this.composer.addPass(this.ssaaRenderPass),this.composer.addPass(this.outputPass),this.composer.setSize(r,s),this.canvas=t,this.canvasEvents.forEach(e=>t.addEventListener(e,this.canvaseventlistener)),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of Bf.getComponents().keys())this._components.push(Bf.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),this.render(this._renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach(t=>t.dispose()),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach(t=>this.canvas.removeEventListener(t,this.canvaseventlistener)),this.canvas=void 0),this.composer&&this.composer.dispose(),this.renderPass&&this.renderPass.dispose(),this.helpersPass&&this.helpersPass.dispose(),this.fxaaPass&&this.fxaaPass.dispose(),this.smaaPass&&this.smaaPass.dispose(),this.ssaaRenderPass&&this.ssaaRenderPass.dispose(),this.outputPass&&this.outputPass.dispose(),this.renderer&&this.renderer.dispose(),this.scene=void 0,this.helpers=void 0,this.camera=void 0,this.renderer=void 0,this.renderPass=void 0,this.helpersPass=void 0,this.fxaaPass=void 0,this.smaaPass=void 0,this.ssaaRenderPass=void 0,this.outputPass=void 0,this.composer=void 0,this}isInitialized(){return!!this.renderer}setSize(t,e,i=!0){if(!this.renderer)return;const n=this.camera,r=t/e;n.isPerspectiveCamera&&(n.aspect=r,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*r,n.right=n.top*r,n.updateProjectionMatrix()),this.renderer.setSize(t,e,i),this.composer.setSize(t,e),this.update(!0),this.emitEvent({type:"resize",width:t,height:e})}update(t=!1){this._renderNeeded=!0,t&&this.render(),this.emitEvent({type:"update",data:t})}render(t,e=!1){var i,n;if(!this.renderer)return;if(!this._renderNeeded&&!e)return;t||(t=performance.now());const r=(t-this._renderTime)/1e3;this._renderTime=t,this._renderNeeded=!1,this.renderer.info.autoReset=!1,this.renderer.info.reset(),!0===this.options.antialiasing||"msaa"===this.options.antialiasing?(this.renderer.render(this.scene,this.camera),this.renderer.render(this.helpers,this.camera)):this.composer.render(r),null===(n=null===(i=this._activeDragger)||void 0===i?void 0:i.updatePreview)||void 0===n||n.call(i),this.emitEvent({type:"render",time:t,deltaTime:r})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;const i=e.mode||"file";"assembly"!==i&&"a"!==i&&"append"!==i&&(this.cancel(),this.clear()),this.emitEvent({type:"open",mode:i,file:t});let n=t;if(n&&"function"==typeof n.getModels){const e=await n.getModels();n=e.find(t=>t.default)||e[0]||t}if(n&&"string"==typeof n.database&&(t=n.file),!n)throw new Error("Format not supported");let r=e.format;r||"string"!=typeof t.type||(r=t.type.split(".").pop()),r||"string"!=typeof t||(r=t.split(".").pop()),!r&&t instanceof globalThis.File&&(r=t.name.split(".").pop());const s=dg.createLoader(this,n,r);if(!s)throw new Error("Format not supported");this.loaders.push(s),this.emitEvent({type:"geometrystart",file:t,model:n});try{await this.loadReferences(n),await s.load(n,r,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:n}),e}return this.emitEvent({type:"geometryend",file:t,model:n}),this}openGltfFile(t,e,i={}){return console.warn("Viewer.openGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e})}loadGltfFile(t,e,i={}){return console.warn("Viewer.loadGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e,mode:"assembly"})}cancel(){return this.loaders.forEach(t=>t.cancel()),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach(t=>t.dispose()),this.loaders=[],this.models.forEach(t=>t.dispose()),this.models=[],this.scene.clear(),this.helpers.clear(),this.extents.makeEmpty(),this.target.set(0,0,0),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this):this}is3D(){return!0}syncOptions(t=this.options){this.renderer&&(this.fxaaPass.enabled="fxaa"===t.antialiasing,this.smaaPass.enabled="smaa"===t.antialiasing,this.ssaaRenderPass.enabled="ssaa"===t.antialiasing,this.renderPass.enabled=!this.ssaaRenderPass.enabled,this.helpersPass.enabled=!this.ssaaRenderPass.enabled,this.update())}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}getSelected2(){return this.executeCommand("getSelected2")}setSelected(t){this.executeCommand("setSelected",t)}setSelected2(t){this.executeCommand("setSelected2",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const n=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(r=pf.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const s=this.canvas;s&&(n&&s.classList.remove(`oda-cursor-${n.name.toLowerCase()}`),r&&s.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find(e=>e.name===t)}drawViewpoint(t){var e,i,n,r;if(!this.renderer)return;const s=({x:t,y:e,z:i})=>new ei(t,e,i),a=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Zi).radius,i=this.renderer.getSize(new $e),n=i.x/i.y,r=new xl;r.top=t.field_height/2,r.bottom=-t.field_height/2,r.left=r.bottom*n,r.right=r.top*n,r.near=0,r.far=1e3*e,r.zoom=t.view_to_world_scale,r.updateProjectionMatrix(),r.up.copy(s(t.up_vector)),r.position.copy(s(t.view_point)),r.lookAt(s(t.direction).add(r.position)),r.updateMatrixWorld(),this.camera=r,this.renderPass.camera=r,this.helpersPass.camera=r,this.ssaaRenderPass.camera=r,this.emitEvent({type:"changecameramode",mode:"orthographic"})}})(t.orthogonal_camera),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Zi).radius,i=this.renderer.getSize(new $e),n=i.x/i.y,r=new Vr;r.fov=t.field_of_view,r.aspect=n,r.near=e/1e3,r.far=1e3*e,r.updateProjectionMatrix(),r.up.copy(s(t.up_vector)),r.position.copy(s(t.view_point)),r.lookAt(s(t.direction).add(r.position)),r.updateMatrixWorld(),this.camera=r,this.renderPass.camera=r,this.helpersPass.camera=r,this.ssaaRenderPass.camera=r,this.emitEvent({type:"changecameramode",mode:"perspective"})}})(t.perspective_camera),(t=>{t&&t.forEach(t=>{const e=new Zs;e.setFromNormalAndCoplanarPoint(s(t.direction),s(t.location)),this.renderer.clippingPlanes.push(e)})})(t.clipping_planes),(t=>{t&&this.setSelected(t.map(t=>t.handle))})((null===(i=t.custom_fields)||void 0===i?void 0:i.selection2)||t.selection),this._markup.setViewpoint(t),this.target.copy(s(null!==(r=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==r?r:this.target)),this.setActiveDragger(a),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new ei)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new ei)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach(i=>{const n={location:t(i.coplanarPoint(new ei)),direction:t(i.normal)};e.push(n)}),e})(),e.selection=(()=>this.getSelected().map(t=>({handle:t})))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),e.custom_fields.selection2=(()=>this.getSelected2().map(t=>({handle:t})))(),this.emitEvent({type:"createviewpoint",data:e}),e}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1;if(this.camera.isPerspectiveCamera){const t=new gc,e=new $e(i,n);t.setFromCamera(e,this.camera);const r=new ei;this.camera.getWorldDirection(r);const s=(new Zs).setFromNormalAndCoplanarPoint(r,this.target),a=new ei;if(t.ray.intersectPlane(s,a),!a){const t=new ei(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}return{x:a.x,y:a.y,z:a.z}}{const t=new ei(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new ei(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return yf.executeCommand(t,this,...e)}},t.commands=yf,t.commandsRegistry=n,t.components=Bf,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=pf,t.draggersRegistry=a,t.loaders=dg,t.loadersRegistry=p});
|
|
37
|
+
this.useVAO=!1,this.visibleEdges=!0,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set,this.objectTransforms=new Map,this.transformedGeometries=new Map,this.activeChunkLoads=0,this.chunkQueue=[],this.objectIdToIndex=new Map,this.maxObjectId=0,this.objectVisibility=new Float32Array,this.maxConcurrentChunks=6,this.mergedObjectMap=new Map,this.mergedGeometryVisibility=new Map,this._webglInfoCache=null}setVisibleEdges(t){this.visibleEdges=t}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t/3}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}updateMemoryIndicator(){this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse(t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach(t=>{t&&t.array&&(e+=t.array.byteLength)}),i.index&&i.index.array&&(e+=i.index.array.byteLength)}}),e}recalculateScene(){const t=[];if(this.scene.traverse(e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}}),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort((t,e)=>e.distance-t.distance);let e=0;for(const i of t)e+=i.size;if(e>this.memoryLimit){console.log(`Memory usage (${Math.round(e/1048576)}MB) exceeds limit`);for(const i of t){if(e<=this.memoryLimit)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=i.object;t.geometry&&(e-=i.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}getStats(){let t=0,e=0,i=0,n=0,r=0,s=0,a=0,o=0;this.scene.traverse(h=>{t++;const l=h.geometry;if(!l)return;let c=0;l.index?c=Math.floor(l.index.count/3):l.attributes&&l.attributes.position&&(c=Math.floor(l.attributes.position.count/3)),i+=c;let d=0;l.index?d=Math.floor(l.index.count/2):l.attributes&&l.attributes.position&&(d=Math.floor(l.attributes.position.count/2)),"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?a+=d:r+=d),!1!==h.visible&&(h.isMesh||h.isLine||h.isPoints)&&(e++,h.isMesh?n+=c:"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?o+=d:s+=d))});const h=this.geometryCache?this.geometryCache.size:0,l=Array.from(this.geometryCache?.values?.()||[]).reduce((t,e)=>t+e,0),c=new Set,d=new Set;if(Array.isArray(this.structures))for(const t of this.structures)try{for(const e of t.materialCache.values())e?.mesh?.uuid&&c.add(e.mesh.uuid),e?.points?.uuid&&c.add(e.points.uuid),e?.lines?.uuid&&c.add(e.lines.uuid)}catch(t){console.error("Error adding material to uniqueMaterialIds",t)}const u=c.size,p=d.size,m=l;if(!this._webglInfoCache)try{const t=this.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");if(e){const i=t.getParameter(e.UNMASKED_RENDERER_WEBGL),n=t.getParameter(e.UNMASKED_VENDOR_WEBGL);this._webglInfoCache={renderer:i,vendor:n}}else this._webglInfoCache={renderer:null,vendor:null}}catch(t){console.error("Error getting webgl info",t),this._webglInfoCache={renderer:null,vendor:null}}const f=new $e;return this.renderer&&this.renderer.getSize&&this.renderer.getSize(f),{scene:{beforeOptimization:{objects:t-e,triangles:i-n,lines:r-s,edges:a-o},afterOptimization:{objects:e,triangles:n,lines:s,edges:o}},memory:{geometries:{count:h,bytes:l},textures:{count:p},materials:{count:u},totalEstimatedGpuBytes:m},system:{webglRenderer:this._webglInfoCache?.renderer||"",webglVendor:this._webglInfoCache?.vendor||"",viewport:{width:f.x||0,height:f.y||0}}}}async loadNode(t,e){const i=this.nodes.get(t);if(!i||i.loaded||i.loading)return;i.loading=!0;const n=i.structure.getJson().meshes[i.meshIndex];try{const t=[],r=new Map;for(let e=0;e<n.primitives.length;e++){const s=n.primitives[e],a=[];if(void 0!==s.attributes.POSITION){const t=s.attributes.POSITION,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"position",primIdx:e})}if(void 0!==s.attributes.NORMAL){const t=s.attributes.NORMAL,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"normal",primIdx:e})}if(void 0!==s.attributes.TEXCOORD_0){const t=s.attributes.TEXCOORD_0,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"uv",primIdx:e})}if(void 0!==s.indices){const t=s.indices,n=i.structure.json.accessors[t],r=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:r,length:h,componentType:n.componentType,accessorIndex:t,type:"index",primIdx:e})}r.set(e,a),t.push(...a)}if(0===t.length)return i.loaded=!0,void(i.loading=!1);t.sort((t,e)=>t.offset-e.offset);const s=t[0].offset,a=Math.max(...t.map(t=>t.offset+t.length))-s,{buffer:o,relOffset:h}=await i.structure.scheduleRequest({offset:s,length:a,componentType:null});for(const e of t){const t=e.offset-s;e.data=i.structure.createTypedArray(o,h+t,e.length,e.componentType)}for(let t=0;t<n.primitives.length;t++){const e=n.primitives[t],s=new _r,a=r.get(t);if(void 0!==e.attributes.POSITION){const t=a.find(t=>"position"===t.type&&t.accessorIndex===e.attributes.POSITION),n=i.structure.json.accessors[e.attributes.POSITION],r=i.structure.getNumComponents(n.type);s.setAttribute("position",new hr(t.data,r))}if(void 0!==e.attributes.NORMAL){const t=a.find(t=>"normal"===t.type&&t.accessorIndex===e.attributes.NORMAL),n=i.structure.json.accessors[e.attributes.NORMAL],r=i.structure.getNumComponents(n.type);s.setAttribute("normal",new hr(t.data,r))}if(void 0!==e.attributes.TEXCOORD_0){const t=a.find(t=>"uv"===t.type&&t.accessorIndex===e.attributes.TEXCOORD_0),n=i.structure.json.accessors[e.attributes.TEXCOORD_0],r=i.structure.getNumComponents(n.type);s.setAttribute("uv",new hr(t.data,r))}if(void 0!==e.indices){const t=a.find(t=>"index"===t.type&&t.accessorIndex===e.indices);s.setIndex(new hr(t.data,1))}let o,h;if(void 0!==e.material){if(o=i.structure.getCachedMaterial(e.material,e.mode),!o){const t=i.structure.json.materials[e.material];o=i.structure.createMaterial(t,e.mode)}}else o=this.createDefaultMaterial(e.mode);e.mode===jf?h=new Ba(s,o):e.mode===Zf||e.mode===Kf||e.mode===Jf||void 0===e.mode?(h=new Lr(s,o),e.mode===Kf?h.drawMode=1:e.mode===Jf&&(h.drawMode=2)):e.mode===Xf?h=new Da(s,o):e.mode===qf?h=new Ra(s,o):e.mode===Yf&&(h=new Oa(s,o)),i.extras&&(h.userData={...h.userData,...i.extras}),n.extras&&(h.userData={...h.userData,...n.extras}),e.extras&&(h.userData={...h.userData,...e.extras}),i.handle?h.userData.handle=i.handle:h.userData.handle=this.getFullHandle(i.structure.id,h.userData.handle),"edges"===h.material.name?h.userData.isEdge=!0:h.userData.isEdge=!1,this.registerObjectWithHandle(h,h.userData.handle),h.position.copy(i.position),s.attributes.normal||s.computeVertexNormals(),o.aoMap&&s.attributes.uv&&s.setAttribute("uv2",s.attributes.uv),i.group?i.group.add(h):this.scene.add(h),i.object=h,this.totalLoadedObjects++,h.visible=this.totalLoadedObjects<this.graphicsObjectLimit}i.loaded=!0,i.loading=!1;const l=this.estimateGeometrySize(i.object);this.geometryCache.set(i.object.uuid,l),this.currentMemoryUsage+=l,e&&e()}catch(e){if(i.loading=!1,"AbortError"===e.name)return;if(i.structure&&i.structure.loadingAborted)return;console.error(`Error loading node ${t}:`,e)}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse(t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}}),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)})}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)await t.initialize(this),this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new qr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const r=i.scenes[i.scene||0];for(const t of r.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const r=i.geometryExtents.getSize(new ei),s=n.geometryExtents.getSize(new ei),a=r.x*r.y*r.z;return s.x*s.y*s.z-a}),!e&&this.visibleEdges&&this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map(t=>({id:t.id,nodeCount:this.nodesToLoad.filter(e=>e.startsWith(t.id)).length}))})}getFullHandle(t,e){return`${t}:${e}`}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let r=null,s=null;if(n.extras?.handle&&(s=this.getFullHandle(t.id,n.extras.handle)),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(r=new qr,r.name=n.name||`node_${e}`,n.extras&&(r.userData={...n.extras},r.userData.handle&&(r.userData.handle=this.getFullHandle(t.id,r.userData.handle))),n.matrix)r.matrix.fromArray(n.matrix),r.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new ei).fromArray(n.translation):new ei,e=n.rotation?(new ti).fromArray(n.rotation):new ti,i=n.scale?(new ei).fromArray(n.scale):new ei(1,1,1);r.matrix.compose(t,e,i),r.matrixAutoUpdate=!1}i&&i.add(r)}if(void 0!==n.mesh){const a=new sn,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Li;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Li((new ei).fromArray(i.min),(new ei).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),h.extras&&h.extras.handle&&(s=this.getFullHandle(t.id,h.extras.handle)),this.nodes.set(o,{position:r?r.position.clone():(new ei).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:r||i,structure:t,extras:n.extras,geometryExtents:l,handle:s||this.getFullHandle(t.id,t._nextObjectId++)})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,r||i);return r}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0,i=0;const n=t.length,r=async()=>{e++,e-i>1e3&&(i=e,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:Math.round(e/n*100),loaded:e,total:n}),this.dispatchEvent("update"),await new Promise(t=>{setTimeout(t,0)}))};try{const i=[];for(const n of t){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=await this.estimateNodeSize(n);if(this.currentMemoryUsage+t>this.memoryLimit)return console.log(`Memory limit reached after loading ${e} nodes`),this.dispatchEvent("geometryerror",{message:"Memory limit reached"}),this.dispatchEvent("update"),e;i.push(this.loadNode(n,r))}for(const t of this.structures)i.push(t.flushBufferRequests());return await Promise.all(i),this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:n}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("Process nodes"),await this.processNodes(),console.timeEnd("Process nodes"),console.time("Optimize scene"),await this.optimizeScene(),console.timeEnd("Optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach(t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)})}createDefaultMaterial(t=void 0){return t===jf?new Na({color:new Jn(8421504),size:.05,sizeAttenuation:!1,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):t===Xf||t===qf||t===Yf?new wa({color:8421504,linewidth:1,alphaTest:.1,depthTest:!0,depthWrite:!0,transparent:!0,opacity:1}):new Mh({color:8421504,specular:2236962,shininess:10,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Li;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone(),n=e.structure?this.structureRoots.get(e.structure.id):null;if(e.group){const t=[];let r=e.group;for(;r&&r!==n;)r.matrix&&!1===r.matrixAutoUpdate&&t.unshift(r.matrix),r=r.parent;for(const e of t)i.applyMatrix4(e)}n&&n.matrix&&i.applyMatrix4(n.matrix);const r=this.objectTransforms.get(e.object);r&&i.applyMatrix4(r),t.union(i)}return this.scene&&this.scene.matrix&&!t.isEmpty()&&t.applyMatrix4(this.scene.matrix),t}loadCamera(t,e,i){const n=t.getJson().cameras[e],r=n[n.type];let s;return"perspective"===n.type?s=new Vr(Qe.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new xl(r.xmag/-2,r.xmag/2,r.ymag/2,r.ymag/-2,r.znear,r.zfar)),i.matrix?(s.matrix.fromArray(i.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale)):(i.translation&&s.position.fromArray(i.translation),i.rotation&&s.quaternion.fromArray(i.rotation),i.scale&&s.scale.fromArray(i.scale)),s}clearNodesToLoad(){this.nodesToLoad=[]}removeOptimization(){this.originalObjects.forEach(t=>t.visible=!0);const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}initializeObjectVisibility(){if(this.maxObjectId>0){this.objectVisibility=new Float32Array(this.maxObjectId);for(let t=0;t<this.maxObjectId;t++)this.objectVisibility[t]=1}}createVisibilityMaterial(t){return t.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include <common>","\n #include <common>\n attribute float visibility;\n varying float vVisibility;\n "),t.fragmentShader=t.fragmentShader.replace("#include <common>","\n #include <common>\n varying float vVisibility;\n "),t.vertexShader=t.vertexShader.replace("void main() {","\n void main() {\n vVisibility = visibility;\n "),t.fragmentShader=t.fragmentShader.replace("void main() {","\n void main() {\n if (vVisibility < 0.5) discard;\n ")},t.needsUpdate=!0,t}clear(){this.chunkQueue=[],this.structures.forEach(t=>{t&&t.clear()}),this.structures=[],this.nodes.forEach(t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach(t=>t.dispose()):t.object.material.dispose()))}),this.nodes.clear(),this.loadedMeshes.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),this.loadedMeshes.clear(),this.structureRoots.forEach(t=>{t&&(t.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),t.parent&&t.parent.remove(t))}),this.structureRoots.clear(),this.mergedMesh.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose()),t.parent&&t.parent.remove(t)}),this.mergedMesh.clear(),this.mergedLines.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLines.clear(),this.mergedLineSegments.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLineSegments.clear(),this.mergedPoints.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.objectTransforms.clear(),this.transformedGeometries.clear(),this.totalLoadedObjects=0,this.currentMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator(),this.objectIdToIndex.clear(),this.maxObjectId=0,this.objectVisibility=new Float32Array}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter(t=>t!==e))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach(t=>t(e))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split(":")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach(t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)}),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,r=t.geometry.index?t.geometry.index.count:0,s=t.material;let a,o=this.getMaterialId(s,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+r>1e5){const a={material:s,objects:[t],totalVertices:n,totalIndices:r};o=this.getMaterialId(s,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=r;else a={material:s,objects:[t],totalVertices:n,totalIndices:r},e.set(o,a),i.push(a);this.originalObjects.add(t)}yieldToUI(){return new Promise(t=>{setTimeout(t,0)})}async optimizeScene(){console.log("Starting scene optimization..."),this.dispatchEvent("optimizationprogress",{phase:"start",progress:0,message:"Starting optimization..."}),this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.dispatchEvent("optimizationprogress",{phase:"collecting",progress:5,message:"Collecting scene objects..."}),this.scene.traverse(e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Lr?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof Da?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Ra?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof Ba&&this.addToMaterialGroup(e,n.mapPoints,n.points)}});let e=0;const i=t.size;this.dispatchEvent("optimizationprogress",{phase:"merging",progress:10,message:`Merging ${i} structure groups...`,current:0,total:i});for(const n of t.values()){n.mapMeshes.clear(),n.mapLines.clear(),n.mapLineSegments.clear(),n.mapPoints.clear(),await this.mergeMeshGroups(n.meshes,n.rootGroup),await this.yieldToUI(),await this.mergeLineGroups(n.lines,n.rootGroup),await this.yieldToUI(),await this.mergeLineSegmentGroups(n.lineSegments,n.rootGroup),await this.yieldToUI(),await this.mergePointsGroups(n.points,n.rootGroup),e++;const t=10+Math.round(e/i*80);this.dispatchEvent("optimizationprogress",{phase:"merging",progress:t,message:`Processing structure ${e}/${i}...`,current:e,total:i}),console.log(`Optimization progress: ${e}/${i} structure groups processed (${t}%)`),await this.yieldToUI()}this.dispatchEvent("optimizationprogress",{phase:"finalizing",progress:95,message:"Finalizing optimization..."}),this.originalObjects.forEach(t=>{t.visible=!1,t instanceof Ba||t.userData.isEdge||this.originalObjectsToSelection.add(t)}),this.initializeObjectVisibility(),console.log(`Optimization complete. Total objects: ${this.maxObjectId}`),this.dispatchEvent("optimizationprogress",{phase:"complete",progress:100,message:`Optimization complete! ${this.maxObjectId} objects processed.`}),this.dispatchEvent("update")}async mergeMeshGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=new Set,s=[],a=new Map;let o=0;for(const e of n.objects){const i=e.geometry.clone(),n=e.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++);const h=this.objectIdToIndex.get(n),l=i.attributes.position.count,c=new Float32Array(l);for(let t=0;t<l;t++)c[t]=h;i.setAttribute("objectId",new hr(c,1)),a.set(e,{geometry:i,startVertexIndex:o,vertexCount:i.attributes.position.count}),o+=i.attributes.position.count,t.push(i),s.push(e),r.add(e.userData.handle)}const h=[];if(t.length>0){const i=tg(t),r=i.attributes.position.count,o=new Float32Array(r);for(let t=0;t<r;t++)o[t]=1;i.setAttribute("visibility",new hr(o,1)),this.useVAO&&this.createVAO(i);const l=this.createVisibilityMaterial(n.material),c=new Lr(i,l);c.userData.isOptimized=!0,e.add(c),this.mergedMesh.add(c),this.optimizedOriginalMap.set(c,s),this.mergedObjectMap.set(c.uuid,{objectMapping:a,visibilityArray:o,totalVertices:r}),this.mergedGeometryVisibility.set(c,o),h.push(c),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...h),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,h)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.error("Failed to merge meshes for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping mesh group with null material")}async mergeLineGroups(t,e){let i=0;for(const n of t){if(0===n.objects.length)continue;if(!n.material){console.warn("Skipping line group with null material");continue}const t=new Set;let r=0;const s=new Map;let a=0;n.objects.map(e=>{t.add(e.userData.handle),r+=e.geometry.attributes.position.count});const o=new Float32Array(3*r);let h=0;const l=[];let c=0,d=!1;n.objects.forEach(t=>{d=t.userData.isEdge;const e=t.geometry.attributes.position,i=e.count,n=t.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++),s.set(t,{startVertexIndex:a,vertexCount:i}),a+=i;const r=new ei;for(let t=0;t<i;t++)r.fromBufferAttribute(e,t),o[h++]=r.x,o[h++]=r.y,o[h++]=r.z;for(let t=0;t<i-1;t++)l.push(c+t,c+t+1);c+=i});const u=new _r;u.setAttribute("position",new hr(o,3)),u.setIndex(l),u.computeBoundingSphere(),u.computeBoundingBox();const p=new Float32Array(r);let m=0;n.objects.forEach(t=>{const e=t.geometry.attributes.position.count,i=t.userData.handle,n=this.objectIdToIndex.get(i);for(let t=0;t<e;t++)p[m++]=n}),u.setAttribute("objectId",new hr(p,1));const f=new Float32Array(r);for(let t=0;t<r;t++)f[t]=1;u.setAttribute("visibility",new hr(f,1));const g=this.createVisibilityMaterial(n.material),v=new Da(u,g);v.userData.isEdge=d,v.userData.isOptimized=!0;const y=[v];this.useVAO&&this.createVAO(v),e.add(v),this.mergedLines.add(v),this.optimizedOriginalMap.set(v,n.objects),this.mergedObjectMap.set(v.uuid,{objectMapping:s,visibilityArray:f,totalVertices:r}),this.mergedGeometryVisibility.set(v,f),t.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...y),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,y)}),i++,i%5==0&&await this.yieldToUI()}}async mergeLineSegmentGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=[],s=new Set,a=new Map;let o=0,h=!1;for(const e of n.objects){h=e.userData.isEdge;const i=e.geometry.clone(),n=e.userData.handle;this.objectIdToIndex.has(n)||this.objectIdToIndex.set(n,this.maxObjectId++);const l=this.objectIdToIndex.get(n),c=i.attributes.position.count,d=new Float32Array(c);for(let t=0;t<c;t++)d[t]=l;i.setAttribute("objectId",new hr(d,1)),a.set(e,{geometry:i,startVertexIndex:o,vertexCount:i.attributes.position.count}),o+=i.attributes.position.count,t.push(i),r.push(e),s.add(e.userData.handle)}const l=[];if(t.length>0){const i=tg(t,!1),s=i.attributes.position.count,o=new Float32Array(s);for(let t=0;t<s;t++)o[t]=1;i.setAttribute("visibility",new hr(o,1));const c=this.createVisibilityMaterial(n.material),d=new Da(i,c);d.userData.isEdge=h,d.userData.isOptimized=!0,this.useVAO&&this.createVAO(d),e.add(d),this.mergedLineSegments.add(d),this.optimizedOriginalMap.set(d,r),this.mergedObjectMap.set(d.uuid,{objectMapping:a,visibilityArray:o,totalVertices:s}),this.mergedGeometryVisibility.set(d,o),l.push(d),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...l),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,l)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge line segments for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping line segment group with null material")}async mergePointsGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],r=[],s=new Set;for(const e of n.objects){const i=e.geometry.clone();t.push(i),r.push(e),s.add(e.userData.handle)}const a=[];if(t.length>0){const i=tg(t,!1),s=new Ba(i,n.material);s.userData.isOptimized=!0,this.useVAO&&this.createVAO(s),e.add(s),this.mergedPoints.add(s),this.optimizedOriginalMap.set(s,r),a.push(s),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...a),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,a)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge points for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping points group with null material")}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter(e=>e.userData.structureId===t);if(0!==i.length)try{const n=[],r=i.some(t=>void 0!==t.geometry.attributes.normal);i.forEach(t=>{const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld),r&&!e.attributes.normal&&e.computeVertexNormals(),!r&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new hr(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)});const s=tg(n,!1),a=new wa({vertexColors:!0});this.useVAO&&this.createVAO(s);const o=new Da(s,a);o.userData.structureId=t,o.userData.isOptimized=!0,e.add(o),this.mergedLineSegments.add(o),i.forEach(t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()})}catch(t){console.error("Failed to merge geometries:",t),i.forEach(t=>{t.visible=!0,e.add(t)})}}showOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!0)})}hideOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!1)})}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],r=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,r),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach(t=>{this.hiddenHandles.add(t)}),this.syncHiddenObjects()}showObjects(t){t.forEach(t=>{this.hiddenHandles.delete(t)}),this.syncHiddenObjects()}_updateVisibilityAttribute(t){if(t.geometry&&t.geometry.attributes.visibility&&t.geometry.attributes.objectId){const e=t.geometry.attributes.visibility.array,i=t.geometry.attributes.objectId.array;for(let t=0;t<e.length;t++){const n=i[t];n<this.objectVisibility.length&&(e[t]=this.objectVisibility[n])}t.geometry.attributes.visibility.needsUpdate=!0}}applyObjectTransforms(t){if(0!==this.mergedObjectMap.size){this.objectTransforms=new Map(t);for(const t of this.mergedMesh)this._applyTransformToMergedObject(t);for(const t of this.mergedLines)this._applyTransformToMergedObject(t);for(const t of this.mergedLineSegments)this._applyTransformToMergedObject(t);for(const t of this.mergedPoints)this._applyTransformToMergedObject(t)}else console.warn("No merged objects to transform")}createExplodeTransforms(t=null,e=null,i=1.5){const n=new Map;if(!e){e=new ei;const t=this.getTotalGeometryExtent();t.isEmpty()||t.getCenter(e)}const r=t?Array.isArray(t)?t:Array.from(t):Array.from(this.originalObjects);for(const t of r){if(!t.geometry||!t.geometry.attributes.position)continue;const r=(new Li).setFromBufferAttribute(t.geometry.attributes.position);if(t.matrixWorld&&r.applyMatrix4(t.matrixWorld),r.isEmpty())continue;const s=new ei;r.getCenter(s);const a=s.clone().sub(e),o=a.length();if(o>0){a.normalize();const e=a.multiplyScalar(o*(i-1)),r=(new sn).makeTranslation(e.x,e.y,e.z);n.set(t,r)}}return n}clearTransforms(){this.objectTransforms.clear();for(const t of this.mergedMesh)this._restoreOriginalGeometry(t);for(const t of this.mergedLines)this._restoreOriginalGeometry(t);for(const t of this.mergedLineSegments)this._restoreOriginalGeometry(t);for(const t of this.mergedPoints)this._restoreOriginalGeometry(t)}clearHandleTransforms(){this.clearTransforms()}_applyTransformToMergedObject(t){const e=this.mergedObjectMap.get(t.uuid);if(!e||!e.objectMapping)return;const i=t.geometry;if(!i||!i.attributes.position)return;const n=i.attributes.position,r=n.array;this.transformedGeometries.has(t.uuid)||this.transformedGeometries.set(t.uuid,new Float32Array(r));const s=this.transformedGeometries.get(t.uuid),a=new ei;for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)r[i]=s[i];continue}const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const i=3*(n+t);a.set(s[i],s[i+1],s[i+2]),a.applyMatrix4(e),r[i]=a.x,r[i+1]=a.y,r[i+2]=a.z}}i.attributes.normal&&this._updateNormalsForTransform(i,e,s),n.needsUpdate=!0,i.computeBoundingSphere(),i.computeBoundingBox()}_updateNormalsForTransform(t,e,i){const n=t.attributes.normal;if(!n)return;const r=n.array,s=new ei,a=new sn,o=`${t.uuid}_normals`;this.transformedGeometries.has(o)||this.transformedGeometries.set(o,new Float32Array(r));const h=this.transformedGeometries.get(o);for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)r[i]=h[i];continue}a.copy(e).invert().transpose();const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const e=3*(n+t);s.set(h[e],h[e+1],h[e+2]),s.applyMatrix4(a).normalize(),r[e]=s.x,r[e+1]=s.y,r[e+2]=s.z}}n.needsUpdate=!0}_restoreOriginalGeometry(t){const e=t.geometry;if(!e||!e.attributes.position)return;const i=this.transformedGeometries.get(t.uuid);if(i){e.attributes.position.array.set(i),e.attributes.position.needsUpdate=!0}const n=`${e.uuid}_normals`,r=this.transformedGeometries.get(n);if(r&&e.attributes.normal){e.attributes.normal.array.set(r),e.attributes.normal.needsUpdate=!0}e.computeBoundingSphere(),e.computeBoundingBox()}syncHiddenObjects(){if(0!==this.mergedObjectMap.size){if(this.objectVisibility.length>0){for(let t=0;t<this.objectVisibility.length;t++)this.objectVisibility[t]=1;this.hiddenHandles.forEach(t=>{const e=this.objectIdToIndex.get(t);void 0!==e&&e<this.objectVisibility.length&&(this.objectVisibility[e]=0)})}for(const t of this.mergedMesh)this._updateVisibilityAttribute(t);for(const t of this.mergedLines)this._updateVisibilityAttribute(t);for(const t of this.mergedLineSegments)this._updateVisibilityAttribute(t);for(const t of this.mergedPoints)this._updateVisibilityAttribute(t)}else console.log("No merged objects to sync")}getStructureGeometryExtent(t){const e=new Li,i=this.structureRoots.get(t);for(const[n,r]of this.nodes.entries()){if(!r.geometryExtents)continue;if(!n.startsWith(t+"_"))continue;if(r.object&&this.hiddenHandles&&this.hiddenHandles.has(r.object.userData.handle))continue;const s=r.geometryExtents.clone();if(r.group){const t=[];let e=r.group;for(;e&&e!==i;)e.matrix&&!1===e.matrixAutoUpdate&&t.unshift(e.matrix),e=e.parent;for(const e of t)s.applyMatrix4(e)}i&&i.matrix&&s.applyMatrix4(i.matrix),e.union(s)}return this.scene&&this.scene.matrix&&!e.isEmpty()&&e.applyMatrix4(this.scene.matrix),e}setMaxConcurrentChunks(t){t<1?console.warn("Max concurrent chunks must be at least 1"):this.maxConcurrentChunks=t}waitForChunkSlot(){return this.activeChunkLoads<this.maxConcurrentChunks?(this.activeChunkLoads++,Promise.resolve()):new Promise(t=>{this.chunkQueue.push(t)})}releaseChunkSlot(){if(this.activeChunkLoads--,this.chunkQueue.length>0){const t=this.chunkQueue.shift();this.activeChunkLoads++,t()}}}class ng extends Qh{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Cl.extractUrlBase(t)):(i.forEach((e,i)=>this.fileURL=e===t?i:this.fileURL),i.set(this.fileURL,t)),i.forEach((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)}),this.setURLModifier(t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t})}dispose(){this.dataURLs.forEach(t=>URL.revokeObjectURL(t))}}const rg="glTF",sg=1313821514,ag=5128258;class og{constructor(t){const e=new DataView(t,0,12),i=new TextDecoder,n=i.decode(new Uint8Array(t.slice(0,4)));if(n!==rg)return void(this.content=i.decode(t));const r=n,s=e.getUint32(4,!0),a=e.getUint32(8,!0);if(r!==rg)throw new Error("Unsupported glTF-Binary header.");if(s<2)throw new Error("Legacy binary file detected.");const o=a-12,h=new DataView(t,12);let l=0;for(;l<o;){const e=h.getUint32(l,!0);l+=4;const n=h.getUint32(l,!0);if(l+=4,n===sg){const n=new Uint8Array(t,12+l,e);this.content=i.decode(n)}else if(n===ag){const i=12+l;this.body=t.slice(i,i+e)}l+=e}if(void 0===this.content)throw new Error("JSON content not found.")}}class hg extends Error{constructor(t,e){super(e),this.name="FetchError",this.status=t}}class lg{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}async load(t,e){const i={headers:{...this.requestHeader,Range:"bytes="+e.map(t=>`${t.offset}-${t.offset+t.length-1}`).join(",")},credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal},n=await fetch(t,i);if(!n.ok)throw new hg(n.status,`Failed to fetch "${t}", status ${n.status}`);if(206!==n.status){const t=await n.arrayBuffer();return this.extractRanges(t,e)}return n.arrayBuffer()}extractRanges(t,e){const i=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(i);let r=0;for(const i of e){const e=new Uint8Array(t,i.offset,i.length);n.set(e,r),r+=i.length}return n.buffer}}class cg extends c{constructor(t){super(),this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear(),this.manager&&this.manager.dispose()}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){this.manager=new ng(t,i);const n=new qr;this.gltfLoader=new ig(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.visibleEdges=this.viewer.options.edgeModel;const r=new Vf(n);r.id=i.modelId||this.extractFileName(t),r.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",()=>{this.viewer.scene.add(n),this.viewer.models.push(r),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t})}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t})}),this.gltfLoader.addEventListener("update",t=>{this.viewer.update()});const s={loadJson:async()=>{const e=new nl(this.manager);e.setPath(this.manager.path),e.setRequestHeader(i.requestHeader||{}),e.setWithCredentials(i.withCredentials||e.withCredentials),e.setResponseType("arraybuffer");const n=await e.loadAsync(this.manager.fileURL,e=>{const{lengthComputable:i,loaded:n,total:r}=e,s=i?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:s,file:t})}),r=new og(n);if(this.gltf=JSON.parse(r.content),this.glb=r.body,/\.glb$/i.test(this.manager.fileURL)&&!this.glb)throw new Error("GLTFFileDynamicLoader: Binary buffer chunk not found or type not supported.");return this.gltf},loadBinaryData:(t,e="")=>{const n=new lg;if(n.setRequestHeader(i.requestHeader||{}),n.setWithCredentials(i.withCredentials||!1),n.setAbortSignal(this.gltfLoader.abortController.signal),this.glb)return n.extractRanges(this.glb,t);const r=this.manager.path||this.manager.resourcePath,s=Cl.resolveURL(e,r);return n.load(this.manager.resolveURL(s),t)},resolveURL:t=>{const e=this.manager.path||this.manager.resourcePath,i=Cl.resolveURL(t,e);return Promise.resolve(this.manager.resolveURL(i))}},a=new $f(r.id,s);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}class dg extends c{constructor(t){super(),this.requestId=0,this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i={}){const n=new qr;this.gltfLoader=new ig(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);const r=new Vf(n);r.id=t.file.id,r.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",e=>{this.viewer.scene.add(n),this.viewer.models.push(r),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t})}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}),this.gltfLoader.addEventListener("update",t=>{this.viewer.update()});const s={loadJson:async()=>{const e=await t.downloadResource(t.database,e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t})},this.gltfLoader.getAbortController().signal),i=(new TextDecoder).decode(e);return JSON.parse(i)},loadBinaryData:e=>{const i=e.map(t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++}));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},resolveURL:e=>{const i=`${t.httpClient.serverUrl}${t.path}/`,n=Cl.resolveURL(e,i);return Promise.resolve(n)}},a=new $f(r.id,s);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const ug=p("threejs");ug.registerLoader("gltf-file",t=>new cg(t)),ug.registerLoader("gltf-cloud",t=>new dg(t));const pg={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\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}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class mg{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const fg=new xl(-1,1,1,-1,0,1);const gg=new class extends _r{constructor(){super(),this.setAttribute("position",new dr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new dr([0,2,0,0,2,0],2))}};class vg{constructor(t){this._mesh=new Lr(gg,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,fg)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class yg extends mg{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof zr?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Fr.clone(t.uniforms),this.material=new zr({name:void 0!==t.name?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new vg(this.material)}render(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class _g extends mg{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const n=t.getContext(),r=t.state;let s,a;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),r.buffers.stencil.setFunc(n.ALWAYS,s,4294967295),r.buffers.stencil.setClear(a),r.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(n.EQUAL,1,4294967295),r.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),r.buffers.stencil.setLocked(!0)}}class xg extends mg{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class wg{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),void 0===e){const i=t.getSize(new $e);this._width=i.width,this._height=i.height,(e=new Ci(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wt})).texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new yg(pg),this.copyPass.material.blending=0,this.clock=new Gl}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let i=!1;for(let e=0,n=this.passes.length;e<n;e++){const n=this.passes[e];if(!1!==n.enabled){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),n.render(this.renderer,this.writeBuffer,this.readBuffer,t,i),n.needsSwap){if(i){const e=this.renderer.getContext(),i=this.renderer.state.buffers.stencil;i.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),i.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==_g&&(n instanceof _g?i=!0:n instanceof xg&&(i=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new $e);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(i,n)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class bg extends mg{constructor(t,e,i=null,n=null,r=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Jn}render(t,e,i){const n=t.autoClear;let r,s;t.autoClear=!1,null!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),null!==this.clearAlpha&&(r=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),!0===this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),null!==this.clearColor&&t.setClearColor(this._oldClearColor),null!==this.clearAlpha&&t.setClearAlpha(r),null!==this.overrideMaterial&&(this.scene.overrideMaterial=s),t.autoClear=n}}const Sg={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\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}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n\t\t}"};class Mg extends yg{constructor(){super(Sg)}setSize(t,e){this.material.uniforms.resolution.value.set(1/t,1/e)}}const Eg={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvoid SMAAEdgeDetectionVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAAEdgeDetectionVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n\t\t\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n\t\t\t// Calculate color deltas:\n\t\t\tvec4 delta;\n\t\t\tvec3 C = texture2D( colorTex, texcoord ).rgb;\n\n\t\t\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n\t\t\tvec3 t = abs( C - Cleft );\n\t\t\tdelta.x = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n\t\t\tt = abs( C - Ctop );\n\t\t\tdelta.y = max( max( t.r, t.g ), t.b );\n\n\t\t\t// We do the usual threshold:\n\t\t\tvec2 edges = step( threshold, delta.xy );\n\n\t\t\t// Then discard if there is no edge:\n\t\t\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n\t\t\t\tdiscard;\n\n\t\t\t// Calculate right and bottom deltas:\n\t\t\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n\t\t\tt = abs( C - Cright );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n\t\t\tt = abs( C - Cbottom );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the maximum delta in the direct neighborhood:\n\t\t\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n\t\t\t// Calculate left-left and top-top deltas:\n\t\t\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n\t\t\tt = abs( C - Cleftleft );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n\t\t\tt = abs( C - Ctoptop );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the final maximum delta:\n\t\t\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n\t\t\t// Local contrast adaptation in action:\n\t\t\tedges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n\t\t\treturn vec4( edges, 0.0, 0.0 );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n\t\t}"},Tg={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\t\tvarying vec2 vPixcoord;\n\n\t\tvoid SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n\t\t\tvPixcoord = texcoord / resolution;\n\n\t\t\t// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n\t\t\t// And these for the searches, they indicate the ends of the loops:\n\t\t\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAABlendingWeightCalculationVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tArea;\n\t\tuniform sampler2D tSearch;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[3];\n\t\tvarying vec2 vPixcoord;\n\n\t\t#if __VERSION__ == 100\n\t\tvec2 round( vec2 x ) {\n\t\t\treturn sign( x ) * floor( abs( x ) + 0.5 );\n\t\t}\n\t\t#endif\n\n\t\tfloat SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n\t\t\t// Not required if searchTex accesses are set to point:\n\t\t\t// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n\t\t\t// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n\t\t\t// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n\t\t\te.r = bias + e.r * scale;\n\t\t\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;\n\t\t}\n\n\t\tfloat SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\t/**\n\t\t\t\t* @PSEUDO_GATHER4\n\t\t\t\t* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n\t\t\t\t* sample between edge, thus fetching four edges in a row.\n\t\t\t\t* Sampling with different offsets in each direction allows to disambiguate\n\t\t\t\t* which edges are active from the four fetched ones.\n\t\t\t\t*/\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\t// We correct the previous (-0.25, -0.125) offset we applied:\n\t\t\ttexcoord.x += 0.25 * resolution.x;\n\n\t\t\t// The searches are bias by 1, so adjust the coords accordingly:\n\t\t\ttexcoord.x += resolution.x;\n\n\t\t\t// Disambiguate the length added by the last step:\n\t\t\ttexcoord.x += 2.0 * resolution.x; // Undo last step\n\t\t\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.x -= 0.25 * resolution.x;\n\t\t\ttexcoord.x -= resolution.x;\n\t\t\ttexcoord.x -= 2.0 * resolution.x;\n\t\t\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tfloat SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tvec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n\t\t\t// Rounding prevents precision errors of bilinear filtering:\n\t\t\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n\t\t\t// We do a scale and bias for mapping to texel space:\n\t\t\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n\t\t\t// Move to proper place, according to the subpixel offset:\n\t\t\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n\t\t\treturn texture2D( areaTex, texcoord, 0.0 ).rg;\n\t\t}\n\n\t\tvec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n\t\t\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n\t\t\tvec2 e = texture2D( edgesTex, texcoord ).rg;\n\n\t\t\tif ( e.g > 0.0 ) { // Edge at north\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the left:\n\t\t\t\tvec2 coords;\n\t\t\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n\t\t\t\tcoords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n\t\t\t\td.x = coords.x;\n\n\t\t\t\t// Now fetch the left crossing edges, two at a time using bilinear\n\t\t\t\t// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n\t\t\t\t// discern what value each edge has:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n\t\t\t\t// Find the distance to the right:\n\t\t\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n\t\t\t\td.y = coords.x;\n\n\t\t\t\t// We want the distances to be in pixel units (doing this here allow to\n\t\t\t\t// better interleave arithmetic and memory accesses):\n\t\t\t\td = d / resolution.x - pixcoord.x;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the right crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n\t\t\t\t// Ok, we know how this pattern looks like, now it is time for getting\n\t\t\t\t// the actual area:\n\t\t\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n\t\t\t}\n\n\t\t\tif ( e.r > 0.0 ) { // Edge at west\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the top:\n\t\t\t\tvec2 coords;\n\n\t\t\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n\t\t\t\tcoords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n\t\t\t\td.x = coords.y;\n\n\t\t\t\t// Fetch the top crossing edges:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n\t\t\t\t// Find the distance to the bottom:\n\t\t\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n\t\t\t\td.y = coords.y;\n\n\t\t\t\t// We want the distances to be in pixel units:\n\t\t\t\td = d / resolution.y - pixcoord.y;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the bottom crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n\t\t\t\t// Get the area for this direction:\n\t\t\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n\t\t\t}\n\n\t\t\treturn weights;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n\t\t}"},Ag={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new $e(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvoid SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAANeighborhoodBlendingVS( vUv );\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 sampler2D tColor;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n\t\t\t// Fetch the blending weights for current pixel:\n\t\t\tvec4 a;\n\t\t\ta.xz = texture2D( blendTex, texcoord ).xz;\n\t\t\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n\t\t\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n\t\t\t// Is there any blending weight with a value greater than 0.0?\n\t\t\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n\t\t\t\treturn texture2D( colorTex, texcoord, 0.0 );\n\t\t\t} else {\n\t\t\t\t// Up to 4 lines can be crossing a pixel (one through each edge). We\n\t\t\t\t// favor blending by choosing the line with the maximum weight for each\n\t\t\t\t// direction:\n\t\t\t\tvec2 offset;\n\t\t\t\toffset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n\t\t\t\toffset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n\t\t\t\t// Then we go in the direction that has the maximum weight:\n\t\t\t\tif ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n\t\t\t\t\toffset.y = 0.0;\n\t\t\t\t} else {\n\t\t\t\t\toffset.x = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Fetch the opposite color and lerp by hand:\n\t\t\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\ttexcoord += sign( offset ) * resolution;\n\t\t\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n\t\t\t\t// WebGL port note: Added gamma correction\n\t\t\t\tC.xyz = pow(C.xyz, vec3(2.2));\n\t\t\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));\n\t\t\t\tvec4 mixed = mix(C, Cop, s);\n\t\t\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n\t\t\t\treturn mixed;\n\t\t\t}\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n\t\t}"};class Cg extends mg{constructor(){super(),this._edgesRT=new Ci(1,1,{depthBuffer:!1,type:wt}),this._edgesRT.texture.name="SMAAPass.edges",this._weightsRT=new Ci(1,1,{depthBuffer:!1,type:wt}),this._weightsRT.texture.name="SMAAPass.weights";const t=this,e=new Image;e.src=this._getAreaTexture(),e.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Ei,this._areaTexture.name="SMAAPass.area",this._areaTexture.image=e,this._areaTexture.minFilter=dt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;const i=new Image;i.src=this._getSearchTexture(),i.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Ei,this._searchTexture.name="SMAAPass.search",this._searchTexture.image=i,this._searchTexture.magFilter=ht,this._searchTexture.minFilter=ht,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=Fr.clone(Eg.uniforms),this._materialEdges=new zr({defines:Object.assign({},Eg.defines),uniforms:this._uniformsEdges,vertexShader:Eg.vertexShader,fragmentShader:Eg.fragmentShader}),this._uniformsWeights=Fr.clone(Tg.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new zr({defines:Object.assign({},Tg.defines),uniforms:this._uniformsWeights,vertexShader:Tg.vertexShader,fragmentShader:Tg.fragmentShader}),this._uniformsBlend=Fr.clone(Ag.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new zr({uniforms:this._uniformsBlend,vertexShader:Ag.vertexShader,fragmentShader:Ag.fragmentShader}),this._fsQuad=new vg(null)}render(t,e,i){this._uniformsEdges.tDiffuse.value=i.texture,this._fsQuad.material=this._materialEdges,t.setRenderTarget(this._edgesRT),this.clear&&t.clear(),this._fsQuad.render(t),this._fsQuad.material=this._materialWeights,t.setRenderTarget(this._weightsRT),this.clear&&t.clear(),this._fsQuad.render(t),this._uniformsBlend.tColor.value=i.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(),this._fsQuad.render(t))}setSize(t,e){this._edgesRT.setSize(t,e),this._weightsRT.setSize(t,e),this._materialEdges.uniforms.resolution.value.set(1/t,1/e),this._materialWeights.uniforms.resolution.value.set(1/t,1/e),this._materialBlend.uniforms.resolution.value.set(1/t,1/e)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return"data:image/png;base64,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"}_getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}}class Rg extends mg{constructor(t,e,i=0,n=0){super(),this.scenes=Array.isArray(t)?t:[t],this.camera=e,this.sampleLevel=2,this.unbiased=!0,this.stencilBuffer=!1,this.clearColor=i,this.clearAlpha=n,this._sampleRenderTarget=null,this._oldClearColor=new Jn,this._copyUniforms=Fr.clone(pg.uniforms),this._copyMaterial=new zr({uniforms:this._copyUniforms,vertexShader:pg.vertexShader,fragmentShader:pg.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:2}),this._fsQuad=new vg(this._copyMaterial)}dispose(){this._sampleRenderTarget&&(this._sampleRenderTarget.dispose(),this._sampleRenderTarget=null),this._copyMaterial.dispose(),this._fsQuad.dispose()}setSize(t,e){this._sampleRenderTarget&&this._sampleRenderTarget.setSize(t,e)}render(t,e,i,n,r){this._sampleRenderTarget||(this._sampleRenderTarget=new Ci(i.width,i.height,{type:wt,stencilBuffer:this.stencilBuffer}),this._sampleRenderTarget.texture.name="SSAAMultiRenderPass.sample");const s=Pg[Math.max(0,Math.min(this.sampleLevel,5))],a=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const o=t.getClearAlpha(),h=1/s.length;this._copyUniforms.tDiffuse.value=this._sampleRenderTarget.texture;const l={fullWidth:i.width,fullHeight:i.height,offsetX:0,offsetY:0,width:i.width,height:i.height},c=Object.assign({},this.camera.view);c.enabled&&Object.assign(l,c);for(let i=0;i<s.length;i++){const n=s[i];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*n[0],l.offsetY+.0625*n[1],l.width,l.height);let r=h;if(this.unbiased){r+=.03125*((i+.5)/s.length-.5)}this._copyUniforms.opacity.value=r,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this._sampleRenderTarget),t.clear(),this.scenes.forEach(e=>t.render(e,this.camera)),t.setRenderTarget(this.renderToScreen?null:e),0===i&&(t.setClearColor(0,0),t.clear()),this._fsQuad.render(t)}this.camera.setViewOffset&&c.enabled?this.camera.setViewOffset(c.fullWidth,c.fullHeight,c.offsetX,c.offsetY,c.width,c.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=a,t.setClearColor(this._oldClearColor,o)}}const Pg=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Lg={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:"\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}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\t#include <tonemapping_pars_fragment>\n\t\t#include <colorspace_pars_fragment>\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 Ig extends mg{constructor(){super(),this.uniforms=Fr.clone(Lg.uniforms),this.material=new wh({name:Lg.name,uniforms:this.uniforms,vertexShader:Lg.vertexShader,fragmentShader:Lg.fragmentShader}),this._fsQuad=new vg(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,this._outputColorSpace===t.outputColorSpace&&this._toneMapping===t.toneMapping||(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},fi.getTransfer(this._outputColorSpace)===Ae&&(this.material.defines.SRGB_TRANSFER=""),1===this._toneMapping?this.material.defines.LINEAR_TONE_MAPPING="":2===this._toneMapping?this.material.defines.REINHARD_TONE_MAPPING="":3===this._toneMapping?this.material.defines.CINEON_TONE_MAPPING="":4===this._toneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":6===this._toneMapping?this.material.defines.AGX_TONE_MAPPING="":7===this._toneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":5===this._toneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),!0===this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Dg{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter(t=>t!==e);return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach(e=>e.call(this,t)),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}const Og=Math.PI/180;const Ng="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Ug={_global:Ng,version:"10.0.12",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>Ug.angleDeg?t*Og:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Ug.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=Ug.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!Ug.DD.node,releaseCanvasOnDestroy:!0,document:Ng.document,_injectGlobal(t){void 0!==Ng.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),Ng.Konva=t}},Fg=t=>{Ug[t.prototype.getClassName()]=t};Ug._injectGlobal(Ug);const zg=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class kg{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new kg(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],r=t*n-e*i,s={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);s.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),s.scaleX=a,s.scaleY=r/a,s.skewX=(t*i+e*n)/r,s.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);s.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),s.scaleX=r/a,s.scaleY=a,s.skewX=0,s.skewY=(t*i+e*n)/r}return s.rotation=Zg._getRotation(s.rotation),s}}const Bg=Math.PI/180,Gg=180/Math.PI,Hg="#",Vg="Konva error: ",Wg={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},jg=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let Xg=[],Yg=null;const qg="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)},Zg={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){Xg.push(t),1===Xg.length&&qg(function(){const t=Xg;Xg=[],t.forEach(function(t){t()})})},createCanvasElement(){zg();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(zg(),document.createElement("img")),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=Zg.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace(Hg,"");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return Hg+t},isCanvasFarblingActive(){if(null!==Yg)return Yg;if("undefined"==typeof document)return Yg=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return Yg=n,this.releaseCanvas(t),Yg},getHitColor(){const t=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(t):t},getHitColorKey(t,e,i){return this.isCanvasFarblingActive()&&(t=5*Math.round(t/5),e=5*Math.round(e/5),i=5*Math.round(i/5)),Hg+this._rgbToHex(t,e,i)},getSnappedHexColor(t){const e=this._hexToRgb(t);return Hg+this._rgbToHex(5*Math.round(e.r/5),5*Math.round(e.g/5),5*Math.round(e.b/5))},getRGB(t){let e;return t in Wg?(e=Wg[t],{r:e[0],g:e[1],b:e[2]}):t[0]===Hg?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=jg.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",Zg._namedColorToRBA(t)||Zg._hex3ColorToRGBA(t)||Zg._hex4ColorToRGBA(t)||Zg._hex6ColorToRGBA(t)||Zg._hex8ColorToRGBA(t)||Zg._rgbColorToRGBA(t)||Zg._rgbaColorToRGBA(t)||Zg._hslColorToRGBA(t)),_namedColorToRBA(t){const e=Wg[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,r=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===r)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+r):s+r-s*r;const l=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*Bg,radToDeg:t=>t*Gg,_degToRad:t=>(Zg.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Zg.degToRad(t)),_radToDeg:t=>(Zg.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Zg.radToDeg(t)),_getRotation:t=>Ug.angleDeg?Zg.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(Vg+t)},error(t){console.error(Vg+t)},warn(t){Ug.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,r,s){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(r-i)*(r-i)+(s-n)*(s-n);else{const c=((r-t)*(i-t)+(s-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=i,o=n,h=(i-r)*(i-r)+(n-s)*(n-s)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=Zg.cloneObject(t);let r=Number.MAX_VALUE;return e.forEach(function(s,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=Zg._getProjectionToSegment(s.x,s.y,o.x,o.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<r&&(n.x=l,n.y=c,r=d)}),n},_prepareArrayForTween(t,e,i){const n=[],r=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});const s=[];return r.forEach(function(t){const e=Zg._getProjectionToLine(t,n,i);s.push(e.x),s.push(e.y)}),s},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||Zg._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===Zg._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){Ug.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let r=e<0?e:0,s=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let a=0,o=0,h=0,l=0;"number"==typeof n?a=o=h=l=Math.min(n,e/2,i/2):(a=Math.min(n[0]||0,e/2,i/2),o=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r+a,s),t.lineTo(r+e-o,s),t.arc(r+e-o,s+o,o,3*Math.PI/2,0,!1),t.lineTo(r+e,s+i-l),t.arc(r+e-l,s+i-l,l,0,Math.PI/2,!1),t.lineTo(r+h,s+i),t.arc(r+h,s+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(r,s+a),t.arc(r+a,s+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,r){n=Math.abs(n);for(let s=0;s<i;s++){const a=e[(s-1+i)%i],o=e[s],h=e[(s+1)%i],l={x:o.x-a.x,y:o.y-a.y},c={x:h.x-o.x,y:h.y-o.y},d=Math.hypot(l.x,l.y),u=Math.hypot(c.x,c.y);let p;p="number"==typeof r?r:s<r.length?r[s]:0;p=n*Math.cos(Math.PI/i)*Math.min(1,p/n*2);const m={x:l.x/d,y:l.y/d},f={x:c.x/u,y:c.y/u},g={x:o.x-m.x*p,y:o.y-m.y*p},v={x:o.x+f.x*p,y:o.y+f.y*p};0===s?t.moveTo(g.x,g.y):t.lineTo(g.x,g.y),t.arcTo(o.x,o.y,v.x,v.y,p)}}};const Kg=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let Jg,Qg=null;function $g(){if(null!==Qg)return Qg;try{const t=Zg.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(Qg=!1,!1)}catch(t){return Qg=!1,!1}}class tv{constructor(t){this.canvas=t,Ug.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,r,s,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],r=n.method,r?(s=n.args,h+=r,t?h+="()":Zg._isArray(s[0])?h+="(["+s.join(",")+"])":(e&&(s=s.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+s.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,r,s){this._context.arc(t,e,i,n,r,s)}arcTo(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,r,s){this._context.bezierCurveTo(t,e,i,n,r,s)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,r,s){return this._context.createRadialGradient(t,e,i,n,r,s)}drawImage(t,e,i,n,r,s,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,r):9===l.length&&c.drawImage(t,e,i,n,r,s,a,o,h)}ellipse(t,e,i,n,r,s,a,o){this._context.ellipse(t,e,i,n,r,s,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,r){this._context.roundRect(t,e,i,n,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,r,s){this._context.setTransform(t,e,i,n,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,r,s){this._context.transform(t,e,i,n,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=Kg.length,r=this.setAttr;const s=function(t){let n,r=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=Zg;for(let r=0;r<i;r++){let i=t[r];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=r.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)s(Kg[t]);i.setAttr=function(){r.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(tv.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class ev extends tv{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)r.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}}class iv extends tv{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class nv{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||Ug.pixelRatio||function(){if(Jg)return Jg;const t=Zg.createCanvasElement(),e=t.getContext("2d");return Jg=(Ug._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),Zg.releaseCanvas(t),Jg}();this.pixelRatio=e,this._canvas=Zg.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return Zg.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class rv extends nv{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new ev(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class sv extends nv{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new iv(this),this.setSize(t.width,t.height)}}const av={get isDragging(){let t=!1;return av._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return av._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const e=[];av._dragElements.forEach((i,n)=>{const{node:r}=i,s=r.getStage();s.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=Zg._getFirstPointerId(t));const a=s._changedPointerPositions.find(t=>t.id===i.pointerId);if(a){if("dragging"!==i.dragStatus){const e=r.dragDistance();if(Math.max(Math.abs(a.x-i.startPointerPos.x),Math.abs(a.y-i.startPointerPos.y))<e)return;if(r.startDrag({evt:t}),!r.isDragging())return}r._setDragPosition(t,i),e.push(r)}}),e.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const e=[];av._dragElements.forEach(i=>{const{node:n}=i,r=n.getStage();t&&r.setPointersPositions(t);if(!r._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(av.justDragged=!0,Ug._mouseListenClick=!1,Ug._touchListenClick=!1,Ug._pointerListenClick=!1,i.dragStatus="stopped");const s=i.node.getLayer()||i.node instanceof Ug.Stage&&i.node;s&&-1===e.indexOf(s)&&e.push(s)}),e.forEach(t=>{t.draw()})},_endDragAfter(t){av._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&av._dragElements.delete(i)})}};function ov(t){return Zg._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||Zg._isBoolean(t)?t:Object.prototype.toString.call(t)}function hv(t){return t>255?255:t<0?0:Math.round(t)}function lv(){if(Ug.isUnminified)return function(t,e){return Zg._isNumber(t)||Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function cv(t){if(Ug.isUnminified)return function(e,i){let n=Zg._isNumber(e),r=Zg._isArray(e)&&e.length==t;return n||r||Zg.warn(ov(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function dv(){if(Ug.isUnminified)return function(t,e){return Zg._isNumber(t)||"auto"===t||Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function uv(){if(Ug.isUnminified)return function(t,e){return Zg._isString(t)||Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function pv(){if(Ug.isUnminified)return function(t,e){const i=Zg._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function mv(){if(Ug.isUnminified)return function(t,e){return!0===t||!1===t||Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}Ug.isBrowser&&(window.addEventListener("mouseup",av._endDragBefore,!0),window.addEventListener("touchend",av._endDragBefore,!0),window.addEventListener("touchcancel",av._endDragBefore,!0),window.addEventListener("mousemove",av._drag),window.addEventListener("touchmove",av._drag),window.addEventListener("mouseup",av._endDragAfter,!1),window.addEventListener("touchend",av._endDragAfter,!1),window.addEventListener("touchcancel",av._endDragAfter,!1));const fv="get",gv="set",vv={addGetterSetter(t,e,i,n,r){vv.addGetter(t,e,i),vv.addSetter(t,e,n,r),vv.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=fv+Zg._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const r=gv+Zg._capitalize(e);t.prototype[r]||vv.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const r=gv+Zg._capitalize(e);t.prototype[r]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,i,n,r){const s=i.length,a=Zg._capitalize,o=fv+a(e),h=gv+a(e);t.prototype[o]=function(){const t={};for(let n=0;n<s;n++){const r=i[n];t[r]=this.getAttr(e+a(r))}return t};const l=function(t){if(Ug.isUnminified)return function(e,i){return null==e||Zg.isObject(e)||Zg.warn(ov(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[h]=function(t){const s=this.attrs[e];n&&(t=n.call(this,t,e)),l&&l.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+a(i),t[i]);return t||i.forEach(t=>{this._setAttr(e+a(t),void 0)}),this._fireChangeEvent(e,s,t),r&&r.call(this),this},vv.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=Zg._capitalize(e),n=gv+i,r=fv+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(t,e,i,n){Zg.error("Adding deprecated "+e);const r=fv+Zg._capitalize(e),s=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[r]=function(){Zg.error(s);const t=this.attrs[e];return void 0===t?i:t},vv.addSetter(t,e,n,function(){Zg.error(s)}),vv.addOverloadedGetterSetter(t,e)},backCompat(t,e){Zg.each(e,function(e,i){const n=t.prototype[i],r=fv+Zg._capitalize(e),s=gv+Zg._capitalize(e);function a(){n.apply(this,arguments),Zg.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[r]=a,t.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function yv(t){const e=/(\w+)\(([^)]+)\)/g;let i;for(;null!==(i=e.exec(t));){const[,t,e]=i;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const i=Ug.Filters;i&&i.Blur&&i.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const i=Ug.Filters;i&&i.Brightness&&i.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const i=100*(Math.sqrt(t)-1);this.contrast(i);const n=Ug.Filters;n&&n.Contrast&&n.Contrast.call(this,e)}}case"grayscale":return function(t){const e=Ug.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=Ug.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=Ug.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:Zg.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const _v="absoluteOpacity",xv="allEventListeners",wv="absoluteTransform",bv="absoluteScale",Sv="canvas",Mv="listening",Ev="Shape",Tv=" ",Av="stage",Cv="transform",Rv="visible",Pv=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Tv);let Lv=1;class Iv{constructor(t){this._id=Lv++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==Cv&&t!==wv||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===Cv||t===wv)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(Tv);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(Sv)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===wv&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Sv)){const{scene:t,filter:e,hit:i,buffer:n}=this._cache.get(Sv);Zg.releaseCanvas(t,e,i,n),this._cache.delete(Sv)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),r=Math.ceil(e.height||i.height),s=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!r)return void Zg.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),r+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const d=new rv({pixelRatio:s,width:n,height:r}),u=new rv({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=new sv({pixelRatio:c,width:n,height:r}),m=d.getContext(),f=p.getContext(),g=new rv({width:d.width/d.pixelRatio+Math.abs(a),height:d.height/d.pixelRatio+Math.abs(o),pixelRatio:d.pixelRatio}),v=g.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(Sv),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),m.save(),f.save(),v.save(),m.translate(-a,-o),f.translate(-a,-o),v.translate(-a,-o),g.x=a,g.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(_v),this._clearSelfAndDescendantCache(bv),this.drawScene(d,this,g),this.drawHit(p,this),this._isUnderCache=!1,m.restore(),f.restore(),l&&(m.save(),m.beginPath(),m.rect(0,0,n,r),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),this._cache.set(Sv,{scene:d,filter:u,hit:p,buffer:g,x:a,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(Sv)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);void 0===n&&(n=s=e.x,r=a=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)}),{x:n,y:r,width:s-n,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,r=this.filters(),s=this._getCanvasCache(),a=s.scene,o=s.filter,h=o.getContext();if(!r||0===r.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<r.length;t++)if("string"==typeof r[t]&&$g(),"string"!=typeof r[t]||!$g()){l=!1;break}const c=a.pixelRatio;if(o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),l){const t=r.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),h.restore(),this._filterUpToDate=!0,o}try{for(t=r.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=r[i],"string"==typeof n&&(n=yv(n)),n.call(this,e),h.putImageData(e,0,0)}catch(t){Zg.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(t,e){if(this._cache&&this._cache.delete(xv),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(Tv);for(let t=0;t<i.length;t++){const n=i[t].split("."),r=n[0],s=n[1]||"";this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:s,handler:e})}return this}off(t,e){let i,n,r,s,a,o,h=(t||"").split(Tv),l=h.length;if(this._cache&&this._cache.delete(xv),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(r=h[i],s=r.split("."),a=s[0],o=s[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;this.on(t,function(t){const r=t.target.findAncestors(e,!0,n);for(let e=0;e<r.length;e++)(t=Zg.cloneObject(t)).currentTarget=r[e],i.call(r[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),av._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(wv),this._clearSelfAndDescendantCache(_v),this._clearSelfAndDescendantCache(bv),this._clearSelfAndDescendantCache(Av),this._clearSelfAndDescendantCache(Rv),this._clearSelfAndDescendantCache(Mv)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+Zg._capitalize(t);return Zg._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Zg._capitalize(e),Zg._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(Mv,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(Rv,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;av._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)});const r=!e&&!Ug.hitOnDragEnabled&&(n||Ug.isTransforming());return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==Ev&&(t=t.concat(n.getChildren().slice())),n._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Cv),this._clearSelfAndDescendantCache(wv)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),r=new kg,s=this.offset();return r.m=n.slice(),r.translate(s.x,s.y),r.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(Cv);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(Cv),this._clearSelfAndDescendantCache(wv),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}_eachAncestorReverse(t,e){let i,n,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Zg.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Zg.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Zg.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Zg.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Zg.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Zg.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(_v,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,r,s=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in s)e=s[t],r=Zg.isObject(e)&&!Zg._isPlainObject(e)&&!Zg._isArray(e),r||(i="function"==typeof this[t]&&this[t],delete s[t],n=i?i.call(this):null,s[t]=e,n!==e&&(a.attrs[t]=e));return Zg._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let r=this.parent;for(;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),r=n.length;for(e=0;e<r;e++)if(i=n[e],Zg.isValidSelector(i)||(Zg.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Zg.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Zg.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Av,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(wv,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new kg,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(wv)||new kg,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,r=this.attrs.offsetY||0;e.translate(t-n,i-r)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Cv,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(Cv)||new kg;i.reset();const n=this.x(),r=this.y(),s=Ug.getAngle(this.rotation()),a=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===r||i.translate(n,r),0!==s&&i.rotate(s),0===h&&0===l||i.skew(h,l),1===a&&1===o||i.scale(a,o),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){let e,i,n,r,s,a=Zg.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,r=0;r<n;r++)s=i[r],s.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(s));return o}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),r=void 0!==t.y?t.y:Math.floor(e.y),s=t.pixelRatio||1,a=new rv({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:s}),o=a.getContext(),h=new rv({width:a.width/a.pixelRatio+Math.abs(n),height:a.height/a.pixelRatio+Math.abs(r),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||r)&&o.translate(-1*n,-1*r),this.drawScene(a,void 0,h),o.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Zg._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Ug.dragDistance}_off(t,e,i){let n,r,s,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(r=a[n].name,s=a[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==s)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+Zg._capitalize(t)];return Zg._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Ug.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||Zg.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===Ev&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const r=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const r=null!==(e=this._cache.get(xv))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(xv,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const r=i._getPointerById(e)||i._changedPointerPositions[0]||n;av._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-n.x,y:r.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){av._dragElements.has(this._id)||this._createDragElement(t);av._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const r=this.dragBoundFunc();if(void 0!==r){const e=r.call(this,n,t);e?n=e:Zg.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=av._dragElements.get(this._id);e&&(e.dragStatus="stopped"),av._endDragBefore(t),av._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=av._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||Ug.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;av._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=av._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&av._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Zg.haveIntersection(i,this.getClientRect())}static create(t,e){return Zg._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let i,n,r,s=Iv.prototype.getClassName.call(t),a=t.children;e&&(t.attrs.container=e),Ug[s]||(Zg.warn('Can not find a node with class name "'+s+'". Fallback to "Shape".'),s="Shape");if(i=new(0,Ug[s])(t.attrs),a)for(n=a.length,r=0;r<n;r++)i.add(Iv._createNode(a[r]));return i}}Iv.prototype.nodeType="Node",Iv.prototype._attrsAffectingSize=[],Iv.prototype.eventListeners={},Iv.prototype.on.call(Iv.prototype,Pv,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Cv),this._clearSelfAndDescendantCache(wv))}),Iv.prototype.on.call(Iv.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(Rv)}),Iv.prototype.on.call(Iv.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(Mv)}),Iv.prototype.on.call(Iv.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(_v)});const Dv=vv.addGetterSetter;Dv(Iv,"zIndex"),Dv(Iv,"absolutePosition"),Dv(Iv,"position"),Dv(Iv,"x",0,lv()),Dv(Iv,"y",0,lv()),Dv(Iv,"globalCompositeOperation","source-over",uv()),Dv(Iv,"opacity",1,lv()),Dv(Iv,"name","",uv()),Dv(Iv,"id","",uv()),Dv(Iv,"rotation",0,lv()),vv.addComponentsGetterSetter(Iv,"scale",["x","y"]),Dv(Iv,"scaleX",1,lv()),Dv(Iv,"scaleY",1,lv()),vv.addComponentsGetterSetter(Iv,"skew",["x","y"]),Dv(Iv,"skewX",0,lv()),Dv(Iv,"skewY",0,lv()),vv.addComponentsGetterSetter(Iv,"offset",["x","y"]),Dv(Iv,"offsetX",0,lv()),Dv(Iv,"offsetY",0,lv()),Dv(Iv,"dragDistance",void 0,lv()),Dv(Iv,"width",0,lv()),Dv(Iv,"height",0,lv()),Dv(Iv,"listening",!0,mv()),Dv(Iv,"preventDefault",!0,mv()),Dv(Iv,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),Dv(Iv,"visible",!0,mv()),Dv(Iv,"transformsEnabled","all",uv()),Dv(Iv,"size"),Dv(Iv,"dragBoundFunc"),Dv(Iv,"draggable",!1,mv()),vv.backCompat(Iv,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Ov extends Iv{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const r=n._isMatch(t);return r&&i.push(n),!(!r||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=Iv.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=Iv.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){s.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),s.beginPath(),h)e=h.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),n=t.copy().invert().getMatrix(),s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach(function(r){r[t](e,i,n)}),d&&s.restore(),l&&s.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let r,s,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,s=i.y,a=i.x+i.width,o=i.y+i.height):(r=Math.min(r,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))});const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}vv.addComponentsGetterSetter(Ov,"clip",["x","y","width","height"]),vv.addGetterSetter(Ov,"clipX",void 0,lv()),vv.addGetterSetter(Ov,"clipY",void 0,lv()),vv.addGetterSetter(Ov,"clipWidth",void 0,lv()),vv.addGetterSetter(Ov,"clipHeight",void 0,lv()),vv.addGetterSetter(Ov,"clipFunc");const Nv=new Map,Uv=void 0!==Ug._global.PointerEvent;function Fv(t){return Nv.get(t)}function zv(t){return{evt:t,pointerId:t.pointerId}}function kv(t,e){return Nv.get(t)===e}function Bv(t,e){Gv(t);e.getStage()&&(Nv.set(t,e),Uv&&e._fire("gotpointercapture",zv(new PointerEvent("gotpointercapture"))))}function Gv(t,e){const i=Nv.get(t);if(!i)return;const n=i.getStage();n&&n.content,Nv.delete(t),Uv&&i._fire("lostpointercapture",zv(new PointerEvent("lostpointercapture")))}const Hv="mouseleave",Vv="mouseover",Wv="mouseenter",jv="mousemove",Xv="mousedown",Yv="mouseup",qv="pointermove",Zv="pointerdown",Kv="pointerup",Jv="pointercancel",Qv="pointerout",$v="pointerleave",ty="pointerover",ey="pointerenter",iy="contextmenu",ny="touchstart",ry="touchend",sy="touchmove",ay="touchcancel",oy="wheel",hy=[[Wv,"_pointerenter"],[Xv,"_pointerdown"],[jv,"_pointermove"],[Yv,"_pointerup"],[Hv,"_pointerleave"],[ny,"_pointerdown"],[sy,"_pointermove"],[ry,"_pointerup"],[ay,"_pointercancel"],[Vv,"_pointerover"],[oy,"_wheel"],[iy,"_contextmenu"],[Zv,"_pointerdown"],[qv,"_pointermove"],[Kv,"_pointerup"],[Jv,"_pointercancel"],[$v,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],ly={mouse:{[Qv]:"mouseout",[$v]:Hv,[ty]:Vv,[ey]:Wv,[qv]:jv,[Zv]:Xv,[Kv]:Yv,[Jv]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Qv]:"touchout",[$v]:"touchleave",[ty]:"touchover",[ey]:"touchenter",[qv]:sy,[Zv]:ny,[Kv]:ry,[Jv]:ay,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Qv]:Qv,[$v]:$v,[ty]:ty,[ey]:ey,[qv]:qv,[Zv]:Zv,[Kv]:Kv,[Jv]:Jv,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},cy=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",dy=t=>{const e=cy(t);return"pointer"===e?Ug.pointerEventsEnabled&&ly.pointer:"touch"===e?ly.touch:"mouse"===e?ly.mouse:void 0};function uy(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&Zg.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const py=[];class my extends Ov{constructor(t){super(uy(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),py.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{uy(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||Zg.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),Ov.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&Zg._isInDocument(t)&&this.container().removeChild(t);const e=py.indexOf(this);return e>-1&&py.splice(e,1),Zg.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(Zg.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new rv({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const i=this.children.length;return i>5&&Zg.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),Ug.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return kv(t,this)}setPointerCapture(t){Bv(t,this)}releaseCapture(t){Gv(t)}getLayers(){return this.children}_bindContentEvents(){Ug.isBrowser&&hy.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=dy(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=dy(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=dy(t.type),i=cy(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),r=!(Ug.isDragging()||Ug.isTransforming())||Ug.hitOnDragEnabled;n&&r?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=dy(t.type),i=cy(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach(r=>{const s=this.getIntersection(r);if(av.justDragged=!1,Ug["_"+i+"ListenClick"]=!0,!s||!s.isListening())return void(this[i+"ClickStartShape"]=void 0);Ug.capturePointerEventsEnabled&&s.setPointerCapture(r.id),this[i+"ClickStartShape"]=s,s._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),n=!0;const a=t.type.indexOf("touch")>=0;s.preventDefault()&&t.cancelable&&a&&t.preventDefault()}),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=dy(t.type),i=cy(t.type);if(!e)return;const n=t.type.indexOf("touch")>=0||"touch"===t.pointerType;Ug.isDragging()&&av.node.preventDefault()&&t.cancelable&&n&&t.preventDefault(),this.setPointersPositions(t);if(!(!(Ug.isDragging()||Ug.isTransforming())||Ug.hitOnDragEnabled))return;const r={};let s=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(n=>{const o=Fv(n.id)||this.getIntersection(n),h=n.id,l={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...l},o),a._fireAndBubble(e.pointerleave,{...l},o)),o){if(r[o._id])return;r[o._id]=!0}o&&o.isListening()?(s=!0,c&&(o._fireAndBubble(e.pointerover,{...l},a),o._fireAndBubble(e.pointerenter,{...l},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=dy(t.type),i=cy(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],r=this[i+"ClickEndShape"],s={};let a=!1;this._changedPointerPositions.forEach(o=>{const h=Fv(o.id)||this.getIntersection(o);if(h){if(h.releaseCapture(o.id),s[h._id])return;s[h._id]=!0}const l=o.id,c={evt:t,pointerId:l};let d=!1;Ug["_"+i+"InDblClickWindow"]?(d=!0,clearTimeout(this[i+"DblTimeout"])):av.justDragged||(Ug["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){Ug["_"+i+"InDblClickWindow"]=!1},Ug.dblClickWindow),h&&h.isListening()?(a=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...c}),Ug["_"+i+"ListenClick"]&&n&&n===h&&(h._fireAndBubble(e.pointerclick,{...c}),d&&r&&r===h&&h._fireAndBubble(e.pointerdblclick,{...c}))):(this[i+"ClickEndShape"]=null,a||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a=!0),Ug["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:l}),d&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:l}))}),a||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Ug["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(iy,{evt:t}):this._fire(iy,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(oy,{evt:t}):this._fire(oy,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=Fv(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(Kv,zv(t)),Gv(t.pointerId)}_lostpointercapture(t){Gv(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:Zg._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:Zg._getFirstPointerId(t)}])}_setPointerPosition(t){Zg.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new rv({width:this.width(),height:this.height()}),this.bufferHitCanvas=new sv({pixelRatio:1,width:this.width(),height:this.height()}),!Ug.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return Zg.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}my.prototype.nodeType="Stage",Fg(my),vv.addGetterSetter(my,"container"),Ug.isBrowser&&document.addEventListener("visibilitychange",()=>{py.forEach(t=>{t.batchDraw()})});const fy="hasShadow",gy="shadowRGBA",vy="patternImage",yy="linearGradient",_y="radialGradient";let xy;function wy(){return xy||(xy=Zg.createCanvasElement().getContext("2d"),xy)}const by={};class Sy extends Iv{constructor(t){let e;super(t);let i=0;for(;e=Zg.getHitColor(),!e||e in by;)if(i++,i>=1e4){Zg.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=Zg.getRandomColor();break}this.colorKey=e,by[e]=this}getContext(){return Zg.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Zg.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(fy,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(vy,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=wy().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new kg;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(Ug.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(yy,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=wy(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(_y,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=wy(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(gy,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=Zg.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return Iv.prototype.destroy.call(this),delete by[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&s&&a)}setStrokeHitEnabled(t){Zg.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+s.x,y:-(a/2+m)+Math.min(d,0)+s.y};return n?f:this._transformedRect(f,r)}drawScene(t,e,i){const n=this.getLayer(),r=(t||n.getCanvas()).getContext(),s=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(s){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore(),this}if(!a)return this;if(r.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();n.clear(),n.save(),n._applyLineJoin(this),n._applyMiterLimit(this);const s=this.getAbsoluteTransform(e).getMatrix();n.transform(s[0],s[1],s[2],s[3],s[4],s[5]),a.call(this,n,this),n.restore();const c=t.pixelRatio;o&&r._applyShadow(this),l||(r._applyOpacity(this),r._applyGlobalCompositeOperation(this)),r.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(r._applyLineJoin(this),r._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r._applyOpacity(this),r._applyGlobalCompositeOperation(this)}o&&r._applyShadow(this),a.call(this,r,this)}return r.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),r=t||n.hitCanvas,s=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCanvasCache(),h=o&&o.hit;if(this.colorKey||Zg.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore(),this}if(!a)return this;s.save(),s._applyLineJoin(this),s._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,s,this),s.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,r=n.getContext(),s=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(i._canvas,0,0,s,a);try{const e=r.getImageData(0,0,s,a),i=e.data,n=i.length,o=Zg._hexToRgb(this.colorKey);for(let e=0;e<n;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}r.putImageData(e,0,0)}catch(t){Zg.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return kv(t,this)}setPointerCapture(t){Bv(t,this)}releaseCapture(t){Gv(t)}}Sy.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Sy.prototype._strokeFunc=function(t){t.stroke()},Sy.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Sy.prototype._strokeFuncHit=function(t){t.stroke()},Sy.prototype._centroid=!1,Sy.prototype.nodeType="Shape",Fg(Sy),Sy.prototype.eventListeners={},Sy.prototype.on.call(Sy.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(fy)}),Sy.prototype.on.call(Sy.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(gy)}),Sy.prototype.on.call(Sy.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(vy)}),Sy.prototype.on.call(Sy.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(yy)}),Sy.prototype.on.call(Sy.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(_y)}),vv.addGetterSetter(Sy,"stroke",void 0,pv()),vv.addGetterSetter(Sy,"strokeWidth",2,lv()),vv.addGetterSetter(Sy,"fillAfterStrokeEnabled",!1),vv.addGetterSetter(Sy,"hitStrokeWidth","auto",dv()),vv.addGetterSetter(Sy,"strokeHitEnabled",!0,mv()),vv.addGetterSetter(Sy,"perfectDrawEnabled",!0,mv()),vv.addGetterSetter(Sy,"shadowForStrokeEnabled",!0,mv()),vv.addGetterSetter(Sy,"lineJoin"),vv.addGetterSetter(Sy,"lineCap"),vv.addGetterSetter(Sy,"miterLimit"),vv.addGetterSetter(Sy,"sceneFunc"),vv.addGetterSetter(Sy,"hitFunc"),vv.addGetterSetter(Sy,"dash"),vv.addGetterSetter(Sy,"dashOffset",0,lv()),vv.addGetterSetter(Sy,"shadowColor",void 0,uv()),vv.addGetterSetter(Sy,"shadowBlur",0,lv()),vv.addGetterSetter(Sy,"shadowOpacity",1,lv()),vv.addComponentsGetterSetter(Sy,"shadowOffset",["x","y"]),vv.addGetterSetter(Sy,"shadowOffsetX",0,lv()),vv.addGetterSetter(Sy,"shadowOffsetY",0,lv()),vv.addGetterSetter(Sy,"fillPatternImage"),vv.addGetterSetter(Sy,"fill",void 0,pv()),vv.addGetterSetter(Sy,"fillPatternX",0,lv()),vv.addGetterSetter(Sy,"fillPatternY",0,lv()),vv.addGetterSetter(Sy,"fillLinearGradientColorStops"),vv.addGetterSetter(Sy,"strokeLinearGradientColorStops"),vv.addGetterSetter(Sy,"fillRadialGradientStartRadius",0),vv.addGetterSetter(Sy,"fillRadialGradientEndRadius",0),vv.addGetterSetter(Sy,"fillRadialGradientColorStops"),vv.addGetterSetter(Sy,"fillPatternRepeat","repeat"),vv.addGetterSetter(Sy,"fillEnabled",!0),vv.addGetterSetter(Sy,"strokeEnabled",!0),vv.addGetterSetter(Sy,"shadowEnabled",!0),vv.addGetterSetter(Sy,"dashEnabled",!0),vv.addGetterSetter(Sy,"strokeScaleEnabled",!0),vv.addGetterSetter(Sy,"fillPriority","color"),vv.addComponentsGetterSetter(Sy,"fillPatternOffset",["x","y"]),vv.addGetterSetter(Sy,"fillPatternOffsetX",0,lv()),vv.addGetterSetter(Sy,"fillPatternOffsetY",0,lv()),vv.addComponentsGetterSetter(Sy,"fillPatternScale",["x","y"]),vv.addGetterSetter(Sy,"fillPatternScaleX",1,lv()),vv.addGetterSetter(Sy,"fillPatternScaleY",1,lv()),vv.addComponentsGetterSetter(Sy,"fillLinearGradientStartPoint",["x","y"]),vv.addComponentsGetterSetter(Sy,"strokeLinearGradientStartPoint",["x","y"]),vv.addGetterSetter(Sy,"fillLinearGradientStartPointX",0),vv.addGetterSetter(Sy,"strokeLinearGradientStartPointX",0),vv.addGetterSetter(Sy,"fillLinearGradientStartPointY",0),vv.addGetterSetter(Sy,"strokeLinearGradientStartPointY",0),vv.addComponentsGetterSetter(Sy,"fillLinearGradientEndPoint",["x","y"]),vv.addComponentsGetterSetter(Sy,"strokeLinearGradientEndPoint",["x","y"]),vv.addGetterSetter(Sy,"fillLinearGradientEndPointX",0),vv.addGetterSetter(Sy,"strokeLinearGradientEndPointX",0),vv.addGetterSetter(Sy,"fillLinearGradientEndPointY",0),vv.addGetterSetter(Sy,"strokeLinearGradientEndPointY",0),vv.addComponentsGetterSetter(Sy,"fillRadialGradientStartPoint",["x","y"]),vv.addGetterSetter(Sy,"fillRadialGradientStartPointX",0),vv.addGetterSetter(Sy,"fillRadialGradientStartPointY",0),vv.addComponentsGetterSetter(Sy,"fillRadialGradientEndPoint",["x","y"]),vv.addGetterSetter(Sy,"fillRadialGradientEndPointX",0),vv.addGetterSetter(Sy,"fillRadialGradientEndPointY",0),vv.addGetterSetter(Sy,"fillPatternRotation",0),vv.addGetterSetter(Sy,"fillRule",void 0,uv()),vv.backCompat(Sy,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const My=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Ey=My.length;class Ty extends Ov{constructor(t){super(t),this.canvas=new rv,this.hitCanvas=new sv({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Iv.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Iv.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Iv.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Iv.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return Iv.prototype.remove.call(this),t&&t.parentNode&&Zg._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Zg.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),Iv.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Zg.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Zg.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Zg.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<Ey;n++){const r=My[n],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(i=!!s.antialiased,!s.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=Zg.getHitColorKey(i[0],i[1],i[2]),e=by[t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Ov.prototype.drawScene.call(this,r,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),Ov.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){Zg.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return Zg.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return Zg.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Ty.prototype.nodeType="Layer",Fg(Ty),vv.addGetterSetter(Ty,"imageSmoothingEnabled",!0),vv.addGetterSetter(Ty,"clearBeforeDraw",!0),vv.addGetterSetter(Ty,"hitGraphEnabled",!0,mv());class Ay extends Ty{constructor(t){super(t),this.listening(!1),Zg.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Ay.prototype.nodeType="FastLayer",Fg(Ay);class Cy extends Ov{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Zg.throw("You may only add groups and shapes to groups.")}}Cy.prototype.nodeType="Group",Fg(Cy);const Ry=Ng.performance&&Ng.performance.now?function(){return Ng.performance.now()}:function(){return(new Date).getTime()};class Py{constructor(t,e){this.id=Py.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ry(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Py.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Ry(),Py._addAnimation(this),this}stop(){return Py._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],r=n.layers,s=n.func;n._updateFrameObject(Ry());const a=r.length;let o;if(o=!s||!1!==s.call(n,n.frame),o)for(let e=0;e<a;e++){const i=r[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=Py;t.animations.length?(t._runFrames(),Zg.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Zg.requestAnimFrame(this._animationLoop))}}Py.animations=[],Py.animIdCounter=0,Py.animRunning=!1;const Ly={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Iy=["fill","stroke","shadowColor"];let Dy=0;class Oy{constructor(t,e,i,n,r,s,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Ny{constructor(t){const e=this,i=t.node,n=i._id,r=t.easing||Uy.Linear,s=!!t.yoyo;let a,o;a=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=i,this._id=Dy++;const h=i.getLayer()||(i instanceof Ug.Stage?i.getLayers():null);for(o in h||Zg.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Py(function(){e.tween.onEnterFrame()},h),this.tween=new Oy(o,function(t){e._tweenFunc(t)},r,0,1,1e3*a,s),this._addListeners(),Ny.attrs[n]||(Ny.attrs[n]={}),Ny.attrs[n][this._id]||(Ny.attrs[n][this._id]={}),Ny.tweens[n]||(Ny.tweens[n]={}),t)void 0===Ly[o]&&this._addAttr(o,t[o]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let r,s,a,o,h;const l=Ny.tweens[n][t];l&&delete Ny.attrs[n][l][t];let c=i.getAttr(t);if(Zg._isArray(e))if(r=[],s=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(o=c,c=Zg._prepareArrayForTween(c,e,i.closed())):(a=e,e=Zg._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<s;t++)if(t%2==0)r.push(e[t]-c[t]);else{const i=Zg.colorToRGBA(c[t]);h=Zg.colorToRGBA(e[t]),c[t]=i,r.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<s;t++)r.push(e[t]-c[t]);else-1!==Iy.indexOf(t)?(c=Zg.colorToRGBA(c),h=Zg.colorToRGBA(e),r={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):r=e-c;Ny.attrs[n][this._id][t]={start:c,diff:r,end:e,trueEnd:a,trueStart:o},Ny.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=Ny.attrs[e._id][this._id];let n,r,s,a,o,h,l,c;for(n in i){if(r=i[n],s=r.start,a=r.diff,c=r.end,Zg._isArray(s))if(o=[],l=Math.max(s.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((s[h]||0)+a[h]*t):o.push("rgba("+Math.round(s[h].r+a[h].r*t)+","+Math.round(s[h].g+a[h].g*t)+","+Math.round(s[h].b+a[h].b*t)+","+(s[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((s[h]||0)+a[h]*t);else o=-1!==Iy.indexOf(n)?"rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":s+a*t;e.setAttr(n,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=Ny.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=Ny.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=Ny.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete Ny.tweens[t][e];delete Ny.attrs[t][e],Ny.tweens[t]&&(0===Object.keys(Ny.tweens[t]).length&&delete Ny.tweens[t],0===Object.keys(Ny.attrs[t]).length&&delete Ny.attrs[t])}}Ny.attrs={},Ny.tweens={},Iv.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new Ny(t).play()};const Uy={BackEaseIn(t,e,i,n){const r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,n){const r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,n){let r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,n,r,s){let a=0;return 0===t?e:1===(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,i,n,r,s){let a=0;return 0===t?e:1===(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/s)+i+e)},ElasticEaseInOut(t,e,i,n,r,s){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(s||(s=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-Uy.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*Uy.BounceEaseIn(2*t,0,i,n)+e:.5*Uy.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},Fy=Zg._assign(Ug,{Util:Zg,Transform:kg,Node:Iv,Container:Ov,Stage:my,stages:py,Layer:Ty,FastLayer:Ay,Group:Cy,DD:av,Shape:Sy,shapes:by,Animation:Py,Tween:Ny,Easings:Uy,Context:tv,Canvas:nv});class zy extends Sy{_sceneFunc(t){const e=Ug.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=Ug.getAngle(i?360-this.angle():this.angle()),r=Math.cos(Math.min(n,Math.PI)),s=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),a=Math.sin(Math.min(n,Math.PI/2)),o=r*(r>0?t:e),h=s*(s>0?t:e),l=a*(a>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}function ky(t,e,i,n,r,s,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(s-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(r-t),n-l*(s-e),i+c*(r-t),n+c*(s-e)]}function By(t,e){const i=t.length,n=[];for(let r=2;r<i-2;r+=2){const i=ky(t[r-2],t[r-1],t[r],t[r+1],t[r+2],t[r+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[r]),n.push(t[r+1]),n.push(i[2]),n.push(i[3]))}return n}zy.prototype._centroid=!0,zy.prototype.className="Arc",zy.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Fg(zy),vv.addGetterSetter(zy,"innerRadius",0,lv()),vv.addGetterSetter(zy,"outerRadius",0,lv()),vv.addGetterSetter(zy,"angle",0,lv()),vv.addGetterSetter(zy,"clockwise",!1,mv());class Gy extends Sy{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,n=this.tension(),r=this.closed(),s=this.bezier();if(!i)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==n&&i>4){const n=this.getTensionPoints(),s=n.length;for(a=r?0:4,r||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);a<s-2;)t.bezierCurveTo(n[a++],n[a++],n[a++],n[a++],n[a++],n[a++]);r||t.quadraticCurveTo(n[s-2],n[s-1],e[i-2],e[i-1])}else if(s)for(a=2;a<i;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<i;a+=2)t.lineTo(e[a],e[a+1]);r?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():By(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=ky(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),r=ky(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),s=By(t,i);return[n[2],n[3]].concat(s).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);return{x:n,y:s,width:r-n,height:a-s}}}Gy.prototype.className="Line",Gy.prototype._attrsAffectingSize=["points","bezier","tension"],Fg(Gy),vv.addGetterSetter(Gy,"closed",!1),vv.addGetterSetter(Gy,"bezier",!1),vv.addGetterSetter(Gy,"tension",0,lv()),vv.addGetterSetter(Gy,"points",[],function(){if(Ug.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(Zg._isArray(t)?t.forEach(function(t){Zg._isNumber(t)||Zg.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Zg.warn(ov(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const Hy=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Vy=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],Wy=[[1],[1,1],[1,2,1],[1,3,3,1]],jy=(t,e,i)=>{let n,r;const s=i/2;n=0;for(let i=0;i<20;i++)r=s*Hy[20][i]+s,n+=Vy[20][i]*Yy(t,e,r);return s*n},Xy=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+r*r),h=4*(n*s+r*a),l=s*s+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};function Yy(t,e,i){const n=qy(1,i,t),r=qy(1,i,e),s=n*n+r*r;return Math.sqrt(s)}const qy=(t,e,i)=>{const n=i.length-1;let r,s;if(0===n)return 0;if(0===t){s=0;for(let t=0;t<=n;t++)s+=Wy[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return s}r=new Array(n);for(let t=0;t<n;t++)r[t]=n*(i[t+1]-i[t]);return qy(t-1,e,r)},Zy=(t,e,i)=>{let n=1,r=t/e,s=(t-i(r))/e,a=0;for(;n>.001;){const o=i(r+s),h=Math.abs(t-o)/e;if(h<n)n=h,r+=s;else{const a=i(r-s),o=Math.abs(t-a)/e;o<n?(n=o,r-=s):s/=2}if(a++,a>500)break}return r};class Ky extends Sy{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Ky.parsePathData(this.data()),this.pathLength=Ky.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const r=e[n].command,s=e[n].points;switch(r){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const e=s[0],n=s[1],r=s[2],a=s[3],o=s[4],h=s[5],l=s[6],c=s[7],d=r>a?r:a,u=r>a?1:r/a,p=r>a?a/r:1;t.translate(e,n),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],r=e.points[4]+n;let s=Math.PI/180;if(Math.abs(i-r)<s&&(s=Math.abs(i-r)),n<0)for(let n=i-s;n>r;n-=s){const i=Ky.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+s;n<r;n+=s){const i=Ky.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=Ky.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)});let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),r=Math.max(r,e)),isNaN(i)||(s=Math.min(s,i),a=Math.max(a,i));return{x:n,y:s,width:r-n,height:a-s}}getLength(){return this.pathLength}getPointAtLength(t){return Ky.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,r=e.length;if(!r)return null;for(;n<r&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===r)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const s=e[n],a=s.points;switch(s.command){case"L":return Ky.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Ky.getPointOnCubicBezier(Zy(t,Ky.getPathLength(e),t=>jy([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],t)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Ky.getPointOnQuadraticBezier(Zy(t,Ky.getPathLength(e),t=>Xy([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],t)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],r=a[2],o=a[3],h=a[5],l=a[6];let c=a[4];return c+=h*t/s.pathLength,Ky.getPointOnEllipticalArc(i,n,r,o,c,l)}return null}static getPointOnLine(t,e,i,n,r,s,a){s=null!=s?s:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,r);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:s,y:a+(r>i?t:-t)};const h=(r-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(s-e))<1e-10)return{x:s+l,y:a+c};const d=((s-e)*(n-e)+(a-i)*(r-i))/(o*o),u=e+d*(n-e),p=i+d*(r-i),m=this.getLineLength(s,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,r,s,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+s*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+r*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,r,s,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:s*o(t)+n*h(t)+e*l(t),y:a*o(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,r,s){const a=Math.cos(s),o=Math.sin(s),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),r=[],s=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),s.length=0;l=h.exec(e);)s.push(l[0]);let c=[],d="A"===i||"a"===i?0:-1;for(let t=0,e=s.length;t<e;t++){const e=s[t];if("00"!==e)if(d>=0){if(3===d){if(/^[01]{2}\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),c.push(parseFloat(e.slice(2))),d+=3,d>=7&&(d-=7);continue}if("11"===e||"10"===e||"01"===e){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}else if(4===d){if(/^[01]\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseFloat(e.slice(1))),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t),d+=1,d>=7&&(d-=7)}else{const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t)}else c.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7))}for(;c.length>0&&!isNaN(c[0]);){let t="",e=[];const n=a,s=o;let h,l,d,u,p,m,f,g,v,y;switch(i){case"l":a+=c.shift(),o+=c.shift(),t="L",e.push(a,o);break;case"L":a=c.shift(),o=c.shift(),e.push(a,o);break;case"m":const n=c.shift(),s=c.shift();if(a+=n,o+=s,t="M",r.length>2&&"z"===r[r.length-1].command)for(let t=r.length-2;t>=0;t--)if("M"===r[t].command){a=r[t].points[0]+n,o=r[t].points[1]+s;break}e.push(a,o),i="l";break;case"M":a=c.shift(),o=c.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=c.shift(),t="L",e.push(a,o);break;case"H":a=c.shift(),t="L",e.push(a,o);break;case"v":o+=c.shift(),t="L",e.push(a,o);break;case"V":o=c.shift(),t="L",e.push(a,o);break;case"C":e.push(c.shift(),c.shift(),c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"c":e.push(a+c.shift(),o+c.shift(),a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"S":l=a,d=o,h=r[r.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,c.shift(),c.shift()),a=c.shift(),o=c.shift(),t="C",e.push(a,o);break;case"s":l=a,d=o,h=r[r.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"Q":e.push(c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"q":e.push(a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="Q",e.push(a,o);break;case"T":l=a,d=o,h=r[r.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a=c.shift(),o=c.shift(),t="Q",e.push(l,d,a,o);break;case"t":l=a,d=o,h=r[r.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a+=c.shift(),o+=c.shift(),t="Q",e.push(l,d,a,o);break;case"A":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,y=o,a=c.shift(),o=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,y,a,o,f,g,u,p,m);break;case"a":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,y=o,a+=c.shift(),o+=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,y,a,o,f,g,u,p,m)}r.push({command:t||i,points:e,start:{x:n,y:s},pathLength:this.calcLength(n,s,t||i,e)})}"z"!==i&&"Z"!==i||r.push({command:"z",points:[],start:void 0,pathLength:0})}return r}static calcLength(t,e,i,n){let r,s,a,o;const h=Ky;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return jy([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return Xy([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":r=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),s=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-d;o>c;o-=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(o=i+d;o<c;o+=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),r+=h.getLineLength(s.x,s.y,a.x,a.y),r}return 0}static convertEndpointToCenterParameterization(t,e,i,n,r,s,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));r===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},w=x([1,0],[(c-m)/a,(d-f)/o]),b=[(c-m)/a,(d-f)/o],S=[(-1*c-m)/a,(-1*d-f)/o];let M=x(b,S);return _(b,S)<=-1&&(M=Math.PI),_(b,S)>=1&&(M=0),0===s&&M>0&&(M-=2*Math.PI),1===s&&M<0&&(M+=2*Math.PI),[g,v,a,o,w,M,l,s]}}Ky.prototype.className="Path",Ky.prototype._attrsAffectingSize=["data"],Fg(Ky),vv.addGetterSetter(Ky,"data");class Jy extends Gy{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const r=0!==this.tension()&&i.length>4;r&&(n=this.getTensionPoints());const s=this.pointerLength(),a=i.length;let o,h;if(r){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=Ky.calcLength(n[n.length-4],n[n.length-3],"C",t),r=Ky.getPointOnQuadraticBezier(Math.min(1,1-s/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-r.x,h=i[a-1]-r.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-s,c/2),t.lineTo(-s,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),r?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-s,c/2),t.lineTo(-s,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Jy.prototype.className="Arrow",Fg(Jy),vv.addGetterSetter(Jy,"pointerLength",10,lv()),vv.addGetterSetter(Jy,"pointerWidth",10,lv()),vv.addGetterSetter(Jy,"pointerAtBeginning",!1),vv.addGetterSetter(Jy,"pointerAtEnding",!0);class Qy extends Sy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}Qy.prototype._centroid=!0,Qy.prototype.className="Circle",Qy.prototype._attrsAffectingSize=["radius"],Fg(Qy),vv.addGetterSetter(Qy,"radius",0,lv());class $y extends Sy{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}$y.prototype.className="Ellipse",$y.prototype._centroid=!0,$y.prototype._attrsAffectingSize=["radiusX","radiusY"],Fg($y),vv.addComponentsGetterSetter($y,"radius",["x","y"]),vv.addGetterSetter($y,"radiusX",0,lv()),vv.addGetterSetter($y,"radiusY",0,lv());let t_=class t extends Sy{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),r=this.attrs.image;let s;if(r){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;s=t&&n?[r,this.cropX(),this.cropY(),t,n,0,0,e,i]:[r,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?Zg.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),r&&(n&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?Zg.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(e,i,n=null){const r=Zg.createImageElement();r.onload=function(){const e=new t({image:r});i(e)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}};t_.prototype.className="Image",t_.prototype._attrsAffectingSize=["image"],Fg(t_),vv.addGetterSetter(t_,"cornerRadius",0,cv(4)),vv.addGetterSetter(t_,"image"),vv.addComponentsGetterSetter(t_,"crop",["x","y","width","height"]),vv.addGetterSetter(t_,"cropX",0,lv()),vv.addGetterSetter(t_,"cropY",0,lv()),vv.addGetterSetter(t_,"cropWidth",0,lv()),vv.addGetterSetter(t_,"cropHeight",0,lv());const e_=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],i_="up",n_="right",r_="down",s_="left",a_=e_.length;class o_ extends Cy{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<a_;e++)t.on(e_[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,r,s,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),r=0,s=0,i){case i_:r=t/2,s=-1*a;break;case n_:r=t+n,s=e/2;break;case r_:r=t/2,s=e+a;break;case s_:r=-1*n,s=e/2}h.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),o.setAttrs({x:-1*r,y:-1*s})}}}o_.prototype.className="Label",Fg(o_);class h_ extends Sy{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),a=this.cornerRadius();let o=0,h=0,l=0,c=0;"number"==typeof a?o=h=l=c=Math.min(a,e/2,i/2):(o=Math.min(a[0]||0,e/2,i/2),h=Math.min(a[1]||0,e/2,i/2),c=Math.min(a[2]||0,e/2,i/2),l=Math.min(a[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===i_&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===n_&&(t.lineTo(e,(i-s)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+s)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===r_&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+s),t.lineTo((e-r)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===s_&&(t.lineTo(0,(i+s)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-s)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),a=this.height();return r===i_?(e-=n,a+=n):r===r_?a+=n:r===s_?(t-=1.5*i,s+=i):r===n_&&(s+=1.5*i),{x:t,y:e,width:s,height:a}}}h_.prototype.className="Tag",Fg(h_),vv.addGetterSetter(h_,"pointerDirection","none"),vv.addGetterSetter(h_,"pointerWidth",0,lv()),vv.addGetterSetter(h_,"pointerHeight",0,lv()),vv.addGetterSetter(h_,"cornerRadius",0,cv(4));class l_ extends Sy{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?Zg.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}l_.prototype.className="Rect",Fg(l_),vv.addGetterSetter(l_,"cornerRadius",0,cv(4));class c_ extends Sy{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),r=this.cornerRadius();if(t.beginPath(),r)Zg.drawRoundedPolygonPath(t,e,n,i,r);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].x,n=t[0].y,r=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),{x:e,y:n,width:i-e,height:r-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}c_.prototype.className="RegularPolygon",c_.prototype._centroid=!0,c_.prototype._attrsAffectingSize=["radius"],Fg(c_),vv.addGetterSetter(c_,"radius",0,lv()),vv.addGetterSetter(c_,"sides",0,lv()),vv.addGetterSetter(c_,"cornerRadius",0,cv(4));const d_=2*Math.PI;class u_ extends Sy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,d_,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),d_,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}u_.prototype.className="Ring",u_.prototype._centroid=!0,u_.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Fg(u_),vv.addGetterSetter(u_,"innerRadius",0,lv()),vv.addGetterSetter(u_,"outerRadius",0,lv());class p_ extends Sy{constructor(t){super(t),this._updated=!0,this.anim=new Py(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+0],o=r[n+1],h=r[n+2],l=r[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(s){const n=s[e],r=2*i;t.drawImage(c,a,o,h,l,n[r+0],n[r+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+2],o=r[n+3];if(t.beginPath(),s){const n=s[e],r=2*i;t.rect(n[r+0],n[r+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}p_.prototype.className="Sprite",Fg(p_),vv.addGetterSetter(p_,"animation"),vv.addGetterSetter(p_,"animations"),vv.addGetterSetter(p_,"frameOffsets"),vv.addGetterSetter(p_,"image"),vv.addGetterSetter(p_,"frameIndex",0,lv()),vv.addGetterSetter(p_,"frameRate",17,lv()),vv.backCompat(p_,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class m_ extends Sy{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*n;r++){const s=r%2==0?i:e,a=s*Math.sin(r*Math.PI/n),o=-1*s*Math.cos(r*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function f_(t){return[...t].reduce((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const r=n[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}m_.prototype.className="Star",m_.prototype._centroid=!0,m_.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Fg(m_),vv.addGetterSetter(m_,"numPoints",5,lv()),vv.addGetterSetter(m_,"innerRadius",0,lv()),vv.addGetterSetter(m_,"outerRadius",0,lv());const g_="auto",v_="inherit",y_="justify",__="left",x_="middle",w_="normal",b_=" ",S_="none",M_=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],E_=M_.length;let T_;function A_(){return T_||(T_=Zg.createCanvasElement().getContext("2d"),T_)}class C_ extends Sy{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<E_;t++)this.on(M_[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,i;const n=this.textArr,r=n.length;if(!this.text())return;let s,a=this.padding(),o=this.fontSize(),h=this.lineHeight()*o,l=this.verticalAlign(),c=this.direction(),d=0,u=this.align(),p=this.getWidth(),m=this.letterSpacing(),f=this.charRenderFunc(),g=this.fill(),v=this.textDecoration(),y=-1!==v.indexOf("underline"),_=-1!==v.indexOf("line-through");c=c===v_?t.direction:c;let x=h/2,w=x_;if(!Ug.legacyTextRendering){const t=this.measureSize("M");w="alphabetic";x=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(i=t.fontBoundingBoxDescent)&&void 0!==i?i:t.actualBoundingBoxDescent))/2+h/2}for("rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",__),l===x_?d=(this.getHeight()-r*h-2*a)/2:"bottom"===l&&(d=this.getHeight()-r*h-2*a),t.translate(a,d+a),s=0;s<r;s++){let e=0,i=0;const l=n[s],d=l.text,v=l.width,w=l.lastInParagraph;if(t.save(),"right"===u?e+=p-v-2*a:"center"===u&&(e+=(p-v-2*a)/2),y){t.save(),t.beginPath();const n=e,r=x+i+(Ug.legacyTextRendering?Math.round(o/2):Math.round(o/4));t.moveTo(n,r);const s=u!==y_||w?v:p-2*a;t.lineTo(n+Math.round(s),r),t.lineWidth=o/15;const h=this._getLinearGradient();t.strokeStyle=h||g,t.stroke(),t.restore()}const b=e;if("rtl"===c||0===m&&u!==y_&&!f)0!==m&&t.setAttr("letterSpacing",`${m}px`),this._partialTextX=e,this._partialTextY=x+i,this._partialText=d,t.fillStrokeShape(this);else{const r=d.split(" ").length-1,o=f_(d);for(let h=0;h<o.length;h++){const l=o[h];if(" "!==l||w||u!==y_||(e+=(p-2*a-v)/r),this._partialTextX=e,this._partialTextY=x+i,this._partialText=l,f){t.save();f({char:l,index:h+n.slice(0,s).reduce((t,e)=>t+f_(e.text).length,0),x:e,y:x+i,lineIndex:s,column:h,isLastInLine:w,width:this.measureSize(l).width,context:t})}t.fillStrokeShape(this),f&&t.restore(),e+=this.measureSize(l).width+m}}if(_){t.save(),t.beginPath();const e=Ug.legacyTextRendering?0:-Math.round(o/4),n=b;t.moveTo(n,x+i+e);const r=u!==y_||w?v:p-2*a;t.lineTo(n+Math.round(r),x+i+e),t.lineWidth=o/15;const s=this._getLinearGradient();t.strokeStyle=s||g,t.stroke(),t.restore()}t.restore(),r>1&&(x+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=Zg._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===g_||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===g_||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Zg.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,r,s,a,o,h,l,c,d;let u,p=A_(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*f,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+b_+this.fontVariant()+b_+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===y_&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return A_().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,a=r!==g_&&void 0!==r,o=s!==g_&&void 0!==s,h=this.padding(),l=r-2*h,c=s-2*h,d=0,u=this.wrap(),p="char"!==u&&u!==S_,m=this.ellipsis();this.textArr=[],A_().font=this._getContextFont();const f=m?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],h=this._getTextWidth(s);if(a&&h>l)for(;s.length>0;){let t=0,e=f_(s).length,r="",a=0;for(;t<e;){const i=t+e>>>1,h=f_(s).slice(0,i+1).join(""),u=this._getTextWidth(h);(m&&o&&d+n>c?u+f:u)<=l?(t=i+1,r=h,a=u):e=i}if(!r)break;if(p){const e=f_(s),i=f_(r),n=e[i.length];let o;if((n===b_||"-"===n)&&a<=l)o=i.length;else{const t=i.lastIndexOf(b_),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,r=e.slice(0,t).join(""),a=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,a),d+=n;if(this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(s=f_(s).slice(t).join("").trimLeft(),s.length>0&&(h=this._getTextWidth(s),h<=l)){this._addTextLine(s),d+=n,i=Math.max(i,h);break}}else this._addTextLine(s),d+=n,i=Math.max(i,h),this._shouldHandleEllipsis(d)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==g_&&void 0!==n,s=n-2*this.padding();return!(this.wrap()!==S_)||r&&t+i>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==g_&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}C_.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},C_.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},C_.prototype.className="Text",C_.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Fg(C_),vv.overWriteSetter(C_,"width",dv()),vv.overWriteSetter(C_,"height",dv()),vv.addGetterSetter(C_,"direction",v_),vv.addGetterSetter(C_,"fontFamily","Arial"),vv.addGetterSetter(C_,"fontSize",12,lv()),vv.addGetterSetter(C_,"fontStyle",w_),vv.addGetterSetter(C_,"fontVariant",w_),vv.addGetterSetter(C_,"padding",0,lv()),vv.addGetterSetter(C_,"align",__),vv.addGetterSetter(C_,"verticalAlign","top"),vv.addGetterSetter(C_,"lineHeight",1,lv()),vv.addGetterSetter(C_,"wrap","word"),vv.addGetterSetter(C_,"ellipsis",!1,mv()),vv.addGetterSetter(C_,"letterSpacing",0,lv()),vv.addGetterSetter(C_,"text","",uv()),vv.addGetterSetter(C_,"textDecoration",""),vv.addGetterSetter(C_,"charRenderFunc",void 0);const R_="normal";function P_(t){t.fillText(this.partialText,0,0)}function L_(t){t.strokeText(this.partialText,0,0)}class I_ extends Sy{constructor(t){super(t),this.dummyCanvas=Zg.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Ky.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:Ky.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Ky.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo,s=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");s&&t.beginPath();for(let e=0;e<r.length;e++){t.save();const i=r[e].p0;t.translate(i.x,i.y),t.rotate(r[e].rotation),this.partialText=r[e].text,t.fillStrokeShape(this),s&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(r[e].width,n/2+1)),t.restore()}if(s&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),a){t.beginPath();for(let e=0;e<r.length;e++){t.save();const i=r[e].p0;t.translate(i.x,i.y),t.rotate(r[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(r[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=n/20,t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Zg.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return C_.prototype.setText.call(this,t)}_getContextFont(){return C_.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=f_(this.text()),e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const r=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);let h=0;"center"===s&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(h=Math.max(0,this.pathLength-o));let l=h;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(l);if(!n)return;const h=e[i].char;let c=e[i].width+r;if(" "===h&&"justify"===s){const t=this.text().split(" ").length-1;c+=(this.pathLength-o)/t}const d=this._getPointAtLength(l+c);if(!d)return;const u=Ky.getLineLength(n.x,n.y,d.x,d.y);let p=0;if(a)try{p=a(e[i-1].char,h)*this.fontSize()}catch(t){p=0}n.x+=p,d.x+=p,this.textWidth+=p;const m=Ky.getPointOnLine(p+u/2,n.x,n.y,d.x,d.y),f=Math.atan2(d.y-n.y,d.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:f,p0:n,p1:d,width:u}),l+=c}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:s-o/2,width:r-n+o,height:a-s+o}}destroy(){return Zg.releaseCanvas(this.dummyCanvas),super.destroy()}}I_.prototype._fillFunc=P_,I_.prototype._strokeFunc=L_,I_.prototype._fillFuncHit=P_,I_.prototype._strokeFuncHit=L_,I_.prototype.className="TextPath",I_.prototype._attrsAffectingSize=["text","fontSize","data"],Fg(I_),vv.addGetterSetter(I_,"data"),vv.addGetterSetter(I_,"fontFamily","Arial"),vv.addGetterSetter(I_,"fontSize",12,lv()),vv.addGetterSetter(I_,"fontStyle",R_),vv.addGetterSetter(I_,"align","left"),vv.addGetterSetter(I_,"letterSpacing",0,lv()),vv.addGetterSetter(I_,"textBaseline","middle"),vv.addGetterSetter(I_,"fontVariant",R_),vv.addGetterSetter(I_,"text",""),vv.addGetterSetter(I_,"textDecoration",""),vv.addGetterSetter(I_,"kerningFunc",void 0);const D_="tr-konva",O_=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${D_}`).join(" "),N_="nodesRect",U_=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],F_={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},z_="ontouchstart"in Ug._global;const k_=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function B_(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:r}}function G_(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return B_(t,e,i)}let H_=0;class V_ extends Cy{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(O_,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return Zg.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return D_+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(Zg.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(U_.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),r=n.x-e.x,s=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+r,y:n.y+s}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(N_),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(N_,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),s=t.getAbsolutePosition(i),a=n.x*r.x-t.offsetX()*r.x,o=n.y*r.y-t.offsetY()*r.y,h=(Ug.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return B_({x:s.x+a*Math.cos(h)+o*Math.sin(-h),y:s.y+o*Math.cos(h)+a*Math.sin(h),width:n.width*r.x,height:n.height*r.y,rotation:h},-Ug.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=e.getAbsoluteTransform();n.forEach(function(e){const i=r.point(e);t.push(i)})});const e=new kg;e.rotate(-Ug.getAngle(this.rotation()));let i=1/0,n=1/0,r=-1/0,s=-1/0;t.forEach(function(t){const a=e.point(t);void 0===i&&(i=r=a.x,n=s=a.y),i=Math.min(i,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),s=Math.max(s,a.y)}),e.invert();const a=e.point({x:i,y:n});return{x:a.x,y:a.y,width:r-i,height:s-n,rotation:Ug.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),k_.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new l_({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:z_?10:"auto"}),i=this;e.on("mousedown touchstart",function(t){i._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const i=Ug.getAngle(this.rotation()),n=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=Zg.degToRad(F_[t]||0);const n=(Zg.radToDeg(e)%360+360)%360;return Zg._inRange(n,337.5,360)||Zg._inRange(n,0,22.5)?"ns-resize":Zg._inRange(n,22.5,67.5)?"nesw-resize":Zg._inRange(n,67.5,112.5)?"ew-resize":Zg._inRange(n,112.5,157.5)?"nwse-resize":Zg._inRange(n,157.5,202.5)?"ns-resize":Zg._inRange(n,202.5,247.5)?"nesw-resize":Zg._inRange(n,247.5,292.5)?"ew-resize":Zg._inRange(n,292.5,337.5)?"nwse-resize":(Zg.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new Sy({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.moveTo(e.width()/2,-n),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*Zg._sign(e.height())-n),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},H_++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,i,n;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const a=s.getPointerPosition();let o={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),r.setAbsolutePosition(o);const l=r.getAbsolutePosition();if(h.x===l.x&&h.y===l.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=r.x()-n.width/2,i=-r.y()+n.height/2;let s=Math.atan2(-i,e)+Math.PI/2;n.height<0&&(s-=Math.PI);const a=Ug.getAngle(this.rotation())+s,o=Ug.getAngle(this.rotationSnapTolerance()),h=function(t,e,i){let n=e;for(let r=0;r<t.length;r++){const s=Ug.getAngle(t[r]),a=Math.abs(s-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(n=s)}return n}(this.rotationSnaps(),a,o),l=G_(n,h-n.rotation);return void this._fitNodesInto(l,t)}const c=this.shiftBehavior();let d;d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(t.y-r.y(),2));const s=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const s=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var p=r.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const s=t.x<r.x()?-1:1,a=r.y()<t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,r.x(t.x-e),r.y(t.y+i)}p=r.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(r.y()-t.y,2));const s=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=n*this.cos*s,i=n*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:r,y:s})}const m=this.findOne(".top-left").getAbsolutePosition();e=m.x,i=m.y;const f=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:f,height:g,rotation:Ug.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();H_--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const i=this._getNodeRect();if(Zg._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(Zg._inRange(t.height,2*-this.padding()-1,1))return void this.update();const n=new kg;if(n.rotate(Ug.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:Zg.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const r=1e7,s=new kg;s.translate(i.x,i.y),s.rotate(i.rotation),s.scale(i.width/r,i.height/r);const a=new kg,o=t.width/r,h=t.height/r;!1===this.flipEnabled()?(a.translate(t.x,t.y),a.rotate(t.rotation),a.translate(t.width<0?t.width:0,t.height<0?t.height:0),a.scale(Math.abs(o),Math.abs(h))):(a.translate(t.x,t.y),a.rotate(t.rotation),a.scale(o,h));const l=a.multiply(s.invert());this._nodes.forEach(t=>{var e;if(!t.getStage())return;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const r=new kg;r.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const s=r.decompose();t.setAttrs(s),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(Zg._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(Zg._getRotation(e.rotation));const i=e.width,n=e.height,r=this.enabledAnchors(),s=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:s&&r.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:s&&r.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:s&&r.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:s&&r.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:s&&r.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:s&&r.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:s&&r.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:s&&r.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*Zg._sign(n)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach(t=>{l(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Cy.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Iv.prototype.toObject.call(this)}clone(t){return Iv.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}V_.isTransforming=()=>H_>0,V_.prototype.className="Transformer",Fg(V_),vv.addGetterSetter(V_,"enabledAnchors",k_,function(t){return t instanceof Array||Zg.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===k_.indexOf(t)&&Zg.warn("Unknown anchor name: "+t+". Available names are: "+k_.join(", "))}),t||[]}),vv.addGetterSetter(V_,"flipEnabled",!0,mv()),vv.addGetterSetter(V_,"resizeEnabled",!0),vv.addGetterSetter(V_,"anchorSize",10,lv()),vv.addGetterSetter(V_,"rotateEnabled",!0),vv.addGetterSetter(V_,"rotateLineVisible",!0),vv.addGetterSetter(V_,"rotationSnaps",[]),vv.addGetterSetter(V_,"rotateAnchorOffset",50,lv()),vv.addGetterSetter(V_,"rotateAnchorCursor","crosshair"),vv.addGetterSetter(V_,"rotationSnapTolerance",5,lv()),vv.addGetterSetter(V_,"borderEnabled",!0),vv.addGetterSetter(V_,"anchorStroke","rgb(0, 161, 255)"),vv.addGetterSetter(V_,"anchorStrokeWidth",1,lv()),vv.addGetterSetter(V_,"anchorFill","white"),vv.addGetterSetter(V_,"anchorCornerRadius",0,lv()),vv.addGetterSetter(V_,"borderStroke","rgb(0, 161, 255)"),vv.addGetterSetter(V_,"borderStrokeWidth",1,lv()),vv.addGetterSetter(V_,"borderDash"),vv.addGetterSetter(V_,"keepRatio",!0),vv.addGetterSetter(V_,"shiftBehavior","default"),vv.addGetterSetter(V_,"centeredScaling",!1),vv.addGetterSetter(V_,"ignoreStroke",!1),vv.addGetterSetter(V_,"padding",0,lv()),vv.addGetterSetter(V_,"nodes"),vv.addGetterSetter(V_,"node"),vv.addGetterSetter(V_,"boundBoxFunc"),vv.addGetterSetter(V_,"anchorDragBoundFunc"),vv.addGetterSetter(V_,"anchorStyleFunc"),vv.addGetterSetter(V_,"shouldOverdrawWholeArea",!1),vv.addGetterSetter(V_,"useSingleNodeRotation",!0),vv.backCompat(V_,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class W_ extends Sy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Ug.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function j_(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}W_.prototype.className="Wedge",W_.prototype._centroid=!0,W_.prototype._attrsAffectingSize=["radius"],Fg(W_),vv.addGetterSetter(W_,"radius",0,lv()),vv.addGetterSetter(W_,"angle",0,lv()),vv.addGetterSetter(W_,"clockwise",!1),vv.backCompat(W_,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const X_=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Y_=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];vv.addGetterSetter(Iv,"blurRadius",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"brightness",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"contrast",0,lv(),vv.afterSetFilter);function q_(t,e,i,n,r){const s=i-e,a=r-n;if(0===s)return n+a/2;if(0===a)return n;let o=(t-e)/s;return o=a*o+n,o}vv.addGetterSetter(Iv,"embossStrength",.5,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"embossWhiteLevel",.5,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"embossDirection","top-left",void 0,vv.afterSetFilter),vv.addGetterSetter(Iv,"embossBlend",!1,void 0,vv.afterSetFilter);vv.addGetterSetter(Iv,"enhance",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"hue",0,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"saturation",0,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"luminance",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"hue",0,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"saturation",0,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"value",0,lv(),vv.afterSetFilter);function Z_(t,e,i){let n=4*(i*t.width+e);const r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function K_(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}vv.addGetterSetter(Iv,"kaleidoscopePower",2,lv(),vv.afterSetFilter),vv.addGetterSetter(Iv,"kaleidoscopeAngle",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"threshold",0,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"noise",.2,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"pixelSize",8,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"levels",.5,lv(),vv.afterSetFilter);vv.addGetterSetter(Iv,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),vv.addGetterSetter(Iv,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),vv.addGetterSetter(Iv,"blue",0,hv,vv.afterSetFilter);vv.addGetterSetter(Iv,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),vv.addGetterSetter(Iv,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),vv.addGetterSetter(Iv,"blue",0,hv,vv.afterSetFilter),vv.addGetterSetter(Iv,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});vv.addGetterSetter(Iv,"threshold",.5,lv(),vv.afterSetFilter);const J_=Fy.Util._assign(Fy,{Arc:zy,Arrow:Jy,Circle:Qy,Ellipse:$y,Image:t_,Label:o_,Tag:h_,Line:Gy,Path:Ky,Rect:l_,RegularPolygon:c_,Ring:u_,Sprite:p_,Star:m_,Text:C_,TextPath:I_,Transformer:V_,Wedge:W_,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,r=t.height;let s,a,o,h,l,c,d,u,p,m,f,g,v,y,_,x,w,b,S,M;const E=e+e+1,T=n-1,A=r-1,C=e+1,R=C*(C+1)/2,P=new j_,L=X_[e],I=Y_[e];let D=null,O=P,N=null,U=null;for(let t=1;t<E;t++)O=O.next=new j_,t===C&&(D=O);O.next=P,o=a=0;for(let t=0;t<r;t++){g=v=y=_=h=l=c=d=0,u=C*(x=i[a]),p=C*(w=i[a+1]),m=C*(b=i[a+2]),f=C*(S=i[a+3]),h+=R*x,l+=R*w,c+=R*b,d+=R*S,O=P;for(let t=0;t<C;t++)O.r=x,O.g=w,O.b=b,O.a=S,O=O.next;for(let t=1;t<C;t++)s=a+((T<t?T:t)<<2),h+=(O.r=x=i[s])*(M=C-t),l+=(O.g=w=i[s+1])*M,c+=(O.b=b=i[s+2])*M,d+=(O.a=S=i[s+3])*M,g+=x,v+=w,y+=b,_+=S,O=O.next;N=P,U=D;for(let t=0;t<n;t++)i[a+3]=S=d*L>>I,0!==S?(S=255/S,i[a]=(h*L>>I)*S,i[a+1]=(l*L>>I)*S,i[a+2]=(c*L>>I)*S):i[a]=i[a+1]=i[a+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,s=o+((s=t+e+1)<T?s:T)<<2,g+=N.r=i[s],v+=N.g=i[s+1],y+=N.b=i[s+2],_+=N.a=i[s+3],h+=g,l+=v,c+=y,d+=_,N=N.next,u+=x=U.r,p+=w=U.g,m+=b=U.b,f+=S=U.a,g-=x,v-=w,y-=b,_-=S,U=U.next,a+=4;o+=n}for(let t=0;t<n;t++){v=y=_=g=l=c=d=h=0,a=t<<2,u=C*(x=i[a]),p=C*(w=i[a+1]),m=C*(b=i[a+2]),f=C*(S=i[a+3]),h+=R*x,l+=R*w,c+=R*b,d+=R*S,O=P;for(let t=0;t<C;t++)O.r=x,O.g=w,O.b=b,O.a=S,O=O.next;let o=n;for(let r=1;r<=e;r++)a=o+t<<2,h+=(O.r=x=i[a])*(M=C-r),l+=(O.g=w=i[a+1])*M,c+=(O.b=b=i[a+2])*M,d+=(O.a=S=i[a+3])*M,g+=x,v+=w,y+=b,_+=S,O=O.next,r<A&&(o+=n);a=t,N=P,U=D;for(let e=0;e<r;e++)s=a<<2,i[s+3]=S=d*L>>I,S>0?(S=255/S,i[s]=(h*L>>I)*S,i[s+1]=(l*L>>I)*S,i[s+2]=(c*L>>I)*S):i[s]=i[s+1]=i[s+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,s=t+((s=e+C)<A?s:A)*n<<2,h+=g+=N.r=i[s],l+=v+=N.g=i[s+1],c+=y+=N.b=i[s+2],d+=_+=N.a=i[s+3],N=N.next,u+=x=U.r,p+=w=U.g,m+=b=U.b,f+=S=U.a,g-=x,v-=w,y-=b,_-=S,U=U.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let r=150,s=150,a=150;for(let t=0;t<n;t+=4)r=i[t],s=i[t+1],a=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,i[t]=r,i[t+1]=s,i[t+2]=a},Emboss:function(t){var e,i,n,r,s,a,o,h,l;const c=t.data,d=t.width,u=t.height,p=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),m=Math.min(1,Math.max(0,null!==(r=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==r?r:.5)),f=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(s=this.embossDirection)||void 0===s?void 0:s.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,g=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),v=10*p,y=255*m,_=f*Math.PI/180,x=Math.cos(_),w=Math.sin(_),b=128/1020*v,S=new Uint8ClampedArray(c),M=new Float32Array(d*u);for(let t=0,e=0;e<c.length;e+=4,t++)M[t]=.2126*S[e]+.7152*S[e+1]+.0722*S[e+2];const E=[-1,0,1,-2,0,2,-1,0,1],T=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],C=t=>t<0?0:t>255?255:t;for(let t=1;t<u-1;t++)for(let e=1;e<d-1;e++){const i=t*d+e;let n=0,r=0;n+=M[i+A[0]]*E[0],r+=M[i+A[0]]*T[0],n+=M[i+A[1]]*E[1],r+=M[i+A[1]]*T[1],n+=M[i+A[2]]*E[2],r+=M[i+A[2]]*T[2],n+=M[i+A[3]]*E[3],r+=M[i+A[3]]*T[3],n+=M[i+A[5]]*E[5],r+=M[i+A[5]]*T[5],n+=M[i+A[6]]*E[6],r+=M[i+A[6]]*T[6],n+=M[i+A[7]]*E[7],r+=M[i+A[7]]*T[7],n+=M[i+A[8]]*E[8],r+=M[i+A[8]]*T[8];const s=C(y+(x*n+w*r)*b),a=4*i;if(g){const t=s-y;c[a]=C(S[a]+t),c[a+1]=C(S[a+1]+t),c[a+2]=C(S[a+2]+t),c[a+3]=S[a+3]}else c[a]=c[a+1]=c[a+2]=s,c[a+3]=S[a+3]}for(let t=0;t<d;t++){let e=4*t,i=4*((u-1)*d+t);c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3],c[i]=S[i],c[i+1]=S[i+1],c[i+2]=S[i+2],c[i+3]=S[i+3]}for(let t=1;t<u-1;t++){let e=t*d*4,i=4*(t*d+(d-1));c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3],c[i]=S[i],c[i+1]=S[i+1],c[i+2]=S[i+2],c[i+3]=S[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,r,s,a=e[0],o=a,h=e[1],l=h,c=e[2],d=c;const u=this.enhance();if(0===u)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),r=e[t+1],r<h?h=r:r>l&&(l=r),s=e[t+2],s<c?c=s:s>d&&(d=s);let p,m,f,g,v,y;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),u>0)p=o+u*(255-o),m=a-u*(a-0),f=l+u*(255-l),g=h-u*(h-0),v=d+u*(255-d),y=c-u*(c-0);else{const t=.5*(o+a);p=o+u*(o-t),m=a+u*(a-t);const e=.5*(l+h);f=l+u*(l-e),g=h+u*(h-e);const i=.5*(d+c);v=d+u*(d-i),y=c+u*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=q_(e[t+0],a,o,m,p),e[t+1]=q_(e[t+1],h,l,g,f),e[t+2]=q_(e[t+2],c,d,y,v)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,s=127*this.luminance(),a=1*n*Math.cos(r*Math.PI/180),o=1*n*Math.sin(r*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,y,_,x;for(let t=0;t<i;t+=4)v=e[t+0],y=e[t+1],_=e[t+2],x=e[t+3],e[t+0]=h*v+l*y+c*_+s,e[t+1]=d*v+u*y+p*_+s,e[t+2]=m*v+f*y+g*_+s,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=n*r*Math.cos(s*Math.PI/180),o=n*r*Math.sin(s*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2],s=e[t+3];e[t+0]=h*i+l*n+c*r,e[t+1]=d*i+u*n+p*r,e[t+2]=m*i+f*n+g*r,e[t+3]=s}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,r,s,a,o,h,l,c,d,u,p=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),f=Math.floor(e*(m%360)/360);if(p<1)return;const g=Zg.createCanvasElement();g.width=e,g.height=i;const v=g.getContext("2d").getImageData(0,0,e,i);Zg.releaseCanvas(g),function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*s+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*s),r[u+0]=m,r[u+1]=f,r[u+2]=g,r[u+3]=v}}}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let y=e/Math.pow(2,p);for(;y<=8;)y*=2,p-=1;y=Math.ceil(y);let _=y,x=0,w=_,b=1;for(f+y>e&&(x=_,w=0,b=-1),r=0;r<i;r+=1)for(n=x;n!==w;n+=b)s=Math.round(n+f)%e,d=4*(e*r+s),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*r+n),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;for(r=0;r<i;r+=1)for(_=Math.floor(y),a=0;a<p;a+=1){for(n=0;n<_+1;n+=1)d=4*(e*r+n),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*r+2*_-n-1),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;_*=2}!function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s;let f,g;for(c=0;c<s;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*s+f);const v=n[u+0],y=n[u+1],_=n[u+2],x=n[u+3];u=4*(d*s+c),r[u+0]=v,r[u+1]=y,r[u+2]=_,r[u+3]=x}}(v,t,{})},Mask:function(t){let e=function(t,e){const i=Z_(t,0,0),n=Z_(t,t.width-1,0),r=Z_(t,0,t.height-1),s=Z_(t,t.width-1,t.height-1),a=e||10;if(K_(i,n)<a&&K_(n,s)<a&&K_(s,r)<a&&K_(r,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,s,r]),o=[];for(let i=0;i<t.width*t.height;i++){const n=K_(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,r=e/2;for(let t=0;t<n;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,r=Math.ceil(i/e),s=Math.ceil(n/e),a=t.data;if(e<=0)Zg.error("pixelSize value can not be <= 0");else for(let t=0;t<r;t+=1)for(let r=0;r<s;r+=1){let s=0,o=0,h=0,l=0;const c=t*e,d=c+e,u=r*e,p=u+e;let m=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const r=4*(i*e+t);s+=a[r+0],o+=a[r+1],h+=a[r+2],l+=a[r+3],m+=1}s/=m,o/=m,h/=m,l/=m;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const r=4*(i*e+t);a[r+0]=s,a[r+1]=o,a[r+2]=h,a[r+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,r=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/r)*r},RGB:function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*r,e[t+2]=i*s,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=r*a+e[t+1]*i,e[t+2]=s*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*r),e[t+1]=Math.min(255,.349*i+.686*n+.168*r),e[t+2]=Math.min(255,.272*i+.534*n+.131*r)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],r=e[t+2];.2126*i+.7152*n+.0722*r>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-r)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}});class Q_{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class $_{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const tx=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class ex{constructor(t,e=null,i=new Q_){var n,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const s=[],a=[];t.points.forEach(t=>{s.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})}),this._ref=new J_.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:tx.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case tx.get("dot"):t="dot";break;case tx.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=tx.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class ix{constructor(t,e=null,i=new Q_){var n,r,s;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new J_.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class nx{constructor(t,e=null,i=new Q_){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new J_.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}function rx(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class sx{constructor(t,e=null,i=new Q_){var n,r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=rx(t.position,t.position2),t.position3?t.radius.y=rx(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new J_.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let s=this._ref.radiusY();n&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const r=n.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(n.point(e).x-r.x),y:Math.abs(n.point(i).y-r.y)})}}class ax{constructor(t,e=null,i=new Q_){var n,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new J_.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),r=n.point({x:i[0],y:i[1]}),s=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,r.x,r.y])}}class ox{constructor(t,e=null,i=new Q_){var n,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new J_.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),t.position2&&this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(i&&this._ref.width(r),n&&this._ref.height(s)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}class hx{constructor(t,e=null,i=new Q_){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new J_.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function s(s,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=a;const n=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=r[e].x+n/c/2,u=r[e].y+h/c/2;const p=r[e+1].x,m=r[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,s,f,g):t.arc(d,u,s,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?s(8,15):i>=25||n>=25?s(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}const lx={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new ex(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new ix(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new nx(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new sx(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new ax(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new ox(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new hx(e,t,...i)}};class cx{constructor(){this._markupIsActive=!1,this._markupColor=new $_(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this._container;i&&n&&(this._markupContainer.style.left=`${t}px`,this._markupContainer.style.top=`${e}px`,this._konvaStage.width(i),this._konvaStage.height(n),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.updateScreenCoordinatesForAll()},this.zoomAt=()=>{this.updateScreenCoordinatesForAll()},this.changeCameraMode=()=>{this.clearOverlay()},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){this._viewer=i,this._worldTransformer=null!=n?n:new Q_,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(t),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt),this._viewer.addEventListener("changecameramode",this.changeCameraMode))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("changecameramode",this.changeCameraMode),this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,this.destroyKonva(),null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new $_(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}colorizeSelectedMarkups(t,e,i){const n=new $_(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}setViewpoint(t){var e,i,n,r,s,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(n=t.texts)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(r=t.rectangles)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(s=t.ellipses)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)}),null===(a=t.arrows)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(o=t.clouds)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={custom_fields:{}}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.snapshot={data:this.combineMarkupWithDrawing()},t.custom_fields.markup_color=this.getMarkupColor(),t}enableEditMode(t){return t&&lx[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=lx[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(lx).forEach(e=>{const i=lx[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map(t=>{const e=t.className,i=Object.values(lx).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=lx[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}updateScreenCoordinatesForAll(){this.getObjects().forEach(t=>{t.updateScreenCoordinates()})}initializeKonva(){const t=new J_.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new J_.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new J_.Group,e.add(this._groupImages),this._groupGeometry=new J_.Group,e.add(this._groupGeometry),this._groupTexts=new J_.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new J_.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,r,s,a=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(n=this.addLine([s.x,s.y,s.x,s.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,n=i?r.x:Math.min(r.x,e.x),s=i?r.y:Math.min(r.y,e.y),a=i?200:Math.abs(r.x-e.x),o=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:s},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:s},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:s},null,Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!a)return;const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,o=i?r.x:Math.min(r.x,e.x),h=i?r.y:Math.min(r.y,e.y),l=i?200:Math.abs(r.x-e.x),c=i?200:Math.abs(r.y-e.y);"Line"===this._markupMode?n.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(e.x,e.y):s=this.addArrow({x:r.x,y:r.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?s?(s.setPosition(o,h),s.setWidth(l),s.setHeight(c)):s=this.addRectangle({x:o,y:h},null,l,c):"Ellipse"===this._markupMode?s?(s.setPosition(o,h),s.setRadiusX(l),s.setRadiusY(c)):s=this.addEllipse({x:o,y:h},null,null,{x:l,y:c}):"Cloud"===this._markupMode&&(s?(s.setPosition(o,h),s.setWidth(Math.max(100,l)),s.setHeight(Math.max(100,c))):s=this.addCloud({x:o,y:h},null,l,c))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(n||r){if(n&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new ex(null,e,this._worldTransformer),r={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(r)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),s=new ix(null,e,this._worldTransformer),a={id:s.id(),position:n,text:s.getText(),text_size:.02*i.y,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()*r.getMatrix()[0]};t.push(a)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new nx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new sx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:r,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=new ax(null,e,this._worldTransformer),s={id:r.id(),start:i,end:n,color:r.getColor()};t.push(s)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],s=new ox(null,e,this._worldTransformer),a={id:s.id(),position:i,position2:n,src:s.getSrc(),width:s.getWidth()*r,height:s.getHeight()*r};t.push(a)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new hx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,n,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new ex({points:s,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!s||s<h)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const l=new ix({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:s||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,r,s,a){if(!t)return;const o=new nx({position:t,position2:e,width:i,height:n,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,r,s,a){if(!t)return;const o=new sx({position:t,position2:e,position3:i,radius:n,lineWidth:r,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const r=new ax({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,n,r,s,a){if(!t||!i||!n)return;const o=new hx({position:t,position2:e,width:i,height:n,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,r,s){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new ox({position:t,position2:e,src:i,width:n,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s},null,this._worldTransformer);return this.addObject(o),o}}class dx extends $r{constructor(){super(...arguments),this.oldAutoClear=!1,this.oldClippingPlanes=[]}onBeforeRender(t){this.oldAutoClear=t.autoClear,this.oldClippingPlanes=t.clippingPlanes,t.autoClear=!1,t.clippingPlanes=[]}onAfterRender(t){t.clippingPlanes=this.oldClippingPlanes,t.autoClear=this.oldAutoClear}}"undefined"!=typeof window&&(window.THREE=Op),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=ng,t.Info=y,t.Loader=c,t.Markup=cx,t.ModelImpl=Hf,t.Options=f,t.Viewer=class extends Dg{constructor(t){super(),this.client=t,this.options=new f(this),this.loaders=[],this.models=[],this.info=new y,this.canvasEvents=v.slice(),this.canvaseventlistener=t=>this.emit(t),this.selected=[],this.extents=new Li,this.target=new ei(0,0,0),this._activeDragger=null,this._components=[],this._updateDelay=1e3,this._renderNeeded=!1,this._renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new cx}get markup(){return this._markup}get draggers(){return[...mf.getDraggers().keys()]}get components(){return[...Gf.getComponents().keys()]}initialize(t,e){this.addEventListener("optionschange",t=>this.syncOptions(t.data)),this.scene=new $r,this.helpers=new dx;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),r=n.width||1,s=n.height||1,a=r/s;this.camera=new Vr(45,a,.001,1e3),this.camera.up.set(0,1,0),this.camera.position.set(0,0,1),this.camera.lookAt(this.target),this.camera.updateProjectionMatrix(),this.renderer=new Dp({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.renderer.setPixelRatio(i),this.renderer.setSize(r,s),this.renderer.outputColorSpace=Ee,this.renderPass=new bg(this.scene,this.camera),this.helpersPass=new bg(this.helpers,this.camera),this.helpersPass.clear=!1,this.fxaaPass=new Mg,this.smaaPass=new Cg,this.ssaaRenderPass=new Rg([this.scene,this.helpers],this.camera),this.ssaaRenderPass.unbiased=!0,this.outputPass=new Ig,this.composer=new wg(this.renderer),this.composer.addPass(this.renderPass),this.composer.addPass(this.helpersPass),this.composer.addPass(this.smaaPass),this.composer.addPass(this.fxaaPass),this.composer.addPass(this.ssaaRenderPass),this.composer.addPass(this.outputPass),this.composer.setSize(r,s),this.canvas=t,this.canvasEvents.forEach(e=>t.addEventListener(e,this.canvaseventlistener)),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of Gf.getComponents().keys())this._components.push(Gf.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),this.render(this._renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach(t=>t.dispose()),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach(t=>this.canvas.removeEventListener(t,this.canvaseventlistener)),this.canvas=void 0),this.composer&&this.composer.dispose(),this.renderPass&&this.renderPass.dispose(),this.helpersPass&&this.helpersPass.dispose(),this.fxaaPass&&this.fxaaPass.dispose(),this.smaaPass&&this.smaaPass.dispose(),this.ssaaRenderPass&&this.ssaaRenderPass.dispose(),this.outputPass&&this.outputPass.dispose(),this.renderer&&this.renderer.dispose(),this.scene=void 0,this.helpers=void 0,this.camera=void 0,this.renderer=void 0,this.renderPass=void 0,this.helpersPass=void 0,this.fxaaPass=void 0,this.smaaPass=void 0,this.ssaaRenderPass=void 0,this.outputPass=void 0,this.composer=void 0,this}isInitialized(){return!!this.renderer}setSize(t,e,i=!0){if(!this.renderer)return;const n=this.camera,r=t/e;n.isPerspectiveCamera&&(n.aspect=r,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*r,n.right=n.top*r,n.updateProjectionMatrix()),this.renderer.setSize(t,e,i),this.composer.setSize(t,e),this.update(!0),this.emitEvent({type:"resize",width:t,height:e})}update(t=!1){const e=performance.now();t=t||e-this._renderTime>=this._updateDelay,this._renderNeeded=!0,t&&this.render(e),this.emitEvent({type:"update",force:t})}render(t){var e,i;if(!this.renderer)return;if(!this._renderNeeded)return;t||(t=performance.now());const n=(t-this._renderTime)/1e3;this._renderTime=t,this._renderNeeded=!1,this.renderer.info.autoReset=!1,this.renderer.info.reset(),!0===this.options.antialiasing||"msaa"===this.options.antialiasing?(this.renderer.render(this.scene,this.camera),this.renderer.render(this.helpers,this.camera)):this.composer.render(n),null===(i=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===i||i.call(e),this.emitEvent({type:"render",time:t,deltaTime:n})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;const i=e.mode||"file";"assembly"!==i&&"a"!==i&&"append"!==i&&(this.cancel(),this.clear()),this.emitEvent({type:"open",mode:i,file:t});let n=t;if(n&&"function"==typeof n.getModels){const e=await n.getModels();n=e.find(t=>t.default)||e[0]||t}if(n&&"string"==typeof n.database&&(t=n.file),!n)throw new Error("Format not supported");let r=e.format;r||"string"!=typeof t.type||(r=t.type.split(".").pop()),r||"string"!=typeof t||(r=t.split(".").pop()),!r&&t instanceof globalThis.File&&(r=t.name.split(".").pop());const s=ug.createLoader(this,n,r);if(!s)throw new Error("Format not supported");this.loaders.push(s),this.emitEvent({type:"geometrystart",file:t,model:n});try{await this.loadReferences(n),await s.load(n,r,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:n}),e}return this.emitEvent({type:"geometryend",file:t,model:n}),this}openGltfFile(t,e,i={}){return console.warn("Viewer.openGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e})}loadGltfFile(t,e,i={}){return console.warn("Viewer.loadGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e,mode:"assembly"})}cancel(){return this.loaders.forEach(t=>t.cancel()),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach(t=>t.dispose()),this.loaders=[],this.models.forEach(t=>t.dispose()),this.models=[],this.scene.clear(),this.helpers.clear(),this.extents.makeEmpty(),this.target.set(0,0,0),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this):this}is3D(){return!0}syncOptions(t=this.options){this.renderer&&(this.fxaaPass.enabled="fxaa"===t.antialiasing,this.smaaPass.enabled="smaa"===t.antialiasing,this.ssaaRenderPass.enabled="ssaa"===t.antialiasing,this.renderPass.enabled=!this.ssaaRenderPass.enabled,this.helpersPass.enabled=!this.ssaaRenderPass.enabled,this.update())}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}getSelected2(){return this.executeCommand("getSelected2")}setSelected(t){this.executeCommand("setSelected",t)}setSelected2(t){this.executeCommand("setSelected2",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const n=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(r=mf.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const s=this.canvas;s&&(n&&s.classList.remove(`oda-cursor-${n.name.toLowerCase()}`),r&&s.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find(e=>e.name===t)}drawViewpoint(t){var e,i,n,r;if(!this.renderer)return;const s=({x:t,y:e,z:i})=>new ei(t,e,i),a=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Zi).radius,i=this.renderer.getSize(new $e),n=i.x/i.y,r=new xl;r.top=t.field_height/2,r.bottom=-t.field_height/2,r.left=r.bottom*n,r.right=r.top*n,r.near=0,r.far=1e3*e,r.zoom=t.view_to_world_scale,r.updateProjectionMatrix(),r.up.copy(s(t.up_vector)),r.position.copy(s(t.view_point)),r.lookAt(s(t.direction).add(r.position)),r.updateMatrixWorld(),this.camera=r,this.renderPass.camera=r,this.helpersPass.camera=r,this.ssaaRenderPass.camera=r,this.options.cameraMode="orthographic",this.emitEvent({type:"changecameramode",mode:"orthographic"})}})(t.orthogonal_camera),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Zi).radius,i=this.renderer.getSize(new $e),n=i.x/i.y,r=new Vr;r.fov=t.field_of_view,r.aspect=n,r.near=e/1e3,r.far=1e3*e,r.updateProjectionMatrix(),r.up.copy(s(t.up_vector)),r.position.copy(s(t.view_point)),r.lookAt(s(t.direction).add(r.position)),r.updateMatrixWorld(),this.camera=r,this.renderPass.camera=r,this.helpersPass.camera=r,this.ssaaRenderPass.camera=r,this.options.cameraMode="perspective",this.emitEvent({type:"changecameramode",mode:"perspective"})}})(t.perspective_camera),(t=>{t&&t.forEach(t=>{const e=new Zs;e.setFromNormalAndCoplanarPoint(s(t.direction),s(t.location)),this.renderer.clippingPlanes.push(e)})})(t.clipping_planes),(t=>{t&&this.setSelected(t.map(t=>t.handle))})((null===(i=t.custom_fields)||void 0===i?void 0:i.selection2)||t.selection),this._markup.setViewpoint(t),this.target.copy(s(null!==(r=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==r?r:this.target)),this.syncOverlay(),this.setActiveDragger(a),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new ei)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new ei)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach(i=>{const n={location:t(i.coplanarPoint(new ei)),direction:t(i.normal)};e.push(n)}),e})(),e.selection=(()=>this.getSelected().map(t=>({handle:t})))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),e.custom_fields.selection2=(()=>this.getSelected2().map(t=>({handle:t})))(),this.emitEvent({type:"createviewpoint",data:e}),e}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1;if(this.camera.isPerspectiveCamera){const t=new gc,e=new $e(i,n);t.setFromCamera(e,this.camera);const r=new ei;this.camera.getWorldDirection(r);const s=(new Zs).setFromNormalAndCoplanarPoint(r,this.target),a=new ei;if(t.ray.intersectPlane(s,a),!a){const t=new ei(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}return{x:a.x,y:a.y,z:a.z}}{const t=new ei(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new ei(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return _f.executeCommand(t,this,...e)}},t.commands=_f,t.commandsRegistry=n,t.components=Gf,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=mf,t.draggersRegistry=a,t.loaders=ug,t.loadersRegistry=p});
|