import{$t as e,A as t,Ar as n,Bt as r,Dn as i,E as a,En as o,Er as s,Fr as c,H as l,It as u,Jn as d,O as f,On as p,Qn as m,Rt as h,S as g,Un as _,Ut as v,V as y,Vt as b,X as x,Xt as S,Y as ee,Zn as C,Zt as te,f as w,gn as T,gr as ne,it as re,jr as E,kr as D,mn as O,nt as ie,on as k,ot as A,qn as ae,qt as oe,tn as se,tr as j,wr as ce,x as le,xr as M}from"./three@0.169.19.js";var ue=`6.39.0`,de=class{dispose(){}},fe=(()=>{let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),n=new g;return n.setAttribute(`position`,new le(e,3)),n.setAttribute(`uv`,new le(t,2)),n})(),N=class e{static get fullscreenGeometry(){return fe}constructor(e=`Pass`,t=new m,n=new O){this.name=e,this.renderer=null,this.scene=t,this.camera=n,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthBlit=!1,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen===null?null:this.screen.material}set fullscreenMaterial(t){let n=this.screen;n===null?(n=new te(e.fullscreenGeometry,t),n.frustumCulled=!1,this.scene===null&&(this.scene=new m),this.scene.add(n),this.screen=n):n.material=t}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=w){}render(e,t,n,r,i){throw Error(`Render method not implemented!`)}setSize(e,t){}initialize(e,t,n){}dispose(){for(let t of Object.keys(this)){let n=this[t];(n instanceof c||n instanceof oe||n instanceof ne||n instanceof e)&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},pe=class extends N{constructor(){super(`ClearMaskPass`,null,null),this.needsSwap=!1}render(e,t,n,r,i){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},me=`#ifdef COLOR_WRITE
#include <common>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#endif
#ifdef DEPTH_WRITE
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#endif
#ifdef USE_WEIGHTS
uniform vec4 channelWeights;
#endif
uniform float opacity;varying vec2 vUv;void main(){
#ifdef COLOR_WRITE
vec4 texel=texture2D(inputBuffer,vUv);
#ifdef USE_WEIGHTS
texel*=channelWeights;
#endif
gl_FragColor=opacity*texel;
#ifdef COLOR_SPACE_CONVERSION
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
#else
gl_FragColor=vec4(0.0);
#endif
#ifdef DEPTH_WRITE
gl_FragDepth=readDepth(vUv);
#endif
}`,P=`varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,he=class extends j{constructor(){super({name:`CopyMaterial`,defines:{COLOR_SPACE_CONVERSION:`1`,DEPTH_PACKING:`0`,COLOR_WRITE:`1`},uniforms:{inputBuffer:new M(null),depthBuffer:new M(null),channelWeights:new M(null),opacity:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:me,vertexShader:P}),this.depthFunc=1}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){let t=e!==null;this.colorWrite!==t&&(t?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=t,this.needsUpdate=!0),this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){let t=e!==null;this.depthWrite!==t&&(t?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=t,this.depthWrite=t,this.needsUpdate=!0),this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get colorSpaceConversion(){return this.defines.COLOR_SPACE_CONVERSION!==void 0}set colorSpaceConversion(e){this.colorSpaceConversion!==e&&(e?this.defines.COLOR_SPACE_CONVERSION=!0:delete this.defines.COLOR_SPACE_CONVERSION,this.needsUpdate=!0)}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(e){e===null?delete this.defines.USE_WEIGHTS:(this.defines.USE_WEIGHTS=`1`,this.uniforms.channelWeights.value=e),this.needsUpdate=!0}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},ge=class extends N{constructor(e,t=!0){super(`CopyPass`),this.fullscreenMaterial=new he,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new c(1,1,{minFilter:u,magFilter:u,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name=`CopyPass.Target`),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,n,r,i){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTarget.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=C):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},_e=new t,ve=class extends N{constructor(e=!0,t=!0,n=!1){super(`ClearPass`,null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=n,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,n){this.color=e,this.depth=t,this.stencil=n}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,n,r,i){let a=this.overrideClearColor,o=this.overrideClearAlpha,s=e.getClearAlpha(),c=a!==null,l=o>=0;c?(e.getClearColor(_e),e.setClearColor(a,l?o:s)):l&&e.setClearAlpha(o),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),c?e.setClearColor(_e,s):l&&e.setClearAlpha(s)}},ye=class extends N{constructor(e,t){super(`MaskPass`,e,t),this.needsSwap=!1,this.clearPass=new ve(!1,!1,!0),this.inverse=!1}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,n,r,i){let a=e.getContext(),o=e.state.buffers,s=this.scene,c=this.camera,l=this.clearPass,u=+!this.inverted,d=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.stencil.setFunc(a.ALWAYS,u,4294967295),o.stencil.setClear(d),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?l.render(e,null):(l.render(e,t),l.render(e,n))),this.renderToScreen?(e.setRenderTarget(null),e.render(s,c)):(e.setRenderTarget(t),e.render(s,c),e.setRenderTarget(n),e.render(s,c)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(a.EQUAL,1,4294967295),o.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),o.stencil.setLocked(!0)}},be=1/1e3,xe=1e3,Se=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<`u`&&document.hidden!==void 0&&(e?document.addEventListener(`visibilitychange`,this):document.removeEventListener(`visibilitychange`,this),this._autoReset=e)}get delta(){return this._delta*be}get fixedDelta(){return this._fixedDelta*be}set fixedDelta(e){this._fixedDelta=e*xe}get elapsed(){return this._elapsed*be}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e===void 0?performance.now():e)-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},Ce=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:r=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,n,i,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new ge,this.depthTexture=null,this.depthRenderTarget=null,this.passes=[],this.timer=new Se,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,e!==null){let t=e.getSize(new D),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===1009&&e.outputColorSpace===`srgb`&&(this.inputBuffer.texture.colorSpace=C,this.outputBuffer.texture.colorSpace=C,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(let t of this.passes)t.initialize(e,n,r)}}replaceRenderer(e,t=!0){let n=this.renderer,r=n.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(n.domElement),r.appendChild(e.domElement)),n}createDepthTexture(){let e=this.inputBuffer,t=new x;this.depthTexture=t,e.stencilBuffer?(t.format=ee,t.type=s):t.type=A;let n=t.clone();return n.name=`EffectComposer.StableDepth`,this.depthRenderTarget=new c(e.width,e.height,{depthBuffer:!0,stencilBuffer:e.stencilBuffer,depthTexture:n}),n}blitDepthBuffer(e){let t=this.renderer,n=this.depthRenderTarget,r=t.properties,i=t.getContext();t.setRenderTarget(n);let a=r.get(e).__webglFramebuffer,o=r.get(n).__webglFramebuffer,s=e.stencilBuffer?i.DEPTH_BUFFER_BIT|i.STENCIL_BUFFER_BIT:i.DEPTH_BUFFER_BIT;i.bindFramebuffer(i.READ_FRAMEBUFFER,a),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,o),i.blitFramebuffer(0,0,e.width,e.height,0,0,n.width,n.height,s,i.NEAREST),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),t.setRenderTarget(null)}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.depthRenderTarget.dispose(),this.depthRenderTarget=null,this.inputBuffer.depthTexture=null,this.outputBuffer.depthTexture=null;for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,r){let i=this.renderer,a=i===null?new D:i.getDrawingBufferSize(new D),o={minFilter:u,magFilter:u,stencilBuffer:t,depthBuffer:e,type:n},s=new c(a.width,a.height,o);return r>0&&(s.samples=r),n===1009&&i!==null&&i.outputColorSpace===`srgb`&&(s.texture.colorSpace=C),s.texture.name=`EffectComposer.Buffer`,s.texture.generateMipmaps=!1,s}setMainScene(e){for(let t of this.passes)t.mainScene=e}setMainCamera(e){for(let t of this.passes)t.mainCamera=e}addPass(e,t){let n=this.passes,r=this.renderer,i=r.getDrawingBufferSize(new D),a=r.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(e.renderer=r,e.setSize(i.width,i.height),e.initialize(r,a,o),this.autoRenderToScreen&&(n.length>0&&(n[n.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t===void 0?n.push(e):n.splice(t,0,e),this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let t=this.createDepthTexture();for(e of n)e.setDepthTexture(t)}else{let t=this.depthRenderTarget.depthTexture;e.setDepthTexture(t)}}removePass(e){let t=this.passes,n=t.indexOf(e);if(n!==-1&&t.splice(n,1).length>0){if(this.depthTexture!==null&&!t.reduce((e,t)=>e||t.needsDepthTexture,!1)){let t=this.depthRenderTarget.depthTexture;e.getDepthTexture()===t&&e.setDepthTexture(null),this.deleteDepthTexture()}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,n=this.copyPass,r=this.inputBuffer,i=this.outputBuffer,a,o=!1;e===void 0&&(this.timer.update(),e=this.timer.getDelta());for(let s of this.passes)if(s.enabled){if(r.depthTexture=this.depthTexture,i.depthTexture=null,s.render(t,r,i,e,o),s.needsDepthBlit&&this.depthRenderTarget!==null&&this.blitDepthBuffer(r),s.needsSwap){if(o){n.renderToScreen=s.renderToScreen;let a=t.getContext(),c=t.state.buffers.stencil;c.setFunc(a.NOTEQUAL,1,4294967295),n.render(t,r,i,e,o),c.setFunc(a.EQUAL,1,4294967295)}a=r,r=i,i=a}s instanceof ye?o=!0:s instanceof pe&&(o=!1)}}setSize(e,t,n){let r=this.renderer,i=r.getSize(new D);(e===void 0||t===void 0)&&(e=i.width,t=i.height),(i.width!==e||i.height!==t)&&r.setSize(e,t,n);let a=r.getDrawingBufferSize(new D);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height),this.depthRenderTarget!==null&&this.depthRenderTarget.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),N.fullscreenGeometry.dispose()}},F={NONE:0,DEPTH:1,CONVOLUTION:2},I={FRAGMENT_HEAD:`FRAGMENT_HEAD`,FRAGMENT_MAIN_UV:`FRAGMENT_MAIN_UV`,FRAGMENT_MAIN_IMAGE:`FRAGMENT_MAIN_IMAGE`,VERTEX_HEAD:`VERTEX_HEAD`,VERTEX_MAIN_SUPPORT:`VERTEX_MAIN_SUPPORT`},we=class{constructor(){this.shaderParts=new Map([[I.FRAGMENT_HEAD,null],[I.FRAGMENT_MAIN_UV,null],[I.FRAGMENT_MAIN_IMAGE,null],[I.VERTEX_HEAD,null],[I.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=F.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=r}};function Te(e){let t;if(e===0)t=new Float64Array;else if(e===1)t=new Float64Array([1]);else if(e>1){let n=new Float64Array(e),r=new Float64Array(e);for(let i=1;i<=e;++i){for(let e=0;e<i;++e)r[e]=e===0||e===i-1?1:n[e-1]+n[e];t=r,r=n,n=t}}return t}var Ee=class{constructor(e,t=2){this.weights=null,this.offsets=null,this.linearWeights=null,this.linearOffsets=null,this.generate(e,t)}get steps(){return this.offsets===null?0:this.offsets.length}get linearSteps(){return this.linearOffsets===null?0:this.linearOffsets.length}generate(e,t){if(e<3||e>1020)throw Error(`The kernel size must be in the range [3, 1020]`);let n=e+t*2,r=t>0?Te(n).slice(t,-t):Te(n),i=Math.floor((r.length-1)/2),a=r.reduce((e,t)=>e+t,0),o=r.slice(i),s=[...Array(i+1).keys()],c=new Float64Array(Math.floor(s.length/2)),l=new Float64Array(c.length);c[0]=o[0]/a;for(let e=1,t=1,n=s.length-1;e<n;e+=2,++t){let n=s[e],r=s[e+1],i=o[e],u=o[e+1],d=i+u,f=(n*i+r*u)/d;c[t]=d/a,l[t]=f}for(let e=0,t=o.length,n=1/a;e<t;++e)o[e]*=n;let u=(c.reduce((e,t)=>e+t,0)-c[0]*.5)*2;if(u!==0)for(let e=0,t=c.length,n=1/u;e<t;++e)c[e]*=n;this.offsets=s,this.weights=o,this.linearOffsets=l,this.linearWeights=c}},De=class{getDelta(){return NaN}getElapsed(){return NaN}},Oe=class{initialize(e,t,n){}},ke=!1,Ae=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case 2:t=this.materialsFlatShadedDoubleSide;break;case 1:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case 2:t=this.materialsDoubleSide;break;case 1:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(e){if(!(e instanceof j))return e.clone();let t=e.uniforms,n=new Map;for(let e in t){let r=t[e].value;r.isRenderTargetTexture&&(t[e].value=null,n.set(e,r))}let r=e.clone();for(let e of n)t[e[0]].value=e[1],r.uniforms[e[0]].value=e[1];return r}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[this.cloneMaterial(e),this.cloneMaterial(e),this.cloneMaterial(e)];for(let n of t)n.uniforms=Object.assign({},e.uniforms),n.side=0;t[2].skinning=!0,this.materialsBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=1,n}),this.materialsDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=2,n}),this.materialsFlatShaded=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=1,n}),this.materialsFlatShadedDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=2,n})}}render(e,t,n){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,ke){let r=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,n);for(let e of r)e[0].material=e[1];this.meshCount!==r.size&&r.clear()}else{let r=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,n),t.overrideMaterial=r}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return ke}static set workaroundEnabled(e){ke=e}},je=class{setSize(e,t){}},L=-1,R=class extends ie{constructor(e,t=L,n=L,r=1){super(),this.resizable=e,this.baseSize=new D(1,1),this.preferredSize=new D(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new D,this.addEventListener(`change`,()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){let e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width===L?t.height===L?n.width=Math.round(e.width*r):n.width=Math.round(t.height*(e.width/Math.max(e.height,1))):n.width=t.width,t.height===L?t.width===L?n.height=Math.round(e.height*r):n.height=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):n.height=t.height}get width(){return this.effectiveSize.width}set width(e){this.preferredWidth=e}get height(){return this.effectiveSize.height}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferredSize.setScalar(L),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.baseSize.width}set baseWidth(e){this.baseSize.width!==e&&(this.baseSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(e){this.baseWidth=e}get baseHeight(){return this.baseSize.height}set baseHeight(e){this.baseSize.height!==e&&(this.baseSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.baseSize.width!==e||this.baseSize.height!==t)&&(this.baseSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(e){this.preferredSize.width!==e&&(this.preferredSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferredSize.height}set preferredHeight(e){this.preferredSize.height!==e&&(this.preferredSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferredSize.width!==e||this.preferredSize.height!==t)&&(this.preferredSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(e){this.s=e.scale,this.baseSize.set(e.baseWidth,e.baseHeight),this.preferredSize.set(e.preferredWidth,e.preferredHeight),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return L}},Me=new class{constructor(e=0){this.nextId=e}getNextId(){return this.nextId++}reset(e=0){return this.nextId=e,this}}(2),Ne=class extends Set{constructor(e,t=Me.getNextId()){super(),this.exclusive=!1,this._layer=t,(this._layer<1||this._layer>31)&&(console.warn(`Layer out of range, resetting to 2`),Me.reset(2),this._layer=Me.getNextId()),e!==void 0&&this.set(e)}get layer(){return this._layer}set layer(e){let t=this._layer;for(let n of this)n.layers.disable(t),n.layers.enable(e);this._layer=e}getLayer(){return this.layer}setLayer(e){this.layer=e}isExclusive(){return this.exclusive}setExclusive(e){this.exclusive=e}clear(){let e=this.layer;for(let t of this)t.layers.disable(e);return super.clear()}set(e){this.clear();for(let t of e)this.add(t);return this}indexOf(e){return this.has(e)?0:-1}add(e){return this.exclusive?e.layers.set(this.layer):e.layers.enable(this.layer),super.add(e)}delete(e){return this.has(e)&&e.layers.disable(this.layer),super.delete(e)}toggle(e){let t;return this.has(e)?(this.delete(e),t=!1):(this.add(e),t=!0),t}setVisible(e){for(let t of this)e?t.layers.enable(0):t.layers.disable(0);return this}},z={SKIP:9,SET:30,ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},Pe=new Map([[z.ADD,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.ALPHA,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,src.a*opacity);}`],[z.AVERAGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=(dst.rgb+src.rgb)*0.5;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.COLOR,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.xy,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.COLOR_BURN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/max(b,1e-9))),vec3(1.0),step(1.0,a));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.COLOR_DODGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.DARKEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.DIFFERENCE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=abs(dst.rgb-src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.DIVIDE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb/max(src.rgb,1e-9);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.DST,null],[z.EXCLUSION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-2.0*dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.HARD_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb,1.0);vec3 b=min(src.rgb,1.0);vec3 c=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.HARD_MIX,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=step(1.0,dst.rgb+src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.HUE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.x,a.yz));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.INVERT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.INVERT_RGB,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=src.rgb*max(1.0-dst.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.LIGHTEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.LINEAR_BURN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.LINEAR_DODGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb+src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.LINEAR_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(2.0*src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.LUMINOSITY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.xy,b.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.MULTIPLY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.NEGATION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-abs(1.0-dst.rgb-src.rgb),0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.NORMAL,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,opacity);}`],[z.OVERLAY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=2.0*src.rgb*dst.rgb;vec3 b=1.0-2.0*(1.0-src.rgb)*(1.0-dst.rgb);vec3 c=mix(a,b,step(0.5,dst.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.PIN_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 c=mix(mix(src2,dst.rgb,step(0.5*dst.rgb,src.rgb)),max(src2-1.0,vec3(0.0)),step(dst.rgb,src2-1.0));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.REFLECT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb*dst.rgb/max(1.0-src.rgb,1e-9),1.0);vec3 c=mix(a,src.rgb,step(1.0,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.SATURATION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.x,b.y,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.SCREEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-min(dst.rgb*src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.SOFT_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 d=dst.rgb+(src2-1.0);vec3 w=step(0.5,src.rgb);vec3 a=dst.rgb-(1.0-src2)*dst.rgb*(1.0-dst.rgb);vec3 b=mix(d*(sqrt(dst.rgb)-dst.rgb),d*dst.rgb*((16.0*dst.rgb-12.0)*dst.rgb+3.0),w*(1.0-step(0.25,dst.rgb)));vec3 c=mix(a,b,w);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.SRC,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return src;}`],[z.SUBTRACT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[z.VIVID_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=mix(max(1.0-min((1.0-dst.rgb)/(2.0*src.rgb),1.0),0.0),min(dst.rgb/(2.0*(1.0-src.rgb)),1.0),step(0.5,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`]]),Fe=class extends ie{constructor(e,t=1){super(),this._blendFunction=e,this.opacity=new M(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this._blendFunction}set blendFunction(e){this._blendFunction=e,this.dispatchEvent({type:`change`})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return Pe.get(this.blendFunction)}},Ie=class extends a{constructor({characters:e=` .:,'-^=*+?!|0#X%WM@`,font:t=`Arial`,fontSize:n=54,size:r=1024,cellCount:i=16}={}){super(document.createElement(`canvas`),void 0,d,d);let a=this.image;a.width=a.height=r;let o=a.getContext(`2d`),s=r/i;o.font=`${n}px ${t}`,o.textAlign=`center`,o.textBaseline=`middle`,o.fillStyle=`#ffffff`;for(let t=0,n=e.length;t<n;++t){let n=e[t],r=t%i,a=Math.floor(t/i);o.fillText(n,r*s+s/2,a*s+s/2)}this.characterCount=e.length,this.cellCount=i}},B=class extends ie{constructor(e,t,{attributes:n=F.NONE,blendFunction:i=z.NORMAL,defines:a=new Map,uniforms:o=new Map,extensions:s=null,vertexShader:c=null}={}){super(),this.name=e,this.renderer=null,this.attributes=n,this.fragmentShader=t,this.vertexShader=c,this.defines=a,this.uniforms=o,this.extensions=s,this.blendMode=new Fe(i),this.blendMode.addEventListener(`change`,e=>this.setChanged()),this._inputColorSpace=r,this._outputColorSpace=``}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(e){this._inputColorSpace=e,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e,this.setChanged()}set mainScene(e){}set mainCamera(e){}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:`change`})}setDepthTexture(e,t=w){}update(e,t,n){}setSize(e,t){}initialize(e,t,n){}dispose(){for(let e of Object.keys(this)){let t=this[e];(t instanceof c||t instanceof oe||t instanceof ne||t instanceof N)&&this[e].dispose()}}},Le=`uniform sampler2D asciiTexture;uniform vec4 cellCount;
#ifdef USE_COLOR
uniform vec3 color;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 pixelizedUv=cellCount.zw*(0.5+floor(uv*cellCount.xy));vec4 texel=texture(inputBuffer,pixelizedUv);float lum=min(luminance(texel.rgb),1.0);
#ifdef INVERTED
lum=1.0-lum;
#endif
float characterIndex=floor(CHAR_COUNT_MINUS_ONE*lum);vec2 characterPosition=vec2(mod(characterIndex,TEX_CELL_COUNT),floor(characterIndex*INV_TEX_CELL_COUNT));vec2 offset=vec2(characterPosition.x,-characterPosition.y)*INV_TEX_CELL_COUNT;vec2 characterUv=mod(uv*(cellCount.xy*INV_TEX_CELL_COUNT),INV_TEX_CELL_COUNT);characterUv=characterUv-vec2(0.0,INV_TEX_CELL_COUNT)+offset;float asciiCharacter=texture(asciiTexture,characterUv).r;
#ifdef USE_COLOR
outputColor=vec4(color*asciiCharacter,inputColor.a);
#else
outputColor=vec4(texel.rgb*asciiCharacter,inputColor.a);
#endif
}`,Re=class extends B{constructor({asciiTexture:e=new Ie,cellSize:n=16,color:r=null,inverted:i=!1}={}){super(`ASCIIEffect`,Le,{uniforms:new Map([[`asciiTexture`,new M(null)],[`cellCount`,new M(new E)],[`color`,new M(new t)]])}),this._cellSize=-1,this.resolution=new D,this.asciiTexture=e,this.cellSize=n,this.color=r,this.inverted=i}get asciiTexture(){return this.uniforms.get(`asciiTexture`).value}set asciiTexture(e){let t=this.uniforms.get(`asciiTexture`).value;if(this.uniforms.get(`asciiTexture`).value=e,t!==null&&t!==e&&t.dispose(),e!==null){let t=e.cellCount;this.defines.set(`CHAR_COUNT_MINUS_ONE`,(e.characterCount-1).toFixed(1)),this.defines.set(`TEX_CELL_COUNT`,t.toFixed(1)),this.defines.set(`INV_TEX_CELL_COUNT`,(1/t).toFixed(9)),this.setChanged()}}get color(){return this.uniforms.get(`color`).value}set color(e){e!==null&&this.uniforms.get(`color`).value.set(e),this.defines.has(`USE_COLOR`)&&e===null?(this.defines.delete(`USE_COLOR`),this.setChanged()):!this.defines.has(`USE_COLOR`)&&e!==null&&(this.defines.set(`USE_COLOR`,`1`),this.setChanged())}get inverted(){return this.defines.has(`INVERTED`)}set inverted(e){this.inverted!==e&&(e?this.defines.set(`INVERTED`,`1`):this.defines.delete(`INVERTED`),this.setChanged())}get cellSize(){return this._cellSize}set cellSize(e){this._cellSize!==e&&(this._cellSize=e,this.updateCellCount())}updateCellCount(){let e=this.uniforms.get(`cellCount`).value,t=this.resolution;e.x=t.width/this.cellSize,e.y=t.height/this.cellSize,e.z=1/e.x,e.w=1/e.y}setSize(e,t){this.resolution.set(e,t),this.updateCellCount()}dispose(){this.asciiTexture!==null&&this.asciiTexture.dispose(),super.dispose()}},V={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},ze=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25;
#include <colorspace_fragment>
}`,Be=`uniform vec4 texelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}`,Ve=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],He=class extends j{constructor(e=new E){super({name:`KawaseBlurMaterial`,uniforms:{inputBuffer:new M(null),texelSize:new M(new E),scale:new M(1),kernel:new M(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:ze,vertexShader:Be}),this.setTexelSize(e.x,e.y),this.kernelSize=V.MEDIUM}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get kernelSequence(){return Ve[this.kernelSize]}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(){return this.uniforms.scale.value}setScale(e){this.uniforms.scale.value=e}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(e){this.uniforms.kernel.value=e}setKernel(e){this.kernel=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t,e*.5,t*.5)}setSize(e,t){let n=1/e,r=1/t;this.uniforms.texelSize.value.set(n,r,n*.5,r*.5)}},H=class extends N{constructor({kernelSize:e=V.MEDIUM,resolutionScale:t=.5,width:n=R.AUTO_SIZE,height:r=R.AUTO_SIZE,resolutionX:i=n,resolutionY:a=r}={}){super(`KawaseBlurPass`),this.renderTargetA=new c(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name=`Blur.Target.A`,this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name=`Blur.Target.B`;let o=this.resolution=new R(this,i,a,t);o.addEventListener(`change`,e=>this.setSize(o.baseWidth,o.baseHeight)),this._blurMaterial=new He,this._blurMaterial.kernelSize=e,this.copyMaterial=new he}getResolution(){return this.resolution}get blurMaterial(){return this._blurMaterial}set blurMaterial(e){this._blurMaterial=e}get dithering(){return this.copyMaterial.dithering}set dithering(e){this.copyMaterial.dithering=e}get kernelSize(){return this.blurMaterial.kernelSize}set kernelSize(e){this.blurMaterial.kernelSize=e}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get scale(){return this.blurMaterial.scale}set scale(e){this.blurMaterial.scale=e}getScale(){return this.blurMaterial.scale}setScale(e){this.blurMaterial.scale=e}getKernelSize(){return this.kernelSize}setKernelSize(e){this.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.renderTargetA,c=this.renderTargetB,l=this.blurMaterial,u=l.kernelSequence,d=t;this.fullscreenMaterial=l;for(let t=0,n=u.length;t<n;++t){let n=t&1?c:s;l.kernel=u[t],l.inputBuffer=d.texture,e.setRenderTarget(n),e.render(a,o),d=n}this.fullscreenMaterial=this.copyMaterial,this.copyMaterial.inputBuffer=d.texture,e.setRenderTarget(this.renderToScreen?null:n),e.render(a,o)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurMaterial.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTargetA.texture.type=n,this.renderTargetB.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTargetA.texture.colorSpace=C,this.renderTargetB.texture.colorSpace=C):(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`,this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`))}static get AUTO_SIZE(){return R.AUTO_SIZE}},Ue=`#include <common>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef RANGE
uniform vec2 range;
#elif defined(THRESHOLD)
uniform float threshold;uniform float smoothing;
#endif
varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0;
#ifdef RANGE
float low=step(range.x,l);float high=step(l,range.y);mask=low*high;
#elif defined(THRESHOLD)
mask=smoothstep(threshold,threshold+smoothing,l);
#endif
#ifdef COLOR
gl_FragColor=texel*mask;
#else
gl_FragColor=vec4(l*mask);
#endif
}`,We=class extends j{constructor(e=!1,t=null){super({name:`LuminanceMaterial`,defines:{THREE_REVISION:o.replace(/\D+/g,``)},uniforms:{inputBuffer:new M(null),threshold:new M(0),smoothing:new M(1),range:new M(null)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ue,vertexShader:P}),this.colorOutput=e,this.luminanceRange=t}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get threshold(){return this.uniforms.threshold.value}set threshold(e){this.smoothing>0||e>0?this.defines.THRESHOLD=`1`:delete this.defines.THRESHOLD,this.uniforms.threshold.value=e}getThreshold(){return this.threshold}setThreshold(e){this.threshold=e}get smoothing(){return this.uniforms.smoothing.value}set smoothing(e){this.threshold>0||e>0?this.defines.THRESHOLD=`1`:delete this.defines.THRESHOLD,this.uniforms.smoothing.value=e}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(e){this.smoothing=e}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(e){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(e){e?this.defines.COLOR=`1`:delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(e){return this.colorOutput}setColorOutputEnabled(e){this.colorOutput=e}get useRange(){return this.luminanceRange!==null}set useRange(e){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(e){e===null?delete this.defines.RANGE:this.defines.RANGE=`1`,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}},Ge=class extends N{constructor({renderTarget:e,luminanceRange:t,colorOutput:n,resolutionScale:r=1,width:i=R.AUTO_SIZE,height:a=R.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`LuminancePass`),this.fullscreenMaterial=new We(n,t),this.needsSwap=!1,this.renderTarget=e,this.renderTarget===void 0&&(this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`LuminancePass.Target`);let l=this.resolution=new R(this,o,s,r);l.addEventListener(`change`,e=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(e,t,n,r,i){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}initialize(e,t,n){n!==void 0&&n!==1009&&(this.renderTarget.texture.type=n,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},Ke=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#define WEIGHT_INNER 0.125
#define WEIGHT_OUTER 0.05556
varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;float clampToBorder(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void main(){vec4 c=vec4(0.0);vec4 w=WEIGHT_INNER*vec4(clampToBorder(vUv00),clampToBorder(vUv01),clampToBorder(vUv02),clampToBorder(vUv03));c+=w.x*texture2D(inputBuffer,vUv00);c+=w.y*texture2D(inputBuffer,vUv01);c+=w.z*texture2D(inputBuffer,vUv02);c+=w.w*texture2D(inputBuffer,vUv03);w=WEIGHT_OUTER*vec4(clampToBorder(vUv04),clampToBorder(vUv05),clampToBorder(vUv06),clampToBorder(vUv07));c+=w.x*texture2D(inputBuffer,vUv04);c+=w.y*texture2D(inputBuffer,vUv05);c+=w.z*texture2D(inputBuffer,vUv06);c+=w.w*texture2D(inputBuffer,vUv07);w=WEIGHT_OUTER*vec4(clampToBorder(vUv08),clampToBorder(vUv09),clampToBorder(vUv10),clampToBorder(vUv11));c+=w.x*texture2D(inputBuffer,vUv08);c+=w.y*texture2D(inputBuffer,vUv09);c+=w.z*texture2D(inputBuffer,vUv10);c+=w.w*texture2D(inputBuffer,vUv11);c+=WEIGHT_OUTER*texture2D(inputBuffer,vUv);gl_FragColor=c;
#include <colorspace_fragment>
}`,qe=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;void main(){vUv=position.xy*0.5+0.5;vUv00=vUv+texelSize*vec2(-1.0,1.0);vUv01=vUv+texelSize*vec2(1.0,1.0);vUv02=vUv+texelSize*vec2(-1.0,-1.0);vUv03=vUv+texelSize*vec2(1.0,-1.0);vUv04=vUv+texelSize*vec2(-2.0,2.0);vUv05=vUv+texelSize*vec2(0.0,2.0);vUv06=vUv+texelSize*vec2(2.0,2.0);vUv07=vUv+texelSize*vec2(-2.0,0.0);vUv08=vUv+texelSize*vec2(2.0,0.0);vUv09=vUv+texelSize*vec2(-2.0,-2.0);vUv10=vUv+texelSize*vec2(0.0,-2.0);vUv11=vUv+texelSize*vec2(2.0,-2.0);gl_Position=vec4(position.xy,1.0,1.0);}`,Je=class extends j{constructor(){super({name:`DownsamplingMaterial`,uniforms:{inputBuffer:new M(null),texelSize:new M(new D)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ke,vertexShader:qe})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},Ye=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer;
#else
uniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer;
#endif
uniform float radius;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vec4 c=vec4(0.0);c+=texture2D(inputBuffer,vUv0)*0.0625;c+=texture2D(inputBuffer,vUv1)*0.125;c+=texture2D(inputBuffer,vUv2)*0.0625;c+=texture2D(inputBuffer,vUv3)*0.125;c+=texture2D(inputBuffer,vUv)*0.25;c+=texture2D(inputBuffer,vUv4)*0.125;c+=texture2D(inputBuffer,vUv5)*0.0625;c+=texture2D(inputBuffer,vUv6)*0.125;c+=texture2D(inputBuffer,vUv7)*0.0625;vec4 baseColor=texture2D(supportBuffer,vUv);gl_FragColor=mix(baseColor,c,radius);
#include <colorspace_fragment>
}`,Xe=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,1.0);vUv1=vUv+texelSize*vec2(0.0,1.0);vUv2=vUv+texelSize*vec2(1.0,1.0);vUv3=vUv+texelSize*vec2(-1.0,0.0);vUv4=vUv+texelSize*vec2(1.0,0.0);vUv5=vUv+texelSize*vec2(-1.0,-1.0);vUv6=vUv+texelSize*vec2(0.0,-1.0);vUv7=vUv+texelSize*vec2(1.0,-1.0);gl_Position=vec4(position.xy,1.0,1.0);}`,Ze=class extends j{constructor(){super({name:`UpsamplingMaterial`,uniforms:{inputBuffer:new M(null),supportBuffer:new M(null),texelSize:new M(new D),radius:new M(.85)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ye,vertexShader:Xe})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}set supportBuffer(e){this.uniforms.supportBuffer.value=e}get radius(){return this.uniforms.radius.value}set radius(e){this.uniforms.radius.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},Qe=class extends N{constructor(){super(`MipmapBlurPass`),this.needsSwap=!1,this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`Upsampling.Mipmap0`,this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new Je,this.upsamplingMaterial=new Ze,this.resolution=new D}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(e){if(this.levels!==e){let t=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let n=0;n<e;++n){let e=t.clone();e.texture.name=`Downsampling.Mipmap`+n,this.downsamplingMipmaps.push(e)}this.upsamplingMipmaps.push(t);for(let n=1,r=e-1;n<r;++n){let e=t.clone();e.texture.name=`Upsampling.Mipmap`+n,this.upsamplingMipmaps.push(e)}this.setSize(this.resolution.x,this.resolution.y)}}get radius(){return this.upsamplingMaterial.radius}set radius(e){this.upsamplingMaterial.radius=e}render(e,t,n,r,i){let{scene:a,camera:o}=this,{downsamplingMaterial:s,upsamplingMaterial:c}=this,{downsamplingMipmaps:l,upsamplingMipmaps:u}=this,d=t;this.fullscreenMaterial=s;for(let t=0,n=l.length;t<n;++t){let n=l[t];s.setSize(d.width,d.height),s.inputBuffer=d.texture,e.setRenderTarget(n),e.render(a,o),d=n}this.fullscreenMaterial=c;for(let t=u.length-1;t>=0;--t){let n=u[t];c.setSize(d.width,d.height),c.inputBuffer=d.texture,c.supportBuffer=l[t].texture,e.setRenderTarget(n),e.render(a,o),d=n}}setSize(e,t){let n=this.resolution;n.set(e,t);let r=n.width,i=n.height;for(let e=0,t=this.downsamplingMipmaps.length;e<t;++e)r=Math.round(r*.5),i=Math.round(i*.5),this.downsamplingMipmaps[e].setSize(r,i),e<this.upsamplingMipmaps.length&&this.upsamplingMipmaps[e].setSize(r,i)}initialize(e,t,n){if(n!==void 0){let t=this.downsamplingMipmaps.concat(this.upsamplingMipmaps);for(let e of t)e.texture.type=n;if(n!==1009)this.downsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`,this.upsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`;else if(e!==null&&e.outputColorSpace===`srgb`)for(let e of t)e.texture.colorSpace=C}}dispose(){super.dispose();for(let e of this.downsamplingMipmaps.concat(this.upsamplingMipmaps))e.dispose()}},$e=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D map;
#else
uniform lowp sampler2D map;
#endif
uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=texture2D(map,uv)*intensity;}`,et=class extends B{constructor({blendFunction:e=z.SCREEN,luminanceThreshold:t=1,luminanceSmoothing:n=.03,mipmapBlur:r=!0,intensity:i=1,radius:a=.85,levels:o=8,kernelSize:s=V.LARGE,resolutionScale:l=.5,width:u=R.AUTO_SIZE,height:d=R.AUTO_SIZE,resolutionX:f=u,resolutionY:p=d}={}){super(`BloomEffect`,$e,{blendFunction:e,uniforms:new Map([[`map`,new M(null)],[`intensity`,new M(i)]])}),this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`Bloom.Target`,this.blurPass=new H({kernelSize:s}),this.luminancePass=new Ge({colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothing=n,this.mipmapBlurPass=new Qe,this.mipmapBlurPass.enabled=r,this.mipmapBlurPass.radius=a,this.mipmapBlurPass.levels=o,this.uniforms.get(`map`).value=r?this.mipmapBlurPass.texture:this.renderTarget.texture;let m=this.resolution=new R(this,f,p,l);m.addEventListener(`change`,e=>this.setSize(m.baseWidth,m.baseHeight))}get texture(){return this.mipmapBlurPass.enabled?this.mipmapBlurPass.texture:this.renderTarget.texture}getTexture(){return this.texture}getResolution(){return this.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get distinction(){return console.warn(this.name,`distinction was removed`),1}set distinction(e){console.warn(this.name,`distinction was removed`)}get intensity(){return this.uniforms.get(`intensity`).value}set intensity(e){this.uniforms.get(`intensity`).value=e}getIntensity(){return this.intensity}setIntensity(e){this.intensity=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}update(e,t,n){let r=this.renderTarget,i=this.luminancePass;i.enabled?(i.render(e,t),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,i.renderTarget):this.blurPass.render(e,i.renderTarget,r)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,t):this.blurPass.render(e,t,r)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.blurPass.resolution.copy(n),this.luminancePass.setSize(e,t),this.mipmapBlurPass.setSize(e,t)}initialize(e,t,n){this.blurPass.initialize(e,t,n),this.luminancePass.initialize(e,t,n),this.mipmapBlurPass.initialize(e,t,n),n!==void 0&&(this.renderTarget.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=C))}},tt=`uniform float focus;uniform float dof;uniform float aperture;uniform float maxBlur;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec2 aspectCorrection=vec2(1.0,aspect);
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearDepth=depth;
#endif
float focusNear=clamp(focus-dof,0.0,1.0);float focusFar=clamp(focus+dof,0.0,1.0);float low=step(linearDepth,focusNear);float high=step(focusFar,linearDepth);float factor=(linearDepth-focusNear)*low+(linearDepth-focusFar)*high;vec2 dofBlur=vec2(clamp(factor*aperture,-maxBlur,maxBlur));vec2 dofblur9=dofBlur*0.9;vec2 dofblur7=dofBlur*0.7;vec2 dofblur4=dofBlur*0.4;vec4 color=inputColor;color+=texture2D(inputBuffer,uv+(vec2(0.0,0.4)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.15,0.37)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.29,0.29)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.37,0.15)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.40,0.0)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.37,-0.15)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.29,-0.29)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.15,-0.37)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.0,-0.4)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.15,0.37)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.29,0.29)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.37,0.15)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.4,0.0)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.37,-0.15)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(-0.29,-0.29)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.15,-0.37)*aspectCorrection)*dofBlur);color+=texture2D(inputBuffer,uv+(vec2(0.15,0.37)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(-0.37,0.15)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(0.37,-0.15)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(-0.15,-0.37)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(-0.15,0.37)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(0.37,0.15)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(-0.37,-0.15)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(0.15,-0.37)*aspectCorrection)*dofblur9);color+=texture2D(inputBuffer,uv+(vec2(0.29,0.29)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(0.40,0.0)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(0.29,-0.29)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(0.0,-0.4)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(-0.29,0.29)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(-0.4,0.0)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(-0.29,-0.29)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(0.0,0.4)*aspectCorrection)*dofblur7);color+=texture2D(inputBuffer,uv+(vec2(0.29,0.29)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(0.4,0.0)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(0.29,-0.29)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(0.0,-0.4)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(-0.29,0.29)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(-0.4,0.0)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(-0.29,-0.29)*aspectCorrection)*dofblur4);color+=texture2D(inputBuffer,uv+(vec2(0.0,0.4)*aspectCorrection)*dofblur4);outputColor=color/41.0;}`,nt=class extends B{constructor({blendFunction:e,focus:t=.5,dof:n=.02,aperture:r=.015,maxBlur:i=1}={}){super(`BokehEffect`,tt,{blendFunction:e,attributes:F.CONVOLUTION|F.DEPTH,uniforms:new Map([[`focus`,new M(t)],[`dof`,new M(n)],[`aperture`,new M(r)],[`maxBlur`,new M(i)]])})}},rt=`uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(color+vec3(0.5),inputColor.a);}`,it=class extends B{constructor({blendFunction:e=z.SRC,brightness:t=0,contrast:n=0}={}){super(`BrightnessContrastEffect`,rt,{blendFunction:e,uniforms:new Map([[`brightness`,new M(t)],[`contrast`,new M(n)]])}),this.inputColorSpace=C}get brightness(){return this.uniforms.get(`brightness`).value}set brightness(e){this.uniforms.get(`brightness`).value=e}getBrightness(){return this.brightness}setBrightness(e){this.brightness=e}get contrast(){return this.uniforms.get(`contrast`).value}set contrast(e){this.uniforms.get(`contrast`).value=e}getContrast(){return this.contrast}setContrast(e){this.contrast=e}},at=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}`,ot=class extends B{constructor(e){super(`ColorAverageEffect`,at,{blendFunction:e})}},st=`uniform float factor;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(floor(inputColor.rgb*factor+0.5)/factor,inputColor.a);}`,ct=class extends B{constructor({blendFunction:e,bits:t=16}={}){super(`ColorDepthEffect`,st,{blendFunction:e,uniforms:new Map([[`factor`,new M(1)]])}),this.bits=0,this.bitDepth=t}get bitDepth(){return this.bits}set bitDepth(e){this.bits=e,this.uniforms.get(`factor`).value=2**(e/3)}getBitDepth(){return this.bitDepth}setBitDepth(e){this.bitDepth=e}},lt=`#ifdef RADIAL_MODULATION
uniform float modulationOffset;
#endif
varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=inputColor.ra;vec2 ba=inputColor.ba;
#ifdef RADIAL_MODULATION
const vec2 center=vec2(0.5);float d=distance(uv,center)*2.0;d=max(d-modulationOffset,0.0);if(vActive>0.0&&d>0.0){ra=texture2D(inputBuffer,mix(uv,vUvR,d)).ra;ba=texture2D(inputBuffer,mix(uv,vUvB,d)).ba;}
#else
if(vActive>0.0){ra=texture2D(inputBuffer,vUvR).ra;ba=texture2D(inputBuffer,vUvB).ba;}
#endif
outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}`,ut=`uniform vec2 offset;varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vActive=(shift.x!=0.0||shift.y!=0.0)?1.0:0.0;vUvR=uv+shift;vUvB=uv-shift;}`,dt=class extends B{constructor({offset:e=new D(.001,5e-4),radialModulation:t=!1,modulationOffset:n=.15}={}){super(`ChromaticAberrationEffect`,lt,{vertexShader:ut,attributes:F.CONVOLUTION,uniforms:new Map([[`offset`,new M(e)],[`modulationOffset`,new M(n)]])}),this.radialModulation=t}get offset(){return this.uniforms.get(`offset`).value}set offset(e){this.uniforms.get(`offset`).value=e}get radialModulation(){return this.defines.has(`RADIAL_MODULATION`)}set radialModulation(e){e?this.defines.set(`RADIAL_MODULATION`,`1`):this.defines.delete(`RADIAL_MODULATION`),this.setChanged()}get modulationOffset(){return this.uniforms.get(`modulationOffset`).value}set modulationOffset(e){this.uniforms.get(`modulationOffset`).value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}},ft=`void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){
#ifdef INVERTED
vec3 color=vec3(1.0-depth);
#else
vec3 color=vec3(depth);
#endif
outputColor=vec4(color,inputColor.a);}`,pt=class extends B{constructor({blendFunction:e=z.SRC,inverted:t=!1}={}){super(`DepthEffect`,ft,{blendFunction:e,attributes:F.DEPTH}),this.inverted=t}get inverted(){return this.defines.has(`INVERTED`)}set inverted(e){this.inverted!==e&&(e?this.defines.set(`INVERTED`,`1`):this.defines.delete(`INVERTED`),this.setChanged())}isInverted(){return this.inverted}setInverted(e){this.inverted=e}},U={RED:0,GREEN:1,BLUE:2,ALPHA:3},mt={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2,MULTIPLY_RGB:3},ht=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#if PASS == 1
uniform vec4 kernel64[32];
#else
uniform vec4 kernel16[8];
#endif
uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;varying vec2 vUv;void main(){
#ifdef FOREGROUND
vec2 cocNearFar=texture2D(cocBuffer,vUv).rg*scale;float coc=cocNearFar.x;
#else
float coc=texture2D(cocBuffer,vUv).g*scale;
#endif
if(coc==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{
#ifdef FOREGROUND
vec2 step=texelSize*max(cocNearFar.x,cocNearFar.y);
#else
vec2 step=texelSize*coc;
#endif
#if PASS == 1
vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0;
#else
vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue;
#endif
}}`,gt=class extends j{constructor(e=!1,t=!1){super({name:`BokehMaterial`,defines:{PASS:e?`2`:`1`},uniforms:{inputBuffer:new M(null),cocBuffer:new M(null),texelSize:new M(new D),kernel64:new M(null),kernel16:new M(null),scale:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:ht,vertexShader:P}),t&&(this.defines.FOREGROUND=`1`),this.generateKernel()}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set cocBuffer(e){this.uniforms.cocBuffer.value=e}setCoCBuffer(e){this.uniforms.cocBuffer.value=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(e){return this.scale}setScale(e){this.scale=e}generateKernel(){let e=new Float64Array(128),t=new Float64Array(32),n=0,r=0;for(let i=0,a=Math.sqrt(80);i<80;++i){let o=i*2.39996323,s=Math.sqrt(i)/a,c=s*Math.cos(o),l=s*Math.sin(o);i%5==0?(t[r++]=c,t[r++]=l):(e[n++]=c,e[n++]=l)}this.uniforms.kernel64.value=e,this.uniforms.kernel16.value=t}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},_t=`#include <common>
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform mat4 projectionMatrix;uniform mat4 projectionMatrixInverse;uniform float cameraNear;uniform float cameraFar;uniform float focusDistance;uniform float focusRange;varying vec2 vUv;float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}
#ifdef PERSPECTIVE_CAMERA
#define getViewZ(depth) perspectiveDepthToViewZ(depth, cameraNear, cameraFar)
#else
#define getViewZ(depth) orthographicDepthToViewZ(depth, cameraNear, cameraFar)
#endif
vec3 getViewPosition(const in vec2 screenPosition,const in float depth,const in float viewZ){vec4 clipPosition=vec4(vec3(screenPosition,depth)*2.0-1.0,1.0);float clipW=projectionMatrix[2][3]*viewZ+projectionMatrix[3][3];clipPosition*=clipW;return(projectionMatrixInverse*clipPosition).xyz;}vec3 getViewPosition(const in vec2 screenPosition,const in float depth){return getViewPosition(screenPosition,depth,getViewZ(depth));}
#define getDistance(viewPosition) length(viewPosition)
void main(){float depth=readDepth(vUv);vec3 viewPosition=getViewPosition(vUv,depth);float distance=getDistance(viewPosition);float signedDistance=distance-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,vt=class extends j{constructor(e=null){super({name:`CircleOfConfusionMaterial`,defines:{DEPTH_PACKING:`0`},uniforms:{depthBuffer:new M(null),projectionMatrix:new M(null),projectionMatrixInverse:new M(null),cameraNear:new M(.3),cameraFar:new M(1e3),focusDistance:new M(0),focusRange:new M(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:_t,vertexShader:P}),this.uniforms.focalLength=this.uniforms.focusRange,e!==null&&this.copyCameraSettings(e)}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(e){this.uniforms.focusDistance.value=e}get worldFocusDistance(){return this.focusDistance}set worldFocusDistance(e){this.focusDistance=e}getFocusDistance(e){this.uniforms.focusDistance.value=e}setFocusDistance(e){this.uniforms.focusDistance.value=e}get focalLength(){return this.focusRange}set focalLength(e){this.focusRange=e}get focusRange(){return this.uniforms.focusRange.value}set focusRange(e){this.uniforms.focusRange.value=e}get worldFocusRange(){return this.focusRange}set worldFocusRange(e){this.focusRange=e}getFocalLength(e){return this.focusRange}setFocalLength(e){this.focusRange=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){this.uniforms.projectionMatrix.value=e.projectionMatrix,this.uniforms.projectionMatrixInverse.value=e.projectionMatrixInverse,this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far;let t=this.defines.PERSPECTIVE_CAMERA!==void 0;e instanceof T?t||(this.defines.PERSPECTIVE_CAMERA=!0,this.needsUpdate=!0):t&&(delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},yt=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef MASK_PRECISION_HIGH
uniform mediump sampler2D maskTexture;
#else
uniform lowp sampler2D maskTexture;
#endif
#if MASK_FUNCTION != 0
uniform float strength;
#endif
varying vec2 vUv;void main(){
#if COLOR_CHANNEL == 0
float mask=texture2D(maskTexture,vUv).r;
#elif COLOR_CHANNEL == 1
float mask=texture2D(maskTexture,vUv).g;
#elif COLOR_CHANNEL == 2
float mask=texture2D(maskTexture,vUv).b;
#else
float mask=texture2D(maskTexture,vUv).a;
#endif
#if MASK_FUNCTION == 0
#ifdef INVERTED
mask=(mask>0.0)?0.0:1.0;
#else
mask=(mask>0.0)?1.0:0.0;
#endif
#else
mask=clamp(mask*strength,0.0,1.0);
#ifdef INVERTED
mask=1.0-mask;
#endif
#endif
#if MASK_FUNCTION == 3
vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=vec4(mask*texel.rgb,texel.a);
#elif MASK_FUNCTION == 2
gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
#else
gl_FragColor=mask*texture2D(inputBuffer,vUv);
#endif
}`,bt=class extends j{constructor(e=null){super({name:`MaskMaterial`,uniforms:{maskTexture:new M(e),inputBuffer:new M(null),strength:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:yt,vertexShader:P}),this.colorChannel=U.RED,this.maskFunction=mt.DISCARD}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set maskTexture(e){this.uniforms.maskTexture.value=e,delete this.defines.MASK_PRECISION_HIGH,e.type!==1009&&(this.defines.MASK_PRECISION_HIGH=`1`),this.needsUpdate=!0}setMaskTexture(e){this.maskTexture=e}set colorChannel(e){this.defines.COLOR_CHANNEL=e.toFixed(0),this.needsUpdate=!0}setColorChannel(e){this.colorChannel=e}set maskFunction(e){this.defines.MASK_FUNCTION=e.toFixed(0),this.needsUpdate=!0}setMaskFunction(e){this.maskFunction=e}get inverted(){return this.defines.INVERTED!==void 0}set inverted(e){this.inverted&&!e?delete this.defines.INVERTED:e&&(this.defines.INVERTED=`1`),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get strength(){return this.uniforms.strength.value}set strength(e){this.uniforms.strength.value=e}getStrength(){return this.strength}setStrength(e){this.strength=e}},W=class extends N{constructor(e,t=`inputBuffer`){super(`ShaderPass`),this.fullscreenMaterial=e,this.input=t}setInput(e){this.input=e}render(e,t,n,r,i){let a=this.fullscreenMaterial.uniforms;t!==null&&a!==void 0&&a[this.input]!==void 0&&(a[this.input].value=t.texture),e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}initialize(e,t,n){n!==void 0&&n!==1009&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},xt=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
#else
uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
#endif
#if MASK_FUNCTION != 1 && MASK_FUNCTION != 2
uniform lowp sampler2D farCoCBuffer;
#endif
uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);
#if MASK_FUNCTION == 1 || MASK_FUNCTION == 2
vec2 cocNearFar=vec2(texture2D(nearCoCBuffer,uv).r,colorFar.a);cocNearFar.x=min(cocNearFar.x*scale,1.0);
#else
vec2 cocNearFar=vec2(texture2D(nearCoCBuffer,uv).r,texture2D(farCoCBuffer,uv).g);cocNearFar=min(cocNearFar*scale,1.0);colorFar.a*=cocNearFar.y;
#endif
vec4 result=inputColor*(1.0-cocNearFar.y)+colorFar;result=mix(result,colorNear,cocNearFar.x);outputColor=result;}`,St=new n,Ct=class extends B{constructor(e,{blendFunction:t,worldFocusDistance:n,worldFocusRange:r,focalLength:i,focusDistance:a=n||3,focusRange:o=r||i||2,bokehScale:s=1,resolutionScale:l=.5,width:u,height:d,resolutionX:f=u||R.AUTO_SIZE,resolutionY:p=d||R.AUTO_SIZE}={}){super(`DepthOfFieldEffect`,xt,{blendFunction:t,attributes:F.DEPTH,uniforms:new Map([[`nearColorBuffer`,new M(null)],[`farColorBuffer`,new M(null)],[`nearCoCBuffer`,new M(null)],[`farCoCBuffer`,new M(null)],[`scale`,new M(1)]])}),this.camera=e,this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`DoF.Intermediate`,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name=`DoF.Masked.Far`,this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name=`DoF.Bokeh.Near`,this.uniforms.get(`nearColorBuffer`).value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name=`DoF.Bokeh.Far`,this.uniforms.get(`farColorBuffer`).value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name=`DoF.CoC`,this.uniforms.get(`farCoCBuffer`).value=this.renderTargetCoC.texture,this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name=`DoF.CoC.Blurred`,this.uniforms.get(`nearCoCBuffer`).value=this.renderTargetCoCBlurred.texture,this.cocPass=new W(new vt(e));let m=this.cocMaterial;m.focusDistance=a,m.focusRange=o,this.blurPass=new H({resolutionScale:l,resolutionX:f,resolutionY:p,kernelSize:V.MEDIUM}),this.maskPass=new W(new bt(this.renderTargetCoC.texture));let h=this.maskPass.fullscreenMaterial;h.colorChannel=U.GREEN,this.maskFunction=mt.MULTIPLY_RGB,this.bokehNearBasePass=new W(new gt(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new W(new gt(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new W(new gt(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new W(new gt(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null;let g=this.resolution=new R(this,f,p,l);g.addEventListener(`change`,e=>this.setSize(g.baseWidth,g.baseHeight)),this.bokehScale=s}set mainCamera(e){this.camera=e,this.cocMaterial.copyCameraSettings(e)}get cocTexture(){return this.renderTargetCoC.texture}get maskFunction(){return this.maskPass.fullscreenMaterial.maskFunction}set maskFunction(e){this.maskFunction!==e&&(this.defines.set(`MASK_FUNCTION`,e.toFixed(0)),this.maskPass.fullscreenMaterial.maskFunction=e,this.setChanged())}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.cocMaterial}getBlurPass(){return this.blurPass}getResolution(){return this.resolution}get bokehScale(){return this.uniforms.get(`scale`).value}set bokehScale(e){this.bokehNearBasePass.fullscreenMaterial.scale=e,this.bokehNearFillPass.fullscreenMaterial.scale=e,this.bokehFarBasePass.fullscreenMaterial.scale=e,this.bokehFarFillPass.fullscreenMaterial.scale=e,this.maskPass.fullscreenMaterial.strength=e,this.uniforms.get(`scale`).value=e}getBokehScale(){return this.bokehScale}setBokehScale(e){this.bokehScale=e}getTarget(){return this.target}setTarget(e){this.target=e}calculateFocusDistance(e){return this.camera.getWorldPosition(St).distanceTo(e)}setDepthTexture(e,t=w){this.cocMaterial.depthBuffer=e,this.cocMaterial.depthPacking=t}update(e,t,n){let r=this.renderTarget,i=this.renderTargetCoC,a=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let e=this.calculateFocusDistance(this.target);this.cocMaterial.focusDistance=e}this.cocPass.render(e,null,i),this.blurPass.render(e,i,a),this.maskPass.render(e,t,o),this.bokehFarBasePass.render(e,o,r),this.bokehFarFillPass.render(e,r,this.renderTargetFar),this.bokehNearBasePass.render(e,t,r),this.bokehNearFillPass.render(e,r,this.renderTargetNear)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.cocPass.setSize(e,t),this.blurPass.setSize(e,t),this.maskPass.setSize(e,t),this.renderTargetFar.setSize(e,t),this.renderTargetCoC.setSize(e,t),this.renderTargetMasked.setSize(e,t),this.renderTarget.setSize(r,i),this.renderTargetNear.setSize(r,i),this.renderTargetCoCBlurred.setSize(r,i),this.bokehNearBasePass.fullscreenMaterial.setSize(e,t),this.bokehNearFillPass.fullscreenMaterial.setSize(e,t),this.bokehFarBasePass.fullscreenMaterial.setSize(e,t),this.bokehFarFillPass.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){this.cocPass.initialize(e,t,n),this.maskPass.initialize(e,t,n),this.bokehNearBasePass.initialize(e,t,n),this.bokehNearFillPass.initialize(e,t,n),this.bokehFarBasePass.initialize(e,t,n),this.bokehFarFillPass.initialize(e,t,n),this.blurPass.initialize(e,t,ce),e.capabilities.logarithmicDepthBuffer&&(this.cocPass.fullscreenMaterial.defines.LOG_DEPTH=`1`),n!==void 0&&(this.renderTarget.texture.type=n,this.renderTargetNear.texture.type=n,this.renderTargetFar.texture.type=n,this.renderTargetMasked.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=C,this.renderTargetNear.texture.colorSpace=C,this.renderTargetFar.texture.colorSpace=C,this.renderTargetMasked.texture.colorSpace=C))}},wt=`uniform vec2 angle;uniform float scale;float pattern(const in vec2 uv){vec2 point=scale*vec2(dot(angle.yx,vec2(uv.x,-uv.y)),dot(angle,uv));return(sin(point.x)*sin(point.y))*4.0;}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(inputColor.rgb*10.0-5.0+pattern(uv*resolution));outputColor=vec4(color,inputColor.a);}`,Tt=class extends B{constructor({blendFunction:e,angle:t=Math.PI*.5,scale:n=1}={}){super(`DotScreenEffect`,wt,{blendFunction:e,uniforms:new Map([[`angle`,new M(new D)],[`scale`,new M(n)]])}),this.angle=t}get angle(){return Math.acos(this.uniforms.get(`angle`).value.y)}set angle(e){this.uniforms.get(`angle`).value.set(Math.sin(e),Math.cos(e))}getAngle(){return this.angle}setAngle(e){this.angle=e}get scale(){return this.uniforms.get(`scale`).value}set scale(e){this.uniforms.get(`scale`).value=e}},Et=`#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))
#define ONE_OVER_TWELVE 0.08333333333333333
varying vec2 vUvDown;varying vec2 vUvUp;varying vec2 vUvLeft;varying vec2 vUvRight;varying vec2 vUvDownLeft;varying vec2 vUvUpRight;varying vec2 vUvUpLeft;varying vec2 vUvDownRight;vec4 fxaa(const in vec4 inputColor,const in vec2 uv){float lumaCenter=luminance(inputColor.rgb);float lumaDown=luminance(texture2D(inputBuffer,vUvDown).rgb);float lumaUp=luminance(texture2D(inputBuffer,vUvUp).rgb);float lumaLeft=luminance(texture2D(inputBuffer,vUvLeft).rgb);float lumaRight=luminance(texture2D(inputBuffer,vUvRight).rgb);float lumaMin=min(lumaCenter,min(min(lumaDown,lumaUp),min(lumaLeft,lumaRight)));float lumaMax=max(lumaCenter,max(max(lumaDown,lumaUp),max(lumaLeft,lumaRight)));float lumaRange=lumaMax-lumaMin;if(lumaRange<max(EDGE_THRESHOLD_MIN,lumaMax*EDGE_THRESHOLD_MAX)){return inputColor;}float lumaDownLeft=luminance(texture2D(inputBuffer,vUvDownLeft).rgb);float lumaUpRight=luminance(texture2D(inputBuffer,vUvUpRight).rgb);float lumaUpLeft=luminance(texture2D(inputBuffer,vUvUpLeft).rgb);float lumaDownRight=luminance(texture2D(inputBuffer,vUvDownRight).rgb);float lumaDownUp=lumaDown+lumaUp;float lumaLeftRight=lumaLeft+lumaRight;float lumaLeftCorners=lumaDownLeft+lumaUpLeft;float lumaDownCorners=lumaDownLeft+lumaDownRight;float lumaRightCorners=lumaDownRight+lumaUpRight;float lumaUpCorners=lumaUpRight+lumaUpLeft;float edgeHorizontal=(abs(-2.0*lumaLeft+lumaLeftCorners)+abs(-2.0*lumaCenter+lumaDownUp)*2.0+abs(-2.0*lumaRight+lumaRightCorners));float edgeVertical=(abs(-2.0*lumaUp+lumaUpCorners)+abs(-2.0*lumaCenter+lumaLeftRight)*2.0+abs(-2.0*lumaDown+lumaDownCorners));bool isHorizontal=(edgeHorizontal>=edgeVertical);float stepLength=isHorizontal?texelSize.y:texelSize.x;float luma1=isHorizontal?lumaDown:lumaLeft;float luma2=isHorizontal?lumaUp:lumaRight;float gradient1=abs(luma1-lumaCenter);float gradient2=abs(luma2-lumaCenter);bool is1Steepest=gradient1>=gradient2;float gradientScaled=0.25*max(gradient1,gradient2);float lumaLocalAverage=0.0;if(is1Steepest){stepLength=-stepLength;lumaLocalAverage=0.5*(luma1+lumaCenter);}else{lumaLocalAverage=0.5*(luma2+lumaCenter);}vec2 currentUv=uv;if(isHorizontal){currentUv.y+=stepLength*0.5;}else{currentUv.x+=stepLength*0.5;}vec2 offset=isHorizontal?vec2(texelSize.x,0.0):vec2(0.0,texelSize.y);vec2 uv1=currentUv-offset*QUALITY(0);vec2 uv2=currentUv+offset*QUALITY(0);float lumaEnd1=luminance(texture2D(inputBuffer,uv1).rgb);float lumaEnd2=luminance(texture2D(inputBuffer,uv2).rgb);lumaEnd1-=lumaLocalAverage;lumaEnd2-=lumaLocalAverage;bool reached1=abs(lumaEnd1)>=gradientScaled;bool reached2=abs(lumaEnd2)>=gradientScaled;bool reachedBoth=reached1&&reached2;if(!reached1){uv1-=offset*QUALITY(1);}if(!reached2){uv2+=offset*QUALITY(1);}if(!reachedBoth){for(int i=2;i<SAMPLES;++i){if(!reached1){lumaEnd1=luminance(texture2D(inputBuffer,uv1).rgb);lumaEnd1=lumaEnd1-lumaLocalAverage;}if(!reached2){lumaEnd2=luminance(texture2D(inputBuffer,uv2).rgb);lumaEnd2=lumaEnd2-lumaLocalAverage;}reached1=abs(lumaEnd1)>=gradientScaled;reached2=abs(lumaEnd2)>=gradientScaled;reachedBoth=reached1&&reached2;if(!reached1){uv1-=offset*QUALITY(i);}if(!reached2){uv2+=offset*QUALITY(i);}if(reachedBoth){break;}}}float distance1=isHorizontal?(uv.x-uv1.x):(uv.y-uv1.y);float distance2=isHorizontal?(uv2.x-uv.x):(uv2.y-uv.y);bool isDirection1=distance1<distance2;float distanceFinal=min(distance1,distance2);float edgeThickness=(distance1+distance2);bool isLumaCenterSmaller=lumaCenter<lumaLocalAverage;bool correctVariation1=(lumaEnd1<0.0)!=isLumaCenterSmaller;bool correctVariation2=(lumaEnd2<0.0)!=isLumaCenterSmaller;bool correctVariation=isDirection1?correctVariation1:correctVariation2;float pixelOffset=-distanceFinal/edgeThickness+0.5;float finalOffset=correctVariation?pixelOffset:0.0;float lumaAverage=ONE_OVER_TWELVE*(2.0*(lumaDownUp+lumaLeftRight)+lumaLeftCorners+lumaRightCorners);float subPixelOffset1=clamp(abs(lumaAverage-lumaCenter)/lumaRange,0.0,1.0);float subPixelOffset2=(-2.0*subPixelOffset1+3.0)*subPixelOffset1*subPixelOffset1;float subPixelOffsetFinal=subPixelOffset2*subPixelOffset2*SUBPIXEL_QUALITY;finalOffset=max(finalOffset,subPixelOffsetFinal);vec2 finalUv=uv;if(isHorizontal){finalUv.y+=finalOffset*stepLength;}else{finalUv.x+=finalOffset*stepLength;}return texture2D(inputBuffer,finalUv);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=fxaa(inputColor,uv);}`,Dt=`varying vec2 vUvDown;varying vec2 vUvUp;varying vec2 vUvLeft;varying vec2 vUvRight;varying vec2 vUvDownLeft;varying vec2 vUvUpRight;varying vec2 vUvUpLeft;varying vec2 vUvDownRight;void mainSupport(const in vec2 uv){vUvDown=uv+vec2(0.0,-1.0)*texelSize;vUvUp=uv+vec2(0.0,1.0)*texelSize;vUvRight=uv+vec2(1.0,0.0)*texelSize;vUvLeft=uv+vec2(-1.0,0.0)*texelSize;vUvDownLeft=uv+vec2(-1.0,-1.0)*texelSize;vUvUpRight=uv+vec2(1.0,1.0)*texelSize;vUvUpLeft=uv+vec2(-1.0,1.0)*texelSize;vUvDownRight=uv+vec2(1.0,-1.0)*texelSize;}`,Ot=class extends B{constructor({blendFunction:e=z.SRC}={}){super(`FXAAEffect`,Et,{vertexShader:Dt,blendFunction:e,defines:new Map([[`EDGE_THRESHOLD_MIN`,`0.0312`],[`EDGE_THRESHOLD_MAX`,`0.125`],[`SUBPIXEL_QUALITY`,`0.75`],[`SAMPLES`,`12`]])})}get minEdgeThreshold(){return Number(this.defines.get(`EDGE_THRESHOLD_MIN`))}set minEdgeThreshold(e){this.defines.set(`EDGE_THRESHOLD_MIN`,e.toFixed(12)),this.setChanged()}get maxEdgeThreshold(){return Number(this.defines.get(`EDGE_THRESHOLD_MAX`))}set maxEdgeThreshold(e){this.defines.set(`EDGE_THRESHOLD_MAX`,e.toFixed(12)),this.setChanged()}get subpixelQuality(){return Number(this.defines.get(`SUBPIXEL_QUALITY`))}set subpixelQuality(e){this.defines.set(`SUBPIXEL_QUALITY`,e.toFixed(12)),this.setChanged()}get samples(){return Number(this.defines.get(`SAMPLES`))}set samples(e){this.defines.set(`SAMPLES`,e.toFixed(0)),this.setChanged()}},kt=`uniform float gamma;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=LinearToGamma(max(inputColor,0.0),gamma);}`,At=class extends B{constructor({blendFunction:e=z.SRC,gamma:t=2}={}){super(`GammaCorrectionEffect`,kt,{blendFunction:e,uniforms:new Map([[`gamma`,new M(t)]])})}},jt={DISABLED:0,SPORADIC:1,CONSTANT_MILD:2,CONSTANT_WILD:3};function Mt(e,t,n){let r=new Map([[ae,1],[_,2],[p,4]]),i;if(r.has(t)||console.error(`Invalid noise texture format`),n===1009){i=new Uint8Array(e*r.get(t));for(let e=0,t=i.length;e<t;++e)i[e]=Math.random()*255+.5}else{i=new Float32Array(e*r.get(t));for(let e=0,t=i.length;e<t;++e)i[e]=Math.random()}return i}var Nt=class extends l{constructor(e,t,n=ae,r=ce){super(Mt(e*t,n,r),e,t,n,r),this.needsUpdate=!0}},Pt=`uniform lowp sampler2D perturbationMap;uniform bool active;uniform float columns;uniform float random;uniform vec2 seeds;uniform vec2 distortion;void mainUv(inout vec2 uv){if(active){if(uv.y<distortion.x+columns&&uv.y>distortion.x-columns*random){float sx=clamp(ceil(seeds.x),0.0,1.0);uv.y=sx*(1.0-(uv.y+distortion.y))+(1.0-sx)*distortion.y;}if(uv.x<distortion.y+columns&&uv.x>distortion.y-columns*random){float sy=clamp(ceil(seeds.y),0.0,1.0);uv.x=sy*distortion.x+(1.0-sy)*(1.0-(uv.x+distortion.x));}vec2 normal=texture2D(perturbationMap,uv*random*random).rg;uv+=normal*seeds*(random*0.2);}}`,Ft=`Glitch.Generated`;function G(e,t){return e+Math.random()*(t-e)}var It=class extends B{constructor({chromaticAberrationOffset:e=null,delay:t=new D(1.5,3.5),duration:n=new D(.6,1),strength:r=new D(.3,1),columns:i=.05,ratio:a=.85,perturbationMap:o=null,dtSize:s=64}={}){if(super(`GlitchEffect`,Pt,{uniforms:new Map([[`perturbationMap`,new M(null)],[`columns`,new M(i)],[`active`,new M(!1)],[`random`,new M(1)],[`seeds`,new M(new D)],[`distortion`,new M(new D)]])}),o===null){let e=new Nt(s,s,p);e.name=Ft,this.perturbationMap=e}else this.perturbationMap=o;this.time=0,this.distortion=this.uniforms.get(`distortion`).value,this.delay=t,this.duration=n,this.breakPoint=new D(G(this.delay.x,this.delay.y),G(this.duration.x,this.duration.y)),this.strength=r,this.mode=jt.SPORADIC,this.ratio=a,this.chromaticAberrationOffset=e}get seeds(){return this.uniforms.get(`seeds`).value}get active(){return this.uniforms.get(`active`).value}isActive(){return this.active}get minDelay(){return this.delay.x}set minDelay(e){this.delay.x=e}getMinDelay(){return this.delay.x}setMinDelay(e){this.delay.x=e}get maxDelay(){return this.delay.y}set maxDelay(e){this.delay.y=e}getMaxDelay(){return this.delay.y}setMaxDelay(e){this.delay.y=e}get minDuration(){return this.duration.x}set minDuration(e){this.duration.x=e}getMinDuration(){return this.duration.x}setMinDuration(e){this.duration.x=e}get maxDuration(){return this.duration.y}set maxDuration(e){this.duration.y=e}getMaxDuration(){return this.duration.y}setMaxDuration(e){this.duration.y=e}get minStrength(){return this.strength.x}set minStrength(e){this.strength.x=e}getMinStrength(){return this.strength.x}setMinStrength(e){this.strength.x=e}get maxStrength(){return this.strength.y}set maxStrength(e){this.strength.y=e}getMaxStrength(){return this.strength.y}setMaxStrength(e){this.strength.y=e}getMode(){return this.mode}setMode(e){this.mode=e}getGlitchRatio(){return 1-this.ratio}setGlitchRatio(e){this.ratio=Math.min(Math.max(1-e,0),1)}get columns(){return this.uniforms.get(`columns`).value}set columns(e){this.uniforms.get(`columns`).value=e}getGlitchColumns(){return this.columns}setGlitchColumns(e){this.columns=e}getChromaticAberrationOffset(){return this.chromaticAberrationOffset}setChromaticAberrationOffset(e){this.chromaticAberrationOffset=e}get perturbationMap(){return this.uniforms.get(`perturbationMap`).value}set perturbationMap(e){let t=this.perturbationMap;t!==null&&t.name===Ft&&t.dispose(),e.minFilter=e.magFilter=k,e.wrapS=e.wrapT=d,e.generateMipmaps=!1,this.uniforms.get(`perturbationMap`).value=e}getPerturbationMap(){return this.perturbationMap}setPerturbationMap(e){this.perturbationMap=e}generatePerturbationMap(e=64){let t=new Nt(e,e,p);return t.name=Ft,t}update(e,t,n){let r=this.mode,i=this.breakPoint,a=this.chromaticAberrationOffset,o=this.strength,s=this.time,c=!1,l=0,u=0,d;r!==jt.DISABLED&&(r===jt.SPORADIC&&(s+=n,d=s>i.x,s>=i.x+i.y&&(i.set(G(this.delay.x,this.delay.y),G(this.duration.x,this.duration.y)),s=0)),l=Math.random(),this.uniforms.get(`random`).value=l,d&&l>this.ratio||r===jt.CONSTANT_WILD?(c=!0,l*=o.y*.03,u=G(-Math.PI,Math.PI),this.seeds.set(G(-o.y,o.y),G(-o.y,o.y)),this.distortion.set(G(0,1),G(0,1))):(d||r===jt.CONSTANT_MILD)&&(c=!0,l*=o.x*.03,u=G(-Math.PI,Math.PI),this.seeds.set(G(-o.x,o.x),G(-o.x,o.x)),this.distortion.set(G(0,1),G(0,1))),this.time=s),a!==null&&(c?a.set(Math.cos(u),Math.sin(u)).multiplyScalar(l):a.set(0,0)),this.uniforms.get(`active`).value=c}dispose(){let e=this.perturbationMap;e!==null&&e.name===Ft&&e.dispose()}},Lt=`#include <common>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform vec2 lightPosition;uniform float exposure;uniform float decay;uniform float density;uniform float weight;uniform float clampMax;varying vec2 vUv;void main(){vec2 coord=vUv;vec2 delta=lightPosition-coord;delta*=1.0/SAMPLES_FLOAT*density;float illuminationDecay=1.0;vec4 color=vec4(0.0);for(int i=0;i<SAMPLES_INT;++i){coord+=delta;vec4 texel=texture2D(inputBuffer,coord);texel*=illuminationDecay*weight;color+=texel;illuminationDecay*=decay;}gl_FragColor=clamp(color*exposure,0.0,clampMax);
#include <dithering_fragment>
}`,Rt=class extends j{constructor(e){super({name:`GodRaysMaterial`,defines:{SAMPLES_INT:`60`,SAMPLES_FLOAT:`60.0`},uniforms:{inputBuffer:new M(null),lightPosition:new M(e),density:new M(1),decay:new M(1),weight:new M(1),exposure:new M(1),clampMax:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Lt,vertexShader:P})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get lightPosition(){return this.uniforms.lightPosition.value}getLightPosition(){return this.uniforms.lightPosition.value}setLightPosition(e){this.uniforms.lightPosition.value=e}get density(){return this.uniforms.density.value}set density(e){this.uniforms.density.value=e}getDensity(){return this.uniforms.density.value}setDensity(e){this.uniforms.density.value=e}get decay(){return this.uniforms.decay.value}set decay(e){this.uniforms.decay.value=e}getDecay(){return this.uniforms.decay.value}setDecay(e){this.uniforms.decay.value=e}get weight(){return this.uniforms.weight.value}set weight(e){this.uniforms.weight.value=e}getWeight(){return this.uniforms.weight.value}setWeight(e){this.uniforms.weight.value=e}get exposure(){return this.uniforms.exposure.value}set exposure(e){this.uniforms.exposure.value=e}getExposure(){return this.uniforms.exposure.value}setExposure(e){this.uniforms.exposure.value=e}get maxIntensity(){return this.uniforms.clampMax.value}set maxIntensity(e){this.uniforms.clampMax.value=e}getMaxIntensity(){return this.uniforms.clampMax.value}setMaxIntensity(e){this.uniforms.clampMax.value=e}get samples(){return Number(this.defines.SAMPLES_INT)}set samples(e){let t=Math.floor(e);this.defines.SAMPLES_INT=t.toFixed(0),this.defines.SAMPLES_FLOAT=t.toFixed(1),this.needsUpdate=!0}getSamples(){return this.samples}setSamples(e){this.samples=e}},zt=class extends N{constructor(e,t,n=null){super(`RenderPass`,e,t),this.needsSwap=!1,this.needsDepthBlit=!0,this.clearPass=new ve,this.overrideMaterialManager=n===null?null:new Ae(n),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e===null?null:e.material}set overrideMaterial(e){let t=this.overrideMaterialManager;e===null?t!==null&&(t.dispose(),this.overrideMaterialManager=null):t===null?this.overrideMaterialManager=new Ae(e):t.setMaterial(e)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.selection,c=o.layers.mask,l=a.background,u=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;s!==null&&o.layers.set(s.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager===null?e.render(a,o):this.overrideMaterialManager.render(e,a,o),o.layers.mask=c,a.background=l,e.shadowMap.autoUpdate=u}},Bt=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D map;
#else
uniform lowp sampler2D map;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=texture2D(map,uv);}`,Vt=new n,Ht=new S,Ut=class extends B{constructor(e,t,{blendFunction:n=z.SCREEN,samples:r=60,density:i=.96,decay:a=.9,weight:o=.4,exposure:s=.6,clampMax:l=1,blur:u=!0,kernelSize:d=V.SMALL,resolutionScale:f=.5,width:p=R.AUTO_SIZE,height:h=R.AUTO_SIZE,resolutionX:g=p,resolutionY:_=h}={}){super(`GodRaysEffect`,Bt,{blendFunction:n,attributes:F.DEPTH,uniforms:new Map([[`map`,new M(null)]])}),this.camera=e,this._lightSource=t,this.lightSource=t,this.lightScene=new m,this.screenPosition=new D,this.renderTargetA=new c(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name=`GodRays.Target.A`,this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name=`GodRays.Target.B`,this.uniforms.get(`map`).value=this.renderTargetB.texture,this.renderTargetLight=new c(1,1),this.renderTargetLight.texture.name=`GodRays.Light`,this.renderTargetLight.depthTexture=new x,this.renderPassLight=new zt(this.lightScene,e),this.renderPassLight.clearPass.enabled=!1,this.blurPass=new H({kernelSize:d}),this.blurPass.enabled=u,this.copyPass=new ge(this.renderTargetLight),this.copyPass.fullscreenMaterial.channelWeights=new E(0,0,0,1),this.godRaysPass=new W(new Rt(this.screenPosition));let v=this.godRaysMaterial;v.density=i,v.decay=a,v.weight=o,v.exposure=s,v.maxIntensity=l,v.samples=r;let y=this.resolution=new R(this,g,_,f);y.addEventListener(`change`,e=>this.setSize(y.baseWidth,y.baseHeight))}set mainCamera(e){this.camera=e,this.renderPassLight.mainCamera=e}get lightSource(){return this._lightSource}set lightSource(e){this._lightSource=e,e!==null&&(e.material.depthWrite=!1,e.material.transparent=!0)}getBlurPass(){return this.blurPass}get texture(){return this.renderTargetB.texture}getTexture(){return this.texture}get godRaysMaterial(){return this.godRaysPass.fullscreenMaterial}getGodRaysMaterial(){return this.godRaysMaterial}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get dithering(){return this.godRaysMaterial.dithering}set dithering(e){let t=this.godRaysMaterial;t.dithering=e,t.needsUpdate=!0}get blur(){return this.blurPass.enabled}set blur(e){this.blurPass.enabled=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}get samples(){return this.godRaysMaterial.samples}set samples(e){this.godRaysMaterial.samples=e}setDepthTexture(e,t=w){this.copyPass.fullscreenMaterial.depthBuffer=e,this.copyPass.fullscreenMaterial.depthPacking=t}update(e,t,n){let r=this.lightSource,i=r.parent,a=r.matrixAutoUpdate,o=this.renderTargetA,s=this.renderTargetLight;r.material.depthWrite=!0,r.matrixAutoUpdate=!1,r.updateWorldMatrix(!0,!1),i!==null&&(a||Ht.copy(r.matrix),r.matrix.copy(r.matrixWorld)),this.lightScene.add(r),this.copyPass.render(e,t),this.renderPassLight.render(e,s),r.material.depthWrite=!1,r.matrixAutoUpdate=a,i!==null&&(a||r.matrix.copy(Ht),i.add(r)),Vt.setFromMatrixPosition(r.matrixWorld).project(this.camera),this.screenPosition.set(Math.min(Math.max((Vt.x+1)*.5,-1),2),Math.min(Math.max((Vt.y+1)*.5,-1),2));let c=s;this.blurPass.enabled&&(this.blurPass.render(e,c,o),c=o),this.godRaysPass.render(e,c,this.renderTargetB)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.renderTargetLight.setSize(e,t),this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurPass.resolution.copy(n)}initialize(e,t,n){this.blurPass.initialize(e,t,n),this.renderPassLight.initialize(e,t,n),this.copyPass.initialize(e,t,n),this.godRaysPass.initialize(e,t,n),n!==void 0&&(this.renderTargetA.texture.type=n,this.renderTargetB.texture.type=n,this.renderTargetLight.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTargetA.texture.colorSpace=C,this.renderTargetB.texture.colorSpace=C,this.renderTargetLight.texture.colorSpace=C))}},Wt=`uniform vec2 scale;uniform float lineWidth;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float grid=0.5-max(abs(mod(uv.x*scale.x,1.0)-0.5),abs(mod(uv.y*scale.y,1.0)-0.5));outputColor=vec4(vec3(smoothstep(0.0,lineWidth,grid)),inputColor.a);}`,Gt=class extends B{constructor({blendFunction:e=z.OVERLAY,scale:t=1,lineWidth:n=0}={}){super(`GridEffect`,Wt,{blendFunction:e,uniforms:new Map([[`scale`,new M(new D)],[`lineWidth`,new M(n)]])}),this.resolution=new D,this.s=0,this.scale=t,this.l=0,this.lineWidth=n}get scale(){return this.s}set scale(e){this.s=Math.max(e,1e-6),this.setSize(this.resolution.width,this.resolution.height)}getScale(){return this.scale}setScale(e){this.scale=e}get lineWidth(){return this.l}set lineWidth(e){this.l=e,this.setSize(this.resolution.width,this.resolution.height)}getLineWidth(){return this.lineWidth}setLineWidth(e){this.lineWidth=e}setSize(e,t){this.resolution.set(e,t);let n=e/t,r=this.scale*(t*.125);this.uniforms.get(`scale`).value.set(n*r,r),this.uniforms.get(`lineWidth`).value=r/t+this.lineWidth}},Kt=`uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}`,qt=class extends B{constructor({blendFunction:e=z.SRC,hue:t=0,saturation:r=0}={}){super(`HueSaturationEffect`,Kt,{blendFunction:e,uniforms:new Map([[`hue`,new M(new n)],[`saturation`,new M(r)]])}),this.hue=t}get saturation(){return this.uniforms.get(`saturation`).value}set saturation(e){this.uniforms.get(`saturation`).value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get(`hue`).value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),n=Math.cos(e);this.uniforms.get(`hue`).value.set((2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}},Jt=`uniform vec2 distortion;uniform vec2 principalPoint;uniform vec2 focalLength;uniform float skew;float mask(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void mainUv(inout vec2 uv){vec2 xn=2.0*(uv.st-0.5);vec3 xDistorted=vec3((1.0+distortion*dot(xn,xn))*xn,1.0);mat3 kk=mat3(vec3(focalLength.x,0.0,0.0),vec3(skew*focalLength.x,focalLength.y,0.0),vec3(principalPoint.x,principalPoint.y,1.0));uv=(kk*xDistorted).xy*0.5+0.5;}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=mask(uv)*inputColor;}`,Yt=class extends B{constructor({distortion:e=new D(0,0),principalPoint:t=new D(0,0),focalLength:n=new D(1,1),skew:r=0}={}){super(`LensDistortionEffect`,Jt,{uniforms:new Map([[`distortion`,new M(e)],[`principalPoint`,new M(t)],[`focalLength`,new M(n)],[`skew`,new M(r)]])})}get distortion(){return this.uniforms.get(`distortion`).value}set distortion(e){this.uniforms.get(`distortion`).value=e}get principalPoint(){return this.uniforms.get(`principalPoint`).value}set principalPoint(e){this.uniforms.get(`principalPoint`).value=e}get focalLength(){return this.uniforms.get(`focalLength`).value}set focalLength(e){this.uniforms.get(`focalLength`).value=e}get skew(){return this.uniforms.get(`skew`).value}set skew(e){this.uniforms.get(`skew`).value=e}},Xt=`#ifdef LUT_PRECISION_HIGH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D lut;
#else
uniform mediump sampler2D lut;
#endif
#else
uniform lowp sampler2D lut;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(texture2D(lut,vec2(inputColor.r,0.5)).r,texture2D(lut,vec2(inputColor.g,0.5)).r,texture2D(lut,vec2(inputColor.b,0.5)).r,inputColor.a);}`,Zt=class extends B{constructor(e,{blendFunction:t=z.SRC}={}){super(`LUT1DEffect`,Xt,{blendFunction:t,uniforms:new Map([[`lut`,new M(null)]])}),this.lut=e}get lut(){return this.uniforms.get(`lut`).value}set lut(e){this.uniforms.get(`lut`).value=e,e!==null&&(e.type===1015||e.type===1016)&&this.defines.set(`LUT_PRECISION_HIGH`,`1`)}},Qt={SCALE_UP:`lut.scaleup`};function $t(e,t,n){let r=document.createElement(`canvas`),i=r.getContext(`2d`);if(r.width=e,r.height=t,n instanceof Image)i.drawImage(n,0,0);else{let r=i.createImageData(e,t);r.data.set(n),i.putImageData(r,0,0)}return r}var K=class e{constructor(e=0,t=0,n=null){this.width=e,this.height=t,this.data=n}toCanvas(){return typeof document>`u`?null:$t(this.width,this.height,this.data)}static from(t){let{width:n,height:r}=t,i;if(t instanceof Image){let e=$t(n,r,t);e!==null&&(i=e.getContext(`2d`).getImageData(0,0,n,r).data)}else i=t.data;return new e(n,r,i)}},en=`"use strict";(()=>{var O={SCALE_UP:"lut.scaleup"};var _=[new Float32Array(3),new Float32Array(3)],n=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],Z=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];function d(a,t,r,m){let i=r[0]-t[0],e=r[1]-t[1],y=r[2]-t[2],h=a[0]-t[0],A=a[1]-t[1],w=a[2]-t[2],c=e*w-y*A,l=y*h-i*w,x=i*A-e*h,u=Math.sqrt(c*c+l*l+x*x),b=u*.5,s=c/u,F=l/u,f=x/u,p=-(a[0]*s+a[1]*F+a[2]*f),M=m[0]*s+m[1]*F+m[2]*f;return Math.abs(M+p)*b/3}function V(a,t,r,m,i,e){let y=(r+m*t+i*t*t)*4;e[0]=a[y+0],e[1]=a[y+1],e[2]=a[y+2]}function k(a,t,r,m,i,e){let y=r*(t-1),h=m*(t-1),A=i*(t-1),w=Math.floor(y),c=Math.floor(h),l=Math.floor(A),x=Math.ceil(y),u=Math.ceil(h),b=Math.ceil(A),s=y-w,F=h-c,f=A-l;if(w===y&&c===h&&l===A)V(a,t,y,h,A,e);else{let p;s>=F&&F>=f?p=Z[0]:s>=f&&f>=F?p=Z[1]:f>=s&&s>=F?p=Z[2]:F>=s&&s>=f?p=Z[3]:F>=f&&f>=s?p=Z[4]:f>=F&&F>=s&&(p=Z[5]);let[M,g,X,Y]=p,P=_[0];P[0]=s,P[1]=F,P[2]=f;let o=_[1],L=x-w,S=u-c,U=b-l;o[0]=L*M[0]+w,o[1]=S*M[1]+c,o[2]=U*M[2]+l,V(a,t,o[0],o[1],o[2],n[0]),o[0]=L*g[0]+w,o[1]=S*g[1]+c,o[2]=U*g[2]+l,V(a,t,o[0],o[1],o[2],n[1]),o[0]=L*X[0]+w,o[1]=S*X[1]+c,o[2]=U*X[2]+l,V(a,t,o[0],o[1],o[2],n[2]),o[0]=L*Y[0]+w,o[1]=S*Y[1]+c,o[2]=U*Y[2]+l,V(a,t,o[0],o[1],o[2],n[3]);let T=d(g,X,Y,P)*6,q=d(M,X,Y,P)*6,C=d(M,g,Y,P)*6,E=d(M,g,X,P)*6;n[0][0]*=T,n[0][1]*=T,n[0][2]*=T,n[1][0]*=q,n[1][1]*=q,n[1][2]*=q,n[2][0]*=C,n[2][1]*=C,n[2][2]*=C,n[3][0]*=E,n[3][1]*=E,n[3][2]*=E,e[0]=n[0][0]+n[1][0]+n[2][0]+n[3][0],e[1]=n[0][1]+n[1][1]+n[2][1]+n[3][1],e[2]=n[0][2]+n[1][2]+n[2][2]+n[3][2]}}var v=class{static expand(t,r){let m=Math.cbrt(t.length/4),i=new Float32Array(3),e=new t.constructor(r**3*4),y=t instanceof Uint8Array?255:1,h=r**2,A=1/(r-1);for(let w=0;w<r;++w)for(let c=0;c<r;++c)for(let l=0;l<r;++l){let x=l*A,u=c*A,b=w*A,s=Math.round(l+c*r+w*h)*4;k(t,m,x,u,b,i),e[s+0]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=y}return e}};self.addEventListener("message",a=>{let t=a.data,r=t.data;t.operation===O.SCALE_UP&&(r=v.expand(r,t.size)),postMessage(r,[r.buffer]),close()});})();
`,tn=new t,nn=class e extends y{constructor(e,t){super(e,t,t,t),this.type=A,this.format=p,this.minFilter=u,this.magFilter=u,this.wrapS=f,this.wrapT=f,this.wrapR=f,this.unpackAlignment=1,this.needsUpdate=!0,this.colorSpace=r,this.domainMin=new n(0,0,0),this.domainMax=new n(1,1,1)}get isLookupTexture3D(){return!0}scaleUp(t,n=!0){let r=this.image,i;return i=t<=r.width?Promise.reject(Error(`The target size must be greater than the current size`)):new Promise((i,a)=>{let o=URL.createObjectURL(new Blob([en],{type:`text/javascript`})),s=new Worker(o);s.addEventListener(`error`,e=>a(e.error)),s.addEventListener(`message`,n=>{let r=new e(n.data,t);this.colorSpace=r.colorSpace,r.type=this.type,r.name=this.name,URL.revokeObjectURL(o),i(r)});let c=n?[r.data.buffer]:[];s.postMessage({operation:Qt.SCALE_UP,data:r.data,size:t},c)}),i}applyLUT(e){let t=this.image,n=e.image,r=Math.min(t.width,t.height,t.depth);if(r!==Math.min(n.width,n.height,n.depth))console.error(`Size mismatch`);else if(e.type!==1015||this.type!==1015)console.error(`Both LUTs must be FloatType textures`);else if(e.format!==1023||this.format!==1023)console.error(`Both LUTs must be RGBA textures`);else{let e=t.data,i=n.data,a=r,o=a**2,s=a-1;for(let t=0,n=a**3;t<n;++t){let n=t*4,r=e[n+0]*s,c=e[n+1]*s,l=e[n+2]*s,u=Math.round(r+c*a+l*o)*4;e[n+0]=i[u+0],e[n+1]=i[u+1],e[n+2]=i[u+2]}this.needsUpdate=!0}return this}convertToUint8(){if(this.type===1015){let e=this.image.data,t=new Uint8Array(e.length);for(let n=0,r=e.length;n<r;++n)t[n]=e[n]*255+.5;this.image.data=t,this.type=ce,this.needsUpdate=!0}return this}convertToFloat(){if(this.type===1009){let e=this.image.data,t=new Float32Array(e.length);for(let n=0,r=e.length;n<r;++n)t[n]=e[n]/255;this.image.data=t,this.type=A,this.needsUpdate=!0}return this}convertToRGBA(){return console.warn(`LookupTexture`,`convertToRGBA() is deprecated, LUTs are now RGBA by default`),this}convertLinearToSRGB(){let e=this.image.data;if(this.type===1015){for(let t=0,n=e.length;t<n;t+=4)tn.fromArray(e,t).convertLinearToSRGB().toArray(e,t);this.colorSpace=C,this.needsUpdate=!0}else console.error(`Color space conversion requires FloatType data`);return this}convertSRGBToLinear(){let e=this.image.data;if(this.type===1015){for(let t=0,n=e.length;t<n;t+=4)tn.fromArray(e,t).convertSRGBToLinear().toArray(e,t);this.colorSpace=r,this.needsUpdate=!0}else console.error(`Color space conversion requires FloatType data`);return this}toDataTexture(){let e=this.image.width,t=this.image.height*this.image.depth,n=new l(this.image.data,e,t);return n.name=this.name,n.type=this.type,n.format=this.format,n.minFilter=u,n.magFilter=u,n.wrapS=this.wrapS,n.wrapT=this.wrapT,n.generateMipmaps=!1,n.needsUpdate=!0,this.colorSpace=n.colorSpace,n}static from(t){let n=t.image,{width:r,height:i}=n,a=Math.min(r,i),o;if(n instanceof Image){let e=K.from(n).data;if(r>i){o=new Uint8Array(e.length);for(let t=0;t<a;++t)for(let n=0;n<a;++n)for(let r=0;r<a;++r){let i=(r+t*a+n*a*a)*4,s=(r+n*a+t*a*a)*4;o[s+0]=e[i+0],o[s+1]=e[i+1],o[s+2]=e[i+2],o[s+3]=e[i+3]}}else o=new Uint8Array(e.buffer)}else o=n.data.slice();let s=new e(o,a);return s.type=t.type,s.name=t.name,t.colorSpace=s.colorSpace,s}static createNeutral(t){let n=new Float32Array(t**3*4),r=t**2,i=1/(t-1);for(let e=0;e<t;++e)for(let a=0;a<t;++a)for(let o=0;o<t;++o){let s=(e+a*t+o*r)*4;n[s+0]=e*i,n[s+1]=a*i,n[s+2]=o*i,n[s+3]=1}let a=new e(n,t);return a.name=`neutral`,a}},rn=`uniform vec3 scale;uniform vec3 offset;
#ifdef CUSTOM_INPUT_DOMAIN
uniform vec3 domainMin;uniform vec3 domainMax;
#endif
#ifdef LUT_3D
#ifdef LUT_PRECISION_HIGH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler3D lut;
#else
uniform mediump sampler3D lut;
#endif
#else
uniform lowp sampler3D lut;
#endif
vec4 applyLUT(const in vec3 rgb){
#ifdef TETRAHEDRAL_INTERPOLATION
vec3 p=floor(rgb);vec3 f=rgb-p;vec3 v1=(p+0.5)*LUT_TEXEL_WIDTH;vec3 v4=(p+1.5)*LUT_TEXEL_WIDTH;vec3 v2,v3;vec3 frac;if(f.r>=f.g){if(f.g>f.b){frac=f.rgb;v2=vec3(v4.x,v1.y,v1.z);v3=vec3(v4.x,v4.y,v1.z);}else if(f.r>=f.b){frac=f.rbg;v2=vec3(v4.x,v1.y,v1.z);v3=vec3(v4.x,v1.y,v4.z);}else{frac=f.brg;v2=vec3(v1.x,v1.y,v4.z);v3=vec3(v4.x,v1.y,v4.z);}}else{if(f.b>f.g){frac=f.bgr;v2=vec3(v1.x,v1.y,v4.z);v3=vec3(v1.x,v4.y,v4.z);}else if(f.r>=f.b){frac=f.grb;v2=vec3(v1.x,v4.y,v1.z);v3=vec3(v4.x,v4.y,v1.z);}else{frac=f.gbr;v2=vec3(v1.x,v4.y,v1.z);v3=vec3(v1.x,v4.y,v4.z);}}vec4 n1=texture(lut,v1);vec4 n2=texture(lut,v2);vec4 n3=texture(lut,v3);vec4 n4=texture(lut,v4);vec4 weights=vec4(1.0-frac.x,frac.x-frac.y,frac.y-frac.z,frac.z);vec4 result=weights*mat4(vec4(n1.r,n2.r,n3.r,n4.r),vec4(n1.g,n2.g,n3.g,n4.g),vec4(n1.b,n2.b,n3.b,n4.b),vec4(1.0));return vec4(result.rgb,1.0);
#else
return texture(lut,rgb);
#endif
}
#else
#ifdef LUT_PRECISION_HIGH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D lut;
#else
uniform mediump sampler2D lut;
#endif
#else
uniform lowp sampler2D lut;
#endif
vec4 applyLUT(const in vec3 rgb){float slice=rgb.b*LUT_SIZE;float slice0=floor(slice);float interp=slice-slice0;float centeredInterp=interp-0.5;float slice1=slice0+sign(centeredInterp);
#ifdef LUT_STRIP_HORIZONTAL
float xOffset=clamp(rgb.r*LUT_TEXEL_HEIGHT,LUT_TEXEL_WIDTH*0.5,LUT_TEXEL_HEIGHT-LUT_TEXEL_WIDTH*0.5);vec2 uv0=vec2(slice0*LUT_TEXEL_HEIGHT+xOffset,rgb.g);vec2 uv1=vec2(slice1*LUT_TEXEL_HEIGHT+xOffset,rgb.g);
#else
float yOffset=clamp(rgb.g*LUT_TEXEL_WIDTH,LUT_TEXEL_HEIGHT*0.5,LUT_TEXEL_WIDTH-LUT_TEXEL_HEIGHT*0.5);vec2 uv0=vec2(rgb.r,slice0*LUT_TEXEL_WIDTH+yOffset);vec2 uv1=vec2(rgb.r,slice1*LUT_TEXEL_WIDTH+yOffset);
#endif
vec4 sample0=texture2D(lut,uv0);vec4 sample1=texture2D(lut,uv1);return mix(sample0,sample1,abs(centeredInterp));}
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 c=inputColor.rgb;
#ifdef CUSTOM_INPUT_DOMAIN
if(c.r>=domainMin.r&&c.g>=domainMin.g&&c.b>=domainMin.b&&c.r<=domainMax.r&&c.g<=domainMax.g&&c.b<=domainMax.b){c=applyLUT(scale*c+offset).rgb;}else{c=inputColor.rgb;}
#else
#if !defined(LUT_3D) || defined(TETRAHEDRAL_INTERPOLATION)
c=clamp(c,0.0,1.0);
#endif
c=applyLUT(scale*c+offset).rgb;
#endif
outputColor=vec4(c,inputColor.a);}`,an=class extends B{constructor(e,{blendFunction:t=z.SRC,tetrahedralInterpolation:r=!1,inputColorSpace:i=C}={}){super(`LUT3DEffect`,rn,{blendFunction:t,uniforms:new Map([[`lut`,new M(null)],[`scale`,new M(new n)],[`offset`,new M(new n)],[`domainMin`,new M(null)],[`domainMax`,new M(null)]])}),this.tetrahedralInterpolation=r,this.inputColorSpace=i,this.lut=e}get lut(){return this.uniforms.get(`lut`).value}set lut(e){let t=this.defines,n=this.uniforms;if(this.lut!==e&&(n.get(`lut`).value=e,e!==null)){let r=e.image,i=this.tetrahedralInterpolation;if(t.clear(),t.set(`LUT_SIZE`,Math.min(r.width,r.height).toFixed(16)),t.set(`LUT_TEXEL_WIDTH`,(1/r.width).toFixed(16)),t.set(`LUT_TEXEL_HEIGHT`,(1/r.height).toFixed(16)),n.get(`domainMin`).value=null,n.get(`domainMax`).value=null,(e.type===1015||e.type===1016)&&t.set(`LUT_PRECISION_HIGH`,`1`),r.width>r.height?t.set(`LUT_STRIP_HORIZONTAL`,`1`):e instanceof y&&t.set(`LUT_3D`,`1`),e instanceof nn){let r=e.domainMin,i=e.domainMax;(r.x!==0||r.y!==0||r.z!==0||i.x!==1||i.y!==1||i.z!==1)&&(t.set(`CUSTOM_INPUT_DOMAIN`,`1`),n.get(`domainMin`).value=r.clone(),n.get(`domainMax`).value=i.clone())}this.tetrahedralInterpolation=i}}getLUT(){return this.lut}setLUT(e){this.lut=e}updateScaleOffset(){let e=this.lut;if(e!==null){let t=Math.min(e.image.width,e.image.height),n=this.uniforms.get(`scale`).value,r=this.uniforms.get(`offset`).value;if(this.tetrahedralInterpolation&&e instanceof y)if(this.defines.has(`CUSTOM_INPUT_DOMAIN`)){let i=e.domainMax.clone().sub(e.domainMin);n.setScalar(t-1).divide(i),r.copy(e.domainMin).negate().multiply(n)}else n.setScalar(t-1),r.setScalar(0);else if(this.defines.has(`CUSTOM_INPUT_DOMAIN`)){let i=e.domainMax.clone().sub(e.domainMin).multiplyScalar(t);n.setScalar(t-1).divide(i),r.copy(e.domainMin).negate().multiply(n).addScalar(1/(2*t))}else n.setScalar((t-1)/t),r.setScalar(1/(2*t))}}configureTetrahedralInterpolation(){let e=this.lut;e!==null&&(e.minFilter=u,e.magFilter=u,this.tetrahedralInterpolation&&(e instanceof y?(e.minFilter=k,e.magFilter=k):console.warn(`Tetrahedral interpolation requires a 3D texture`)),e.needsUpdate=!0)}get tetrahedralInterpolation(){return this.defines.has(`TETRAHEDRAL_INTERPOLATION`)}set tetrahedralInterpolation(e){e?this.defines.set(`TETRAHEDRAL_INTERPOLATION`,`1`):this.defines.delete(`TETRAHEDRAL_INTERPOLATION`),this.configureTetrahedralInterpolation(),this.updateScaleOffset(),this.setChanged()}setTetrahedralInterpolationEnabled(e){this.tetrahedralInterpolation=e}},on={FULL:0,SINGLE:1},sn={DEFAULT:0,KEEP_MAX_DEPTH:1,DISCARD_MAX_DEPTH:2},cn={DEPTH:0,LUMA:1,COLOR:2},ln={DISABLED:0,DEPTH:1,CUSTOM:2},un={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},q={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,UNCHARTED2:4,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},dn={DEFAULT:0,ESKIL:1},fn={DERIVATIVES:`derivatives`,FRAG_DEPTH:`fragDepth`,DRAW_BUFFERS:`drawBuffers`,SHADER_TEXTURE_LOD:`shaderTextureLOD`},pn=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*(1.0+time)));
#ifdef PREMULTIPLY
outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
#else
outputColor=vec4(noise,inputColor.a);
#endif
}`,mn=class extends B{constructor({blendFunction:e=z.SCREEN,premultiply:t=!1}={}){super(`NoiseEffect`,pn,{blendFunction:e}),this.premultiply=t}get premultiply(){return this.defines.has(`PREMULTIPLY`)}set premultiply(e){this.premultiply!==e&&(e?this.defines.set(`PREMULTIPLY`,`1`):this.defines.delete(`PREMULTIPLY`),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(e){this.premultiply=e}},hn=`#include <packing>
#include <clipping_planes_pars_fragment>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform float cameraNear;uniform float cameraFar;centroid varying float vViewZ;centroid varying vec4 vProjTexCoord;void main(){
#include <clipping_planes_fragment>
vec2 projTexCoord=(vProjTexCoord.xy/vProjTexCoord.w)*0.5+0.5;
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,projTexCoord));
#else
float depth=texture2D(depthBuffer,projTexCoord).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
float viewZ=orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
float depthTest=(-vViewZ>-viewZ)?1.0:0.0;gl_FragColor.rg=vec2(0.0,depthTest);}`,gn=`#include <common>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
varying float vViewZ;varying vec4 vProjTexCoord;void main(){
#include <skinbase_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
vViewZ=mvPosition.z;vProjTexCoord=gl_Position;
#include <clipping_planes_vertex>
}`,_n=class extends j{constructor(e=null,t){super({name:`DepthComparisonMaterial`,defines:{DEPTH_PACKING:`0`},uniforms:{depthBuffer:new M(null),cameraNear:new M(.3),cameraFar:new M(1e3)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:hn,vertexShader:gn}),this.depthBuffer=e,this.depthPacking=i,this.copyCameraSettings(t)}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=i){this.depthBuffer=e,this.depthPacking=t}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof T?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},vn=`uniform lowp sampler2D inputBuffer;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 c0=texture2D(inputBuffer,vUv0).rg;vec2 c1=texture2D(inputBuffer,vUv1).rg;vec2 c2=texture2D(inputBuffer,vUv2).rg;vec2 c3=texture2D(inputBuffer,vUv3).rg;float d0=(c0.x-c1.x)*0.5;float d1=(c2.x-c3.x)*0.5;float d=length(vec2(d0,d1));float a0=min(c0.y,c1.y);float a1=min(c2.y,c3.y);float visibilityFactor=min(a0,a1);gl_FragColor.rg=(1.0-visibilityFactor>0.001)?vec2(d,0.0):vec2(0.0,d);}`,yn=`uniform vec2 texelSize;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vUv0=vec2(uv.x+texelSize.x,uv.y);vUv1=vec2(uv.x-texelSize.x,uv.y);vUv2=vec2(uv.x,uv.y+texelSize.y);vUv3=vec2(uv.x,uv.y-texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`,bn=class extends j{constructor(e=new D){super({name:`OutlineMaterial`,uniforms:{inputBuffer:new M(null),texelSize:new M(new D)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:vn,vertexShader:yn}),this.uniforms.texelSize.value.set(e.x,e.y),this.uniforms.maskTexture=this.uniforms.inputBuffer}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},xn=class extends N{constructor(t,n,{renderTarget:r,resolutionScale:a=1,width:o=R.AUTO_SIZE,height:s=R.AUTO_SIZE,resolutionX:l=o,resolutionY:u=s}={}){super(`DepthPass`),this.needsSwap=!1,this.renderPass=new zt(t,n,new e({depthPacking:i}));let d=this.renderPass;d.skipShadowMapUpdate=!0,d.ignoreBackground=!0,this.renderTarget=r,this.renderTarget===void 0&&(this.renderTarget=new c(1,1,{minFilter:k,magFilter:k}),this.renderTarget.texture.name=`DepthPass.Target`);let f=this.resolution=new R(this,l,u,a);f.addEventListener(`change`,e=>this.setSize(f.baseWidth,f.baseHeight))}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}initialize(e,n,r){let i=e.capabilities.reversedDepthBuffer?0:16777215,a=this.renderPass.clearPass;a.overrideClearColor=new t(i),a.overrideClearAlpha=1}},Sn=`uniform lowp sampler2D edgeTexture;uniform lowp sampler2D maskTexture;uniform vec3 visibleEdgeColor;uniform vec3 hiddenEdgeColor;uniform float pulse;uniform float edgeStrength;
#ifdef USE_PATTERN
uniform lowp sampler2D patternTexture;varying vec2 vUvPattern;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 edge=texture2D(edgeTexture,uv).rg;vec2 mask=texture2D(maskTexture,uv).rg;
#ifndef X_RAY
edge.y=0.0;
#endif
edge*=(edgeStrength*mask.x*pulse);vec3 color=edge.x*visibleEdgeColor+edge.y*hiddenEdgeColor;float visibilityFactor=0.0;
#ifdef USE_PATTERN
vec4 patternColor=texture2D(patternTexture,vUvPattern);
#ifdef X_RAY
float hiddenFactor=0.5;
#else
float hiddenFactor=0.0;
#endif
visibilityFactor=(1.0-mask.y>0.0)?1.0:hiddenFactor;visibilityFactor*=(1.0-mask.x)*patternColor.a;color+=visibilityFactor*patternColor.rgb;
#endif
float alpha=max(max(edge.x,edge.y),visibilityFactor);
#ifdef ALPHA
outputColor=vec4(color,alpha);
#else
outputColor=vec4(color,max(alpha,inputColor.a));
#endif
}`,Cn=`uniform float patternScale;varying vec2 vUvPattern;void mainSupport(const in vec2 uv){vUvPattern=uv*vec2(aspect,1.0)*patternScale;}`,wn=class extends B{constructor(e,n,{blendFunction:r=z.SCREEN,patternTexture:i=null,patternScale:a=1,edgeStrength:o=1,pulseSpeed:s=0,visibleEdgeColor:l=16777215,hiddenEdgeColor:u=2230538,kernelSize:d=V.VERY_SMALL,blur:f=!1,xRay:p=!0,multisampling:m=0,resolutionScale:h=.5,width:g=R.AUTO_SIZE,height:_=R.AUTO_SIZE,resolutionX:v=g,resolutionY:y=_}={}){super(`OutlineEffect`,Sn,{uniforms:new Map([[`maskTexture`,new M(null)],[`edgeTexture`,new M(null)],[`edgeStrength`,new M(o)],[`visibleEdgeColor`,new M(new t(l))],[`hiddenEdgeColor`,new M(new t(u))],[`pulse`,new M(1)],[`patternScale`,new M(a)],[`patternTexture`,new M(null)]])}),this.blendMode.addEventListener(`change`,e=>{this.blendMode.blendFunction===z.ALPHA?this.defines.set(`ALPHA`,`1`):this.defines.delete(`ALPHA`),this.setChanged()}),this.blendMode.blendFunction=r,this.patternTexture=i,this.xRay=p,this.scene=e,this.camera=n,this.renderTargetMask=new c(1,1),this.renderTargetMask.samples=m,this.renderTargetMask.texture.name=`Outline.Mask`,this.uniforms.get(`maskTexture`).value=this.renderTargetMask.texture,this.renderTargetOutline=new c(1,1,{depthBuffer:!1}),this.renderTargetOutline.texture.name=`Outline.Edges`,this.uniforms.get(`edgeTexture`).value=this.renderTargetOutline.texture,this.clearPass=new ve,this.clearPass.overrideClearColor=new t(0),this.clearPass.overrideClearAlpha=1,this.depthPass=new xn(e,n),this.maskPass=new zt(e,n,new _n(this.depthPass.texture,n));let b=this.maskPass.clearPass;b.overrideClearColor=new t(16777215),b.overrideClearAlpha=1,this.blurPass=new H({resolutionScale:h,resolutionX:v,resolutionY:y,kernelSize:d}),this.blurPass.enabled=f;let x=this.blurPass.resolution;x.addEventListener(`change`,e=>this.setSize(x.baseWidth,x.baseHeight)),this.outlinePass=new W(new bn);let S=this.outlinePass.fullscreenMaterial;S.inputBuffer=this.renderTargetMask.texture,this.time=0,this.forceUpdate=!0,this.selection=new Ne,this.pulseSpeed=s}set mainScene(e){this.scene=e,this.depthPass.mainScene=e,this.maskPass.mainScene=e}set mainCamera(e){this.camera=e,this.depthPass.mainCamera=e,this.maskPass.mainCamera=e,this.maskPass.overrideMaterial.copyCameraSettings(e)}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.getResolution()}get multisampling(){return this.renderTargetMask.samples}set multisampling(e){this.renderTargetMask.samples=e,this.renderTargetMask.dispose()}get patternScale(){return this.uniforms.get(`patternScale`).value}set patternScale(e){this.uniforms.get(`patternScale`).value=e}get edgeStrength(){return this.uniforms.get(`edgeStrength`).value}set edgeStrength(e){this.uniforms.get(`edgeStrength`).value=e}get visibleEdgeColor(){return this.uniforms.get(`visibleEdgeColor`).value}set visibleEdgeColor(e){this.uniforms.get(`visibleEdgeColor`).value=e}get hiddenEdgeColor(){return this.uniforms.get(`hiddenEdgeColor`).value}set hiddenEdgeColor(e){this.uniforms.get(`hiddenEdgeColor`).value=e}getBlurPass(){return this.blurPass}getSelection(){return this.selection}getPulseSpeed(){return this.pulseSpeed}setPulseSpeed(e){this.pulseSpeed=e}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get selectionLayer(){return this.selection.layer}set selectionLayer(e){this.selection.layer=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get blur(){return this.blurPass.enabled}set blur(e){this.blurPass.enabled=e}get xRay(){return this.defines.has(`X_RAY`)}set xRay(e){this.xRay!==e&&(e?this.defines.set(`X_RAY`,`1`):this.defines.delete(`X_RAY`),this.setChanged())}isXRayEnabled(){return this.xRay}setXRayEnabled(e){this.xRay=e}get patternTexture(){return this.uniforms.get(`patternTexture`).value}set patternTexture(e){e===null?(this.defines.delete(`USE_PATTERN`),this.setVertexShader(null)):(e.wrapS=e.wrapT=d,this.defines.set(`USE_PATTERN`,`1`),this.setVertexShader(Cn)),this.uniforms.get(`patternTexture`).value=e,this.setChanged()}setPatternTexture(e){this.patternTexture=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}setSelection(e){return this.selection.set(e),this}clearSelection(){return this.selection.clear(),this}selectObject(e){return this.selection.add(e),this}deselectObject(e){return this.selection.delete(e),this}update(e,t,n){let r=this.scene,i=this.camera,a=this.selection,o=this.uniforms.get(`pulse`),s=r.background,c=i.layers.mask;(this.forceUpdate||a.size>0)&&(r.background=null,o.value=1,this.pulseSpeed>0&&(o.value=Math.cos(this.time*this.pulseSpeed*10)*.375+.625),this.time+=n,a.setVisible(!1),this.depthPass.render(e),a.setVisible(!0),i.layers.set(a.layer),this.maskPass.render(e,this.renderTargetMask),i.layers.mask=c,r.background=s,this.outlinePass.render(e,null,this.renderTargetOutline),this.blurPass.enabled&&this.blurPass.render(e,this.renderTargetOutline,this.renderTargetOutline)),this.forceUpdate=a.size>0}setSize(e,t){this.blurPass.setSize(e,t),this.renderTargetMask.setSize(e,t);let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.depthPass.setSize(r,i),this.renderTargetOutline.setSize(r,i),this.outlinePass.fullscreenMaterial.setSize(r,i)}initialize(e,t,n){this.blurPass.initialize(e,t,ce),n!==void 0&&(this.depthPass.initialize(e,t,n),this.maskPass.initialize(e,t,n),this.outlinePass.initialize(e,t,n))}},Tn=`uniform bool active;uniform vec4 d;void mainUv(inout vec2 uv){if(active){uv=d.xy*(floor(uv*d.zw)+0.5);}}`,En=class extends B{constructor(e=30){super(`PixelationEffect`,Tn,{uniforms:new Map([[`active`,new M(!1)],[`d`,new M(new E)]])}),this.resolution=new D,this._granularity=0,this.granularity=e}get granularity(){return this._granularity}set granularity(e){let t=Math.floor(e);t%2>0&&(t+=1),this._granularity=t,this.uniforms.get(`active`).value=t>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(e){this.granularity=e}setSize(e,t){let n=this.resolution;n.set(e,t);let r=this.granularity,i=r/n.x,a=r/n.y;this.uniforms.get(`d`).value.set(i,a,1/i,1/a)}},Dn=`uniform float focus;uniform float focalLength;uniform float fStop;uniform float maxBlur;uniform float luminanceThreshold;uniform float luminanceGain;uniform float bias;uniform float fringe;
#ifdef MANUAL_DOF
uniform vec4 dof;
#endif
#ifdef PENTAGON
float pentagon(const in vec2 coords){const vec4 HS0=vec4(1.0,0.0,0.0,1.0);const vec4 HS1=vec4(0.309016994,0.951056516,0.0,1.0);const vec4 HS2=vec4(-0.809016994,0.587785252,0.0,1.0);const vec4 HS3=vec4(-0.809016994,-0.587785252,0.0,1.0);const vec4 HS4=vec4(0.309016994,-0.951056516,0.0,1.0);const vec4 HS5=vec4(0.0,0.0,1.0,1.0);const vec4 ONE=vec4(1.0);const float P_FEATHER=0.4;const float N_FEATHER=-P_FEATHER;float inOrOut=-4.0;vec4 P=vec4(coords,vec2(RINGS_FLOAT-1.3));vec4 dist=vec4(dot(P,HS0),dot(P,HS1),dot(P,HS2),dot(P,HS3));dist=smoothstep(N_FEATHER,P_FEATHER,dist);inOrOut+=dot(dist,ONE);dist.x=dot(P,HS4);dist.y=HS5.w-abs(P.z);dist=smoothstep(N_FEATHER,P_FEATHER,dist);inOrOut+=dist.x;return clamp(inOrOut,0.0,1.0);}
#endif
vec3 processTexel(const in vec2 coords,const in float blur){vec2 scale=texelSize*fringe*blur;vec3 c=vec3(texture2D(inputBuffer,coords+vec2(0.0,1.0)*scale).r,texture2D(inputBuffer,coords+vec2(-0.866,-0.5)*scale).g,texture2D(inputBuffer,coords+vec2(0.866,-0.5)*scale).b);float luminance=linearToRelativeLuminance(c);float threshold=max((luminance-luminanceThreshold)*luminanceGain,0.0);return c+mix(vec3(0.0),c,threshold*blur);}float gather(const in float i,const in float j,const in float ringSamples,const in vec2 uv,const in vec2 blurFactor,const in float blur,inout vec3 color){float step=PI2/ringSamples;vec2 wh=vec2(cos(j*step)*i,sin(j*step)*i);
#ifdef PENTAGON
float p=pentagon(wh);
#else
float p=1.0;
#endif
color+=processTexel(wh*blurFactor+uv,blur)*mix(1.0,i/RINGS_FLOAT,bias)*p;return mix(1.0,i/RINGS_FLOAT,bias)*p;}void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearDepth=depth;
#endif
#ifdef MANUAL_DOF
float focalPlane=linearDepth-focus;float farDoF=(focalPlane-dof.z)/dof.w;float nearDoF=(-focalPlane-dof.x)/dof.y;float blur=(focalPlane>0.0)?farDoF:nearDoF;
#else
const float CIRCLE_OF_CONFUSION=0.03;float focalPlaneMM=focus*1000.0;float depthMM=linearDepth*1000.0;float focalPlane=(depthMM*focalLength)/(depthMM-focalLength);float farDoF=(focalPlaneMM*focalLength)/(focalPlaneMM-focalLength);float nearDoF=(focalPlaneMM-focalLength)/(focalPlaneMM*fStop*CIRCLE_OF_CONFUSION);float blur=abs(focalPlane-farDoF)*nearDoF;
#endif
const int MAX_RING_SAMPLES=RINGS_INT*SAMPLES_INT;blur=clamp(blur,0.0,1.0);vec3 color=inputColor.rgb;if(blur>=0.05){vec2 blurFactor=blur*maxBlur*texelSize;float s=1.0;int ringSamples;for(int i=1;i<=RINGS_INT;i++){ringSamples=i*SAMPLES_INT;for(int j=0;j<MAX_RING_SAMPLES;j++){if(j>=ringSamples){break;}s+=gather(float(i),float(j),float(ringSamples),uv,blurFactor,blur,color);}}color/=s;}
#ifdef SHOW_FOCUS
float edge=0.002*linearDepth;float m=clamp(smoothstep(0.0,edge,blur),0.0,1.0);float e=clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);color=mix(color,vec3(1.0,0.5,0.0),(1.0-m)*0.6);color=mix(color,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);
#endif
outputColor=vec4(color,inputColor.a);}`,On=class extends B{constructor({blendFunction:e,focus:t=1,focalLength:n=24,fStop:r=.9,luminanceThreshold:i=.5,luminanceGain:a=2,bias:o=.5,fringe:s=.7,maxBlur:c=1,rings:l=3,samples:u=2,showFocus:d=!1,manualDoF:f=!1,pentagon:p=!1}={}){super(`RealisticBokehEffect`,Dn,{blendFunction:e,attributes:F.CONVOLUTION|F.DEPTH,uniforms:new Map([[`focus`,new M(t)],[`focalLength`,new M(n)],[`fStop`,new M(r)],[`luminanceThreshold`,new M(i)],[`luminanceGain`,new M(a)],[`bias`,new M(o)],[`fringe`,new M(s)],[`maxBlur`,new M(c)],[`dof`,new M(null)]])}),this.rings=l,this.samples=u,this.showFocus=d,this.manualDoF=f,this.pentagon=p}get rings(){return Number.parseInt(this.defines.get(`RINGS_INT`))}set rings(e){let t=Math.floor(e);this.defines.set(`RINGS_INT`,t.toFixed(0)),this.defines.set(`RINGS_FLOAT`,t.toFixed(1)),this.setChanged()}get samples(){return Number.parseInt(this.defines.get(`SAMPLES_INT`))}set samples(e){let t=Math.floor(e);this.defines.set(`SAMPLES_INT`,t.toFixed(0)),this.defines.set(`SAMPLES_FLOAT`,t.toFixed(1)),this.setChanged()}get showFocus(){return this.defines.has(`SHOW_FOCUS`)}set showFocus(e){this.showFocus!==e&&(e?this.defines.set(`SHOW_FOCUS`,`1`):this.defines.delete(`SHOW_FOCUS`),this.setChanged())}get manualDoF(){return this.defines.has(`MANUAL_DOF`)}set manualDoF(e){this.manualDoF!==e&&(e?(this.defines.set(`MANUAL_DOF`,`1`),this.uniforms.get(`dof`).value=new E(.2,1,.2,2)):(this.defines.delete(`MANUAL_DOF`),this.uniforms.get(`dof`).value=null),this.setChanged())}get pentagon(){return this.defines.has(`PENTAGON`)}set pentagon(e){this.pentagon!==e&&(e?this.defines.set(`PENTAGON`,`1`):this.defines.delete(`PENTAGON`),this.setChanged())}},kn=`uniform float count;
#ifdef SCROLL
uniform float scrollSpeed;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float y=uv.y;
#ifdef SCROLL
y+=time*scrollSpeed;
#endif
vec2 sl=vec2(sin(y*count),cos(y*count));outputColor=vec4(sl.xyx,inputColor.a);}`,An=class extends B{constructor({blendFunction:e=z.OVERLAY,density:t=1.25,scrollSpeed:n=0}={}){super(`ScanlineEffect`,kn,{blendFunction:e,uniforms:new Map([[`count`,new M(0)],[`scrollSpeed`,new M(0)]])}),this.resolution=new D,this.d=t,this.scrollSpeed=n}get density(){return this.d}set density(e){this.d=e,this.setSize(this.resolution.width,this.resolution.height)}getDensity(){return this.density}setDensity(e){this.density=e}get scrollSpeed(){return this.uniforms.get(`scrollSpeed`).value}set scrollSpeed(e){this.uniforms.get(`scrollSpeed`).value=e,e===0?this.defines.delete(`SCROLL`)&&this.setChanged():this.defines.has(`SCROLL`)||(this.defines.set(`SCROLL`,`1`),this.setChanged())}setSize(e,t){this.resolution.set(e,t),this.uniforms.get(`count`).value=Math.round(t*this.density)}},jn=`uniform bool active;uniform vec2 center;uniform float waveSize;uniform float radius;uniform float maxRadius;uniform float amplitude;varying float vSize;void mainUv(inout vec2 uv){if(active){vec2 aspectCorrection=vec2(aspect,1.0);vec2 difference=uv*aspectCorrection-center*aspectCorrection;float distance=sqrt(dot(difference,difference))*vSize;if(distance>radius){if(distance<radius+waveSize){float angle=(distance-radius)*PI2/waveSize;float cosSin=(1.0-cos(angle))*0.5;float extent=maxRadius+waveSize;float decay=max(extent-distance*distance,0.0)/extent;uv-=((cosSin*amplitude*difference)/distance)*decay;}}}}`,Mn=`uniform float size;uniform float cameraDistance;varying float vSize;void mainSupport(){vSize=(0.1*cameraDistance)/size;}`,Nn=Math.PI*.5,Pn=new n,Fn=new n,In=class extends B{constructor(e,t=new n,{speed:r=2,maxRadius:i=1,waveSize:a=.2,amplitude:o=.05}={}){super(`ShockWaveEffect`,jn,{vertexShader:Mn,uniforms:new Map([[`active`,new M(!1)],[`center`,new M(new D(.5,.5))],[`cameraDistance`,new M(1)],[`size`,new M(1)],[`radius`,new M(-a)],[`maxRadius`,new M(i)],[`waveSize`,new M(a)],[`amplitude`,new M(o)]])}),this.position=t,this.speed=r,this.camera=e,this.screenPosition=this.uniforms.get(`center`).value,this.time=0,this.active=!1}set mainCamera(e){this.camera=e}get amplitude(){return this.uniforms.get(`amplitude`).value}set amplitude(e){this.uniforms.get(`amplitude`).value=e}get waveSize(){return this.uniforms.get(`waveSize`).value}set waveSize(e){this.uniforms.get(`waveSize`).value=e}get maxRadius(){return this.uniforms.get(`maxRadius`).value}set maxRadius(e){this.uniforms.get(`maxRadius`).value=e}get epicenter(){return this.position}set epicenter(e){this.position=e}getPosition(){return this.position}setPosition(e){this.position=e}getSpeed(){return this.speed}setSpeed(e){this.speed=e}explode(){this.time=0,this.active=!0,this.uniforms.get(`active`).value=!0}update(e,t,n){let r=this.position,i=this.camera,a=this.uniforms,o=a.get(`active`);if(this.active){let e=a.get(`waveSize`).value;i.getWorldDirection(Pn),Fn.copy(i.position).sub(r),o.value=Pn.angleTo(Fn)>Nn,o.value&&(a.get(`cameraDistance`).value=i.position.distanceTo(r),Pn.copy(r).project(i),this.screenPosition.set((Pn.x+1)*.5,(Pn.y+1)*.5)),this.time+=n*this.speed;let t=this.time-e;a.get(`radius`).value=t,t>=(a.get(`maxRadius`).value+e)*2&&(this.active=!1,o.value=!1)}}},Ln=`#include <common>
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer0;uniform highp sampler2D depthBuffer1;
#else
uniform mediump sampler2D depthBuffer0;uniform mediump sampler2D depthBuffer1;
#endif
uniform sampler2D inputBuffer;uniform vec2 cameraNearFar;float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#else
return orthographicDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#endif
}varying vec2 vUv;void main(){vec2 depth;
#if DEPTH_PACKING_0 == 3201
depth.x=unpackRGBAToDepth(texture2D(depthBuffer0,vUv));
#else
depth.x=texture2D(depthBuffer0,vUv).r;
#endif
#if DEPTH_PACKING_1 == 3201
depth.y=unpackRGBAToDepth(texture2D(depthBuffer1,vUv));
#else
depth.y=texture2D(depthBuffer1,vUv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float a=cameraNearFar.y/(cameraNearFar.y-cameraNearFar.x);float b=cameraNearFar.y*cameraNearFar.x/(cameraNearFar.x-cameraNearFar.y);float c=log2(cameraNearFar.y+1.0);float d=pow(2.0,depth.x*c)-1.0;depth.x=a+b/d;d=pow(2.0,depth.y*c)-1.0;depth.y=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth.x=1.0-depth.x;depth.y=1.0-depth.y;
#endif
bool isMaxDepth=(depth.x==1.0);
#ifdef PERSPECTIVE_CAMERA
depth.x=viewZToOrthographicDepth(getViewZ(depth.x),cameraNearFar.x,cameraNearFar.y);depth.y=viewZToOrthographicDepth(getViewZ(depth.y),cameraNearFar.x,cameraNearFar.y);
#endif
#if DEPTH_TEST_STRATEGY == 0
bool keep=depthTest(depth.x,depth.y);
#elif DEPTH_TEST_STRATEGY == 1
bool keep=isMaxDepth||depthTest(depth.x,depth.y);
#else
bool keep=!isMaxDepth&&depthTest(depth.x,depth.y);
#endif
if(keep){gl_FragColor=texture2D(inputBuffer,vUv);}else{discard;}}`,Rn=class extends j{constructor(){super({name:`DepthMaskMaterial`,defines:{DEPTH_EPSILON:`0.0001`,DEPTH_PACKING_0:`0`,DEPTH_PACKING_1:`0`,DEPTH_TEST_STRATEGY:sn.KEEP_MAX_DEPTH},uniforms:{inputBuffer:new M(null),depthBuffer0:new M(null),depthBuffer1:new M(null),cameraNearFar:new M(new D(1,1))},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ln,vertexShader:P}),this.depthMode=2}set depthBuffer0(e){this.uniforms.depthBuffer0.value=e}set depthPacking0(e){this.defines.DEPTH_PACKING_0=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer0(e,t=w){this.depthBuffer0=e,this.depthPacking0=t}set depthBuffer1(e){this.uniforms.depthBuffer1.value=e}set depthPacking1(e){this.defines.DEPTH_PACKING_1=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer1(e,t=w){this.depthBuffer1=e,this.depthPacking1=t}get maxDepthStrategy(){return Number(this.defines.DEPTH_TEST_STRATEGY)}set maxDepthStrategy(e){this.defines.DEPTH_TEST_STRATEGY=e.toFixed(0),this.needsUpdate=!0}get keepFar(){return this.maxDepthStrategy}set keepFar(e){this.maxDepthStrategy=e?sn.KEEP_MAX_DEPTH:sn.DISCARD_MAX_DEPTH}getMaxDepthStrategy(){return this.maxDepthStrategy}setMaxDepthStrategy(e){this.maxDepthStrategy=e}get epsilon(){return Number(this.defines.DEPTH_EPSILON)}set epsilon(e){this.defines.DEPTH_EPSILON=e.toFixed(16),this.needsUpdate=!0}getEpsilon(){return this.epsilon}setEpsilon(e){this.epsilon=e}get depthMode(){return Number(this.defines.DEPTH_MODE)}set depthMode(e){let t;switch(e){case 0:t=`false`;break;case 1:t=`true`;break;case 4:t=`abs(d1 - d0) <= DEPTH_EPSILON`;break;case 7:t=`abs(d1 - d0) > DEPTH_EPSILON`;break;case 2:t=`d0 > d1`;break;case 3:t=`d0 >= d1`;break;case 5:t=`d0 <= d1`;break;default:t=`d0 < d1`;break}this.defines.DEPTH_MODE=e.toFixed(0),this.defines[`depthTest(d0, d1)`]=t,this.needsUpdate=!0}getDepthMode(){return this.depthMode}setDepthMode(e){this.depthMode=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNearFar.value.set(e.near,e.far),e instanceof T?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},zn=class extends et{constructor(e,n,r){super(r),this.setAttributes(this.getAttributes()|F.DEPTH),this.camera=n,this.depthPass=new xn(e,n),this.clearPass=new ve(!0,!1,!1),this.clearPass.overrideClearColor=new t(0),this.depthMaskPass=new W(new Rn);let a=this.depthMaskMaterial;a.copyCameraSettings(n),a.depthBuffer1=this.depthPass.texture,a.depthPacking1=i,a.depthMode=4,this.renderTargetMasked=new c(1,1,{depthBuffer:!1}),this.renderTargetMasked.texture.name=`Bloom.Masked`,this.selection=new Ne,this._inverted=!1,this._ignoreBackground=!1}set mainScene(e){this.depthPass.mainScene=e}set mainCamera(e){this.camera=e,this.depthPass.mainCamera=e,this.depthMaskMaterial.copyCameraSettings(e)}getSelection(){return this.selection}get depthMaskMaterial(){return this.depthMaskPass.fullscreenMaterial}get inverted(){return this._inverted}set inverted(e){this._inverted=e,this.depthMaskMaterial.depthMode=e?7:4}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get ignoreBackground(){return this._ignoreBackground}set ignoreBackground(e){this._ignoreBackground=e,this.depthMaskMaterial.maxDepthStrategy=e?sn.DISCARD_MAX_DEPTH:sn.KEEP_MAX_DEPTH}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}setDepthTexture(e,t=w){this.depthMaskMaterial.depthBuffer0=e,this.depthMaskMaterial.depthPacking0=t}update(e,t,n){let r=this.camera,i=this.selection,a=this.inverted,o=t;if(this.ignoreBackground||!a||i.size>0){let n=r.layers.mask;r.layers.set(i.layer),this.depthPass.render(e),r.layers.mask=n,o=this.renderTargetMasked,this.clearPass.render(e,o),this.depthMaskPass.render(e,t,o)}super.update(e,o,n)}setSize(e,t){super.setSize(e,t),this.renderTargetMasked.setSize(e,t),this.depthPass.setSize(e,t)}initialize(e,t,n){super.initialize(e,t,n),this.clearPass.initialize(e,t,n),this.depthPass.initialize(e,t,n),this.depthMaskPass.initialize(e,t,n),e!==null&&e.capabilities.logarithmicDepthBuffer&&(this.depthMaskPass.fullscreenMaterial.defines.LOG_DEPTH=`1`),n!==void 0&&(this.renderTargetMasked.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTargetMasked.texture.colorSpace=C))}},Bn=`uniform vec3 weightsR;uniform vec3 weightsG;uniform vec3 weightsB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,weightsR),dot(inputColor.rgb,weightsG),dot(inputColor.rgb,weightsB));outputColor=vec4(color,inputColor.a);}`,Vn=class extends B{constructor({blendFunction:e,intensity:t=1}={}){super(`SepiaEffect`,Bn,{blendFunction:e,uniforms:new Map([[`weightsR`,new M(new n(.393,.769,.189))],[`weightsG`,new M(new n(.349,.686,.168))],[`weightsB`,new M(new n(.272,.534,.131))]])})}get intensity(){return this.blendMode.opacity.value}set intensity(e){this.blendMode.opacity.value=e}getIntensity(){return this.intensity}setIntensity(e){this.intensity=e}get weightsR(){return this.uniforms.get(`weightsR`).value}get weightsG(){return this.uniforms.get(`weightsG`).value}get weightsB(){return this.uniforms.get(`weightsB`).value}},Hn=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
#if EDGE_DETECTION_MODE != 0
varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
#endif
#if EDGE_DETECTION_MODE == 1
#include <common>
#endif
#if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}
#elif PREDICATION_MODE == 2
uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);}
#endif
#if PREDICATION_MODE != 0
vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);}
#endif
#if EDGE_DETECTION_MODE != 0
uniform sampler2D inputBuffer;
#endif
void main(){
#if EDGE_DETECTION_MODE == 0
const vec2 threshold=vec2(DEPTH_THRESHOLD);
#elif PREDICATION_MODE != 0
vec2 threshold=calculatePredicatedThreshold();
#else
const vec2 threshold=vec2(EDGE_THRESHOLD);
#endif
#if EDGE_DETECTION_MODE == 0
vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0);
#elif EDGE_DETECTION_MODE == 1
float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
#elif EDGE_DETECTION_MODE == 2
vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
#endif
}`,Un=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
#if EDGE_DETECTION_MODE != 0
varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
#endif
void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0);
#if EDGE_DETECTION_MODE != 0
vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0);
#endif
gl_Position=vec4(position.xy,1.0,1.0);}`,Wn=class extends j{constructor(e=new D,t=cn.COLOR){super({name:`EdgeDetectionMaterial`,defines:{THREE_REVISION:o.replace(/\D+/g,``),LOCAL_CONTRAST_ADAPTATION_FACTOR:`2.0`,EDGE_THRESHOLD:`0.1`,DEPTH_THRESHOLD:`0.01`,PREDICATION_MODE:`0`,PREDICATION_THRESHOLD:`0.01`,PREDICATION_SCALE:`2.0`,PREDICATION_STRENGTH:`1.0`,DEPTH_PACKING:`0`},uniforms:{inputBuffer:new M(null),depthBuffer:new M(null),predicationBuffer:new M(null),texelSize:new M(e)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Hn,vertexShader:Un}),this.edgeDetectionMode=t}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(e){this.defines.EDGE_DETECTION_MODE=e.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(e){this.edgeDetectionMode=e}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(e){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=e.toFixed(`6`),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(e){this.localContrastAdaptationFactor=e}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(e){this.defines.EDGE_THRESHOLD=e.toFixed(`6`),this.defines.DEPTH_THRESHOLD=(e*.1).toFixed(`6`),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(e){this.edgeDetectionThreshold=e}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(e){this.defines.PREDICATION_MODE=e.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(e){this.predicationMode=e}set predicationBuffer(e){this.uniforms.predicationBuffer.value=e}setPredicationBuffer(e){this.uniforms.predicationBuffer.value=e}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(e){this.defines.PREDICATION_THRESHOLD=e.toFixed(`6`),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(e){this.predicationThreshold=e}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(e){this.defines.PREDICATION_SCALE=e.toFixed(`6`),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(e){this.predicationScale=e}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(e){this.defines.PREDICATION_STRENGTH=e.toFixed(`6`),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(e){this.predicationStrength=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},Gn=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
#if __VERSION__ < 300
#define round(v) floor(v + 0.5)
#endif
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x>end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x<end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.y>end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;i++){if(!(texCoord.y<end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
#if !defined(DISABLE_CORNER_DETECTION)
vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0);
#endif
}void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
#if !defined(DISABLE_CORNER_DETECTION)
vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0);
#endif
}void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){
#if !defined(DISABLE_DIAG_DETECTION)
weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){
#endif
vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d);
#if !defined(DISABLE_DIAG_DETECTION)
}else{e.r=0.0;}
#endif
}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,Kn=`uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}`,qn=class extends j{constructor(e=new D,t=new D){super({name:`SMAAWeightsMaterial`,defines:{MAX_SEARCH_STEPS_INT:`16`,MAX_SEARCH_STEPS_FLOAT:`16.0`,MAX_SEARCH_STEPS_DIAG_INT:`8`,MAX_SEARCH_STEPS_DIAG_FLOAT:`8.0`,CORNER_ROUNDING:`25`,CORNER_ROUNDING_NORM:`0.25`,AREATEX_MAX_DISTANCE:`16.0`,AREATEX_MAX_DISTANCE_DIAG:`20.0`,AREATEX_PIXEL_SIZE:`(1.0 / vec2(160.0, 560.0))`,AREATEX_SUBTEX_SIZE:`(1.0 / 7.0)`,SEARCHTEX_SIZE:`vec2(66.0, 33.0)`,SEARCHTEX_PACKED_SIZE:`vec2(64.0, 16.0)`},uniforms:{inputBuffer:new M(null),searchTexture:new M(null),areaTexture:new M(null),resolution:new M(t),texelSize:new M(e)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Gn,vertexShader:Kn})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(e){this.uniforms.searchTexture.value=e}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(e){this.uniforms.areaTexture.value=e}setLookupTextures(e,t){this.searchTexture=e,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(e){let t=Math.min(Math.max(e,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed(`0`),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed(`1`),this.needsUpdate=!0}setOrthogonalSearchSteps(e){this.orthogonalSearchSteps=e}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(e){let t=Math.min(Math.max(e,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed(`0`),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed(`1`),this.needsUpdate=!0}setDiagonalSearchSteps(e){this.diagonalSearchSteps=e}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(e){e?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION=`1`,this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(e){this.diagonalDetection=e}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(e){let t=Math.min(Math.max(e,0),100);this.defines.CORNER_ROUNDING=t.toFixed(`4`),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed(`4`),this.needsUpdate=!0}setCornerRounding(e){this.cornerRounding=e}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(e){e?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION=`1`,this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(e){this.cornerDetection=e}setSize(e,t){let n=this.uniforms;n.texelSize.value.set(1/e,1/t),n.resolution.value.set(e,t)}},Jn=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC`,Yn=`data:image/png;base64, `,Xn=`uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}`,Zn=`varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}`,Qn=class extends B{constructor({blendFunction:e=z.SRC,preset:n=un.MEDIUM,edgeDetectionMode:r=cn.COLOR,predicationMode:i=ln.DISABLED}={}){super(`SMAAEffect`,Xn,{vertexShader:Zn,blendFunction:e,attributes:F.CONVOLUTION|F.DEPTH,uniforms:new Map([[`weightMap`,new M(null)]])});let a,o;arguments.length>1&&(a=arguments[0],o=arguments[1],arguments.length>2&&(n=arguments[2]),arguments.length>3&&(r=arguments[3])),this.renderTargetEdges=new c(1,1,{depthBuffer:!1}),this.renderTargetEdges.texture.name=`SMAA.Edges`,this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name=`SMAA.Weights`,this.uniforms.get(`weightMap`).value=this.renderTargetWeights.texture,this.clearPass=new ve(!0,!1,!1),this.clearPass.overrideClearColor=new t(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new W(new Wn),this.edgeDetectionMaterial.edgeDetectionMode=r,this.edgeDetectionMaterial.predicationMode=i,this.weightsPass=new W(new qn);let s=new v;s.onLoad=()=>{let e=new ne(a);e.name=`SMAA.Search`,e.magFilter=k,e.minFilter=k,e.generateMipmaps=!1,e.needsUpdate=!0,e.flipY=!0,this.weightsMaterial.searchTexture=e;let t=new ne(o);t.name=`SMAA.Area`,t.magFilter=u,t.minFilter=u,t.generateMipmaps=!1,t.needsUpdate=!0,t.flipY=!1,this.weightsMaterial.areaTexture=t,this.dispatchEvent({type:`load`})},s.itemStart(`search`),s.itemStart(`area`),a!==void 0&&o!==void 0?(s.itemEnd(`search`),s.itemEnd(`area`)):typeof Image<`u`&&(a=new Image,o=new Image,a.addEventListener(`load`,()=>s.itemEnd(`search`)),o.addEventListener(`load`,()=>s.itemEnd(`area`)),a.src=Jn,o.src=Yn),this.applyPreset(n)}get edgesTexture(){return this.renderTargetEdges.texture}getEdgesTexture(){return this.edgesTexture}get weightsTexture(){return this.renderTargetWeights.texture}getWeightsTexture(){return this.weightsTexture}get edgeDetectionMaterial(){return this.edgeDetectionPass.fullscreenMaterial}get colorEdgesMaterial(){return this.edgeDetectionMaterial}getEdgeDetectionMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.fullscreenMaterial}getWeightsMaterial(){return this.weightsMaterial}setEdgeDetectionThreshold(e){this.edgeDetectionMaterial.edgeDetectionThreshold=e}setOrthogonalSearchSteps(e){this.weightsMaterial.orthogonalSearchSteps=e}applyPreset(e){let t=this.edgeDetectionMaterial,n=this.weightsMaterial;switch(e){case un.LOW:t.edgeDetectionThreshold=.15,n.orthogonalSearchSteps=4,n.diagonalDetection=!1,n.cornerDetection=!1;break;case un.MEDIUM:t.edgeDetectionThreshold=.1,n.orthogonalSearchSteps=8,n.diagonalDetection=!1,n.cornerDetection=!1;break;case un.HIGH:t.edgeDetectionThreshold=.1,n.orthogonalSearchSteps=16,n.diagonalSearchSteps=8,n.cornerRounding=25,n.diagonalDetection=!0,n.cornerDetection=!0;break;case un.ULTRA:t.edgeDetectionThreshold=.05,n.orthogonalSearchSteps=32,n.diagonalSearchSteps=16,n.cornerRounding=25,n.diagonalDetection=!0,n.cornerDetection=!0;break}}setDepthTexture(e,t=w){this.edgeDetectionMaterial.depthBuffer=e,this.edgeDetectionMaterial.depthPacking=t}update(e,t,n){this.clearPass.render(e,this.renderTargetEdges),this.edgeDetectionPass.render(e,t,this.renderTargetEdges),this.weightsPass.render(e,this.renderTargetEdges,this.renderTargetWeights)}setSize(e,t){this.edgeDetectionMaterial.setSize(e,t),this.weightsMaterial.setSize(e,t),this.renderTargetEdges.setSize(e,t),this.renderTargetWeights.setSize(e,t)}dispose(){let{searchTexture:e,areaTexture:t}=this.weightsMaterial;e!==null&&t!==null&&(e.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return Jn}static get areaImageDataURL(){return Yn}};function $n(e,t,n){return e*(t-n)-t}function er(e,t,n){return Math.min(Math.max((e+t)/(t-n),0),1)}var tr=`#include <common>
#include <packing>
uniform vec2 cameraNearFar;
#define cameraNear cameraNearFar.x
#define cameraFar cameraNearFar.y
#ifdef NORMAL_DEPTH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D normalDepthBuffer;
#else
uniform mediump sampler2D normalDepthBuffer;
#endif
float readDepth(const in vec2 uv){float depth=texture2D(normalDepthBuffer,uv).a;
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#endif
return depth;}
#else
uniform lowp sampler2D normalBuffer;
#if DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#endif
return depth;}
#endif
uniform lowp sampler2D noiseTexture;uniform mat4 inverseProjectionMatrix;uniform mat4 projectionMatrix;uniform vec2 texelSize;uniform float intensity;uniform float minRadiusScale;uniform float fade;uniform float bias;uniform vec2 distanceCutoff;uniform vec2 proximityCutoff;varying vec2 vUv;varying vec2 vUv2;float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
}vec3 getViewPosition(const in vec2 screenPosition,const in float depth,const in float viewZ){vec4 clipPosition=vec4(vec3(screenPosition,depth)*2.0-1.0,1.0);float clipW=projectionMatrix[2][3]*viewZ+projectionMatrix[3][3];clipPosition*=clipW;return(inverseProjectionMatrix*clipPosition).xyz;}float getAmbientOcclusion(const in vec3 p,const in vec3 n,const in float depth,const in vec2 uv){float radiusScale=1.0-smoothstep(0.0,distanceCutoff.y,depth);radiusScale=radiusScale*(1.0-minRadiusScale)+minRadiusScale;float radius=RADIUS*radiusScale;float noise=texture2D(noiseTexture,vUv2).r;float baseAngle=noise*PI2;float rings=SPIRAL_TURNS*PI2;float occlusion=0.0;int taps=0;for(int i=0;i<SAMPLES_INT;++i){float alpha=(float(i)+0.5)*INV_SAMPLES_FLOAT;float angle=alpha*rings+baseAngle;vec2 rotation=vec2(cos(angle),sin(angle));vec2 coords=alpha*radius*rotation*texelSize+uv;if(coords.s<0.0||coords.s>1.0||coords.t<0.0||coords.t>1.0){continue;}float sampleDepth=readDepth(coords);float viewZ=getViewZ(sampleDepth);
#ifdef PERSPECTIVE_CAMERA
float linearSampleDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearSampleDepth=sampleDepth;
#endif
float proximity=abs(depth-linearSampleDepth);if(proximity<proximityCutoff.y){float falloff=1.0-smoothstep(proximityCutoff.x,proximityCutoff.y,proximity);vec3 Q=getViewPosition(coords,sampleDepth,viewZ);vec3 v=Q-p;float vv=dot(v,v);float vn=dot(v,n)-bias;float f=max(RADIUS_SQ-vv,0.0)/RADIUS_SQ;occlusion+=(f*f*f*max(vn/(fade+vv),0.0))*falloff;}++taps;}return occlusion/(4.0*max(float(taps),1.0));}void main(){
#ifdef NORMAL_DEPTH
vec4 normalDepth=texture2D(normalDepthBuffer,vUv);
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,normalDepth.a*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);normalDepth.a=a+b/d;
#endif
#else
vec4 normalDepth=vec4(texture2D(normalBuffer,vUv).xyz,readDepth(vUv));
#endif
float ao=0.0;float depth=normalDepth.a;float viewZ=getViewZ(depth);
#ifdef PERSPECTIVE_CAMERA
float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearDepth=depth;
#endif
if(linearDepth<distanceCutoff.y){vec3 viewPosition=getViewPosition(vUv,depth,viewZ);vec3 viewNormal=unpackRGBToNormal(normalDepth.rgb);ao+=getAmbientOcclusion(viewPosition,viewNormal,linearDepth,vUv);float d=smoothstep(distanceCutoff.x,distanceCutoff.y,linearDepth);ao=mix(ao,0.0,d);
#ifdef LEGACY_INTENSITY
ao=clamp(1.0-pow(1.0-ao,abs(intensity)),0.0,1.0);
#endif
}gl_FragColor.r=ao;}`,nr=`uniform vec2 noiseScale;varying vec2 vUv;varying vec2 vUv2;void main(){vUv=position.xy*0.5+0.5;vUv2=vUv*noiseScale;gl_Position=vec4(position.xy,1.0,1.0);}`,rr=class extends j{constructor(e){super({name:`SSAOMaterial`,defines:{SAMPLES_INT:`0`,INV_SAMPLES_FLOAT:`0.0`,SPIRAL_TURNS:`0.0`,RADIUS:`1.0`,RADIUS_SQ:`1.0`,DISTANCE_SCALING:`1`,DEPTH_PACKING:`0`},uniforms:{depthBuffer:new M(null),normalBuffer:new M(null),normalDepthBuffer:new M(null),noiseTexture:new M(null),inverseProjectionMatrix:new M(new S),projectionMatrix:new M(new S),texelSize:new M(new D),cameraNearFar:new M(new D),distanceCutoff:new M(new D),proximityCutoff:new M(new D),noiseScale:new M(new D),minRadiusScale:new M(.33),intensity:new M(1),fade:new M(.01),bias:new M(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:tr,vertexShader:nr}),this.copyCameraSettings(e),this.resolution=new D,this.r=1}get near(){return this.uniforms.cameraNearFar.value.x}get far(){return this.uniforms.cameraNearFar.value.y}set normalDepthBuffer(e){this.uniforms.normalDepthBuffer.value=e,e===null?delete this.defines.NORMAL_DEPTH:this.defines.NORMAL_DEPTH=`1`,this.needsUpdate=!0}setNormalDepthBuffer(e){this.normalDepthBuffer=e}set normalBuffer(e){this.uniforms.normalBuffer.value=e}setNormalBuffer(e){this.uniforms.normalBuffer.value=e}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.depthPacking=t}set noiseTexture(e){this.uniforms.noiseTexture.value=e}setNoiseTexture(e){this.uniforms.noiseTexture.value=e}get samples(){return Number(this.defines.SAMPLES_INT)}set samples(e){this.defines.SAMPLES_INT=e.toFixed(0),this.defines.INV_SAMPLES_FLOAT=(1/e).toFixed(9),this.needsUpdate=!0}getSamples(){return this.samples}setSamples(e){this.samples=e}get rings(){return Number(this.defines.SPIRAL_TURNS)}set rings(e){this.defines.SPIRAL_TURNS=e.toFixed(1),this.needsUpdate=!0}getRings(){return this.rings}setRings(e){this.rings=e}get intensity(){return this.uniforms.intensity.value}set intensity(e){this.uniforms.intensity.value=e,this.defines.LEGACY_INTENSITY===void 0&&(this.defines.LEGACY_INTENSITY=`1`,this.needsUpdate=!0)}getIntensity(){return this.uniforms.intensity.value}setIntensity(e){this.uniforms.intensity.value=e}get fade(){return this.uniforms.fade.value}set fade(e){this.uniforms.fade.value=e}getFade(){return this.uniforms.fade.value}setFade(e){this.uniforms.fade.value=e}get bias(){return this.uniforms.bias.value}set bias(e){this.uniforms.bias.value=e}getBias(){return this.uniforms.bias.value}setBias(e){this.uniforms.bias.value=e}get minRadiusScale(){return this.uniforms.minRadiusScale.value}set minRadiusScale(e){this.uniforms.minRadiusScale.value=e}getMinRadiusScale(){return this.uniforms.minRadiusScale.value}setMinRadiusScale(e){this.uniforms.minRadiusScale.value=e}updateRadius(){let e=this.r*this.resolution.height;this.defines.RADIUS=e.toFixed(11),this.defines.RADIUS_SQ=(e*e).toFixed(11),this.needsUpdate=!0}get radius(){return this.r}set radius(e){this.r=Math.min(Math.max(e,1e-6),1),this.updateRadius()}getRadius(){return this.radius}setRadius(e){this.radius=e}get distanceScaling(){return!0}set distanceScaling(e){}isDistanceScalingEnabled(){return this.distanceScaling}setDistanceScalingEnabled(e){this.distanceScaling=e}get distanceThreshold(){return this.uniforms.distanceCutoff.value.x}set distanceThreshold(e){this.uniforms.distanceCutoff.value.set(Math.min(Math.max(e,0),1),Math.min(Math.max(e+this.distanceFalloff,0),1))}get worldDistanceThreshold(){return-$n(this.distanceThreshold,this.near,this.far)}set worldDistanceThreshold(e){this.distanceThreshold=er(-e,this.near,this.far)}get distanceFalloff(){return this.uniforms.distanceCutoff.value.y-this.distanceThreshold}set distanceFalloff(e){this.uniforms.distanceCutoff.value.y=Math.min(Math.max(this.distanceThreshold+e,0),1)}get worldDistanceFalloff(){return-$n(this.distanceFalloff,this.near,this.far)}set worldDistanceFalloff(e){this.distanceFalloff=er(-e,this.near,this.far)}setDistanceCutoff(e,t){this.uniforms.distanceCutoff.value.set(Math.min(Math.max(e,0),1),Math.min(Math.max(e+t,0),1))}get proximityThreshold(){return this.uniforms.proximityCutoff.value.x}set proximityThreshold(e){this.uniforms.proximityCutoff.value.set(Math.min(Math.max(e,0),1),Math.min(Math.max(e+this.proximityFalloff,0),1))}get worldProximityThreshold(){return-$n(this.proximityThreshold,this.near,this.far)}set worldProximityThreshold(e){this.proximityThreshold=er(-e,this.near,this.far)}get proximityFalloff(){return this.uniforms.proximityCutoff.value.y-this.proximityThreshold}set proximityFalloff(e){this.uniforms.proximityCutoff.value.y=Math.min(Math.max(this.proximityThreshold+e,0),1)}get worldProximityFalloff(){return-$n(this.proximityFalloff,this.near,this.far)}set worldProximityFalloff(e){this.proximityFalloff=er(-e,this.near,this.far)}setProximityCutoff(e,t){this.uniforms.proximityCutoff.value.set(Math.min(Math.max(e,0),1),Math.min(Math.max(e+t,0),1))}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNearFar.value.set(e.near,e.far),this.uniforms.projectionMatrix.value.copy(e.projectionMatrix),this.uniforms.inverseProjectionMatrix.value.copy(e.projectionMatrix).invert(),e instanceof T?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let n=this.uniforms,r=n.noiseTexture.value;r!==null&&n.noiseScale.value.set(e/r.image.width,t/r.image.height),n.texelSize.value.set(1/e,1/t),this.resolution.set(e,t),this.updateRadius()}},ir=`#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
#ifdef DOWNSAMPLE_NORMALS
uniform lowp sampler2D normalBuffer;
#endif
varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]<maxDistance){remaining[j++]=i;}else{rejected[k++]=i;}}for(;j<3;++j){remaining[j]=rejected[--k];}vec3 s=vec3(samples[remaining[0]],samples[remaining[1]],samples[remaining[2]]);c=(s.x+s.y+s.z)/3.0;distances[0]=abs(c-s.x);distances[1]=abs(c-s.y);distances[2]=abs(c-s.z);float minDistance=min(distances[0],min(distances[1],distances[2]));for(i=0;i<3;++i){if(distances[i]==minDistance){break;}}return remaining[i];}void main(){float d[4];d[0]=readDepth(vUv0);d[1]=readDepth(vUv1);d[2]=readDepth(vUv2);d[3]=readDepth(vUv3);int index=findBestDepth(d);
#ifdef DOWNSAMPLE_NORMALS
vec3 n[4];n[0]=texture2D(normalBuffer,vUv0).rgb;n[1]=texture2D(normalBuffer,vUv1).rgb;n[2]=texture2D(normalBuffer,vUv2).rgb;n[3]=texture2D(normalBuffer,vUv3).rgb;
#else
vec3 n[4];n[0]=vec3(0.0);n[1]=vec3(0.0);n[2]=vec3(0.0);n[3]=vec3(0.0);
#endif
gl_FragColor=vec4(n[index],d[index]);}`,ar=`uniform vec2 texelSize;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vUv0=uv;vUv1=vec2(uv.x,uv.y+texelSize.y);vUv2=vec2(uv.x+texelSize.x,uv.y);vUv3=uv+texelSize;gl_Position=vec4(position.xy,1.0,1.0);}`,or=class extends j{constructor(){super({name:`DepthDownsamplingMaterial`,defines:{DEPTH_PACKING:`0`},uniforms:{depthBuffer:new M(null),normalBuffer:new M(null),texelSize:new M(new D)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:ir,vertexShader:ar})}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.depthPacking=t}set normalBuffer(e){this.uniforms.normalBuffer.value=e,e===null?delete this.defines.DOWNSAMPLE_NORMALS:this.defines.DOWNSAMPLE_NORMALS=`1`,this.needsUpdate=!0}setNormalBuffer(e){this.normalBuffer=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},sr=class extends N{constructor({normalBuffer:e=null,resolutionScale:t=.5,width:n=R.AUTO_SIZE,height:r=R.AUTO_SIZE,resolutionX:i=n,resolutionY:a=r}={}){super(`DepthDownsamplingPass`);let o=new or;o.normalBuffer=e,this.fullscreenMaterial=o,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new c(1,1,{minFilter:k,magFilter:k,depthBuffer:!1,type:A}),this.renderTarget.texture.name=`DepthDownsamplingPass.Target`,this.renderTarget.texture.generateMipmaps=!1;let s=this.resolution=new R(this,i,a,t);s.addEventListener(`change`,e=>this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e,t=w){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t}render(e,t,n,r,i){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){let r=e.getContext();if(!(r.getExtension(`EXT_color_buffer_float`)||r.getExtension(`EXT_color_buffer_half_float`)))throw Error(`Rendering to float texture is not supported.`)}},cr=`uniform lowp sampler2D aoBuffer;uniform float luminanceInfluence;uniform float intensity;
#if defined(DEPTH_AWARE_UPSAMPLING) && defined(NORMAL_DEPTH)
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D normalDepthBuffer;
#else
uniform mediump sampler2D normalDepthBuffer;
#endif
#endif
#ifdef COLORIZE
uniform vec3 color;
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){float aoLinear=texture2D(aoBuffer,uv).r;
#if defined(DEPTH_AWARE_UPSAMPLING) && defined(NORMAL_DEPTH) && __VERSION__ == 300
vec4 normalDepth[4];normalDepth[0]=textureOffset(normalDepthBuffer,uv,ivec2(0,0));normalDepth[1]=textureOffset(normalDepthBuffer,uv,ivec2(0,1));normalDepth[2]=textureOffset(normalDepthBuffer,uv,ivec2(1,0));normalDepth[3]=textureOffset(normalDepthBuffer,uv,ivec2(1,1));float dot01=dot(normalDepth[0].rgb,normalDepth[1].rgb);float dot02=dot(normalDepth[0].rgb,normalDepth[2].rgb);float dot03=dot(normalDepth[0].rgb,normalDepth[3].rgb);float minDot=min(dot01,min(dot02,dot03));float s=step(THRESHOLD,minDot);float smallestDistance=1.0;int index;for(int i=0;i<4;++i){float distance=abs(depth-normalDepth[i].a);if(distance<smallestDistance){smallestDistance=distance;index=i;}}ivec2 offsets[4];offsets[0]=ivec2(0,0);offsets[1]=ivec2(0,1);offsets[2]=ivec2(1,0);offsets[3]=ivec2(1,1);ivec2 coord=ivec2(uv*vec2(textureSize(aoBuffer,0)))+offsets[index];float aoNearest=texelFetch(aoBuffer,coord,0).r;float ao=mix(aoNearest,aoLinear,s);
#else
float ao=aoLinear;
#endif
float l=luminance(inputColor.rgb);ao=mix(ao,0.0,l*luminanceInfluence);ao=clamp(ao*intensity,0.0,1.0);
#ifdef COLORIZE
outputColor=vec4(1.0-ao*(1.0-color),inputColor.a);
#else
outputColor=vec4(vec3(1.0-ao),inputColor.a);
#endif
}`,lr=64,ur=class extends B{constructor(e,t,{blendFunction:n=z.MULTIPLY,samples:r=9,rings:i=7,normalDepthBuffer:a=null,depthAwareUpsampling:o=!0,worldDistanceThreshold:s,worldDistanceFalloff:l,worldProximityThreshold:u,worldProximityFalloff:f,distanceThreshold:m=.97,distanceFalloff:h=.03,rangeThreshold:g=5e-4,rangeFalloff:_=.001,minRadiusScale:v=.1,luminanceInfluence:y=.7,radius:b=.1825,intensity:x=1,bias:S=.025,fade:ee=.01,color:C=null,resolutionScale:te=1,width:w=R.AUTO_SIZE,height:T=R.AUTO_SIZE,resolutionX:ne=w,resolutionY:re=T}={}){super(`SSAOEffect`,cr,{blendFunction:n,attributes:F.DEPTH,defines:new Map([[`THRESHOLD`,`0.997`]]),uniforms:new Map([[`aoBuffer`,new M(null)],[`normalDepthBuffer`,new M(a)],[`luminanceInfluence`,new M(y)],[`color`,new M(null)],[`intensity`,new M(x)],[`scale`,new M(0)]])}),this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`AO.Target`,this.uniforms.get(`aoBuffer`).value=this.renderTarget.texture;let E=this.resolution=new R(this,ne,re,te);E.addEventListener(`change`,e=>this.setSize(E.baseWidth,E.baseHeight)),this.camera=e,this.depthDownsamplingPass=new sr({normalBuffer:t,resolutionScale:te}),this.depthDownsamplingPass.enabled=a===null,this.ssaoPass=new W(new rr(e));let D=new Nt(lr,lr,p);D.wrapS=D.wrapT=d;let O=this.ssaoMaterial;O.normalBuffer=t,O.noiseTexture=D,O.minRadiusScale=v,O.samples=r,O.radius=b,O.rings=i,O.fade=ee,O.bias=S,O.distanceThreshold=m,O.distanceFalloff=h,O.proximityThreshold=g,O.proximityFalloff=_,s!==void 0&&(O.worldDistanceThreshold=s),l!==void 0&&(O.worldDistanceFalloff=l),u!==void 0&&(O.worldProximityThreshold=u),f!==void 0&&(O.worldProximityFalloff=f),a!==null&&(this.ssaoMaterial.normalDepthBuffer=a,this.defines.set(`NORMAL_DEPTH`,`1`)),this.depthAwareUpsampling=o,this.color=C}set mainCamera(e){this.camera=e,this.ssaoMaterial.copyCameraSettings(e)}get normalBuffer(){return this.ssaoMaterial.normalBuffer}set normalBuffer(e){this.ssaoMaterial.normalBuffer=e,this.depthDownsamplingPass.fullscreenMaterial.normalBuffer=e}getResolution(){return this.resolution}get ssaoMaterial(){return this.ssaoPass.fullscreenMaterial}getSSAOMaterial(){return this.ssaoMaterial}get samples(){return this.ssaoMaterial.samples}set samples(e){this.ssaoMaterial.samples=e}get rings(){return this.ssaoMaterial.rings}set rings(e){this.ssaoMaterial.rings=e}get radius(){return this.ssaoMaterial.radius}set radius(e){this.ssaoMaterial.radius=e}get depthAwareUpsampling(){return this.defines.has(`DEPTH_AWARE_UPSAMPLING`)}set depthAwareUpsampling(e){this.depthAwareUpsampling!==e&&(e?this.defines.set(`DEPTH_AWARE_UPSAMPLING`,`1`):this.defines.delete(`DEPTH_AWARE_UPSAMPLING`),this.setChanged())}isDepthAwareUpsamplingEnabled(){return this.depthAwareUpsampling}setDepthAwareUpsamplingEnabled(e){this.depthAwareUpsampling=e}get distanceScaling(){return!0}set distanceScaling(e){}get color(){return this.uniforms.get(`color`).value}set color(e){let n=this.uniforms,r=this.defines;e===null?r.has(`COLORIZE`)&&(r.delete(`COLORIZE`),n.get(`color`).value=null,this.setChanged()):r.has(`COLORIZE`)?n.get(`color`).value.set(e):(r.set(`COLORIZE`,`1`),n.get(`color`).value=new t(e),this.setChanged())}get luminanceInfluence(){return this.uniforms.get(`luminanceInfluence`).value}set luminanceInfluence(e){this.uniforms.get(`luminanceInfluence`).value=e}get intensity(){return this.uniforms.get(`intensity`).value}set intensity(e){this.uniforms.get(`intensity`).value=e}getColor(){return this.color}setColor(e){this.color=e}setDistanceCutoff(e,t){this.ssaoMaterial.distanceThreshold=e,this.ssaoMaterial.distanceFalloff=t}setProximityCutoff(e,t){this.ssaoMaterial.proximityThreshold=e,this.ssaoMaterial.proximityFalloff=t}setDepthTexture(e,t=w){this.depthDownsamplingPass.setDepthTexture(e,t),this.ssaoMaterial.depthBuffer=e,this.ssaoMaterial.depthPacking=t}update(e,t,n){let r=this.renderTarget;this.depthDownsamplingPass.enabled&&this.depthDownsamplingPass.render(e),this.ssaoPass.render(e,null,r)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.ssaoMaterial.copyCameraSettings(this.camera),this.ssaoMaterial.setSize(r,i),this.renderTarget.setSize(r,i),this.depthDownsamplingPass.resolution.scale=n.scale,this.depthDownsamplingPass.setSize(e,t)}initialize(e,t,n){try{let r=this.uniforms.get(`normalDepthBuffer`).value;r===null&&(this.depthDownsamplingPass.initialize(e,t,n),r=this.depthDownsamplingPass.texture,this.uniforms.get(`normalDepthBuffer`).value=r,this.ssaoMaterial.normalDepthBuffer=r,this.defines.set(`NORMAL_DEPTH`,`1`))}catch{this.depthDownsamplingPass.enabled=!1}}},dr=`#ifdef TEXTURE_PRECISION_HIGH
uniform mediump sampler2D map;
#else
uniform lowp sampler2D map;
#endif
varying vec2 vUv2;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){
#ifdef UV_TRANSFORM
vec4 texel=texture2D(map,vUv2);
#else
vec4 texel=texture2D(map,uv);
#endif
outputColor=TEXEL;outputColor.a=max(inputColor.a,outputColor.a);}`,fr=`#ifdef ASPECT_CORRECTION
uniform float scale;
#else
uniform mat3 uvTransform;
#endif
varying vec2 vUv2;void mainSupport(const in vec2 uv){
#ifdef ASPECT_CORRECTION
vUv2=uv*vec2(aspect,1.0)*scale;
#else
vUv2=(uvTransform*vec3(uv,1.0)).xy;
#endif
}`,pr=class extends B{constructor({blendFunction:e,texture:t=null,aspectCorrection:n=!1}={}){super(`TextureEffect`,dr,{blendFunction:e,defines:new Map([[`TEXEL`,`texel`]]),uniforms:new Map([[`map`,new M(null)],[`scale`,new M(1)],[`uvTransform`,new M(null)]])}),this.texture=t,this.aspectCorrection=n}get texture(){return this.uniforms.get(`map`).value}set texture(e){let t=this.texture,n=this.uniforms,r=this.defines;t!==e&&(n.get(`map`).value=e,n.get(`uvTransform`).value=e.matrix,r.delete(`TEXTURE_PRECISION_HIGH`),e!==null&&(e.matrixAutoUpdate?(r.set(`UV_TRANSFORM`,`1`),this.setVertexShader(fr)):(r.delete(`UV_TRANSFORM`),this.setVertexShader(null)),e.type!==1009&&r.set(`TEXTURE_PRECISION_HIGH`,`1`),(t===null||t.type!==e.type||t.encoding!==e.encoding)&&this.setChanged()))}getTexture(){return this.texture}setTexture(e){this.texture=e}get aspectCorrection(){return this.defines.has(`ASPECT_CORRECTION`)}set aspectCorrection(e){this.aspectCorrection!==e&&(e?this.defines.set(`ASPECT_CORRECTION`,`1`):this.defines.delete(`ASPECT_CORRECTION`),this.setChanged())}get uvTransform(){let e=this.texture;return e!==null&&e.matrixAutoUpdate}set uvTransform(e){let t=this.texture;t!==null&&(t.matrixAutoUpdate=e)}setTextureSwizzleRGBA(e,t=e,n=e,r=e){let i=`rgba`,a=``;(e!==U.RED||t!==U.GREEN||n!==U.BLUE||r!==U.ALPHA)&&(a=[`.`,i[e],i[t],i[n],i[r]].join(``)),this.defines.set(`TEXEL`,`texel`+a),this.setChanged()}update(e,t,n){this.texture.matrixAutoUpdate&&this.texture.updateMatrix()}},mr=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform vec4 maskParams;varying vec2 vUv;varying vec2 vUv2;varying vec2 vOffset;float linearGradientMask(const in float x){return smoothstep(maskParams.x,maskParams.y,x)-smoothstep(maskParams.w,maskParams.z,x);}void main(){vec2 dUv=vOffset*(1.0-linearGradientMask(vUv2.y));vec4 sum=texture2D(inputBuffer,vec2(vUv.x-dUv.x,vUv.y+dUv.y));sum+=texture2D(inputBuffer,vec2(vUv.x+dUv.x,vUv.y+dUv.y));sum+=texture2D(inputBuffer,vec2(vUv.x+dUv.x,vUv.y-dUv.y));sum+=texture2D(inputBuffer,vec2(vUv.x-dUv.x,vUv.y-dUv.y));gl_FragColor=sum*0.25;
#include <colorspace_fragment>
}`,hr=`uniform vec4 texelSize;uniform float kernel;uniform float scale;uniform float aspect;uniform vec2 rotation;varying vec2 vUv;varying vec2 vUv2;varying vec2 vOffset;void main(){vec2 uv=position.xy*0.5+0.5;vUv=uv;vUv2=(uv-0.5)*2.0*vec2(aspect,1.0);vUv2=vec2(dot(rotation,vUv2),dot(rotation,vec2(vUv2.y,-vUv2.x)));vOffset=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;gl_Position=vec4(position.xy,1.0,1.0);}`,gr=class extends He{constructor({kernelSize:e=V.MEDIUM,offset:t=0,rotation:n=0,focusArea:r=.4,feather:i=.3}={}){super(),this.fragmentShader=mr,this.vertexShader=hr,this.kernelSize=e,this.uniforms.aspect=new M(1),this.uniforms.rotation=new M(new D),this.uniforms.maskParams=new M(new E),this._offset=t,this._focusArea=r,this._feather=i,this.rotation=n,this.updateParams()}updateParams(){let e=this.uniforms.maskParams.value,t=Math.max(this.focusArea,0),n=Math.max(t-this.feather,0);e.set(this.offset-t,this.offset-n,this.offset+t,this.offset+n)}get rotation(){return Math.acos(this.uniforms.rotation.value.x)}set rotation(e){this.uniforms.rotation.value.set(Math.cos(e),Math.sin(e))}get offset(){return this._offset}set offset(e){this._offset=e,this.updateParams()}get focusArea(){return this._focusArea}set focusArea(e){this._focusArea=e,this.updateParams()}get feather(){return this._feather}set feather(e){this._feather=e,this.updateParams()}setSize(e,t){super.setSize(e,t),this.uniforms.aspect.value=e/t}},_r=class extends H{constructor({offset:e=0,rotation:t=0,focusArea:n=.4,feather:r=.3,kernelSize:i=V.MEDIUM,resolutionScale:a=.5,resolutionX:o=R.AUTO_SIZE,resolutionY:s=R.AUTO_SIZE}={}){super({kernelSize:i,resolutionScale:a,resolutionX:o,resolutionY:s}),this.blurMaterial=new gr({kernelSize:i,offset:e,rotation:t,focusArea:n,feather:r})}},vr=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D map;
#else
uniform lowp sampler2D map;
#endif
uniform vec2 maskParams;varying vec2 vUv2;float linearGradientMask(const in float x){return step(maskParams.x,x)-step(maskParams.y,x);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float mask=linearGradientMask(vUv2.y);vec4 texel=texture2D(map,uv);outputColor=mix(texel,inputColor,mask);}`,yr=`uniform vec2 rotation;varying vec2 vUv2;void mainSupport(const in vec2 uv){vUv2=(uv-0.5)*2.0*vec2(aspect,1.0);vUv2=vec2(dot(rotation,vUv2),dot(rotation,vec2(vUv2.y,-vUv2.x)));}`,br=class extends B{constructor({blendFunction:e,offset:t=0,rotation:n=0,focusArea:r=.4,feather:i=.3,kernelSize:a=V.MEDIUM,resolutionScale:o=.5,resolutionX:s=R.AUTO_SIZE,resolutionY:l=R.AUTO_SIZE}={}){super(`TiltShiftEffect`,vr,{vertexShader:yr,blendFunction:e,uniforms:new Map([[`rotation`,new M(new D)],[`maskParams`,new M(new D)],[`map`,new M(null)]])}),this._offset=t,this._focusArea=r,this._feather=i,this.renderTarget=new c(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`TiltShift.Target`,this.uniforms.get(`map`).value=this.renderTarget.texture,this.blurPass=new _r({kernelSize:a,resolutionScale:o,resolutionX:s,resolutionY:l,offset:t,rotation:n,focusArea:r,feather:i});let u=this.resolution=new R(this,s,l,o);u.addEventListener(`change`,e=>this.setSize(u.baseWidth,u.baseHeight)),this.rotation=n,this.updateParams()}updateParams(){let e=this.uniforms.get(`maskParams`).value,t=Math.max(this.focusArea-this.feather,0);e.set(this.offset-t,this.offset+t)}get rotation(){return Math.acos(this.uniforms.get(`rotation`).value.x)}set rotation(e){this.uniforms.get(`rotation`).value.set(Math.cos(e),Math.sin(e)),this.blurPass.blurMaterial.rotation=e}get offset(){return this._offset}set offset(e){this._offset=e,this.blurPass.blurMaterial.offset=e,this.updateParams()}get focusArea(){return this._focusArea}set focusArea(e){this._focusArea=e,this.blurPass.blurMaterial.focusArea=e,this.updateParams()}get feather(){return this._feather}set feather(e){this._feather=e,this.blurPass.blurMaterial.feather=e,this.updateParams()}get bias(){return 0}set bias(e){}update(e,t,n){this.blurPass.render(e,t,this.renderTarget)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.blurPass.resolution.copy(n)}initialize(e,t,n){this.blurPass.initialize(e,t,n),n!==void 0&&(this.renderTarget.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=C))}},xr=`#include <packing>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
uniform lowp sampler2D luminanceBuffer0;uniform lowp sampler2D luminanceBuffer1;uniform float minLuminance;uniform float deltaTime;uniform float tau;varying vec2 vUv;void main(){float l0=unpackRGBAToFloat(texture2D(luminanceBuffer0,vUv));
#if __VERSION__ < 300
float l1=texture2DLodEXT(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#else
float l1=textureLod(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#endif
l0=max(minLuminance,l0);l1=max(minLuminance,l1);float adaptedLum=l0+(l1-l0)*(1.0-exp(-deltaTime*tau));gl_FragColor=(adaptedLum==1.0)?vec4(1.0):packFloatToRGBA(adaptedLum);}`,Sr=class extends j{constructor(){super({name:`AdaptiveLuminanceMaterial`,defines:{MIP_LEVEL_1X1:`0.0`},uniforms:{luminanceBuffer0:new M(null),luminanceBuffer1:new M(null),minLuminance:new M(.01),deltaTime:new M(0),tau:new M(1)},extensions:{shaderTextureLOD:!0},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:xr,vertexShader:P})}set luminanceBuffer0(e){this.uniforms.luminanceBuffer0.value=e}setLuminanceBuffer0(e){this.uniforms.luminanceBuffer0.value=e}set luminanceBuffer1(e){this.uniforms.luminanceBuffer1.value=e}setLuminanceBuffer1(e){this.uniforms.luminanceBuffer1.value=e}set mipLevel1x1(e){this.defines.MIP_LEVEL_1X1=e.toFixed(1),this.needsUpdate=!0}setMipLevel1x1(e){this.mipLevel1x1=e}set deltaTime(e){this.uniforms.deltaTime.value=e}setDeltaTime(e){this.uniforms.deltaTime.value=e}get minLuminance(){return this.uniforms.minLuminance.value}set minLuminance(e){this.uniforms.minLuminance.value=e}getMinLuminance(){return this.uniforms.minLuminance.value}setMinLuminance(e){this.uniforms.minLuminance.value=e}get adaptationRate(){return this.uniforms.tau.value}set adaptationRate(e){this.uniforms.tau.value=e}getAdaptationRate(){return this.uniforms.tau.value}setAdaptationRate(e){this.uniforms.tau.value=e}},Cr=class extends N{constructor(e,{minLuminance:t=.01,adaptationRate:n=1}={}){super(`AdaptiveLuminancePass`),this.fullscreenMaterial=new Sr,this.needsSwap=!1,this.renderTargetPrevious=new c(1,1,{minFilter:k,magFilter:k,depthBuffer:!1}),this.renderTargetPrevious.texture.name=`Luminance.Previous`;let r=this.fullscreenMaterial;r.luminanceBuffer0=this.renderTargetPrevious.texture,r.luminanceBuffer1=e,r.minLuminance=t,r.adaptationRate=n,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name=`Luminance.Adapted`,this.copyPass=new ge(this.renderTargetPrevious,!1)}get texture(){return this.renderTargetAdapted.texture}getTexture(){return this.renderTargetAdapted.texture}set mipLevel1x1(e){this.fullscreenMaterial.mipLevel1x1=e}get adaptationRate(){return this.fullscreenMaterial.adaptationRate}set adaptationRate(e){this.fullscreenMaterial.adaptationRate=e}render(e,t,n,r,i){this.fullscreenMaterial.deltaTime=r,e.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),e.render(this.scene,this.camera),this.copyPass.render(e,this.renderTargetAdapted)}},wr=`#include <tonemapping_pars_fragment>
uniform float whitePoint;
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
uniform float middleGrey;
#if TONE_MAPPING_MODE == 3
uniform lowp sampler2D luminanceBuffer;
#else
uniform float averageLuminance;
#endif
vec3 Reinhard2ToneMapping(vec3 color){color*=toneMappingExposure;float l=luminance(color);
#if TONE_MAPPING_MODE == 3
float lumAvg=unpackRGBAToFloat(texture2D(luminanceBuffer,vec2(0.5)));
#else
float lumAvg=averageLuminance;
#endif
float lumScaled=(l*middleGrey)/max(lumAvg,1e-6);float lumCompressed=lumScaled*(1.0+lumScaled/(whitePoint*whitePoint));lumCompressed/=(1.0+lumScaled);return clamp(lumCompressed*color,0.0,1.0);}
#elif TONE_MAPPING_MODE == 4
#define A 0.15
#define B 0.50
#define C 0.10
#define D 0.20
#define E 0.02
#define F 0.30
vec3 Uncharted2Helper(const in vec3 x){return((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}vec3 Uncharted2ToneMapping(vec3 color){color*=toneMappingExposure;return clamp(Uncharted2Helper(color)/Uncharted2Helper(vec3(whitePoint)),0.0,1.0);}
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
outputColor=vec4(Reinhard2ToneMapping(inputColor.rgb),inputColor.a);
#elif TONE_MAPPING_MODE == 4
outputColor=vec4(Uncharted2ToneMapping(inputColor.rgb),inputColor.a);
#else
outputColor=vec4(toneMapping(inputColor.rgb),inputColor.a);
#endif
}`,Tr=class extends B{constructor({blendFunction:e=z.SRC,adaptive:t=!1,mode:n=t?q.REINHARD2_ADAPTIVE:q.AGX,resolution:r=256,maxLuminance:i=4,whitePoint:a=i,middleGrey:o=.6,minLuminance:s=.01,averageLuminance:l=1,adaptationRate:u=1}={}){super(`ToneMappingEffect`,wr,{blendFunction:e,uniforms:new Map([[`luminanceBuffer`,new M(null)],[`maxLuminance`,new M(i)],[`whitePoint`,new M(a)],[`middleGrey`,new M(o)],[`averageLuminance`,new M(l)]])}),this.renderTargetLuminance=new c(1,1,{minFilter:h,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name=`Luminance`,this.luminancePass=new Ge({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new Cr(this.luminancePass.texture,{minLuminance:s,adaptationRate:u}),this.uniforms.get(`luminanceBuffer`).value=this.adaptiveLuminancePass.texture,this.resolution=r,this.mode=n}get mode(){return Number(this.defines.get(`TONE_MAPPING_MODE`))}set mode(e){if(this.mode===e)return;let t=`169.19`.replace(/\D+/g,``)>=168?`CineonToneMapping(texel)`:`OptimizedCineonToneMapping(texel)`;switch(this.defines.clear(),this.defines.set(`TONE_MAPPING_MODE`,e.toFixed(0)),e){case q.LINEAR:this.defines.set(`toneMapping(texel)`,`LinearToneMapping(texel)`);break;case q.REINHARD:this.defines.set(`toneMapping(texel)`,`ReinhardToneMapping(texel)`);break;case q.CINEON:case q.OPTIMIZED_CINEON:this.defines.set(`toneMapping(texel)`,t);break;case q.ACES_FILMIC:this.defines.set(`toneMapping(texel)`,`ACESFilmicToneMapping(texel)`);break;case q.AGX:this.defines.set(`toneMapping(texel)`,`AgXToneMapping(texel)`);break;case q.NEUTRAL:this.defines.set(`toneMapping(texel)`,`NeutralToneMapping(texel)`);break;default:this.defines.set(`toneMapping(texel)`,`texel`);break}this.adaptiveLuminancePass.enabled=e===q.REINHARD2_ADAPTIVE,this.setChanged()}getMode(){return this.mode}setMode(e){this.mode=e}get whitePoint(){return this.uniforms.get(`whitePoint`).value}set whitePoint(e){this.uniforms.get(`whitePoint`).value=e}get middleGrey(){return this.uniforms.get(`middleGrey`).value}set middleGrey(e){this.uniforms.get(`middleGrey`).value=e}get averageLuminance(){return this.uniforms.get(`averageLuminance`).value}set averageLuminance(e){this.uniforms.get(`averageLuminance`).value=e}get adaptiveLuminanceMaterial(){return this.adaptiveLuminancePass.fullscreenMaterial}getAdaptiveLuminanceMaterial(){return this.adaptiveLuminanceMaterial}get resolution(){return this.luminancePass.resolution.width}set resolution(e){let t=Math.max(0,Math.ceil(Math.log2(e))),n=2**t;this.luminancePass.resolution.setPreferredSize(n,n),this.adaptiveLuminanceMaterial.mipLevel1x1=t}getResolution(){return this.resolution}setResolution(e){this.resolution=e}get adaptive(){return this.mode===q.REINHARD2_ADAPTIVE}set adaptive(e){this.mode=e?q.REINHARD2_ADAPTIVE:q.REINHARD2}get adaptationRate(){return this.adaptiveLuminanceMaterial.adaptationRate}set adaptationRate(e){this.adaptiveLuminanceMaterial.adaptationRate=e}get distinction(){return console.warn(this.name,`distinction was removed.`),1}set distinction(e){console.warn(this.name,`distinction was removed.`)}update(e,t,n){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(e,t),this.adaptiveLuminancePass.render(e,null,null,n))}initialize(e,t,n){this.adaptiveLuminancePass.initialize(e,t,n)}},Er=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb;
#if VIGNETTE_TECHNIQUE == 0
float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
#else
vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
#endif
outputColor=vec4(color,inputColor.a);}`,Dr=class extends B{constructor({blendFunction:e,eskil:t=!1,technique:n=t?dn.ESKIL:dn.DEFAULT,offset:r=.5,darkness:i=.5}={}){super(`VignetteEffect`,Er,{blendFunction:e,defines:new Map([[`VIGNETTE_TECHNIQUE`,n.toFixed(0)]]),uniforms:new Map([[`offset`,new M(r)],[`darkness`,new M(i)]])})}get technique(){return Number(this.defines.get(`VIGNETTE_TECHNIQUE`))}set technique(e){this.technique!==e&&(this.defines.set(`VIGNETTE_TECHNIQUE`,e.toFixed(0)),this.setChanged())}get eskil(){return this.technique===dn.ESKIL}set eskil(e){this.technique=e?dn.ESKIL:dn.DEFAULT}getTechnique(){return this.technique}setTechnique(e){this.technique=e}get offset(){return this.uniforms.get(`offset`).value}set offset(e){this.uniforms.get(`offset`).value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}get darkness(){return this.uniforms.get(`darkness`).value}set darkness(e){this.uniforms.get(`darkness`).value=e}getDarkness(){return this.darkness}setDarkness(e){this.darkness=e}},Or=class extends b{load(e,t=()=>{},n=()=>{},r=null){let i=this.manager,a=new v,o=new re(a);o.setPath(this.path),o.setResponseType(`text`),i.itemStart(e),o.load(e,n=>{try{let r=this.parse(n);i.itemEnd(e),t(r)}catch(t){a.onError(e),r(t)}},n)}loadAsync(e,t=()=>{}){let n=this.manager,r=new v;return new Promise((i,a)=>{r.onError=e=>{n.itemError(e),a(`Failed to load ${e}`)},this.load(e,i,t)})}parse(e){let t=/^[\d ]+$/m,n=/^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm,r=t.exec(e);if(r===null)throw Error(`Missing grid information`);let i=r[0].trim().split(/\s+/g).map(e=>Number(e)),a=i[1]-i[0],o=i.length,s=o**2;for(let e=1,t=i.length;e<t;++e)if(a!==i[e]-i[e-1])throw Error(`Inconsistent grid size`);let c=new Float32Array(o**3*4),l=0,u=0;for(;(r=n.exec(e))!==null;){let e=Number(r[1]),t=Number(r[2]),n=Number(r[3]);l=Math.max(l,e,t,n);let i=u%o,a=Math.floor(u/o)%o,d=Math.floor(u/s)%o,f=(i*s+a*o+d)*4;c[f+0]=e,c[f+1]=t,c[f+2]=n,c[f+3]=1,++u}let d=2**Math.ceil(Math.log2(l));for(let e=0,t=c.length;e<t;e+=4)c[e+0]/=d,c[e+1]/=d,c[e+2]/=d;return new nn(c,o)}},kr=class extends b{load(e,t=()=>{},n=()=>{},r=null){let i=this.manager,a=new v,o=new re(a);o.setPath(this.path),o.setResponseType(`text`),o.load(e,n=>{try{let r=this.parse(n);i.itemEnd(e),t(r)}catch(t){a.onError(e),r(t)}},n)}loadAsync(e,t=()=>{}){let n=this.manager,r=new v;return new Promise((i,a)=>{r.onError=e=>{n.itemError(e),a(`Failed to load ${e}`)},this.load(e,i,t)})}parse(e){let t=/TITLE +"([^"]*)"/,r=/LUT_3D_SIZE +(\d+)/,i=/DOMAIN_MIN +([\d.]+) +([\d.]+) +([\d.]+)/,a=/DOMAIN_MAX +([\d.]+) +([\d.]+) +([\d.]+)/,o=/^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm,s=t.exec(e),c=s===null?null:s[1];if(s=r.exec(e),s===null)throw Error(`Missing LUT_3D_SIZE information`);let l=Number(s[1]),u=new Float32Array(l**3*4),d=new n(0,0,0),f=new n(1,1,1);if(s=i.exec(e),s!==null&&d.set(Number(s[1]),Number(s[2]),Number(s[3])),s=a.exec(e),s!==null&&f.set(Number(s[1]),Number(s[2]),Number(s[3])),d.x>f.x||d.y>f.y||d.z>f.z)throw d.set(0,0,0),f.set(1,1,1),Error(`Invalid input domain`);let p=0;for(;(s=o.exec(e))!==null;)u[p++]=Number(s[1]),u[p++]=Number(s[2]),u[p++]=Number(s[3]),u[p++]=1;let m=new nn(u,l);return m.domainMin.copy(d),m.domainMax.copy(f),c!==null&&(m.name=c),m}},Ar=class extends b{load(e=()=>{},t=null){arguments.length===4?(e=arguments[1],t=arguments[3]):(arguments.length===3||typeof arguments[0]!=`function`)&&(e=arguments[1],t=null);let n=this.manager,r=new v;return new Promise((i,a)=>{let o=new Image,s=new Image;r.onError=e=>{n.itemError(e),t===null?a(`Failed to load ${e}`):(t(`Failed to load ${e}`),i())},r.onLoad=()=>{let t=[o,s];e(t),i(t)},o.addEventListener(`error`,e=>{r.itemError(`smaa-search`)}),s.addEventListener(`error`,e=>{r.itemError(`smaa-area`)}),o.addEventListener(`load`,()=>{n.itemEnd(`smaa-search`),r.itemEnd(`smaa-search`)}),s.addEventListener(`load`,()=>{n.itemEnd(`smaa-area`),r.itemEnd(`smaa-area`)}),n.itemStart(`smaa-search`),n.itemStart(`smaa-area`),r.itemStart(`smaa-search`),r.itemStart(`smaa-area`),o.src=Jn,s.src=Yn})}},jr=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef BILATERAL
#include <packing>
uniform vec2 cameraNearFar;
#define cameraNear cameraNearFar.x
#define cameraFar cameraNearFar.y
#ifdef NORMAL_DEPTH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D normalDepthBuffer;
#else
uniform mediump sampler2D normalDepthBuffer;
#endif
float readDepth(const in vec2 uv){float depth=texture2D(normalDepthBuffer,uv).a;
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}
#else
#if DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}
#endif
float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#else
return orthographicDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#endif
}
#ifdef PERSPECTIVE_CAMERA
#define linearDepth(v) viewZToOrthographicDepth(getViewZ(readDepth(v)), cameraNearFar.x, cameraNearFar.y)
#else
#define linearDepth(v) readDepth(v)
#endif
#endif
#define getTexel(v) texture2D(inputBuffer, v)
#if KERNEL_SIZE == 3
varying vec2 vUv00,vUv01,vUv02;varying vec2 vUv03,vUv04,vUv05;varying vec2 vUv06,vUv07,vUv08;
#elif KERNEL_SIZE == 5 && MAX_VARYING_VECTORS >= 13
varying vec2 vUv00,vUv01,vUv02,vUv03,vUv04;varying vec2 vUv05,vUv06,vUv07,vUv08,vUv09;varying vec2 vUv10,vUv11,vUv12,vUv13,vUv14;varying vec2 vUv15,vUv16,vUv17,vUv18,vUv19;varying vec2 vUv20,vUv21,vUv22,vUv23,vUv24;
#else
uniform vec2 texelSize;uniform float scale;varying vec2 vUv;
#endif
void main(){
#if KERNEL_SIZE == 3
vec4 c[]=vec4[KERNEL_SIZE_SQ](getTexel(vUv00),getTexel(vUv01),getTexel(vUv02),getTexel(vUv03),getTexel(vUv04),getTexel(vUv05),getTexel(vUv06),getTexel(vUv07),getTexel(vUv08));
#ifdef BILATERAL
float z[]=float[KERNEL_SIZE_SQ](linearDepth(vUv00),linearDepth(vUv01),linearDepth(vUv02),linearDepth(vUv03),linearDepth(vUv04),linearDepth(vUv05),linearDepth(vUv06),linearDepth(vUv07),linearDepth(vUv08));
#endif
#elif KERNEL_SIZE == 5 && MAX_VARYING_VECTORS >= 13
vec4 c[]=vec4[KERNEL_SIZE_SQ](getTexel(vUv00),getTexel(vUv01),getTexel(vUv02),getTexel(vUv03),getTexel(vUv04),getTexel(vUv05),getTexel(vUv06),getTexel(vUv07),getTexel(vUv08),getTexel(vUv09),getTexel(vUv10),getTexel(vUv11),getTexel(vUv12),getTexel(vUv13),getTexel(vUv14),getTexel(vUv15),getTexel(vUv16),getTexel(vUv17),getTexel(vUv18),getTexel(vUv19),getTexel(vUv20),getTexel(vUv21),getTexel(vUv22),getTexel(vUv23),getTexel(vUv24));
#ifdef BILATERAL
float z[]=float[KERNEL_SIZE_SQ](linearDepth(vUv00),linearDepth(vUv01),linearDepth(vUv02),linearDepth(vUv03),linearDepth(vUv04),linearDepth(vUv05),linearDepth(vUv06),linearDepth(vUv07),linearDepth(vUv08),linearDepth(vUv09),linearDepth(vUv10),linearDepth(vUv11),linearDepth(vUv12),linearDepth(vUv13),linearDepth(vUv14),linearDepth(vUv15),linearDepth(vUv16),linearDepth(vUv17),linearDepth(vUv18),linearDepth(vUv19),linearDepth(vUv20),linearDepth(vUv21),linearDepth(vUv22),linearDepth(vUv23),linearDepth(vUv24));
#endif
#endif
vec4 result=vec4(0.0);
#ifdef BILATERAL
float w=0.0;
#if KERNEL_SIZE == 3 || (KERNEL_SIZE == 5 && MAX_VARYING_VECTORS >= 13)
float centerDepth=z[KERNEL_SIZE_SQ_HALF];for(int i=0;i<KERNEL_SIZE_SQ;++i){float d=step(abs(z[i]-centerDepth),DISTANCE_THRESHOLD);result+=c[i]*d;w+=d;}
#else
float centerDepth=linearDepth(vUv);vec2 s=texelSize*scale;for(int x=-KERNEL_SIZE_HALF;x<=KERNEL_SIZE_HALF;++x){for(int y=-KERNEL_SIZE_HALF;y<=KERNEL_SIZE_HALF;++y){vec2 coords=vUv+vec2(x,y)*s;vec4 c=getTexel(coords);float z=(x==0&&y==0)?centerDepth:linearDepth(coords);float d=step(abs(z-centerDepth),DISTANCE_THRESHOLD);result+=c*d;w+=d;}}
#endif
gl_FragColor=result/max(w,1.0);
#else
#if KERNEL_SIZE == 3 || (KERNEL_SIZE == 5 && MAX_VARYING_VECTORS >= 13)
for(int i=0;i<KERNEL_SIZE_SQ;++i){result+=c[i];}
#else
vec2 s=texelSize*scale;for(int x=-KERNEL_SIZE_HALF;x<=KERNEL_SIZE_HALF;++x){for(int y=-KERNEL_SIZE_HALF;y<=KERNEL_SIZE_HALF;++y){result+=getTexel(uv+vec2(x,y)*s);}}
#endif
gl_FragColor=result*INV_KERNEL_SIZE_SQ;
#endif
}`,Mr=`uniform vec2 texelSize;uniform float scale;
#if KERNEL_SIZE == 3
varying vec2 vUv00,vUv01,vUv02;varying vec2 vUv03,vUv04,vUv05;varying vec2 vUv06,vUv07,vUv08;
#elif KERNEL_SIZE == 5 && MAX_VARYING_VECTORS >= 13
varying vec2 vUv00,vUv01,vUv02,vUv03,vUv04;varying vec2 vUv05,vUv06,vUv07,vUv08,vUv09;varying vec2 vUv10,vUv11,vUv12,vUv13,vUv14;varying vec2 vUv15,vUv16,vUv17,vUv18,vUv19;varying vec2 vUv20,vUv21,vUv22,vUv23,vUv24;
#else
varying vec2 vUv;
#endif
void main(){vec2 uv=position.xy*0.5+0.5;
#if KERNEL_SIZE == 3
vec2 s=texelSize*scale;vUv00=uv+s*vec2(-1.0,-1.0);vUv01=uv+s*vec2(0.0,-1.0);vUv02=uv+s*vec2(1.0,-1.0);vUv03=uv+s*vec2(-1.0,0.0);vUv04=uv;vUv05=uv+s*vec2(1.0,0.0);vUv06=uv+s*vec2(-1.0,1.0);vUv07=uv+s*vec2(0.0,1.0);vUv08=uv+s*vec2(1.0,1.0);
#elif KERNEL_SIZE == 5
vec2 s=texelSize*scale;vUv00=uv+s*vec2(-2.0,-2.0);vUv01=uv+s*vec2(-1.0,-2.0);vUv02=uv+s*vec2(0.0,-2.0);vUv03=uv+s*vec2(1.0,-2.0);vUv04=uv+s*vec2(2.0,-2.0);vUv05=uv+s*vec2(-2.0,-1.0);vUv06=uv+s*vec2(-1.0,-1.0);vUv07=uv+s*vec2(0.0,-1.0);vUv08=uv+s*vec2(1.0,-1.0);vUv09=uv+s*vec2(2.0,-1.0);vUv10=uv+s*vec2(-2.0,0.0);vUv11=uv+s*vec2(-1.0,0.0);vUv12=uv;vUv13=uv+s*vec2(1.0,0.0);vUv14=uv+s*vec2(2.0,0.0);vUv15=uv+s*vec2(-2.0,1.0);vUv16=uv+s*vec2(-1.0,1.0);vUv17=uv+s*vec2(0.0,1.0);vUv18=uv+s*vec2(1.0,1.0);vUv19=uv+s*vec2(2.0,1.0);vUv20=uv+s*vec2(-2.0,2.0);vUv21=uv+s*vec2(-1.0,2.0);vUv22=uv+s*vec2(0.0,2.0);vUv23=uv+s*vec2(1.0,2.0);vUv24=uv+s*vec2(2.0,2.0);
#else
vUv=uv;
#endif
gl_Position=vec4(position.xy,1.0,1.0);}`,Nr=class extends j{constructor({bilateral:e=!1,kernelSize:t=5}={}){super({name:`BoxBlurMaterial`,defines:{DEPTH_PACKING:`0`,DISTANCE_THRESHOLD:`0.1`},uniforms:{inputBuffer:new M(null),depthBuffer:new M(null),normalDepthBuffer:new M(null),texelSize:new M(new D),cameraNearFar:new M(new D),scale:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:jr,vertexShader:Mr}),this.bilateral=e,this.kernelSize=t,this.maxVaryingVectors=8}set maxVaryingVectors(e){this.defines.MAX_VARYING_VECTORS=e.toFixed(0)}get kernelSize(){return Number(this.defines.KERNEL_SIZE)}set kernelSize(e){if(e%2==0)throw Error(`The kernel size must be an odd number`);this.defines.KERNEL_SIZE=e.toFixed(0),this.defines.KERNEL_SIZE_HALF=Math.floor(e/2).toFixed(0),this.defines.KERNEL_SIZE_SQ=(e**2).toFixed(0),this.defines.KERNEL_SIZE_SQ_HALF=Math.floor(e**2/2).toFixed(0),this.defines.INV_KERNEL_SIZE_SQ=(1/e**2).toFixed(6),this.needsUpdate=!0}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}get near(){return this.uniforms.cameraNearFar.value.x}get far(){return this.uniforms.cameraNearFar.value.y}set inputBuffer(e){this.uniforms.inputBuffer.value=e}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set normalDepthBuffer(e){this.uniforms.normalDepthBuffer.value=e,e===null?delete this.defines.NORMAL_DEPTH:this.defines.NORMAL_DEPTH=`1`,this.needsUpdate=!0}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get bilateral(){return this.defines.BILATERAL!==void 0}set bilateral(e){e===null?delete this.defines.BILATERAL:this.defines.BILATERAL=`1`,this.needsUpdate=!0}get worldDistanceThreshold(){return-$n(Number(this.defines.DISTANCE_THRESHOLD),this.near,this.far)}set worldDistanceThreshold(e){let t=er(-e,this.near,this.far);this.defines.DISTANCE_THRESHOLD=t.toFixed(12),this.needsUpdate=!0}copyCameraSettings(e){e&&(this.uniforms.cameraNearFar.value.set(e.near,e.far),e instanceof T?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},Pr=`#include <packing>
varying vec2 vUv;
#ifdef NORMAL_DEPTH
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D normalDepthBuffer;
#else
uniform mediump sampler2D normalDepthBuffer;
#endif
float readDepth(const in vec2 uv){return texture2D(normalDepthBuffer,uv).a;}
#else
#if INPUT_DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if INPUT_DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#endif
void main(){
#if INPUT_DEPTH_PACKING == OUTPUT_DEPTH_PACKING
gl_FragColor=texture2D(depthBuffer,vUv);
#else
float depth=readDepth(vUv);
#if OUTPUT_DEPTH_PACKING == 3201
gl_FragColor=(depth==1.0)?vec4(1.0):packDepthToRGBA(depth);
#else
gl_FragColor=vec4(vec3(depth),1.0);
#endif
#endif
}`,Fr=`varying vec2 vUv;
#if DEPTH_COPY_MODE == 1
uniform vec2 texelPosition;
#endif
void main(){
#if DEPTH_COPY_MODE == 1
vUv=texelPosition;
#else
vUv=position.xy*0.5+0.5;
#endif
gl_Position=vec4(position.xy,1.0,1.0);}`,Ir=class extends j{constructor(){super({name:`DepthCopyMaterial`,defines:{INPUT_DEPTH_PACKING:`0`,OUTPUT_DEPTH_PACKING:`0`,DEPTH_COPY_MODE:`0`},uniforms:{depthBuffer:new M(null),texelPosition:new M(new D)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Pr,vertexShader:Fr}),this.depthCopyMode=on.FULL}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set inputDepthPacking(e){this.defines.INPUT_DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get outputDepthPacking(){return Number(this.defines.OUTPUT_DEPTH_PACKING)}set outputDepthPacking(e){this.defines.OUTPUT_DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.inputDepthPacking=t}getInputDepthPacking(){return Number(this.defines.INPUT_DEPTH_PACKING)}setInputDepthPacking(e){this.defines.INPUT_DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}getOutputDepthPacking(){return Number(this.defines.OUTPUT_DEPTH_PACKING)}setOutputDepthPacking(e){this.defines.OUTPUT_DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get texelPosition(){return this.uniforms.texelPosition.value}getTexelPosition(){return this.uniforms.texelPosition.value}setTexelPosition(e){this.uniforms.texelPosition.value=e}get mode(){return this.depthCopyMode}set mode(e){this.depthCopyMode=e,this.defines.DEPTH_COPY_MODE=e.toFixed(0),this.needsUpdate=!0}getMode(){return this.mode}setMode(e){this.mode=e}},Lr=`#include <common>
#include <packing>
#include <dithering_pars_fragment>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#if DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return 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);}float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
}vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0;
#ifdef ENCODE_OUTPUT
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
}`,Rr=`uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}`,zr=class extends j{constructor(e,t,n,r,i=!1){super({name:`EffectMaterial`,defines:{THREE_REVISION:o.replace(/\D+/g,``),DEPTH_PACKING:`0`,ENCODE_OUTPUT:`1`},uniforms:{inputBuffer:new M(null),depthBuffer:new M(null),resolution:new M(new D),texelSize:new M(new D),cameraNear:new M(.3),cameraFar:new M(1e3),aspect:new M(1),time:new M(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:i}),e&&this.setShaderParts(e),t&&this.setDefines(t),n&&this.setUniforms(n),this.copyCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=w){this.depthBuffer=e,this.depthPacking=t}setShaderData(e){this.setShaderParts(e.shaderParts),this.setDefines(e.defines),this.setUniforms(e.uniforms),this.setExtensions(e.extensions)}setShaderParts(e){return this.fragmentShader=Lr.replace(I.FRAGMENT_HEAD,e.get(I.FRAGMENT_HEAD)||``).replace(I.FRAGMENT_MAIN_UV,e.get(I.FRAGMENT_MAIN_UV)||``).replace(I.FRAGMENT_MAIN_IMAGE,e.get(I.FRAGMENT_MAIN_IMAGE)||``),this.vertexShader=Rr.replace(I.VERTEX_HEAD,e.get(I.VERTEX_HEAD)||``).replace(I.VERTEX_MAIN_SUPPORT,e.get(I.VERTEX_MAIN_SUPPORT)||``),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT=`1`:delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof T?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let n=this.uniforms;n.resolution.value.set(e,t),n.texelSize.value.set(1/e,1/t),n.aspect.value=e/t}static get Section(){return I}},Br=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform vec2 kernel[STEPS];varying vec2 vOffset;varying vec2 vUv;void main(){vec4 result=texture2D(inputBuffer,vUv)*kernel[0].y;for(int i=1;i<STEPS;++i){vec2 offset=kernel[i].x*vOffset;vec4 c0=texture2D(inputBuffer,vUv+offset);vec4 c1=texture2D(inputBuffer,vUv-offset);result+=(c0+c1)*kernel[i].y;}gl_FragColor=result;
#include <colorspace_fragment>
}`,Vr=`uniform vec2 texelSize;uniform vec2 direction;uniform float scale;varying vec2 vOffset;varying vec2 vUv;void main(){vOffset=direction*texelSize*scale;vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,Hr=class extends j{constructor({kernelSize:e=35}={}){super({name:`GaussianBlurMaterial`,uniforms:{inputBuffer:new M(null),texelSize:new M(new D),direction:new M(new D),kernel:new M(null),scale:new M(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Br,vertexShader:Vr}),this._kernelSize=0,this.kernelSize=e}set inputBuffer(e){this.uniforms.inputBuffer.value=e}get kernelSize(){return this._kernelSize}set kernelSize(e){this._kernelSize=e,this.generateKernel(e)}get direction(){return this.uniforms.direction.value}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}generateKernel(e){let t=new Ee(e),n=t.linearSteps,r=new Float64Array(n*2);for(let e=0,i=0;e<n;++e)r[i++]=t.linearOffsets[e],r[i++]=t.linearWeights[e];this.uniforms.kernel.value=r,this.defines.STEPS=n.toFixed(0),this.needsUpdate=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},Ur=class extends N{constructor({kernelSize:e=5,iterations:t=1,bilateral:n=!1,resolutionScale:r=1,resolutionX:i=R.AUTO_SIZE,resolutionY:a=R.AUTO_SIZE}={}){super(`BoxBlurPass`),this.needsDepthTexture=n,this.renderTargetA=new c(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name=`Blur.Target.A`,this.renderTargetB=new c(1,1,{depthBuffer:!1}),this.renderTargetB.texture.name=`Blur.Target.B`,this.blurMaterial=new Nr({bilateral:n,kernelSize:e}),this.copyMaterial=new he;let o=this.resolution=new R(this,i,a,r);o.addEventListener(`change`,e=>this.setSize(o.baseWidth,o.baseHeight)),this.iterations=t}set mainCamera(e){this.blurMaterial.copyCameraSettings(e)}setDepthTexture(e,t=w){this.blurMaterial.depthBuffer=e,this.blurMaterial.depthPacking=t}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.renderTargetA,c=this.renderTargetB,l=this.blurMaterial;this.fullscreenMaterial=l;let u=t;for(let t=0,n=Math.max(this.iterations,1);t<n;++t){let n=t&1?c:s;l.inputBuffer=u.texture,e.setRenderTarget(n),e.render(a,o),u=n}this.copyMaterial.inputBuffer=u.texture,this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:n),e.render(a,o)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurMaterial.setSize(e,t)}initialize(e,t,n){e!==null&&(this.blurMaterial.maxVaryingVectors=e.capabilities.maxVaryings),n!==void 0&&(this.renderTargetA.texture.type=n,this.renderTargetB.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTargetA.texture.colorSpace=C,this.renderTargetB.texture.colorSpace=C):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},Wr=class extends N{constructor({depthPacking:e=i}={}){super(`DepthCopyPass`);let t=new Ir;t.outputDepthPacking=e,this.fullscreenMaterial=t,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new c(1,1,{type:e===3201?ce:A,minFilter:k,magFilter:k,depthBuffer:!1}),this.renderTarget.texture.name=`DepthCopyPass.Target`}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}get depthPacking(){return this.fullscreenMaterial.outputDepthPacking}getDepthPacking(){return this.fullscreenMaterial.outputDepthPacking}setDepthTexture(e,t=w){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.inputDepthPacking=t}render(e,t,n,r,i){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.renderTarget.setSize(e,t)}},Gr=Number(o.replace(/\D+/g,``)),J=255/256,Kr=new Float32Array([J/256**3,J/256**2,J/256,J]),qr=new Float32Array([J,J/256,J/256**2,1/256**3]);function Jr(e){let t=Gr>=167?qr:Kr;return(e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3])/255}var Yr=class extends Wr{constructor({depthPacking:e=i,mode:t=on.SINGLE}={}){if(e!==3201&&e!==3200)throw Error(`Unsupported depth packing: ${e}`);super({depthPacking:e}),this.name=`DepthPickingPass`,this.fullscreenMaterial.mode=t,this.pixelBuffer=e===3201?new Uint8Array(4):new Float32Array(4),this.callback=null}readDepth(e){return this.fullscreenMaterial.texelPosition.set(e.x*.5+.5,e.y*.5+.5),new Promise(e=>{this.callback=e})}render(e,t,n,r,i){let a=this.fullscreenMaterial,o=a.mode;if(o===on.FULL&&super.render(e),this.callback!==null){let t=this.renderTarget,n=this.pixelBuffer,r=t.texture.type!==A,i=0,s=0;if(o===on.SINGLE)super.render(e);else{let e=a.texelPosition;i=Math.round(e.x*t.width),s=Math.round(e.y*t.height)}e.readRenderTargetPixels(t,i,s,1,1,n),this.callback(r?Jr(n):n[0]),this.callback=null}}setSize(e,t){this.fullscreenMaterial.mode===on.FULL&&super.setSize(e,t)}};function Xr(e,t,n){for(let r of t){let t=`$1`+e+r.charAt(0).toUpperCase()+r.slice(1),i=RegExp(`([^\\.])(\\b`+r+`\\b)`,`g`);for(let e of n.entries())e[1]!==null&&n.set(e[0],e[1].replace(i,t))}}function Zr(e,t,n){let r=t.getFragmentShader(),i=t.getVertexShader(),a=r!==void 0&&/mainImage/.test(r),o=r!==void 0&&/mainUv/.test(r);if(n.attributes|=t.getAttributes(),r===void 0)throw Error(`Missing fragment shader (${t.name})`);if(o&&(n.attributes&F.CONVOLUTION)!==0)throw Error(`Effects that transform UVs are incompatible with convolution effects (${t.name})`);if(!a&&!o)throw Error(`Could not find mainImage or mainUv function (${t.name})`);{let s=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=n.shaderParts,l=c.get(I.FRAGMENT_HEAD)||``,u=c.get(I.FRAGMENT_MAIN_UV)||``,d=c.get(I.FRAGMENT_MAIN_IMAGE)||``,f=c.get(I.VERTEX_HEAD)||``,p=c.get(I.VERTEX_MAIN_SUPPORT)||``,m=new Set,h=new Set;if(o&&(u+=`	${e}MainUv(UV);
`,n.uvTransformation=!0),i!==null&&/mainSupport/.test(i)){let t=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);p+=`	${e}MainSupport(`,p+=t?`vUv);
`:`);
`;for(let e of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(let t of e[1].split(/\s*,\s*/))n.varyings.add(t),m.add(t),h.add(t);for(let e of i.matchAll(s))h.add(e[1])}for(let e of r.matchAll(s))h.add(e[1]);for(let e of t.defines.keys())h.add(e.replace(/\([\w\s,]*\)/g,``));for(let e of t.uniforms.keys())h.add(e);h.delete(`while`),h.delete(`for`),h.delete(`if`),t.uniforms.forEach((t,r)=>n.uniforms.set(e+r.charAt(0).toUpperCase()+r.slice(1),t)),t.defines.forEach((t,r)=>n.defines.set(e+r.charAt(0).toUpperCase()+r.slice(1),t));let g=new Map([[`fragment`,r],[`vertex`,i]]);Xr(e,h,n.defines),Xr(e,h,g),r=g.get(`fragment`),i=g.get(`vertex`);let _=t.blendMode;if(n.blendModes.set(_.blendFunction,_),a){t.inputColorSpace!==null&&t.inputColorSpace!==n.colorSpace&&(d+=t.inputColorSpace===`srgb`?`color0 = sRGBTransferOETF(color0);
	`:`color0 = sRGBToLinear(color0);
	`),t.outputColorSpace===``?t.inputColorSpace!==null&&(n.colorSpace=t.inputColorSpace):n.colorSpace=t.outputColorSpace,d+=`${e}MainImage(color0, UV, `,(n.attributes&F.DEPTH)!==0&&/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/.test(r)&&(d+=`depth, `,n.readDepth=!0),d+=`color1);
	`;let i=e+`BlendOpacity`;n.uniforms.set(i,_.opacity),d+=`color0 = blend${_.blendFunction}(color0, color1, ${i});

	`,l+=`uniform float ${i};

`}if(l+=r+`
`,i!==null&&(f+=i+`
`),c.set(I.FRAGMENT_HEAD,l),c.set(I.FRAGMENT_MAIN_UV,u),c.set(I.FRAGMENT_MAIN_IMAGE,d),c.set(I.VERTEX_HEAD,f),c.set(I.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(let e of t.extensions)n.extensions.add(e)}}var Qr=class extends N{constructor(e,...t){super(`EffectPass`),this.fullscreenMaterial=new zr(null,null,null,e),this.listener=e=>this.handleEvent(e),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=1/0,this.timeScale=1}set mainScene(e){for(let t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(let t of this.effects)t.mainCamera=e}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(let e of this.effects)e.removeEventListener(`change`,this.listener);this.effects=e.sort((e,t)=>t.attributes-e.attributes);for(let e of this.effects)e.addEventListener(`change`,this.listener)}updateMaterial(){let e=new we,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===z.DST)e.attributes|=n.getAttributes()&F.DEPTH;else if((e.attributes&n.getAttributes()&F.CONVOLUTION)!==0)throw Error(`Convolution effects cannot be merged (${n.name})`);else Zr(`e`+ t++,n,e);let n=e.shaderParts.get(I.FRAGMENT_HEAD),r=e.shaderParts.get(I.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(I.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let t of e.blendModes.values())n+=t.getShaderCode().replace(a,`blend${t.blendFunction}`)+`
`;(e.attributes&F.DEPTH)===0?this.needsDepthTexture=!1:(e.readDepth&&(r=`float depth = readDepth(UV);

	`+r),this.needsDepthTexture=this.getDepthTexture()===null),e.colorSpace===`srgb`&&(r+=`color0 = sRGBToLinear(color0);
	`),e.uvTransformation?(i=`vec2 transformedUv = vUv;
`+i,e.defines.set(`UV`,`transformedUv`)):e.defines.set(`UV`,`vUv`),e.shaderParts.set(I.FRAGMENT_HEAD,n),e.shaderParts.set(I.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(I.FRAGMENT_MAIN_UV,i);for(let[t,n]of e.shaderParts)n!==null&&e.shaderParts.set(t,n.trim().replace(/^#/,`
#`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=w){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let n of this.effects)n.setDepthTexture(e,t)}render(e,t,n,r,i){for(let n of this.effects)n.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let i=this.fullscreenMaterial;i.inputBuffer=t.texture,i.time+=r*this.timeScale,e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let n of this.effects)n.setSize(e,t)}initialize(e,t,n){this.renderer=e;for(let r of this.effects)r.initialize(e,t,n);this.updateMaterial(),n!==void 0&&n!==1009&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}dispose(){super.dispose();for(let e of this.effects)e.removeEventListener(`change`,this.listener),e.dispose()}handleEvent(e){switch(e.type){case`change`:this.recompile();break}}},$r=class extends N{constructor({kernelSize:e=35,iterations:t=1,resolutionScale:n=1,resolutionX:r=R.AUTO_SIZE,resolutionY:i=R.AUTO_SIZE}={}){super(`GaussianBlurPass`),this.renderTargetA=new c(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name=`Blur.Target.A`,this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name=`Blur.Target.B`,this.blurMaterial=new Hr({kernelSize:e}),this.copyMaterial=new he,this.copyMaterial.inputBuffer=this.renderTargetB.texture;let a=this.resolution=new R(this,r,i,n);a.addEventListener(`change`,e=>this.setSize(a.baseWidth,a.baseHeight)),this.iterations=t}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.renderTargetA,c=this.renderTargetB,l=this.blurMaterial;this.fullscreenMaterial=l;let u=t;for(let t=0,n=Math.max(this.iterations,1);t<n;++t)l.direction.set(1,0),l.inputBuffer=u.texture,e.setRenderTarget(s),e.render(a,o),l.direction.set(0,1),l.inputBuffer=s.texture,e.setRenderTarget(c),e.render(a,o),t===0&&n>1&&(u=c);this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:n),e.render(a,o)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurMaterial.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTargetA.texture.type=n,this.renderTargetB.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTargetA.texture.colorSpace=C,this.renderTargetB.texture.colorSpace=C):(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`,this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`))}},ei=class extends N{constructor(e){super(`LambdaPass`,null,null),this.needsSwap=!1,this.f=e}render(e,t,n,r,i){this.f()}},ti=class extends N{constructor(e,n,{renderTarget:r,resolutionScale:i=1,width:a=R.AUTO_SIZE,height:o=R.AUTO_SIZE,resolutionX:s=a,resolutionY:l=o}={}){super(`NormalPass`),this.needsSwap=!1,this.renderPass=new zt(e,n,new se);let u=this.renderPass;u.ignoreBackground=!0,u.skipShadowMapUpdate=!0;let d=u.getClearPass();d.overrideClearColor=new t(7829503),d.overrideClearAlpha=1,this.renderTarget=r,this.renderTarget===void 0&&(this.renderTarget=new c(1,1,{minFilter:k,magFilter:k}),this.renderTarget.texture.name=`NormalPass.Target`);let f=this.resolution=new R(this,s,l,i);f.addEventListener(`change`,e=>this.setSize(f.baseWidth,f.baseHeight))}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a,a)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}},ni=[new Float32Array(3),new Float32Array(3)],Y=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],ri=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];function ii(e,t,n,r){let i=n[0]-t[0],a=n[1]-t[1],o=n[2]-t[2],s=e[0]-t[0],c=e[1]-t[1],l=e[2]-t[2],u=a*l-o*c,d=o*s-i*l,f=i*c-a*s,p=Math.sqrt(u*u+d*d+f*f),m=p*.5,h=u/p,g=d/p,_=f/p,v=-(e[0]*h+e[1]*g+e[2]*_),y=r[0]*h+r[1]*g+r[2]*_;return Math.abs(y+v)*m/3}function ai(e,t,n,r,i,a){let o=(n+r*t+i*t*t)*4;a[0]=e[o+0],a[1]=e[o+1],a[2]=e[o+2]}function oi(e,t,n,r,i,a){let o=n*(t-1),s=r*(t-1),c=i*(t-1),l=Math.floor(o),u=Math.floor(s),d=Math.floor(c),f=Math.ceil(o),p=Math.ceil(s),m=Math.ceil(c),h=o-l,g=s-u,_=c-d;if(l===o&&u===s&&d===c)ai(e,t,o,s,c,a);else{let n;h>=g&&g>=_?n=ri[0]:h>=_&&_>=g?n=ri[1]:_>=h&&h>=g?n=ri[2]:g>=h&&h>=_?n=ri[3]:g>=_&&_>=h?n=ri[4]:_>=g&&g>=h&&(n=ri[5]);let[r,i,o,s]=n,c=ni[0];c[0]=h,c[1]=g,c[2]=_;let v=ni[1],y=f-l,b=p-u,x=m-d;v[0]=y*r[0]+l,v[1]=b*r[1]+u,v[2]=x*r[2]+d,ai(e,t,v[0],v[1],v[2],Y[0]),v[0]=y*i[0]+l,v[1]=b*i[1]+u,v[2]=x*i[2]+d,ai(e,t,v[0],v[1],v[2],Y[1]),v[0]=y*o[0]+l,v[1]=b*o[1]+u,v[2]=x*o[2]+d,ai(e,t,v[0],v[1],v[2],Y[2]),v[0]=y*s[0]+l,v[1]=b*s[1]+u,v[2]=x*s[2]+d,ai(e,t,v[0],v[1],v[2],Y[3]);let S=ii(i,o,s,c)*6,ee=ii(r,o,s,c)*6,C=ii(r,i,s,c)*6,te=ii(r,i,o,c)*6;Y[0][0]*=S,Y[0][1]*=S,Y[0][2]*=S,Y[1][0]*=ee,Y[1][1]*=ee,Y[1][2]*=ee,Y[2][0]*=C,Y[2][1]*=C,Y[2][2]*=C,Y[3][0]*=te,Y[3][1]*=te,Y[3][2]*=te,a[0]=Y[0][0]+Y[1][0]+Y[2][0]+Y[3][0],a[1]=Y[0][1]+Y[1][1]+Y[2][1]+Y[3][1],a[2]=Y[0][2]+Y[1][2]+Y[2][2]+Y[3][2]}}var si=class{static expand(e,t){let n=Math.cbrt(e.length/4),r=new Float32Array(3),i=new e.constructor(t**3*4),a=e instanceof Uint8Array?255:1,o=t**2,s=1/(t-1);for(let c=0;c<t;++c)for(let l=0;l<t;++l)for(let u=0;u<t;++u){let d=u*s,f=l*s,p=c*s,m=Math.round(u+l*t+c*o)*4;oi(e,n,d,f,p,r),i[m+0]=r[0],i[m+1]=r[1],i[m+2]=r[2],i[m+3]=a}return i}},X=[new Float32Array(2),new Float32Array(2)],ci=16,li=20,ui=30,di=32,fi=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),pi=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],mi=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],hi=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function gi(e,t,n){return e+(t-e)*n}function _i(e){return Math.min(Math.max(e,0),1)}function vi(e){let t=X[0],n=X[1],r=Math.sqrt(t[0]*2)*.5,i=Math.sqrt(t[1]*2)*.5,a=Math.sqrt(n[0]*2)*.5,o=Math.sqrt(n[1]*2)*.5,s=_i(e/di);t[0]=gi(r,t[0],s),t[1]=gi(i,t[1],s),n[0]=gi(a,n[0],s),n[1]=gi(o,n[1],s)}function Z(e,t,n,r,i,a){let o=n-e,s=r-t,c=i,l=i+1,u=t+s*(c-e)/o,d=t+s*(l-e)/o;if(c>=e&&c<n||l>e&&l<=n)if(Math.sign(u)===Math.sign(d)||Math.abs(u)<1e-4||Math.abs(d)<1e-4){let e=(u+d)/2;e<0?(a[0]=Math.abs(e),a[1]=0):(a[0]=0,a[1]=Math.abs(e))}else{let r=-t*o/s+e,i=Math.trunc(r),c=r>e?u*(r-i)/2:0,l=r<n?d*(1-(r-i))/2:0;(Math.abs(c)>Math.abs(l)?c:-l)<0?(a[0]=Math.abs(c),a[1]=Math.abs(l)):(a[0]=Math.abs(l),a[1]=Math.abs(c))}else a[0]=0,a[1]=0;return a}function yi(e,t,n,r,i){let a=X[0],o=X[1],s=.5+r,c=.5+r-1,l=t+n+1;switch(e){case 0:i[0]=0,i[1]=0;break;case 1:t<=n?Z(0,c,l/2,0,t,i):(i[0]=0,i[1]=0);break;case 2:t>=n?Z(l/2,0,l,c,t,i):(i[0]=0,i[1]=0);break;case 3:Z(0,c,l/2,0,t,a),Z(l/2,0,l,c,t,o),vi(l,X),i[0]=a[0]+o[0],i[1]=a[1]+o[1];break;case 4:t<=n?Z(0,s,l/2,0,t,i):(i[0]=0,i[1]=0);break;case 5:i[0]=0,i[1]=0;break;case 6:Math.abs(r)>0?(Z(0,s,l,c,t,a),Z(0,s,l/2,0,t,o),Z(l/2,0,l,c,t,i),o[0]+=i[0],o[1]+=i[1],i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2):Z(0,s,l,c,t,i);break;case 7:Z(0,s,l,c,t,i);break;case 8:t>=n?Z(l/2,0,l,s,t,i):(i[0]=0,i[1]=0);break;case 9:Math.abs(r)>0?(Z(0,c,l,s,t,a),Z(0,c,l/2,0,t,o),Z(l/2,0,l,s,t,i),o[0]+=i[0],o[1]+=i[1],i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2):Z(0,c,l,s,t,i);break;case 10:i[0]=0,i[1]=0;break;case 11:Z(0,c,l,s,t,i);break;case 12:Z(0,s,l/2,0,t,a),Z(l/2,0,l,s,t,o),vi(l,X),i[0]=a[0]+o[0],i[1]=a[1]+o[1];break;case 13:Z(0,c,l,s,t,i);break;case 14:Z(0,s,l,c,t,i);break;case 15:i[0]=0,i[1]=0;break}return i}function bi(e,t,n,r,i,a){let o=e===n&&t===r;if(!o){let s=(e+n)/2,c=(t+r)/2,l=r-t,u=e-n;o=l*(i-s)+u*(a-c)>0}return o}function xi(e,t,n,r,i,a){let o=0;for(let s=0;s<ui;++s)for(let c=0;c<ui;++c){let l=c/(ui-1),u=s/(ui-1);bi(e,t,n,r,i+l,a+u)&&++o}return o/(ui*ui)}function Q(e,t,n,r,i,a,o,s){let c=hi[e],l=c[0],u=c[1];return l>0&&(t+=o[0],n+=o[1]),u>0&&(r+=o[0],i+=o[1]),s[0]=1-xi(t,n,r,i,1+a,0+a),s[1]=xi(t,n,r,i,1+a,1+a),s}function Si(e,t,n,r,i){let a=X[0],o=X[1],s=t+n+1;switch(e){case 0:Q(e,1,1,1+s,1+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 1:Q(e,1,0,0+s,0+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 2:Q(e,0,0,1+s,0+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 3:Q(e,1,0,1+s,0+s,t,r,i);break;case 4:Q(e,1,1,0+s,0+s,t,r,a),Q(e,1,1,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 5:Q(e,1,1,0+s,0+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 6:Q(e,1,1,1+s,0+s,t,r,i);break;case 7:Q(e,1,1,1+s,0+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 8:Q(e,0,0,1+s,1+s,t,r,a),Q(e,1,0,1+s,1+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 9:Q(e,1,0,1+s,1+s,t,r,i),Q(e,1,0,1+s,1+s,t,r,i);break;case 10:Q(e,0,0,1+s,1+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 11:Q(e,1,0,1+s,1+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 12:Q(e,1,1,1+s,1+s,t,r,i);break;case 13:Q(e,1,1,1+s,1+s,t,r,a),Q(e,1,0,1+s,1+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 14:Q(e,1,1,1+s,1+s,t,r,a),Q(e,1,1,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break;case 15:Q(e,1,1,1+s,1+s,t,r,a),Q(e,1,0,1+s,0+s,t,r,o),i[0]=(a[0]+o[0])/2,i[1]=(a[1]+o[1])/2;break}return i}function Ci(e,t,n){let r=new Float32Array(2);for(let i=0,a=e.length;i<a;++i){let a=e[i],o=a.data,s=a.width;for(let e=0;e<s;++e)for(let a=0;a<s;++a){n?yi(i,a,e,t,r):Si(i,a,e,t,r);let c=(e*s+a)*2;o[c]=r[0]*255,o[c+1]=r[1]*255}}}function wi(e,t,n,r,i,a,o){let s=o.data,c=o.width;for(let o=0,l=n.length;o<l;++o){let l=r[o],u=n[o],d=u.data,f=u.width;for(let n=0;n<i;++n)for(let r=0;r<i;++r){let o=l[0]*i+e+r,u=((l[1]*i+t+n)*c+o)*4,p=a?(n*n*f+r*r)*2:(n*f+r)*2;s[u]=d[p],s[u+1]=d[p+1],s[u+2]=0,s[u+3]=255}}}var Ti=class{static generate(){let e=10*ci,t=fi.length*5*ci,n=new Uint8ClampedArray(e*t*4),r=new K(e,t,n),i=(ci-1)**2+1,a=li,o=[],s=[];for(let e=3,t=n.length;e<t;e+=4)n[e]=255;for(let e=0;e<16;++e)o.push(new K(i,i,new Uint8ClampedArray(i*i*2),2)),s.push(new K(a,a,new Uint8ClampedArray(a*a*2),2));for(let e=0,t=fi.length;e<t;++e)Ci(o,fi[e],!0),wi(0,5*ci*e,o,mi,ci,!0,r);for(let e=0,t=pi.length;e<t;++e)Ci(s,pi[e],!1),wi(5*ci,4*li*e,s,hi,li,!1,r);return r}},Ei=`"use strict";(()=>{function q(t,a,s){let e=document.createElement("canvas"),n=e.getContext("2d");if(e.width=t,e.height=a,s instanceof Image)n.drawImage(s,0,0);else{let r=n.createImageData(t,a);r.data.set(s),n.putImageData(r,0,0)}return e}var F=class t{constructor(a=0,s=0,e=null){this.width=a,this.height=s,this.data=e}toCanvas(){return typeof document=="undefined"?null:q(this.width,this.height,this.data)}static from(a){let{width:s,height:e}=a,n;if(a instanceof Image){let r=q(s,e,a);r!==null&&(n=r.getContext("2d").getImageData(0,0,s,e).data)}else n=a.data;return new t(s,e,n)}};var M=[new Float32Array(2),new Float32Array(2)],D=16,W=20,I=30,j=32,v=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),N=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],z=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],p=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function C(t,a,s){return t+(a-t)*s}function B(t){return Math.min(Math.max(t,0),1)}function _(t){let a=M[0],s=M[1],e=Math.sqrt(a[0]*2)*.5,n=Math.sqrt(a[1]*2)*.5,r=Math.sqrt(s[0]*2)*.5,o=Math.sqrt(s[1]*2)*.5,c=B(t/j);a[0]=C(e,a[0],c),a[1]=C(n,a[1],c),s[0]=C(r,s[0],c),s[1]=C(o,s[1],c)}function d(t,a,s,e,n,r){let o=s-t,c=e-a,h=n,i=n+1,w=a+c*(h-t)/o,b=a+c*(i-t)/o;if(h>=t&&h<s||i>t&&i<=s)if(Math.sign(w)===Math.sign(b)||Math.abs(w)<1e-4||Math.abs(b)<1e-4){let g=(w+b)/2;g<0?(r[0]=Math.abs(g),r[1]=0):(r[0]=0,r[1]=Math.abs(g))}else{let g=-a*o/c+t,k=Math.trunc(g),m=g>t?w*(g-k)/2:0,U=g<s?b*(1-(g-k))/2:0;(Math.abs(m)>Math.abs(U)?m:-U)<0?(r[0]=Math.abs(m),r[1]=Math.abs(U)):(r[0]=Math.abs(U),r[1]=Math.abs(m))}else r[0]=0,r[1]=0;return r}function J(t,a,s,e,n){let r=M[0],o=M[1],c=.5+e,h=.5+e-1,i=a+s+1;switch(t){case 0:{n[0]=0,n[1]=0;break}case 1:{a<=s?d(0,h,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 2:{a>=s?d(i/2,0,i,h,a,n):(n[0]=0,n[1]=0);break}case 3:{d(0,h,i/2,0,a,r),d(i/2,0,i,h,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 4:{a<=s?d(0,c,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 5:{n[0]=0,n[1]=0;break}case 6:{Math.abs(e)>0?(d(0,c,i,h,a,r),d(0,c,i/2,0,a,o),d(i/2,0,i,h,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,c,i,h,a,n);break}case 7:{d(0,c,i,h,a,n);break}case 8:{a>=s?d(i/2,0,i,c,a,n):(n[0]=0,n[1]=0);break}case 9:{Math.abs(e)>0?(d(0,h,i,c,a,r),d(0,h,i/2,0,a,o),d(i/2,0,i,c,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,h,i,c,a,n);break}case 10:{n[0]=0,n[1]=0;break}case 11:{d(0,h,i,c,a,n);break}case 12:{d(0,c,i/2,0,a,r),d(i/2,0,i,c,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 13:{d(0,h,i,c,a,n);break}case 14:{d(0,c,i,h,a,n);break}case 15:{n[0]=0,n[1]=0;break}}return n}function K(t,a,s,e,n,r){let o=t===s&&a===e;if(!o){let c=(t+s)/2,h=(a+e)/2,i=e-a,w=t-s;o=i*(n-c)+w*(r-h)>0}return o}function G(t,a,s,e,n,r){let o=0;for(let c=0;c<I;++c)for(let h=0;h<I;++h){let i=h/(I-1),w=c/(I-1);K(t,a,s,e,n+i,r+w)&&++o}return o/(I*I)}function A(t,a,s,e,n,r,o,c){let h=p[t],i=h[0],w=h[1];return i>0&&(a+=o[0],s+=o[1]),w>0&&(e+=o[0],n+=o[1]),c[0]=1-G(a,s,e,n,1+r,0+r),c[1]=G(a,s,e,n,1+r,1+r),c}function Q(t,a,s,e,n){let r=M[0],o=M[1],c=a+s+1;switch(t){case 0:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 1:{A(t,1,0,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 2:{A(t,0,0,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 3:{A(t,1,0,1+c,0+c,a,e,n);break}case 4:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 5:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 6:{A(t,1,1,1+c,0+c,a,e,n);break}case 7:{A(t,1,1,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 8:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 9:{A(t,1,0,1+c,1+c,a,e,n),A(t,1,0,1+c,1+c,a,e,n);break}case 10:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 11:{A(t,1,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 12:{A(t,1,1,1+c,1+c,a,e,n);break}case 13:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 14:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 15:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}}return n}function R(t,a,s){let e=new Float32Array(2);for(let n=0,r=t.length;n<r;++n){let o=t[n],c=o.data,h=o.width;for(let i=0;i<h;++i)for(let w=0;w<h;++w){s?J(n,w,i,a,e):Q(n,w,i,a,e);let b=(i*h+w)*2;c[b]=e[0]*255,c[b+1]=e[1]*255}}}function T(t,a,s,e,n,r,o){let c=o.data,h=o.width;for(let i=0,w=s.length;i<w;++i){let b=e[i],g=s[i],k=g.data,m=g.width;for(let U=0;U<n;++U)for(let x=0;x<n;++x){let Z=b[0]*n+t+x,O=((b[1]*n+a+U)*h+Z)*4,L=r?(U*U*m+x*x)*2:(U*m+x)*2;c[O]=k[L],c[O+1]=k[L+1],c[O+2]=0,c[O+3]=255}}}var S=class{static generate(){let a=10*D,s=v.length*5*D,e=new Uint8ClampedArray(a*s*4),n=new F(a,s,e),r=Math.pow(D-1,2)+1,o=W,c=[],h=[];for(let i=3,w=e.length;i<w;i+=4)e[i]=255;for(let i=0;i<16;++i)c.push(new F(r,r,new Uint8ClampedArray(r*r*2),2)),h.push(new F(o,o,new Uint8ClampedArray(o*o*2),2));for(let i=0,w=v.length;i<w;++i)R(c,v[i],!0),T(0,5*D*i,c,z,D,!0,n);for(let i=0,w=N.length;i<w;++i)R(h,N[i],!1),T(5*D,4*W*i,h,p,W,!1,n);return n}};var P=new Map([[y(0,0,0,0),new Float32Array([0,0,0,0])],[y(0,0,0,1),new Float32Array([0,0,0,1])],[y(0,0,1,0),new Float32Array([0,0,1,0])],[y(0,0,1,1),new Float32Array([0,0,1,1])],[y(0,1,0,0),new Float32Array([0,1,0,0])],[y(0,1,0,1),new Float32Array([0,1,0,1])],[y(0,1,1,0),new Float32Array([0,1,1,0])],[y(0,1,1,1),new Float32Array([0,1,1,1])],[y(1,0,0,0),new Float32Array([1,0,0,0])],[y(1,0,0,1),new Float32Array([1,0,0,1])],[y(1,0,1,0),new Float32Array([1,0,1,0])],[y(1,0,1,1),new Float32Array([1,0,1,1])],[y(1,1,0,0),new Float32Array([1,1,0,0])],[y(1,1,0,1),new Float32Array([1,1,0,1])],[y(1,1,1,0),new Float32Array([1,1,1,0])],[y(1,1,1,1),new Float32Array([1,1,1,1])]]);function H(t,a,s){return t+(a-t)*s}function y(t,a,s,e){let n=H(t,a,.75),r=H(s,e,1-.25);return H(n,r,1-.125)}function V(t,a){let s=0;return a[3]===1&&(s+=1),s===1&&a[2]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s}function $(t,a){let s=0;return a[3]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s===1&&a[2]===1&&t[0]!==1&&t[2]!==1&&(s+=1),s}var E=class{static generate(){let o=new Uint8ClampedArray(2178),c=new Uint8ClampedArray(1024*4);for(let h=0;h<33;++h)for(let i=0;i<66;++i){let w=.03125*i,b=.03125*h;if(P.has(w)&&P.has(b)){let g=P.get(w),k=P.get(b),m=h*66+i;o[m]=127*V(g,k),o[m+33]=127*$(g,k)}}for(let h=0,i=17;i<33;++i)for(let w=0;w<64;++w,h+=4)c[h]=o[i*66+w],c[h+3]=255;return new F(64,16,c)}};self.addEventListener("message",t=>{let a=S.generate(),s=E.generate();postMessage({areaImageData:a,searchImageData:s},[a.data.buffer,s.data.buffer]),close()});})();
`;function Di(e=!0){let t=URL.createObjectURL(new Blob([Ei],{type:`text/javascript`})),n=new Worker(t);return URL.revokeObjectURL(t),new Promise((t,r)=>{n.addEventListener(`error`,e=>r(e.error)),n.addEventListener(`message`,n=>{let r=K.from(n.data.searchImageData),i=K.from(n.data.areaImageData),a=[r.toCanvas().toDataURL(`image/png`,1),i.toCanvas().toDataURL(`image/png`,1)];e&&(localStorage.setItem(`smaa-search`,a[0]),localStorage.setItem(`smaa-area`,a[1])),t(a)}),n.postMessage(null)})}var Oi=class{constructor(){this.disableCache=!1}setCacheEnabled(e){this.disableCache=!e}generate(){let e=!this.disableCache&&window.localStorage!==void 0,t=e?[localStorage.getItem(`smaa-search`),localStorage.getItem(`smaa-area`)]:[null,null];return(t[0]!==null&&t[1]!==null?Promise.resolve(t):Di(e)).then(e=>new Promise((t,n)=>{let r=new Image,i=new Image,a=new v;a.onLoad=()=>t([r,i]),a.onError=n,r.addEventListener(`error`,e=>a.itemError(`smaa-search`)),i.addEventListener(`error`,e=>a.itemError(`smaa-area`)),r.addEventListener(`load`,()=>a.itemEnd(`smaa-search`)),i.addEventListener(`load`,()=>a.itemEnd(`smaa-area`)),a.itemStart(`smaa-search`),a.itemStart(`smaa-area`),r.src=e[0],i.src=e[1]}))}},ki=new Map([[$(0,0,0,0),new Float32Array([0,0,0,0])],[$(0,0,0,1),new Float32Array([0,0,0,1])],[$(0,0,1,0),new Float32Array([0,0,1,0])],[$(0,0,1,1),new Float32Array([0,0,1,1])],[$(0,1,0,0),new Float32Array([0,1,0,0])],[$(0,1,0,1),new Float32Array([0,1,0,1])],[$(0,1,1,0),new Float32Array([0,1,1,0])],[$(0,1,1,1),new Float32Array([0,1,1,1])],[$(1,0,0,0),new Float32Array([1,0,0,0])],[$(1,0,0,1),new Float32Array([1,0,0,1])],[$(1,0,1,0),new Float32Array([1,0,1,0])],[$(1,0,1,1),new Float32Array([1,0,1,1])],[$(1,1,0,0),new Float32Array([1,1,0,0])],[$(1,1,0,1),new Float32Array([1,1,0,1])],[$(1,1,1,0),new Float32Array([1,1,1,0])],[$(1,1,1,1),new Float32Array([1,1,1,1])]]);function Ai(e,t,n){return e+(t-e)*n}function $(e,t,n,r){return Ai(Ai(e,t,.75),Ai(n,r,.75),.875)}function ji(e,t){let n=0;return t[3]===1&&(n+=1),n===1&&t[2]===1&&e[1]!==1&&e[3]!==1&&(n+=1),n}function Mi(e,t){let n=0;return t[3]===1&&e[1]!==1&&e[3]!==1&&(n+=1),n===1&&t[2]===1&&e[0]!==1&&e[2]!==1&&(n+=1),n}var Ni=class{static generate(){let e=new Uint8ClampedArray(2178),t=new Uint8ClampedArray(1024*4);for(let t=0;t<33;++t)for(let n=0;n<66;++n){let r=.03125*n,i=.03125*t;if(ki.has(r)&&ki.has(i)){let a=ki.get(r),o=ki.get(i),s=t*66+n;e[s]=127*ji(a,o),e[s+33]=127*Mi(a,o)}}for(let n=0,r=17;r<33;++r)for(let i=0;i<64;++i,n+=4)t[n]=e[r*66+i],t[n+3]=255;return new K(64,16,t)}};export{Ut as $,gr as $t,Ct as A,ln as At,F as B,un as Bt,Ir as C,Nt as Ct,sr as D,Ae as Dt,or as E,bn as Et,Tt as F,R as Ft,I as G,An as Gt,zr as H,qn as Ht,Je as I,Ti as It,Ee as J,Vn as Jt,Ot as K,Ne as Kt,Wn as L,Qn as Lt,Yr as M,On as Mt,sn as N,zt as Nt,pt as O,N as Ot,de as P,je as Pt,jt as Q,pr as Qt,cn as R,Oi as Rt,_n as S,mn as St,Wr as T,wn as Tt,Qr as U,ur as Ut,Ce as V,Ni as Vt,we as W,rr as Wt,$r as X,In as Xt,Hr as Y,W as Yt,It as Z,si as Zt,ot as _,Ge as _t,z as a,Ze as an,He as at,he as b,ye as bt,nt as c,fn as cn,Zt as ct,Ur as d,kr as dt,_r as en,Rt as et,it as f,Qt as ft,ve as g,We as gt,pe as h,nn as ht,Cr as i,q as in,Oe as it,xn as j,K as jt,Rn as k,En as kt,gt as l,ue as ln,an as lt,vt as m,Yt as mt,Ie as n,Se as nn,qt as nt,Fe as o,Dr as on,H as ot,dt as p,ei as pt,At as q,zn as qt,Sr as r,Tr as rn,De as rt,et as s,dn as sn,V as st,Re as t,br as tn,Gt as tt,Nr as u,Or as ut,U as v,mt as vt,on as w,ti as wt,ge as x,Qe as xt,ct as y,bt as yt,B as z,Ar as zt};