animate/webGl/my-threejs-test/node_modules/postprocessing/build/postprocessing.min.js

873 lines
313 KiB
JavaScript
Raw Normal View History

2024-06-24 09:24:00 +00:00
/**
* postprocessing v6.35.3 build Sat Mar 30 2024
* https://github.com/pmndrs/postprocessing
* Copyright 2015-2024 Raoul van Rüschen
* @license Zlib
*/
if(typeof window==="object"&&!window.require)window.require=()=>window.THREE;
"use strict";var POSTPROCESSING=(()=>{var Pr=Object.defineProperty;var ra=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var sa=Object.prototype.hasOwnProperty;var m=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var na=(o,e)=>{for(var t in e)Pr(o,t,{get:e[t],enumerable:!0})},aa=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ia(e))!sa.call(o,i)&&i!==t&&Pr(o,i,{get:()=>e[i],enumerable:!(r=ra(e,i))||r.enumerable});return o};var oa=o=>aa(Pr({},"__esModule",{value:!0}),o);var Ul={};na(Ul,{AdaptiveLuminanceMaterial:()=>ur,AdaptiveLuminancePass:()=>hr,BlendFunction:()=>v,BlendMode:()=>Nt,BloomEffect:()=>Qt,BlurPass:()=>ie,BokehEffect:()=>Or,BokehMaterial:()=>qe,BoxBlurMaterial:()=>dr,BoxBlurPass:()=>xi,BrightnessContrastEffect:()=>Nr,ChromaticAberrationEffect:()=>kr,CircleOfConfusionMaterial:()=>Kt,ClearMaskPass:()=>bt,ClearPass:()=>q,ColorAverageEffect:()=>Hr,ColorChannel:()=>Re,ColorDepthEffect:()=>Gr,ColorEdgesMaterial:()=>Ct,ConvolutionMaterial:()=>Ze,CopyMaterial:()=>Ee,CopyPass:()=>Ke,DepthComparisonMaterial:()=>$t,DepthCopyMaterial:()=>pr,DepthCopyMode:()=>tt,DepthCopyPass:()=>yt,DepthDownsamplingMaterial:()=>ar,DepthDownsamplingPass:()=>or,DepthEffect:()=>zr,DepthMaskMaterial:()=>ht,DepthOfFieldEffect:()=>Qr,DepthPass:()=>mt,DepthPickingPass:()=>Di,DepthSavePass:()=>yt,DepthTestStrategy:()=>et,Disposable:()=>Ir,DotScreenEffect:()=>Vr,DownsamplingMaterial:()=>Gt,EdgeDetectionMaterial:()=>Ct,EdgeDetectionMode:()=>qt,Effect:()=>A,EffectAttribute:()=>P,EffectComposer:()=>Ur,EffectMaterial:()=>mr,EffectPass:()=>Ei,EffectShaderData:()=>Ft,EffectShaderSection:()=>C,FXAAEffect:()=>Yr,GammaCorrectionEffect:()=>Wr,GaussKernel:()=>Ot,GaussianBlurMaterial:()=>vr,GaussianBlurPass:()=>wi,GlitchEffect:()=>_r,GlitchMode:()=>ft,GodRaysEffect:()=>Xr,GodRaysMaterial:()=>jt,GridEffect:()=>Zr,HueSaturationEffect:()=>jr,ImmutableTimer:()=>Rr,Initializable:()=>br,KawaseBlurMaterial:()=>Ze,KawaseBlurPass:()=>ie,KernelSize:()=>Y,LUT1DEffect:()=>qr,LUT3DEffect:()=>Tr,LUT3dlLoader:()=>vi,LUTCubeLoader:()=>gi,LUTEffect:()=>Tr,LUTOperation:()=>$r,LambdaPass:()=>Ti,LensDistortionEffect:()=>Jr,LookupTexture:()=>Fe,LookupTexture3D:()=>Fe,LuminanceMaterial:()=>Ht,LuminancePass:()=>ut,MaskFunction:()=>_t,MaskMaterial:()=>Xt,MaskPass:()=>Lt,MipmapBlurPass:()=>zt,NoiseEffect:()=>ti,NoiseTexture:()=>$e,NormalPass:()=>Si,OutlineEdgesMaterial:()=>St,OutlineEffect:()=>ri,OutlineMaterial:()=>St,OverrideMaterialManager:()=>Dt,Pass:()=>T,PixelationEffect:()=>ii,PredicationMode:()=>ei,RawImageData:()=>le,RealisticBokehEffect:()=>si,RenderPass:()=>Se,Resizable:()=>Fr,Resizer:()=>x,Resolution:()=>x,SMAAAreaImageData:()=>yi,SMAAEffect:()=>ci,SMAAImageGenerator:()=>Pi,SMAAImageLoader:()=>Ai,SMAAPreset:()=>dt,SMAASearchImageData:()=>Ui,SMAAWeightsMaterial:()=>rr,SSAOEffect:()=>ui,SSAOMaterial:()=>nr,SavePass:()=>Ke,ScanlineEffect:()=>ni,Section:()=>C,Selection:()=>ct,SelectiveBloomEffect:()=>oi,SepiaEffect:()=>li,ShaderPass:()=>H,ShockWaveEffect:()=>ai,TetrahedralUpscaler:()=>Ci,TextureEffect:()=>fi,TiltShiftBlurMaterial:()=>lr,TiltShiftBlurPass:()=>cr,TiltShiftEffect:()=>hi,Timer:()=>Rt,ToneMappingEffect:()=>di,ToneMappingMode:()=>ce,UpsamplingMaterial:()=>kt,VignetteEffect:()=>mi,VignetteTechnique:()=>pt,WebGLExtension:()=>Po,version:()=>Ri});var Ri="6.35.3";var Ir=class{dispose(){}};var I=m("three");var Rt=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!="undefined"&&document.hidden!==void 0&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=e)}get delta(){return this._delta*.001}get fixedDelta()
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;
#include <colorspace_fragment>
#include <dithering_fragment>
}`;var X="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var Ee=class extends lt.ShaderMaterial{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new lt.Uniform(null),opacity:new lt.Uniform(1)},blending:lt.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Li,vertexShader:X}),this.fragmentShader=te(this.fragmentShader)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}};var Ke=class extends T{constructor(e,t=!0){super("CopyPass"),this.fullscreenMaterial=new Ee,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new Ue.WebGLRenderTarget(1,1,{minFilter:Ue.LinearFilter,magFilter:Ue.LinearFilter,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,r,i,s){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,r){r!==void 0&&(this.renderTarget.texture.type=r,r!==Ue.UnsignedByteType?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":e!==null&&e.outputColorSpace===Ue.SRGBColorSpace&&(this.renderTarget.texture.colorSpace=Ue.SRGBColorSpace))}};var Oi=m("three");var Fi=new Oi.Color,q=class extends T{constructor(e=!0,t=!0,r=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=r,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,r){this.color=e,this.depth=t,this.stencil=r}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,r,i,s){let a=this.overrideClearColor,n=this.overrideClearAlpha,c=e.getClearAlpha(),l=a!==null,u=n>=0;l?(e.getClearColor(Fi),e.setClearColor(a,u?n:c)):u&&e.setClearAlpha(n),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),l?e.setClearColor(Fi,c):u&&e.setClearAlpha(c)}};var Lt=class extends T{constructor(e,t){super("MaskPass",e,t),this.needsSwap=!1,this.clearPass=new q(!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,r,i,s){let a=e.getContext(),n=e.state.buffers,c=this.scene,l=this.camera,u=this.clearPass,f=this.inverted?0:1,h=1-f;n.color.setMask(!1),n.depth.setMask(!1),n.color.setLocked(!0),n.depth.setLocked(!0),n.stencil.setTest(!0),n.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),n.stencil.setFunc(a.ALWAYS,f,4294967295),n.stencil.setClear(h),n.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?u.render(e,null):(u.render(e,t),u.render(e,r))),this.renderToScreen?(e.setRenderTarget(null),e.render(c,l)):(e.setRenderTarget(t),e.render(c,l),e.setRenderTarget(r),e.render(c,l)),n.color.setLocked(!1),n.depth.setLocked(!1),n.stencil.setLocked(!1),n.stencil.setFunc(a.EQUAL,1,4294967295),n.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),n.stencil.setLocked(!0)}};var Ur=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:r=!1,multisampling:i=0,frameBufferType:s}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,r,s,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new Ke,this.depthTexture=null,this.passes=[],this.timer=new Rt,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,r=this
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>
}`;var As="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);}";var Za=[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])],Ze=class extends me.ShaderMaterial{constructor(e=new me.Vector4){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new me.Uniform(null),texelSize:new me.Uniform(new me.Vector4),scale:new me.Uniform(1),kernel:new me.Uniform(0)},blending:me.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:gs,vertexShader:As}),this.fragmentShader=te(this.fragmentShader),this.setTexelSize(e.x,e.y),this.kernelSize=Y.MEDIUM}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get kernelSequence(){return Za[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 r=1/e,i=1/t;this.uniforms.texelSize.value.set(r,i,r*.5,i*.5)}};var ie=class extends T{constructor({kernelSize:e=Y.MEDIUM,resolutionScale:t=.5,width:r=x.AUTO_SIZE,height:i=x.AUTO_SIZE,resolutionX:s=r,resolutionY:a=i}={}){super("KawaseBlurPass"),this.renderTargetA=new je.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let n=this.resolution=new x(this,s,a,t);n.addEventListener("change",c=>this.setSize(n.baseWidth,n.baseHeight)),this._blurMaterial=new Ze,this._blurMaterial.kernelSize=e,this.copyMaterial=new Ee}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,r,i,s){let a=this.scene,n=this.camera,c=this.renderTargetA,l=this.renderTargetB,u=this.blurMaterial,f=u.kernelSequence,h=t;this.fullscreenMaterial=u;for(let d=0,p=f.length;d<p;++d){let g=d&1?l:c;u.kernel=f[d],u.inputBuffer=h.texture,e.setRenderTarget(g),e.render(a,n),h=g}this.fullscreenMaterial=this.copyMaterial,this.copyMaterial.inputBuffer=h.texture,e.setRenderTarget(this.renderToScreen?null:r),e.render(a,n)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t);let i=r.width,s=r.height;this.renderTargetA.setSize(i,s),this.renderTargetB.setSize(i,s),this.blurMaterial.setSize(e,t)}initialize(e,t,r){r!==void 0&&(this.renderTargetA.texture.type=r,this.renderTargetB.texture.type=r,r!==je.UnsignedByteType?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):e!==null&&e.outputColorSpace===je.SRGBColorSpace&&(this.renderTargetA.texture.colorSpace=je.SRGBColorSpace,this.renderTargetB.texture.colorSpace=je.SRGBColorSpace))}static get AUTO_SIZE(){return x.AUTO_SIZE}
#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);
#ifdef RANGE
float low=step(range.x,l);float high=step(l,range.y);l*=low*high;
#elif defined(THRESHOLD)
l=smoothstep(threshold,threshold+smoothing,l)*l;
#endif
#ifdef COLOR
gl_FragColor=vec4(texel.rgb*clamp(l,0.0,1.0),l);
#else
gl_FragColor=vec4(l);
#endif
}`;var Ht=class extends we.ShaderMaterial{constructor(e=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:we.REVISION.replace(/\D+/g,"")},uniforms:{inputBuffer:new we.Uniform(null),threshold:new we.Uniform(0),smoothing:new we.Uniform(1),range:new we.Uniform(null)},blending:we.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:xs,vertexShader:X}),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?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}};var ut=class extends T{constructor({renderTarget:e,luminanceRange:t,colorOutput:r,resolutionScale:i=1,width:s=x.AUTO_SIZE,height:a=x.AUTO_SIZE,resolutionX:n=s,resolutionY:c=a}={}){super("LuminancePass"),this.fullscreenMaterial=new Ht(r,t),this.needsSwap=!1,this.renderTarget=e,this.renderTarget===void 0&&(this.renderTarget=new Er.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");let l=this.resolution=new x(this,n,c,i);l.addEventListener("change",u=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(e,t,r,i,s){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 r=this.resolution;r.setBaseSize(e,t),this.renderTarget.setSize(r.width,r.height)}initialize(e,t,r){r!==void 0&&r!==Er.UnsignedByteType&&(this.renderTarget.texture.type=r,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}};var ke=m("three");var Ge=m("three");var Ds=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#define WEIGHT_INNER 0.125
#define WEIGHT_OUTER 0.0555555
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>
}`;var Es="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);}";var Gt=class extends Ge.ShaderMaterial{constructor(){super({name:"DownsamplingMaterial",uniforms:{inputBuffer:new Ge.Uniform(null),texelSize:new Ge.Uniform(new Ge.Vector2)},blending:Ge.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ds,vertexShader:Es}),this.fragmentShader=te(this.fragmentShader)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}};var Te=m("three");var ws=`#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>
}`;var Ts="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);}";var kt=class extends Te.ShaderMaterial{constructor(){super({name:"UpsamplingMaterial",uniforms:{inputBuffer:new Te.Uniform(null),supportBuffer:new Te.Uniform(null),texelSize:new Te.Uniform(new Te.Vector2),radius:new Te.Uniform(.85)},blending:Te.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:ws,vertexShader:Ts}),this.fragmentShader=te(this.fragmentShader)}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)}};var zt=class extends T{constructor(){super("MipmapBlurPass"),this.needsSwap=!1,this.renderTarget=new ke.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Upsampling.Mipmap0",this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new Gt,this.upsamplingMaterial=new kt,this.resolution=new ke.Vector2}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 r=0;r<e;++r){let i=t.clone();i.texture.name="Downsampling.Mipmap"+r,this.downsamplingMipmaps.push(i)}this.upsamplingMipmaps.push(t);for(let r=1,i=e-1;r<i;++r){let s=t.clone();s.texture.name="Upsampling.Mipmap"+r,this.upsamplingMipmaps.push(s)}this.setSize(this.resolution.x,this.resolution.y)}}get radius(){return this.upsamplingMaterial.radius}set radius(e){this.upsamplingMaterial.radius=e}render(e,t,r,i,s){let{scene:a,camera:n}=this,{downsamplingMaterial:c,upsamplingMaterial:l}=this,{downsamplingMipmaps:u,upsamplingMipmaps:f}=this,h=t;this.fullscreenMaterial=c;for(let d=0,p=u.length;d<p;++d){let g=u[d];c.setSize(h.width,h.height),c.inputBuffer=h.texture,e.setRenderTarget(g),e.render(a,n),h=g}this.fullscreenMaterial=l;for(let d=f.length-1;d>=0;--d){let p=f[d];l.setSize(h.width,h.height),l.inputBuffer=h.texture,l.supportBuffer=u[d].texture,e.setRenderTarget(p),e.render(a,n),h=p}}setSize(e,t){let r=this.resolution;r.set(e,t);let i=r.width,s=r.height;for(let a=0,n=this.downsamplingMipmaps.length;a<n;++a)i=Math.round(i*.5),s=Math.round(s*.5),this.downsamplingMipmaps[a].setSize(i,s),a<this.upsamplingMipmaps.length&&this.upsamplingMipmaps[a].setSize(i,s)}initialize(e,t,r){if(r!==void 0){let i=this.downsamplingMipmaps.concat(this.upsamplingMipmaps);for(let s of i)s.texture.type=r;if(r!==ke.UnsignedByteType)this.downsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.upsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1";else if(e!==null&&e.outputColorSpace===ke.SRGBColorSpace)for(let s of i)s.texture.colorSpace=ke.SRGBColorSpace}}dispose(){super.dispose();for(let e of this.downsamplingMipmaps.concat(this.upsamplingMipmaps))e.dispose()}};var se=m("three");var A=class extends se.EventDispatcher{constructor(e,t,{attributes:r=P.NONE,blendFunction:i=v.NORMAL,defines:s=new Map,uniforms:a=new Map,extensions:n=null,vertexShader:c=null}={}){super(),this.name=e,this.renderer=null,this.attributes=r,this.fragmentShader=t,this.vertexShader=c,this.defines=s,this.uniforms=a,this.extensions=n,this.blendMode=new Nt(i),this.blendMode.addEventListener("change",l=>this.setChanged()),this._inputColorSpace=se.LinearSRGBColorSpace,this._outputColorSpace=se.NoColorSpace}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(e){this._inputColorSpace=e,this.setChanged()}get outputColorSpace(){return this
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){vec4 texel=texture2D(map,uv);outputColor=vec4(texel.rgb*intensity,texel.a);}`;var Qt=class extends A{constructor({blendFunction:e=v.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:r=.025,mipmapBlur:i=!1,intensity:s=1,radius:a=.85,levels:n=8,kernelSize:c=Y.LARGE,resolutionScale:l=.5,width:u=x.AUTO_SIZE,height:f=x.AUTO_SIZE,resolutionX:h=u,resolutionY:d=f}={}){super("BloomEffect",Ss,{blendFunction:e,uniforms:new Map([["map",new Je.Uniform(null)],["intensity",new Je.Uniform(s)]])}),this.renderTarget=new Je.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.blurPass=new ie({kernelSize:c}),this.luminancePass=new ut({colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothing=r,this.mipmapBlurPass=new zt,this.mipmapBlurPass.enabled=i,this.mipmapBlurPass.radius=a,this.mipmapBlurPass.levels=n,this.uniforms.get("map").value=i?this.mipmapBlurPass.texture:this.renderTarget.texture;let p=this.resolution=new x(this,h,d,l);p.addEventListener("change",g=>this.setSize(p.baseWidth,p.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,r){let i=this.renderTarget,s=this.luminancePass;s.enabled?(s.render(e,t),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,s.renderTarget):this.blurPass.render(e,s.renderTarget,i)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,t):this.blurPass.render(e,t,i)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t),this.renderTarget.setSize(r.width,r.height),this.blurPass.resolution.copy(r),this.luminancePass.setSize(e,t),this.mipmapBlurPass.setSize(e,t)}initialize(e,t,r){this.blurPass.initialize(e,t,r),this.luminancePass.initialize(e,t,r),this.mipmapBlurPass.initialize(e,t,r),r!==void 0&&(this.renderTarget.texture.type=r,e!==null&&e.outputColorSpace===Je.SRGBColorSpace&&(this.renderTarget.texture.colorSpace=Je.SRGBColorSpace))}};var Vt=m("three");var Cs=`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;}`;var Or=class extends A{constructor({blendFunction:e,focus:t=.5,dof:r=.02,aperture:i=.015,maxBlur:s=1}={}){super("BokehEffect",Cs,{blendFunction:e,attributes:P.CONVOLUTION|P.DEPTH,uniforms:new Map([["focus",new Vt.Uniform(t)],["dof",new Vt.Uniform(r)],["aperture",new Vt.Uniform(i)],["maxBlur",new Vt.Uniform(s)]])})}};var Yt=m("three");var Bs="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=ve
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));}`;var Us="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;}";var kr=class extends A{constructor({offset:e=new Wt.Vector2(.001,5e-4),radialModulation:t=!1,modulationOffset:r=.15}={}){super("ChromaticAberrationEffect",Is,{vertexShader:Us,attributes:P.CONVOLUTION,uniforms:new Map([["offset",new Wt.Uniform(e)],["modulationOffset",new Wt.Uniform(r)]])}),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}};var Rs=`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);}`;var zr=class extends A{constructor({blendFunction:e=v.SRC,inverted:t=!1}={}){super("DepthEffect",Rs,{blendFunction:e,attributes:P.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}};var _=m("three");var Re={RED:0,GREEN:1,BLUE:2,ALPHA:3};var _t={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2,MULTIPLY_RGB:3};var fe=m("three");var bs=`#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
}}`;var qe=class extends fe.ShaderMaterial{constructor(e=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:e?"2":"1"},uniforms:{inputBuffer:new fe.Uniform(null),cocBuffer:new fe.Uniform(null),texelSize:new fe.Uniform(new fe.Vector2),kernel64:new fe.Uniform(null),kernel16:new fe.Uniform(null),scale:new fe.Uniform(1)},blending:fe.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:bs,vertexShader:X}),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=2.39996323,t=new Float64Array(128),r=new Float64Array(32),i=0,s=0;for(let a=0,n=Math.sqrt(80);a<80;++a){let c=a*e,l=Math.sqrt(a)/n,u=l*Math.cos(c),f=l*Math.sin(c);a%5===0?(r[s++]=u,r[s++]=f):(t[i++]=u,t[i++]=f)}this.uniforms.kernel64.value=t,this.uniforms.kernel16.value=r}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}};var ne=m("three");function be(o,e,t){return o*(e-t)-e}function ve(o,e,t){return Math.min(Math.max((o+e)/(e-t),0),1)}var Ls=`#include <common>
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;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
#ifdef 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;}void main(){float depth=readDepth(vUv);
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearDepth=depth;
#endif
float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`;var Kt=class extends ne.ShaderMaterial{constructor(e){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ne.Uniform(null),focusDistance:new ne.Uniform(0),focusRange:new ne.Uniform(0),cameraNear:new ne.Uniform(.3),cameraFar:new ne.Uniform(1e3)},blending:ne.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ls,vertexShader:X}),this.uniforms.focalLength=this.uniforms.focusRange,this.copyCameraSettings(e)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=ne.BasicDepthPacking){this.depthBuffer=e,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(e){this.uniforms.focusDistance.value=e}get worldFocusDistance(){return-be(this.focusDistance,this.near,this.far)}set worldFocusDistance(e){this.focusDistance=ve(-e,this.near,this.far)}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-be(this.focusRange,this.near,this.far)}set worldFocusRange(e){this.focusRange=ve(-e,this.near,this.far)}getFocalLength(e){return this.focusRange}setFocalLength(e){this.focusRange=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof ne.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}};var Le=m("three");var Fs=`#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=step(mask,0.0);
#else
mask=1.0-step(mask,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
}`;var Xt=class extends Le.ShaderMaterial{constructor(e=null){super({name:"MaskMaterial",uniforms:{maskTexture:new Le.Uniform(e),inputBuffer:new Le.Uniform(null),strength:new Le.Uniform(1)},blending:Le.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Fs,vertexShader:X}),this.colorChannel=Re.RED,this.maskFunction=_t.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!==Le.UnsignedByteType&&(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}};var Os=m("three");var H=class extends T{constructor(e,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=e,this.input=t}setInput(e){this.input=e}render(e,t,r,i,s){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:r),e.render(this.scene,this.camera)}initialize(e,t,r){r!==void 0&&r!==Os.UnsignedByteType&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}};var Ns=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
#else
uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
#endif
uniform lowp sampler2D nearCoCBuffer;uniform lowp sampler2D farCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);
#if MASK_FUNCTION == 1
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);
#endif
vec4 result=inputColor*(1.0-cocNearFar.y)+colorFar;result=mix(result,colorNear,cocNearFar.x);outputColor=result;}`;var Qr=class extends A{constructor(e,{blendFunction:t,worldFocusDistance:r,worldFocusRange:i,focusDistance:s=0,focalLength:a=.1,focusRange:n=a,bokehScale:c=1,resolutionScale:l=1,width:u=x.AUTO_SIZE,height:f=x.AUTO_SIZE,resolutionX:h=u,resolutionY:d=f}={}){super("DepthOfFieldEffect",Ns,{blendFunction:t,attributes:P.DEPTH,uniforms:new Map([["nearColorBuffer",new _.Uniform(null)],["farColorBuffer",new _.Uniform(null)],["nearCoCBuffer",new _.Uniform(null)],["farCoCBuffer",new _.Uniform(null)],["scale",new _.Uniform(1)]])}),this.camera=e,this.renderTarget=new _.WebGLRenderTarget(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 H(new Kt(e));let p=this.cocMaterial;p.focusDistance=s,p.focusRange=n,r!==void 0&&(p.worldFocusDistance=r),i!==void 0&&(p.worldFocusRange=i),this.blurPass=new ie({resolutionScale:l,resolutionX:h,resolutionY:d,kernelSize:Y.MEDIUM}),this.maskPass=new H(new Xt(this.renderTargetCoC.texture));let g=this.maskPass.fullscreenMaterial;g.colorChannel=Re.GREEN,this.maskFunction=_t.MULTIPLY_RGB,this.bokehNearBasePass=new H(new qe(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new H(new qe(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new H(new qe(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new H(new qe(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null;let E=this.resolution=new x(this,h,d,l);E.addEventListener("change",B=>this.setSize(E.baseWidth,E.baseHeight)),this.bokehScale=c}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){let t=this.camera,r=t.position.distanceTo(e);return ve(-r,t.near,t.far)}setDepthTexture(e,t=_.BasicDepthPacking){this.cocMaterial.depthBuffer=e,this.cocMaterial.depthPacking=t}update(e,t,r){let i=this.renderTarget,s=this.renderTargetCoC,a=this.renderTargetCoCBlurred,n=this.renderTargetMasked;if(this.target!==null){let c=this.calculateFocusDistance(this.target);th
#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,sub
#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;
#ifdef LOG_DEPTH
float d=pow(2.0,depth.x*log2(cameraNearFar.y+1.0))-1.0;float a=cameraNearFar.y/(cameraNearFar.y-cameraNearFar.x);float b=cameraNearFar.y*cameraNearFar.x/(cameraNearFar.x-cameraNearFar.y);depth.x=a+b/d;
#endif
#endif
#if DEPTH_PACKING_1 == 3201
depth.y=unpackRGBAToDepth(texture2D(depthBuffer1,vUv));
#else
depth.y=texture2D(depthBuffer1,vUv).r;
#ifdef LOG_DEPTH
float d=pow(2.0,depth.y*log2(cameraNearFar.y+1.0))-1.0;float a=cameraNearFar.y/(cameraNearFar.y-cameraNearFar.x);float b=cameraNearFar.y*cameraNearFar.x/(cameraNearFar.x-cameraNearFar.y);depth.y=a+b/d;
#endif
#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;}}`;var ht=class extends y.ShaderMaterial{constructor(){super({name:"DepthMaskMaterial",defines:{DEPTH_EPSILON:"0.0001",DEPTH_PACKING_0:"0",DEPTH_PACKING_1:"0",DEPTH_TEST_STRATEGY:et.KEEP_MAX_DEPTH},uniforms:{inputBuffer:new y.Uniform(null),depthBuffer0:new y.Uniform(null),depthBuffer1:new y.Uniform(null),cameraNearFar:new y.Uniform(new y.Vector2(1,1))},blending:y.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ys,vertexShader:X}),this.depthMode=y.LessDepth}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=y.BasicDepthPacking){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=y.BasicDepthPacking){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?et.KEEP_MAX_DEPTH:et.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 y.NeverDepth:t="false";break;case y.AlwaysDepth:t="true";break;case y.EqualDepth:t="abs(d1 - d0) <= DEPTH_EPSILON";break;case y.NotEqualDepth:t="abs(d1 - d0) > DEPTH_EPSILON";break;case y.LessDepth:t="d0 > d1";break;case y.LessEqualDepth:t="d0 >= d1";break;case y.GreaterEqualDepth:t="d0 <= d1";break;case y.GreaterDepth: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 y.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}};var ge=m("three");var Ws=`#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>
}`;var jt=class extends ge.ShaderMaterial{constructor(e){super({name:"GodRaysMaterial",defines:{SAMPLES_INT:"60",SAMPLES_FLOAT:"60.0"},uniforms:{inputBuffer:new ge.Uniform(null),lightPosition:new ge.Uniform(e),density:new ge.Uniform(1),decay:new ge.Uniform(1),weight:new ge.Uniform(1),exposure:new ge.Uniform(1),clampMax:new ge.Uniform(1)},blending:ge.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ws,vertexShader:X})}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}};var Se=class extends T{constructor(e,t,r=null){super("RenderPass",e,t),this.needsSwap=!1,this.clearPass=new q,this.overrideMaterialManager=r===null?null:new Dt(r),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?e.material:null}set overrideMaterial(e){let t=this.overrideMaterialManager;e!==null?t!==null?t.setMaterial(e):this.overrideMaterialManager=new Dt(e):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}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,r,i,s){let a=this.scene,n=this.camera,c=this.selection,l=n.layers.mask,u=a.background,f=e.shadowMap.autoUpdate,h=this.renderToScreen?null:t;c!==null&&n.layers.set(c.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(h),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(e,a,n):e.render(a,n),n.layers.mask=l,a.background=u,e.shadowMap.autoUpdate=f}};var _s=`#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);}`;var Kr=new F.Vector3,Ks=new F.Matrix4,Xr=class extends A{constructor(e,t,{blendFunction:r=v.SCREEN,samples:i=60,density:s=.96,decay:a=.9,weight:n=.4,exposure:c=.6,clampMax:l=1,blur:u=!0,kernelSize:f=Y.SMALL,resolutionScale:h=.5,width:d=x.AUTO_SIZE,height:p=x.AUTO_SIZE,resolutionX:g=d,resolutionY:E=p}={}){super("GodRaysEffect",_s,{blendFunction:r,attributes:P.DEPTH,uniforms:new Map([["map",new F.Uniform(null)]])}),this.camera=e,this._lightSource=t,this.lightSource=t,this.lightScene=new F.Scene,this.screenPosition=new F.Vector2,this.renderTargetA=new F.WebGLRenderTarget(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 F.WebGLRenderTarget(1,1),this.renderTargetLight.texture.name="GodRays.Light",this.renderTargetLight.depthTexture=new F.DepthTexture,this.renderPassLight=new Se(this.lightScene,e),this.renderPassLight.clearPass.overrideClearColor=new F.Color(0),this.clearPass=new q(!0,!1,!1),this.clearPass.overrideClearColor=new F.Color(0),this.blurPass=new ie({kernelSize:f}),this.blurPass.enabled=u,this.depthMaskPass=new H(new ht);let B=this.depthMaskMaterial;B.depthBuffer1=this.renderTargetLight.depthTexture,B.copyCameraSettings(e),this.godRaysPass=new H(new jt(this.screenPosition));let D=this.godRaysMaterial;D.density=s,D.decay=a,D.weight=n,D.exposure=c,D.maxIntensity=l,D.samples=i;let w=this.resolution=new x(this,g,E,h);w.addEventListener("change",R=>this.setSize(w.baseWidth,w.baseHeight))}set mainCamera(e){this.camera=e,this.renderPassLight.mainCamera=e,this.depthMaskMaterial.copyCameraSettings(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 depthMaskMaterial(){return this.depthMaskPass.fullscreenMaterial}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=F.BasicDepthPacking){this.depthMaskPass.fullscreenMaterial.depthBuffer0=e,this.depthMaskPass.fullscreenMaterial.depthPacking0=t}update(e,t,r){let i=this.lightSource,s=i.parent,a=i.matrixAutoUpdate,n=this.renderTargetA,c=this.renderTargetLight;i.material.depthWrite=!0,i.matrixAutoUpdate=!1,i.updateWorldMatrix(!0,!1),s!==null&&(a||Ks.copy(i.matrix),i.matrix.copy(i.matrixWorld)),this.lightScene.add(i),this.renderPassLight.render(e,c),this.clearPass.render(e,n),this.depthMaskPass.render(e,c,n),i.material.depthWrite=!1,i.matrixAutoUpdate=a,s!==null&&(a||i.matrix.copy(Ks),s.add(i)),Kr.setFromMatrixPosition(i.matrixWorld).project(this.camera),this.screenPosition.set(Math.min(Math.max((Kr.x+1)*.5,-1),2),Math.min(Math.max((Kr.y+1)*.5,-1),2)),this.blurPass.enabled&&this.blurPass.render(e,n,n),this.godRaysPass.render(e,n,this.renderTargetB)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t);let i=r.width,s=r.height;this.renderTargetA.setSize(i,s),this.renderTargetB.setSize(i,s),this.renderTargetLight.setSize(i,s),this.blurPass.resolution.copy(r)}initialize(e,t,r){this.blurPa
#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);}`;var qr=class extends A{constructor(e,{blendFunction:t=v.SRC}={}){super("LUT1DEffect",Js,{blendFunction:t,uniforms:new Map([["lut",new Tt.Uniform(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===Tt.FloatType||e.type===Tt.HalfFloatType)&&this.defines.set("LUT_PRECISION_HIGH","1")}};var O=m("three");var S=m("three");var $r={SCALE_UP:"lut.scaleup"};function qs(o,e,t){let r=document.createElement("canvas"),i=r.getContext("2d");if(r.width=o,r.height=e,t instanceof Image)i.drawImage(t,0,0);else{let s=i.createImageData(o,e);s.data.set(t),i.putImageData(s,0,0)}return r}var le=class o{constructor(e=0,t=0,r=null){this.width=e,this.height=t,this.data=r}toCanvas(){return typeof document=="undefined"?null:qs(this.width,this.height,this.data)}static from(e){let{width:t,height:r}=e,i;if(e instanceof Image){let s=qs(t,r,e);s!==null&&(i=s.getContext("2d").getImageData(0,0,t,r).data)}else i=e.data;return new o(t,r,i)}};var $s=`"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;switch(t.operation){case O.SCALE_UP:r=v.expand(r,t.size);break}postMessage(r,[r.buffer]),close()});})();
`;var en=new S.Color,Fe=class o extends S.Data3DTexture{constructor(e,t){super(e,t,t,t),this.type=S.FloatType,this.format=S.RGBAFormat,this.minFilter=S.LinearFilter,this.magFilter=S.LinearFilter,this.wrapS=S.ClampToEdgeWrapping,this.wrapT=S.ClampToEdgeWrapping,this.wrapR=S.ClampToEdgeWrapping,this.unpackAlignment=1,this.needsUpdate=!0,this.colorSpace=S.LinearSRGBColorSpace,this.domainMin=new S.Vector3(0,0,0),this.domainMax=new S.Vector3(1,1,1)}get isLookupTexture3D(){return!0}scaleUp(e,t=!0){let r=this.image,i;return e<=r.width?i=Promise.reject(new Error("The target size must be greater than the current size")):i=new Promise((s,a)=>{let n=URL.createObjectURL(new Blob([$s],{type:"text/javascript"})),c=new Worker(n);c.addEventListener("error",u=>a(u.error)),c.addEventListener("message",u=>{let f=new o(u.data,e);this.colorSpace=f.colorSpace,f.type=this.type,f.name=this.name,URL.revokeObjectURL(n),s(f)});let l=t?[r.data.buffer]:[];c.postMessage({operation:$r.SCALE_UP,data:r.data,size:e},l)}),i}applyLUT(e){let t=this.image,r=e.image,i=Math.min(t.width,t.height,t.depth),s=Math.min(r.width,r.height,r.depth);if(i!==s)console.error("Size mismatch");else if(e.type!==S.FloatType||this.type!==S.FloatType)console.error("Both LUTs must be FloatType textures");else if(e.format!==S.RGBAFormat||this.format!==S.RGBAFormat)console.error("Both LUTs must be RGBA textures");else{let a=t.data,n=r.data,c=i,l=c**2,u=c-1;for(let f=0,h=c**3;f<h;++f){let d=f*4,p=a[d+0]*u,g=a[d+1]*u,E=a[d+2]*u,B=Math.round(p+g*c+E*l)*4;a[d+0]=n[B+0],a[d+1]=n[B+1],a[d+2]=n[B+2]}this.needsUpdate=!0}return this}convertToUint8(){if(this.type===S.FloatType){let e=this.image.data,t=new Uint8Array(e.length);for(let r=0,i=e.length;r<i;++r)t[r]=e[r]*255+.5;this.image.data=t,this.type=S.UnsignedByteType,this.needsUpdate=!0}return this}convertToFloat(){if(this.type===S.UnsignedByteType){let e=this.image.data,t=new Float32Array(e.length);for(let r=0,i=e.length;r<i;++r)t[r]=e[r]/255;this.image.data=t,this.type=S.FloatType,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===S.FloatType){for(let t=0,r=e.length;t<r;t+=4)en.fromArray(e,t).convertLinearToSRGB().toArray(e,t);this.colorSpace=S.SRGBColorSpace,this.needsUpdate=!0}else console.error("Color space conversion requires FloatType data");return this}convertSRGBToLinear(){let e=this.image.data;if(this.type===S.FloatType){for(let t=0,r=e.length;t<r;t+=4)en.fromArray(e,t).convertSRGBToLinear().toArray(e,t);this.colorSpace=S.LinearSRGBColorSpace,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,r=new S.DataTexture(this.image.data,e,t);return r.name=this.name,r.type=this.type,r.format=this.format,r.minFilter=S.LinearFilter,r.magFilter=S.LinearFilter,r.wrapS=this.wrapS,r.wrapT=this.wrapT,r.generateMipmaps=!1,r.needsUpdate=!0,this.colorSpace=r.colorSpace,r}static from(e){let t=e.image,{width:r,height:i}=t,s=Math.min(r,i),a;if(t instanceof Image){let l=le.from(t).data;if(r>i){a=new Uint8Array(l.length);for(let u=0;u<s;++u)for(let f=0;f<s;++f)for(let h=0;h<s;++h){let d=(h+u*s+f*s*s)*4,p=(h+f*s+u*s*s)*4;a[p+0]=l[d+0],a[p+1]=l[d+1],a[p+2]=l[d+2],a[p+3]=l[d+3]}}else a=new Uint8Array(l.buffer)}else a=t.data.slice();let n=new o(a,s);return n.type=e.type,n.name=e.name,e.colorSpace=n.colorSpace,n}static createNeutral(e){let t=new Float32Array(e**3*4),r=e**2,i=1/(e-1);for(let a=0;a<e;++a)for(let n=0;n<e;++n)for(let c=0;c<e;++c){let l=(a+n*e+c*r)*4;t[l+0]=a*i,t[l+1]=n*i,t[l+2]=c*i,t[l+3]=1}let s=new o(t,e);return s.name="neutral",s}};var tn=`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);}`;var Tr=class extends A{constructor(e,{blendFunction:t=v.SRC,tetrahedralInterpolation:r=!1,inputColorSpace:i=O.SRGBColorSpace}={}){super("LUT3DEffect",tn,{blendFunction:t,uniforms:new Map([["lut",new O.Uniform(null)],["scale",new O.Uniform(new O.Vector3)],["offset",new O.Uniform(new O.Vector3)],["domainMin",new O.Uniform(null)],["domainMax",new O.Uniform(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,r=this.uniforms;if(this.lut!==e&&(r.get("lut").value=e,e!==null)){let i=e.image,s=this.tetrahedralInterpolation;if(t.clear(),t.set("LUT_SIZE",Math.min(i.width,i.height).toFixed(16)),t.set("LUT_TEXEL_WIDTH",(1/i.width).toFixed(16)),t.set("LUT_TEXEL_HEIGHT",(1/i.height).toFixed(16)),r.get("domainMin").value=null,r.get("domainMax").value=null,(e.type===O.FloatType||e.type===O.HalfFloatType)&&t.set("LUT_PRECISION_HIGH","1"),i.width>i.height?t.set("LUT_STRIP_HORIZONTAL","1"):e instanceof O.Data3DTexture&&t.set("LUT_3D","1"),e instanceof Fe){let a=e.domainMin,n=e.domainMax;(a.x!==0||a.y!==0||a.z!==0||n.x!==1||n.y!==1||n.z!==1)&&(t.set("CUSTOM_INPUT_DOMAIN","1"),r.get("domainMin").value=a.clone(),r.get("domainMax").value=n.clone())}this.tetrahedralInterpolation=s}}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),r=this.uniforms.get("scale").value,i=this.uniforms.get("offset").value;if(this.tetrahedralInterpolation&&e instanceof O.Data3DTexture)if(this.defines.has("CUSTOM_INPUT_DOMAIN")){let s=e.domainMax.clone().sub(e.domainMin);r.setScalar(t-1).divide(s),i.copy(e.domainMin).negate().multiply(r)}else r.setScalar(t-1),i.setScalar(0);else if(this.defines.has("CUSTOM_INPUT_DOMAIN")){let s=e.domainMax.clone().sub(e.domainMin).multiplyScalar(t);r.setScalar(t-1).divide(s),i.copy(e.domainMin).negate().multiply(r).addScalar(1/(2*t))}else r.setScalar((t-1)/t),i.setScalar(1/(2*t))}}configureTetrahedralInterpolation(){let e=this.lut;e!==null&&(e.minFilter=O.LinearFilter,e.magFilter=O.LinearFilter,this.tetrahedralInterpolation&&(e instanceof O.Data3DTexture?(e.minFilter=O.NearestFilter,e.magFilter=O.NearestFilter):console.warn("Tetrahedral interpolation requires a 3D texture")),e.source===void 0&&(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}};var tt={FULL:0,SINGLE:1};var qt={DEPTH:0,LUMA:1,COLOR:2};var ei={DISABLED:0,DEPTH:1,CUSTOM:2};var dt={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3};var ce={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,UNCHARTED2:4,OPTIMIZED_CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8};var pt={DEFAULT:0,ESKIL:1};var Po={DERIVATIVES:"derivatives",FRAG_DEPTH:"fragDepth",DRAW_BUFFERS:"drawBuffers",SHADER_TEXTURE_LOD:"shaderTextureLOD"};var rn=`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
}`;var ti=class extends A{constructor({blendFunction:e=v.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",rn,{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}};var z=m("three");var he=m("three");var sn=`#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;projTexCoord=clamp(projTexCoord,0.002,0.998);
#if DEPTH_PACKING == 3201
float fragCoordZ=unpackRGBAToDepth(texture2D(depthBuffer,projTexCoord));
#else
float fragCoordZ=texture2D(depthBuffer,projTexCoord).r;
#endif
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(fragCoordZ,cameraNear,cameraFar);
#else
float viewZ=orthographicDepthToViewZ(fragCoordZ,cameraNear,cameraFar);
#endif
float depthTest=(-vViewZ>-viewZ)?1.0:0.0;gl_FragColor.rg=vec2(0.0,depthTest);}`;var nn=`#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>
}`;var $t=class extends he.ShaderMaterial{constructor(e=null,t){super({name:"DepthComparisonMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new he.Uniform(null),cameraNear:new he.Uniform(.3),cameraFar:new he.Uniform(1e3)},blending:he.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:sn,vertexShader:nn}),this.depthBuffer=e,this.depthPacking=he.RGBADepthPacking,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=he.RGBADepthPacking){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 he.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}};var Oe=m("three");var an="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);}";var on="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);}";var St=class extends Oe.ShaderMaterial{constructor(e=new Oe.Vector2){super({name:"OutlineMaterial",uniforms:{inputBuffer:new Oe.Uniform(null),texelSize:new Oe.Uniform(new Oe.Vector2)},blending:Oe.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:an,vertexShader:on}),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)}};var Ce=m("three");var mt=class extends T{constructor(e,t,{renderTarget:r,resolutionScale:i=1,width:s=x.AUTO_SIZE,height:a=x.AUTO_SIZE,resolutionX:n=s,resolutionY:c=a}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new Se(e,t,new Ce.MeshDepthMaterial({depthPacking:Ce.RGBADepthPacking}));let l=this.renderPass;l.skipShadowMapUpdate=!0,l.ignoreBackground=!0;let u=l.clearPass;u.overrideClearColor=new Ce.Color(16777215),u.overrideClearAlpha=1,this.renderTarget=r,this.renderTarget===void 0&&(this.renderTarget=new Ce.WebGLRenderTarget(1,1,{minFilter:Ce.NearestFilter,magFilter:Ce.NearestFilter}),this.renderTarget.texture.name="DepthPass.Target");let f=this.resolution=new x(this,n,c,i);f.addEventListener("change",h=>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,r,i,s){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t),this.renderTarget.setSize(r.width,r.height)}};var ln=`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
}`;var cn="uniform float patternScale;varying vec2 vUvPattern;void mainSupport(const in vec2 uv){vUvPattern=uv*vec2(aspect,1.0)*patternScale;}";var ri=class extends A{constructor(e,t,{blendFunction:r=v.SCREEN,patternTexture:i=null,patternScale:s=1,edgeStrength:a=1,pulseSpeed:n=0,visibleEdgeColor:c=16777215,hiddenEdgeColor:l=2230538,kernelSize:u=Y.VERY_SMALL,blur:f=!1,xRay:h=!0,multisampling:d=0,resolutionScale:p=.5,width:g=x.AUTO_SIZE,height:E=x.AUTO_SIZE,resolutionX:B=g,resolutionY:D=E}={}){super("OutlineEffect",ln,{uniforms:new Map([["maskTexture",new z.Uniform(null)],["edgeTexture",new z.Uniform(null)],["edgeStrength",new z.Uniform(a)],["visibleEdgeColor",new z.Uniform(new z.Color(c))],["hiddenEdgeColor",new z.Uniform(new z.Color(l))],["pulse",new z.Uniform(1)],["patternScale",new z.Uniform(s)],["patternTexture",new z.Uniform(null)]])}),this.blendMode.addEventListener("change",Pe=>{this.blendMode.blendFunction===v.ALPHA?this.defines.set("ALPHA","1"):this.defines.delete("ALPHA"),this.setChanged()}),this.blendMode.blendFunction=r,this.patternTexture=i,this.xRay=h,this.scene=e,this.camera=t,this.renderTargetMask=new z.WebGLRenderTarget(1,1),this.renderTargetMask.samples=d,this.renderTargetMask.texture.name="Outline.Mask",this.uniforms.get("maskTexture").value=this.renderTargetMask.texture,this.renderTargetOutline=new z.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTargetOutline.texture.name="Outline.Edges",this.uniforms.get("edgeTexture").value=this.renderTargetOutline.texture,this.clearPass=new q,this.clearPass.overrideClearColor=new z.Color(0),this.clearPass.overrideClearAlpha=1,this.depthPass=new mt(e,t),this.maskPass=new Se(e,t,new $t(this.depthPass.texture,t));let w=this.maskPass.clearPass;w.overrideClearColor=new z.Color(16777215),w.overrideClearAlpha=1,this.blurPass=new ie({resolutionScale:p,resolutionX:B,resolutionY:D,kernelSize:u}),this.blurPass.enabled=f;let R=this.blurPass.resolution;R.addEventListener("change",Pe=>this.setSize(R.baseWidth,R.baseHeight)),this.outlinePass=new H(new St);let ye=this.outlinePass.fullscreenMaterial;ye.inputBuffer=this.renderTargetMask.texture,this.time=0,this.forceUpdate=!0,this.selection=new ct,this.selection.layer=10,this.pulseSpeed=n}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}setXR
#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);}`;var si=class extends A{constructor({blendFunction:e,focus:t=1,focalLength:r=24,fStop:i=.9,luminanceThreshold:s=.5,luminanceGain:a=2,bias:n=.5,fringe:c=.7,maxBlur:l=1,rings:u=3,samples:f=2,showFocus:h=!1,manualDoF:d=!1,pentagon:p=!1}={}){super("RealisticBokehEffect",fn,{blendFunction:e,attributes:P.CONVOLUTION|P.DEPTH,uniforms:new Map([["focus",new Ae.Uniform(t)],["focalLength",new Ae.Uniform(r)],["fStop",new Ae.Uniform(i)],["luminanceThreshold",new Ae.Uniform(s)],["luminanceGain",new Ae.Uniform(a)],["bias",new Ae.Uniform(n)],["fringe",new Ae.Uniform(c)],["maxBlur",new Ae.Uniform(l)],["dof",new Ae.Uniform(null)]])}),this.rings=u,this.samples=f,this.showFocus=h,this.manualDoF=d,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 Ae.Vector4(.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())}};var er=m("three");var hn=`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);}`;var ni=class extends A{constructor({blendFunction:e=v.OVERLAY,density:t=1.25,scrollSpeed:r=0}={}){super("ScanlineEffect",hn,{blendFunction:e,uniforms:new Map([["count",new er.Uniform(0)],["scrollSpeed",new er.Uniform(0)]])}),this.resolution=new er.Vector2,this.d=t,this.scrollSpeed=r}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)}};var $=m("three");var dn="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;}}}}";var pn="uniform float size;uniform float cameraDistance;varying float vSize;void mainSupport(){vSize=(0.1*cameraDistance)/size;}";var Qo=Math.PI*.5,tr=new $.Vector3,mn=new $.Vector3,ai=class extends A{constructor(e,t=new $.Vector3,{speed:r=2,maxRadius:i=1,waveSize:s=.2,amplitude:a=.05}={}){super("ShockWaveEffect",dn,{vertexShader:pn,uniforms:new Map([["active",new $.Uniform(!1)],["center",new $.Uniform(new $.Vector2(.5,.5))],["cameraDistance",new $.Uniform(1)],["size",new $.Uniform(1)],["radius",new $.Uniform(-s)],["maxRadius",new $.Uniform(i)],["waveSize",new $.Uniform(s)],["amplitude",new $.Uniform(a)]])}),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,r){let i=this.position,s=this.camera,a=this.uniforms,n=a.get("active");if(this.active){let c=a.get("waveSize").value;s.getWorldDirection(tr),mn.copy(s.position).sub(i),n.value=tr.angleTo(mn)>Qo,n.value&&(a.get("cameraDistance").value=s.position.distanceTo(i),tr.copy(i).project(s),this.screenPosition.set((tr.x+1)*.5,(tr.y+1)*.5)),this.time+=r*this.speed;let l=this.time-c;a.get("radius").value=l,l>=(a.get("maxRadius").value+c)*2&&(this.active=!1,n.value=!1)}}};var Z=m("three");var oi=class extends Qt{constructor(e,t,r){super(r),this.setAttributes(this.getAttributes()|P.DEPTH),this.camera=t,this.depthPass=new mt(e,t),this.clearPass=new q(!0,!1,!1),this.clearPass.overrideClearColor=new Z.Color(0),this.depthMaskPass=new H(new ht);let i=this.depthMaskMaterial;i.copyCameraSettings(t),i.depthBuffer1=this.depthPass.texture,i.depthPacking1=Z.RGBADepthPacking,i.depthMode=Z.EqualDepth,this.renderTargetMasked=new Z.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTargetMasked.texture.name="Bloom.Masked",this.selection=new ct,this.selection.layer=11,this._inverted=!1,this._ignoreBackground=!1}set mainScene(e){this.depthPass.mainScene=e}set mainCamera(e){this.camera=
#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
}`;var An=`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);}`;var Ct=class extends ee.ShaderMaterial{constructor(e=new ee.Vector2,t=qt.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:ee.REVISION.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 ee.Uniform(null),depthBuffer:new ee.Uniform(null),predicationBuffer:new ee.Uniform(null),texelSize:new ee.Uniform(e)},blending:ee.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:gn,vertexShader:An}),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=ee.BasicDepthPacking){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)}};var de=m("three");var xn=`#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
#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;}`;var Dn="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);}";var rr=class extends de.ShaderMaterial{constructor(e=new de.Vector2,t=new de.Vector2){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 de.Uniform(null),searchTexture:new de.Uniform(null),areaTexture:new de.Uniform(null),resolution:new de.Uniform(t),texelSize:new de.Uniform(e)},blending:de.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:xn,vertexShader:Dn})}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 r=this.uniforms;r.texelSize.value.set(1/e,1/t),r.resolution.value.set(e,t)}};var ir="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC";var sr="data:image/png;base64,iVBORw0KGgoAAA
#include <packing>
#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
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
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#endif
uniform lowp sampler2D noiseTexture;uniform mat4 inverseProjectionMatrix;uniform mat4 projectionMatrix;uniform vec2 texelSize;uniform vec2 cameraNearFar;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,cameraNearFar.x,cameraNearFar.y);
#else
return orthographicDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#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,cameraNearFar.x,cameraNearFar.y);
#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);
#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,cameraNearFar.x,cameraNearFar.y);
#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;}`;var Sn="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);}";var nr=class extends M.ShaderMaterial{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.Uniform(null),normalBuffer:new M.Uniform(null),normalDepthBuffer:new M.Uniform(null),noiseTexture:new M.Uniform(null),inverseProjectionMatrix:new M.Uniform(new M.Matrix4),projectionMatrix:new M.Uniform(new M.Matrix4),texelSize:new M.Uniform(new M.Vector2),cameraNearFar:new M.Uniform(new M.Vector2),distanceCutoff:new M.Uniform(new M.Vector2),proximityCutoff:new M.Uniform(new M.Vector2),noiseScale:new M.Uniform(new M.Vector2),minRadiusScale:new M.Uniform(.33),intensity:new M.Uniform(1),fade:new M.Uniform(.01),bias:new M.Uniform(0)},blending:M.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Tn,vertexShader:Sn}),this.copyCameraSettings(e),this.resolution=new M.Vector2,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?this.defines.NORMAL_DEPTH="1":delete this.defines.NORMAL_DEPTH,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=M.BasicDepthPacking){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-be(this.distanceThreshold,this.near,this.far)}set worldDistanceThreshold(e){this.distanceThreshold=ve(-e,this.near,this.far)}get distanceFalloff(){return this.uniforms.distanceCutoff.value.y-this.distanceThreshold}set distanceFalloff(e
#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]);}`;var Bn="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);}";var ar=class extends xe.ShaderMaterial{constructor(){super({name:"DepthDownsamplingMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new xe.Uniform(null),normalBuffer:new xe.Uniform(null),texelSize:new xe.Uniform(new xe.Vector2)},blending:xe.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Cn,vertexShader:Bn})}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=xe.BasicDepthPacking){this.depthBuffer=e,this.depthPacking=t}set normalBuffer(e){this.uniforms.normalBuffer.value=e,e!==null?this.defines.DOWNSAMPLE_NORMALS="1":delete this.defines.DOWNSAMPLE_NORMALS,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)}};var or=class extends T{constructor({normalBuffer:e=null,resolutionScale:t=.5,width:r=x.AUTO_SIZE,height:i=x.AUTO_SIZE,resolutionX:s=r,resolutionY:a=i}={}){super("DepthDownsamplingPass");let n=new ar;n.normalBuffer=e,this.fullscreenMaterial=n,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new Qe.WebGLRenderTarget(1,1,{minFilter:Qe.NearestFilter,magFilter:Qe.NearestFilter,depthBuffer:!1,type:Qe.FloatType}),this.renderTarget.texture.name="DepthDownsamplingPass.Target",this.renderTarget.texture.generateMipmaps=!1;let c=this.resolution=new x(this,s,a,t);c.addEventListener("change",l=>this.setSize(c.baseWidth,c.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e,t=Qe.BasicDepthPacking){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t}render(e,t,r,i,s){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t),this.renderTarget.setSize(r.width,r.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,r){let i=e.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}};var Mn=`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
}`;var yn=64,ui=class extends A{constructor(e,t,{blendFunction:r=v.MULTIPLY,samples:i=9,rings:s=7,normalDepthBuffer:a=null,depthAwareUpsampling:n=!0,worldDistanceThreshold:c,worldDistanceFalloff:l,worldProximityThreshold:u,worldProximityFalloff:f,distanceThreshold:h=.97,distanceFalloff:d=.03,rangeThreshold:p=5e-4,rangeFalloff:g=.001,minRadiusScale:E=.1,luminanceInfluence:B=.7,radius:D=.1825,intensity:w=1,bias:R=.025,fade:ye=.01,color:Pe=null,resolutionScale:Ie=1,width:L=x.AUTO_SIZE,height:gt=x.AUTO_SIZE,resolutionX:At=L,resolutionY:xt=gt}={}){super("SSAOEffect",Mn,{blendFunction:r,attributes:P.DEPTH,defines:new Map([["THRESHOLD","0.997"]]),uniforms:new Map([["aoBuffer",new K.Uniform(null)],["normalDepthBuffer",new K.Uniform(a)],["luminanceInfluence",new K.Uniform(B)],["color",new K.Uniform(null)],["intensity",new K.Uniform(w)],["scale",new K.Uniform(0)]])}),this.renderTarget=new K.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="AO.Target",this.uniforms.get("aoBuffer").value=this.renderTarget.texture;let at=this.resolution=new x(this,At,xt,Ie);at.addEventListener("change",xr=>this.setSize(at.baseWidth,at.baseHeight)),this.camera=e,this.depthDownsamplingPass=new or({normalBuffer:t,resolutionScale:Ie}),this.depthDownsamplingPass.enabled=a===null,this.ssaoPass=new H(new nr(e));let ot=new $e(yn,yn,K.RGBAFormat);ot.wrapS=ot.wrapT=K.RepeatWrapping;let Q=this.ssaoMaterial;Q.normalBuffer=t,Q.noiseTexture=ot,Q.minRadiusScale=E,Q.samples=i,Q.radius=D,Q.rings=s,Q.fade=ye,Q.bias=R,Q.distanceThreshold=h,Q.distanceFalloff=d,Q.proximityThreshold=p,Q.proximityFalloff=g,c!==void 0&&(Q.worldDistanceThreshold=c),l!==void 0&&(Q.worldDistanceFalloff=l),u!==void 0&&(Q.worldProximityThreshold=u),f!==void 0&&(Q.worldProximityFalloff=f),a!==null&&(this.ssaoMaterial.normalDepthBuffer=a,this.defines.set("NORMAL_DEPTH","1")),this.depthAwareUpsampling=n,this.color=Pe}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 t=this.uniforms,r=this.defines;e!==null?r.has("COLORIZE")?t.get("color").value.set(e):(r.set("COLORIZE","1"),t.get("color").value=new K.Color(e),this.setChanged()):r.has("COLORIZE")&&(r.delete("COLORIZE"),t.get("color").value=null,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=K.BasicDepthPacking){this.depthDownsamplingPass.setDepthTexture(e,t),this.ssaoMaterial.depthBuffer=e,this.ssaoMaterial.depthPacking=t}update(e,t,r){let i=this.renderTarget;this.depthDownsamplingPass.enabled&&this.depthDownsamplingPass.render(e),this.ssaoPass.render(e,
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;}`;var In=`#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
}`;var fi=class extends A{constructor({blendFunction:e,texture:t=null,aspectCorrection:r=!1}={}){super("TextureEffect",Pn,{blendFunction:e,defines:new Map([["TEXEL","texel"]]),uniforms:new Map([["map",new Bt.Uniform(null)],["scale",new Bt.Uniform(1)],["uvTransform",new Bt.Uniform(null)]])}),this.texture=t,this.aspectCorrection=r}get texture(){return this.uniforms.get("map").value}set texture(e){let t=this.texture,r=this.uniforms,i=this.defines;t!==e&&(r.get("map").value=e,r.get("uvTransform").value=e.matrix,i.delete("TEXTURE_PRECISION_HIGH"),e!==null&&(e.matrixAutoUpdate?(i.set("UV_TRANSFORM","1"),this.setVertexShader(In)):(i.delete("UV_TRANSFORM"),this.setVertexShader(null)),e.type!==Bt.UnsignedByteType&&i.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,r=e,i=e){let s="rgba",a="";(e!==Re.RED||t!==Re.GREEN||r!==Re.BLUE||i!==Re.ALPHA)&&(a=[".",s[e],s[t],s[r],s[i]].join("")),this.defines.set("TEXEL","texel"+a),this.setChanged()}update(e,t,r){this.texture.matrixAutoUpdate&&this.texture.updateMatrix()}};var De=m("three");var it=m("three");var Un=`#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>
}`;var Rn="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);}";var lr=class extends Ze{constructor({kernelSize:e=Y.MEDIUM,offset:t=0,rotation:r=0,focusArea:i=.4,feather:s=.3}={}){super(),this.fragmentShader=Un,this.vertexShader=Rn,this.kernelSize=e,this.fragmentShader=te(this.fragmentShader),this.uniforms.aspect=new it.Uniform(1),this.uniforms.rotation=new it.Uniform(new it.Vector2),this.uniforms.maskParams=new it.Uniform(new it.Vector4),this._offset=t,this._focusArea=i,this._feather=s,this.rotation=r,this.updateParams()}updateParams(){let e=this.uniforms.maskParams.value,t=Math.max(this.focusArea,0),r=Math.max(t-this.feather,0);e.set(this.offset-t,this.offset-r,this.offset+t,this.offset+r)}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}};var cr=class extends ie{constructor({offset:e=0,rotation:t=0,focusArea:r=.4,feather:i=.3,kernelSize:s=Y.MEDIUM,resolutionScale:a=.5,resolutionX:n=x.AUTO_SIZE,resolutionY:c=x.AUTO_SIZE}={}){super({kernelSize:s,resolutionScale:a,resolutionX:n,resolutionY:c}),this.blurMaterial=new lr({kernelSize:s,offset:e,rotation:t,focusArea:r,feather:i})}};var bn=`#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);}`;var Ln="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)));}";var hi=class extends A{constructor({blendFunction:e,offset:t=0,rotation:r=0,focusArea:i=.4,feather:s=.3,kernelSize:a=Y.MEDIUM,resolutionScale:n=.5,resolutionX:c=x.AUTO_SIZE,resolutionY:l=x.AUTO_SIZE}={}){super("TiltShiftEffect",bn,{vertexShader:Ln,blendFunction:e,uniforms:new Map([["rotation",new De.Uniform(new De.Vector2)],["maskParams",new De.Uniform(new De.Vector2)],["map",new De.Uniform(null)]])}),this._offset=t,this._focusArea=i,this._feather=s,this.renderTarget=new De.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="TiltShift.Target",this.uniforms.get("map").value=this.renderTarget.texture,this.blurPass=new cr({kernelSize:a,resolutionScale:n,resolutionX:c,resolutionY:l,offset:t,rotation:r,focusArea:i,feather:s});let u=this.resolution=new x(this,c,l,n);u.addEventListener("change",f=>this.setSize(u.baseWidth,u.baseHeight)),this.rotation=r,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,r){this.blurPass.render(e,t,this.renderTarget)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t),this.renderTarget.setSize(r.width,r.height),this.blurPass.resolution.copy(r)}initialize(e,t,r){this.blurPass.initialize(e,t,r),r!==void 0&&(this.renderTarget.texture.type=r,e!==null&&e.outputColorSpace===De.SRGBColorSpace&&(this.renderTarget.texture.colorSpace=De.SRGBColorSpace))}};var He=m("three");var fr=m("three");var Ne=m("three");var Fn=`#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);}`;var ur=class extends Ne.ShaderMaterial{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new Ne.Uniform(null),luminanceBuffer1:new Ne.Uniform(null),minLuminance:new Ne.Uniform(.01),deltaTime:new Ne.Uniform(0),tau:new Ne.Uniform(1)},extensions:{shaderTextureLOD:!0},blending:Ne.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Fn,vertexShader:X})}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}};var hr=class extends T{constructor(e,{minLuminance:t=.01,adaptationRate:r=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new ur,this.needsSwap=!1,this.renderTargetPrevious=new fr.WebGLRenderTarget(1,1,{minFilter:fr.NearestFilter,magFilter:fr.NearestFilter,depthBuffer:!1}),this.renderTargetPrevious.texture.name="Luminance.Previous";let i=this.fullscreenMaterial;i.luminanceBuffer0=this.renderTargetPrevious.texture,i.luminanceBuffer1=e,i.minLuminance=t,i.adaptationRate=r,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name="Luminance.Adapted",this.copyPass=new Ke(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,r,i,s){this.fullscreenMaterial.deltaTime=i,e.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),e.render(this.scene,this.camera),this.copyPass.render(e,this.renderTargetAdapted)}};var On=`#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
}`;var di=class extends A{constructor({blendFunction:e=v.SRC,adaptive:t=!1,mode:r=t?ce.REINHARD2_ADAPTIVE:ce.AGX,resolution:i=256,maxLuminance:s=4,whitePoint:a=s,middleGrey:n=.6,minLuminance:c=.01,averageLuminance:l=1,adaptationRate:u=1}={}){super("ToneMappingEffect",On,{blendFunction:e,uniforms:new Map([["luminanceBuffer",new He.Uniform(null)],["maxLuminance",new He.Uniform(s)],["whitePoint",new He.Uniform(a)],["middleGrey",new He.Uniform(n)],["averageLuminance",new He.Uniform(l)]])}),this.renderTargetLuminance=new He.WebGLRenderTarget(1,1,{minFilter:He.LinearMipmapLinearFilter,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new ut({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new hr(this.luminancePass.texture,{minLuminance:c,adaptationRate:u}),this.uniforms.get("luminanceBuffer").value=this.adaptiveLuminancePass.texture,this.resolution=i,this.mode=r}get mode(){return Number(this.defines.get("TONE_MAPPING_MODE"))}set mode(e){if(this.mode!==e){switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",e.toFixed(0)),e){case ce.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case ce.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case ce.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)","OptimizedCineonToneMapping(texel)");break;case ce.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case ce.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case ce.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=e===ce.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))),r=Math.pow(2,t);this.luminancePass.resolution.setPreferredSize(r,r),this.adaptiveLuminanceMaterial.mipLevel1x1=t}getResolution(){return this.resolution}setResolution(e){this.resolution=e}get adaptive(){return this.mode===ce.REINHARD2_ADAPTIVE}set adaptive(e){this.mode=e?ce.REINHARD2_ADAPTIVE:ce.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,r){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(e,t),this.adaptiveLuminancePass.render(e,null,null,r))}initialize(e,t,r){this.adaptiveLuminancePass.initialize(e,t,r)}};var pi=m("three");var Nn=`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);}`;var mi=class extends A{constructor({blendFunction:e,eskil:t=!1,technique:r=t?pt.ESKIL:pt.DEFAULT,offset:i=.5,darkness:s=.5}={}){super("VignetteEffect",Nn,{blendFunction:e,defines:new Map([["VIGNETTE_TECHNIQUE",r.toFixed(0)]]),uniforms:new Map([["offset",new pi.Uniform(i)],["darkness",new pi.Uniform(s)]])})}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===pt.ESKIL}set eskil(e){this.technique=e?pt.ESKIL:pt.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}};var Mt=m("three");var vi=class extends Mt.Loader{load(e,t=()=>{},r=()=>{},i=null){let s=this.manager,a=new Mt.LoadingManager,n=new Mt.FileLoader(a);return n.setPath(this.path),n.setResponseType("text"),new Promise((c,l)=>{a.onError=u=>{s.itemError(u),i!==null?(i(`Failed to load ${u}`),c()):l(`Failed to load ${u}`)},s.itemStart(e),n.load(e,u=>{try{let f=this.parse(u);s.itemEnd(e),t(f),c(f)}catch(f){console.error(f),a.onError(e)}},r)})}parse(e){let t=/^[\d ]+$/m,r=/^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm,i=t.exec(e);if(i===null)throw new Error("Missing grid information");let s=i[0].trim().split(/\s+/g).map(p=>Number(p)),a=s[1]-s[0],n=s.length,c=n**2;for(let p=1,g=s.length;p<g;++p)if(a!==s[p]-s[p-1])throw new Error("Inconsistent grid size");let l=new Float32Array(n**3*4),u=0,f=0;for(;(i=r.exec(e))!==null;){let p=Number(i[1]),g=Number(i[2]),E=Number(i[3]);u=Math.max(u,p,g,E);let B=f%n,D=Math.floor(f/n)%n,w=Math.floor(f/c)%n,R=(B*c+D*n+w)*4;l[R+0]=p,l[R+1]=g,l[R+2]=E,l[R+3]=1,++f}let h=Math.ceil(Math.log2(u)),d=Math.pow(2,h);for(let p=0,g=l.length;p<g;p+=4)l[p+0]/=d,l[p+1]/=d,l[p+2]/=d;return new Fe(l,n)}};var Ve=m("three");var gi=class extends Ve.Loader{load(e,t=()=>{},r=()=>{},i=null){let s=this.manager,a=new Ve.LoadingManager,n=new Ve.FileLoader(a);return n.setPath(this.path),n.setResponseType("text"),new Promise((c,l)=>{a.onError=u=>{s.itemError(u),i!==null?(i(`Failed to load ${u}`),c()):l(`Failed to load ${u}`)},s.itemStart(e),n.load(e,u=>{try{let f=this.parse(u);s.itemEnd(e),t(f),c(f)}catch(f){console.error(f),a.onError(e)}},r)})}parse(e){let t=/TITLE +"([^"]*)"/,r=/LUT_3D_SIZE +(\d+)/,i=/DOMAIN_MIN +([\d.]+) +([\d.]+) +([\d.]+)/,s=/DOMAIN_MAX +([\d.]+) +([\d.]+) +([\d.]+)/,a=/^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm,n=t.exec(e),c=n!==null?n[1]:null;if(n=r.exec(e),n===null)throw new Error("Missing LUT_3D_SIZE information");let l=Number(n[1]),u=new Float32Array(l**3*4),f=new Ve.Vector3(0,0,0),h=new Ve.Vector3(1,1,1);if(n=i.exec(e),n!==null&&f.set(Number(n[1]),Number(n[2]),Number(n[3])),n=s.exec(e),n!==null&&h.set(Number(n[1]),Number(n[2]),Number(n[3])),f.x>h.x||f.y>h.y||f.z>h.z)throw f.set(0,0,0),h.set(1,1,1),new Error("Invalid input domain");let d=0;for(;(n=a.exec(e))!==null;)u[d++]=Number(n[1]),u[d++]=Number(n[2]),u[d++]=Number(n[3]),u[d++]=1;let p=new Fe(u,l);return p.domainMin.copy(f),p.domainMax.copy(h),c!==null&&(p.name=c),p}};var Sr=m("three");var Ai=class extends Sr.Loader{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 r=this.manager,i=new Sr.LoadingManager;return new Promise((s,a)=>{let n=new Image,c=new Image;i.onError=l=>{r.itemError(l),t!==null?(t(`Failed to load ${l}`),s()):a(`Failed to load ${l}`)},i.onLoad=()=>{let l=[n,c];e(l),s(l)},n.addEventListener("error",l=>{i.itemError("smaa-search")}),c.addEventListener("error",l=>{i.itemError("smaa-area")}),n.addEventListener("load",()=>{r.itemEnd("smaa-search"),i.itemEnd("smaa-search")}),c.addEventListener("load",()=>{r.itemEnd(
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef BILATERAL
#include <packing>
uniform vec2 cameraNearFar;
#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 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
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#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
}`;var Gn=`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);}`;var dr=class extends j.ShaderMaterial{constructor({bilateral:e=!1,kernelSize:t=5}={}){super({name:"BoxBlurMaterial",defines:{DEPTH_PACKING:"0",DISTANCE_THRESHOLD:"0.1"},uniforms:{inputBuffer:new j.Uniform(null),depthBuffer:new j.Uniform(null),normalDepthBuffer:new j.Uniform(null),texelSize:new j.Uniform(new j.Vector2),cameraNearFar:new j.Uniform(new j.Vector2),scale:new j.Uniform(1)},blending:j.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Hn,vertexShader:Gn}),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 new 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?this.defines.NORMAL_DEPTH="1":delete this.defines.NORMAL_DEPTH,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?this.defines.BILATERAL="1":delete this.defines.BILATERAL,this.needsUpdate=!0}get worldDistanceThreshold(){return-be(Number(this.defines.DISTANCE_THRESHOLD),this.near,this.far)}set worldDistanceThreshold(e){let t=ve(-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 j.PerspectiveCamera?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)}};var Be=m("three");var kn=`#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
}`;var zn=`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);}`;var pr=class extends Be.ShaderMaterial{constructor(){super({name:"DepthCopyMaterial",defines:{INPUT_DEPTH_PACKING:"0",OUTPUT_DEPTH_PACKING:"0",DEPTH_COPY_MODE:"0"},uniforms:{depthBuffer:new Be.Uniform(null),texelPosition:new Be.Uniform(new Be.Vector2)},blending:Be.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:kn,vertexShader:zn}),this.depthCopyMode=tt.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=Be.BasicDepthPacking){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}};var G=m("three");var Qn=`#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;
#if THREE_REVISION < 143
#define luminance(v) linearToRelativeLuminance(v)
#endif
#if THREE_REVISION >= 137
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);}
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}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>
}`;var Vn="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);}";var mr=class extends G.ShaderMaterial{constructor(e,t,r,i,s=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:G.REVISION.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new G.Uniform(null),depthBuffer:new G.Uniform(null),resolution:new G.Uniform(new G.Vector2),texelSize:new G.Uniform(new G.Vector2),cameraNear:new G.Uniform(.3),cameraFar:new G.Uniform(1e3),aspect:new G.Uniform(1),time:new G.Uniform(0)},blending:G.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:s}),e&&this.setShaderParts(e),t&&this.setDefines(t),r&&this.setUniforms(r),this.copyCameraSettings(i)}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=G.BasicDepthPacking){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=Qn.replace(C.FRAGMENT_HEAD,e.get(C.FRAGMENT_HEAD)||"").replace(C.FRAGMENT_MAIN_UV,e.get(C.FRAGMENT_MAIN_UV)||"").replace(C.FRAGMENT_MAIN_IMAGE,e.get(C.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=Vn.replace(C.VERTEX_HEAD,e.get(C.VERTEX_HEAD)||"").replace(C.VERTEX_MAIN_SUPPORT,e.get(C.VERTEX_MAIN_SUPPORT)||""),this.fragmentShader=te(this.fragmentShader),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 G.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let r=this.uniforms;r.resolution.value.set(e,t),r.texelSize.value.set(1/e,1/t),r.aspect.value=e/t}static get Section(){return C}};var pe=m("three");var Yn=`#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>
}`;var Wn="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);}";var vr=class extends pe.ShaderMaterial{constructor({kernelSize:e=35}={}){super({name:"GaussianBlurMaterial",uniforms:{inputBuffer:new pe.Uniform(null),texelSize:new pe.Uniform(new pe.Vector2),direction:new pe.Uniform(new pe.Vector2),kernel:new pe.Uniform(null),scale:new pe.Uniform(1)},blending:pe.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Yn,vertexShader:Wn}),this.fragmentShader=te(this.fragmentShader),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 Ot(e),r=t.linearSteps,i=new Float64Array(r*2);for(let s=0,a=0;s<r;++s)i[a++]=t.linearOffsets[s],i[a++]=t.linearWeights[s];this.uniforms.kernel.value=i,this.defines.STEPS=r.toFixed(0),this.needsUpdate=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}};var Me=m("three");var xi=class extends T{constructor({kernelSize:e=5,iterations:t=1,bilateral:r=!1,resolutionScale:i=1,resolutionX:s=x.AUTO_SIZE,resolutionY:a=x.AUTO_SIZE}={}){super("BoxBlurPass"),this.needsDepthTexture=r,this.renderTargetA=new Me.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=new Me.WebGLRenderTarget(1,1,{depthBuffer:!1}),this.renderTargetB.texture.name="Blur.Target.B",this.blurMaterial=new dr({bilateral:r,kernelSize:e}),this.copyMaterial=new Ee;let n=this.resolution=new x(this,s,a,i);n.addEventListener("change",c=>this.setSize(n.baseWidth,n.baseHeight)),this.iterations=t}set mainCamera(e){this.blurMaterial.copyCameraSettings(e)}setDepthTexture(e,t=Me.BasicDepthPacking){this.blurMaterial.depthBuffer=e,this.blurMaterial.depthPacking=t}render(e,t,r,i,s){let a=this.scene,n=this.camera,c=this.renderTargetA,l=this.renderTargetB,u=this.blurMaterial;this.fullscreenMaterial=u;let f=t;for(let h=0,d=Math.max(this.iterations,1);h<d;++h){let p=h&1?l:c;u.inputBuffer=f.texture,e.setRenderTarget(p),e.render(a,n),f=p}this.copyMaterial.inputBuffer=f.texture,this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:r),e.render(a,n)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t);let i=r.width,s=r.height;this.renderTargetA.setSize(i,s),this.renderTargetB.setSize(i,s),this.blurMaterial.setSize(e,t)}initialize(e,t,r){e!==null&&(this.blurMaterial.maxVaryingVectors=e.capabilities.maxVaryings),r!==void 0&&(this.renderTargetA.texture.type=r,this.renderTargetB.texture.type=r,r!==Me.UnsignedByteType?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":e!==null&&e.outputColorSpace===Me.SRGBColorSpace&&(this.renderTargetA.texture.colorSpace=Me.SRGBColorSpace,this.renderTargetB.texture.colorSpace=Me.SRGBColorSpace))}};var gr=m("three");var ue=m("three");var yt=class extends T{constructor({depthPacking:e=ue.RGBADepthPacking}={}){super("DepthCopyPass");let t=new pr;t.outputDepthPacking=e,this.fullscreenMaterial=t,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new ue.WebGLRenderTarget(1,1,{type:e===ue.RGBADepthPacking?ue.UnsignedByteType:ue.FloatType,minFilter:ue.NearestFilter,magFilter:ue.NearestFilter,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=ue.BasicDepthPacking){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.inputDepthPacking=t}render(e,t,r,i,s){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.renderTarget.setSize
`,t.uvTransformation=!0),i!==null&&/mainSupport/.test(i)){let D=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);d+=` ${o}MainSupport(`,d+=D?`vUv);
`:`);
`;for(let w of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(let R of w[1].split(/\s*,\s*/))t.varyings.add(R),p.add(R),g.add(R);for(let w of i.matchAll(n))g.add(w[1])}for(let D of r.matchAll(n))g.add(D[1]);for(let D of e.defines.keys())g.add(D.replace(/\([\w\s,]*\)/g,""));for(let D of e.uniforms.keys())g.add(D);g.delete("while"),g.delete("for"),g.delete("if"),e.uniforms.forEach((D,w)=>t.uniforms.set(o+w.charAt(0).toUpperCase()+w.slice(1),D)),e.defines.forEach((D,w)=>t.defines.set(o+w.charAt(0).toUpperCase()+w.slice(1),D));let E=new Map([["fragment",r],["vertex",i]]);_n(o,g,t.defines),_n(o,g,E),r=E.get("fragment"),i=E.get("vertex");let B=e.blendMode;if(t.blendModes.set(B.blendFunction,B),s){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(f+=e.inputColorSpace===Ye.SRGBColorSpace?`color0 = LinearTosRGB(color0);
`:`color0 = sRGBToLinear(color0);
`),e.outputColorSpace!==Ye.NoColorSpace?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);let D=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;f+=`${o}MainImage(color0, UV, `,t.attributes&P.DEPTH&&D.test(r)&&(f+="depth, ",t.readDepth=!0),f+=`color1);
`;let w=o+"BlendOpacity";t.uniforms.set(w,B.opacity),f+=`color0 = blend${B.blendFunction}(color0, color1, ${w});
`,l+=`uniform float ${w};
`}if(l+=r+`
`,i!==null&&(h+=i+`
`),c.set(C.FRAGMENT_HEAD,l),c.set(C.FRAGMENT_MAIN_UV,u),c.set(C.FRAGMENT_MAIN_IMAGE,f),c.set(C.VERTEX_HEAD,h),c.set(C.VERTEX_MAIN_SUPPORT,d),e.extensions!==null)for(let D of e.extensions)t.extensions.add(D)}}var Ei=class extends T{constructor(e,...t){super("EffectPass"),this.fullscreenMaterial=new mr(null,null,null,e),this.listener=r=>this.handleEvent(r),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,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 t of this.effects)t.removeEventListener("change",this.listener);this.effects=e.sort((t,r)=>r.attributes-t.attributes);for(let t of this.effects)t.addEventListener("change",this.listener)}updateMaterial(){let e=new Ft,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===v.DST)e.attributes|=n.getAttributes()&P.DEPTH;else{if(e.attributes&n.getAttributes()&P.CONVOLUTION)throw new Error(`Convolution effects cannot be merged (${n.name})`);xl("e"+t++,n,e)}let r=e.shaderParts.get(C.FRAGMENT_HEAD),i=e.shaderParts.get(C.FRAGMENT_MAIN_IMAGE),s=e.shaderParts.get(C.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let n of e.blendModes.values())r+=n.getShaderCode().replace(a,`blend${n.blendFunction}`)+`
`;e.attributes&P.DEPTH?(e.readDepth&&(i=`float depth = readDepth(UV);
`+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,e.colorSpace===Ye.SRGBColorSpace&&(i+=`color0 = sRGBToLinear(color0);
`),e.uvTransformation?(s=`vec2 transformedUv = vUv;
`+s,e.defines.set("UV","transformedUv")):e.defines.set("UV","vUv"),e.shaderParts.set(C.FRAGMENT_HEAD,r),e.shaderParts.set(C.FRAGMENT_MAIN_IMAGE,i),e.shaderParts.set(C.FRAGMENT_MAIN_UV,s);for(let[n,c]of e.shaderParts)c!==null&&e.shaderParts.set(n,c.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=Ye.BasicDepthPacking){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let r of this.effects)r.setDepthTexture(e,t)}render(e,t,r,i,s){for(let a of this.effects)a.update(e,t,i);if(!this.skipRendering||this.renderToScreen){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,a.time+=i*this.timeScale,e.setRenderTarget(this.renderToScreen?null:r),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let r of this.effects)r.setSize(e,t)}initialize(e,t,r){this.renderer=e;for(let i of this.effects)i.initialize(e,t,r);this.updateMaterial(),r!==void 0&&r!==Ye.UnsignedByteType&&(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}}};var st=m("three");var wi=class extends T{constructor({kernelSize:e=35,iterations:t=1,resolutionScale:r=1,resolutionX:i=x.AUTO_SIZE,resolutionY:s=x.AUTO_SIZE}={}){super("GaussianBlurPass"),this.renderTargetA=new st.WebGLRenderTarget(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 vr({kernelSize:e}),this.copyMaterial=new Ee,this.copyMaterial.inputBuffer=this.renderTargetB.texture;let a=this.resolution=new x(this,i,s,r);a.addEventListener("change",n=>this.setSize(a.baseWidth,a.baseHeight)),this.iterations=t}render(e,t,r,i,s){let a=this.scene,n=this.camera,c=this.renderTargetA,l=this.renderTargetB,u=this.blurMaterial;this.fullscreenMaterial=u;let f=t;for(let h=0,d=Math.max(this.iterations,1);h<d;++h)u.direction.set(1,0),u.inputBuffer=f.texture,e.setRenderTarget(c),e.render(a,n),u.direction.set(0,1),u.inputBuffer=c.texture,e.setRenderTarget(l),e.render(a,n),h===0&&d>1&&(f=l);this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:r),e.render(a,n)}setSize(e,t){let r=this.resolution;r.setBaseSize(e,t);let i=r.width,s=r.height;this.renderTargetA.setSize(i,s),this.renderTargetB.setSize(i,s),this.blurMaterial.setSize(e,t)}initialize(e,t,r){r!==void 0&&(this.renderTargetA.texture.type=r,this.renderTargetB.texture.type=r,r!==st.UnsignedByteType?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):e!==null&&e.outputColorSpace===st.SRGBColorSpace&&(this.renderTargetA.texture.colorSpace=st.SRGBColorSpace,this.renderTargetB.texture.colorSpace=st.SRGBColorSpace))}};var Ti=class extends T{constructor(e){super("LambdaPass",null,null),this.needsSwap=!1,this.f=e}render(e,t,r,i,s){this.f()}};var We=m("three");var Si=class extends T{constructor(e,t,{renderTarget:r,resolutionScale:i=1,width:s=x.AUTO_SIZE,height:a=x.AUTO_SIZE,resolutionX:n=s,resolutionY:c=a}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new Se(e,t,new We.MeshNormalMaterial);let l=this.renderPass;l.ignoreBackground=!0,l.skipShadowMapUpdate=!0;let u=l.getClearPass();u.overrideClearColor=new We.Color(7829503),u.overrideClearAlpha=1,this.renderTarget=r,this.renderTarget===void 0&&(this.renderTarget=new We.WebGLRenderTarget(1,1,{minFilter:We.NearestFilter,magFilter:We.NearestFilter}),this.renderTarget.texture.name="NormalPass.Target");let f=this.resolution=new x(this,n,c,i);f.addEventListener("change",h=>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,r,i,s){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a,a)}setSize
`;function yl(o=!0){let e=URL.createObjectURL(new Blob([ea],{type:"text/javascript"})),t=new Worker(e);return URL.revokeObjectURL(e),new Promise((r,i)=>{t.addEventListener("error",s=>i(s.error)),t.addEventListener("message",s=>{let a=le.from(s.data.searchImageData),n=le.from(s.data.areaImageData),c=[a.toCanvas().toDataURL("image/png",1),n.toCanvas().toDataURL("image/png",1)];o&&(localStorage.setItem("smaa-search",c[0]),localStorage.setItem("smaa-area",c[1])),r(c)}),t.postMessage(null)})}var Pi=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):yl(e)).then(i=>new Promise((s,a)=>{let n=new Image,c=new Image,l=new ta.LoadingManager;l.onLoad=()=>s([n,c]),l.onError=a,n.addEventListener("error",u=>l.itemError("smaa-search")),c.addEventListener("error",u=>l.itemError("smaa-area")),n.addEventListener("load",()=>l.itemEnd("smaa-search")),c.addEventListener("load",()=>l.itemEnd("smaa-area")),l.itemStart("smaa-search"),l.itemStart("smaa-area"),n.src=i[0],c.src=i[1]}))}};var yr=new Map([[J(0,0,0,0),new Float32Array([0,0,0,0])],[J(0,0,0,1),new Float32Array([0,0,0,1])],[J(0,0,1,0),new Float32Array([0,0,1,0])],[J(0,0,1,1),new Float32Array([0,0,1,1])],[J(0,1,0,0),new Float32Array([0,1,0,0])],[J(0,1,0,1),new Float32Array([0,1,0,1])],[J(0,1,1,0),new Float32Array([0,1,1,0])],[J(0,1,1,1),new Float32Array([0,1,1,1])],[J(1,0,0,0),new Float32Array([1,0,0,0])],[J(1,0,0,1),new Float32Array([1,0,0,1])],[J(1,0,1,0),new Float32Array([1,0,1,0])],[J(1,0,1,1),new Float32Array([1,0,1,1])],[J(1,1,0,0),new Float32Array([1,1,0,0])],[J(1,1,0,1),new Float32Array([1,1,0,1])],[J(1,1,1,0),new Float32Array([1,1,1,0])],[J(1,1,1,1),new Float32Array([1,1,1,1])]]);function Ii(o,e,t){return o+(e-o)*t}function J(o,e,t,r){let i=Ii(o,e,.75),s=Ii(t,r,1-.25);return Ii(i,s,1-.125)}function Pl(o,e){let t=0;return e[3]===1&&(t+=1),t===1&&e[2]===1&&o[1]!==1&&o[3]!==1&&(t+=1),t}function Il(o,e){let t=0;return e[3]===1&&o[1]!==1&&o[3]!==1&&(t+=1),t===1&&e[2]===1&&o[0]!==1&&o[2]!==1&&(t+=1),t}var Ui=class{static generate(){let a=new Uint8ClampedArray(2178),n=new Uint8ClampedArray(64*16*4);for(let c=0;c<33;++c)for(let l=0;l<66;++l){let u=.03125*l,f=.03125*c;if(yr.has(u)&&yr.has(f)){let h=yr.get(u),d=yr.get(f),p=c*66+l;a[p]=127*Pl(h,d),a[p+33]=127*Il(h,d)}}for(let c=0,l=17;l<33;++l)for(let u=0;u<64;++u,c+=4)n[c]=a[l*66+u],n[c+3]=255;return new le(64,16,n)}};return oa(Ul);})();
if(typeof module==="object"&&module.exports)module.exports=POSTPROCESSING;