@needle-tools/engine 4.12.0-next.0b39d59 → 4.12.0-next.c6c0281

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";const r=require("./three-Bf2NBxAw.umd.cjs"),Zt=require("./three-examples-Dho7cuu4.umd.cjs");var jt="6.38.1",Jt=class{dispose(){}},Me=1/1e3,qt=1e3,ot=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<"u"&&document.hidden!==void 0&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=e)}get delta(){return this._delta*Me}get fixedDelta(){return this._fixedDelta*Me}set fixedDelta(e){this._fixedDelta=e*qt}get elapsed(){return this._elapsed*Me}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e!==void 0?e:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},_t=(()=>{const e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),i=new r.BufferGeometry;return i.setAttribute("position",new r.BufferAttribute(e,3)),i.setAttribute("uv",new r.BufferAttribute(t,2)),i})(),P=class Fe{static get fullscreenGeometry(){return _t}constructor(t="Pass",i=new r.Scene,a=new r.OrthographicCamera){this.name=t,this.renderer=null,this.scene=i,this.camera=a,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(t){if(this.rtt===t){const i=this.fullscreenMaterial;i!==null&&(i.needsUpdate=!0),this.rtt=!t}}set mainScene(t){}set mainCamera(t){}setRenderer(t){this.renderer=t}isEnabled(){return this.enabled}setEnabled(t){this.enabled=t}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(t){let i=this.screen;i!==null?i.material=t:(i=new r.Mesh(Fe.fullscreenGeometry,t),i.frustumCulled=!1,this.scene===null&&(this.scene=new r.Scene),this.scene.add(i),this.screen=i)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(t){this.fullscreenMaterial=t}getDepthTexture(){return null}setDepthTexture(t,i=r.BasicDepthPacking){}render(t,i,a,s,o){throw new Error("Render method not implemented!")}setSize(t,i){}initialize(t,i,a){}dispose(){for(const t of Object.keys(this)){const i=this[t];(i instanceof r.WebGLRenderTarget||i instanceof r.Material||i instanceof r.Texture||i instanceof Fe)&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},lt=class extends P{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,i,a,s){const o=e.state.buffers.stencil;o.setLocked(!1),o.setTest(!1)}},$t=`#ifdef COLOR_WRITE
1
+ "use strict";const r=require("./three-Bf2NBxAw.umd.cjs"),Zt=require("./three-examples-Dho7cuu4.umd.cjs");var jt="6.38.2",Jt=class{dispose(){}},Me=1/1e3,qt=1e3,ot=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<"u"&&document.hidden!==void 0&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=e)}get delta(){return this._delta*Me}get fixedDelta(){return this._fixedDelta*Me}set fixedDelta(e){this._fixedDelta=e*qt}get elapsed(){return this._elapsed*Me}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e!==void 0?e:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},_t=(()=>{const e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),i=new r.BufferGeometry;return i.setAttribute("position",new r.BufferAttribute(e,3)),i.setAttribute("uv",new r.BufferAttribute(t,2)),i})(),P=class Fe{static get fullscreenGeometry(){return _t}constructor(t="Pass",i=new r.Scene,a=new r.OrthographicCamera){this.name=t,this.renderer=null,this.scene=i,this.camera=a,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(t){if(this.rtt===t){const i=this.fullscreenMaterial;i!==null&&(i.needsUpdate=!0),this.rtt=!t}}set mainScene(t){}set mainCamera(t){}setRenderer(t){this.renderer=t}isEnabled(){return this.enabled}setEnabled(t){this.enabled=t}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(t){let i=this.screen;i!==null?i.material=t:(i=new r.Mesh(Fe.fullscreenGeometry,t),i.frustumCulled=!1,this.scene===null&&(this.scene=new r.Scene),this.scene.add(i),this.screen=i)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(t){this.fullscreenMaterial=t}getDepthTexture(){return null}setDepthTexture(t,i=r.BasicDepthPacking){}render(t,i,a,s,o){throw new Error("Render method not implemented!")}setSize(t,i){}initialize(t,i,a){}dispose(){for(const t of Object.keys(this)){const i=this[t];(i instanceof r.WebGLRenderTarget||i instanceof r.Material||i instanceof r.Texture||i instanceof Fe)&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},lt=class extends P{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,i,a,s){const o=e.state.buffers.stencil;o.setLocked(!1),o.setTest(!1)}},$t=`#ifdef COLOR_WRITE
2
2
  #include <common>
3
3
  #include <dithering_pars_fragment>
4
4
  #ifdef FRAMEBUFFER_PRECISION_HIGH
@@ -261,7 +261,7 @@ uniform mediump sampler2D lut;
261
261
  #else
262
262
  uniform lowp sampler2D lut;
263
263
  #endif
264
- 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);}`,Fi=class extends C{constructor(e,{blendFunction:t=v.SRC}={}){super("LUT1DEffect",bi,{blendFunction:t,uniforms:new Map([["lut",new r.Uniform$1(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===r.FloatType||e.type===r.HalfFloatType)&&this.defines.set("LUT_PRECISION_HIGH","1")}},wt={SCALE_UP:"lut.scaleup"};function je(e,t,i){const a=document.createElement("canvas"),s=a.getContext("2d");if(a.width=e,a.height=t,i instanceof Image)s.drawImage(i,0,0);else{const o=s.createImageData(e,t);o.data.set(i),s.putImageData(o,0,0)}return a}var Y=class St{constructor(t=0,i=0,a=null){this.width=t,this.height=i,this.data=a}toCanvas(){return typeof document>"u"?null:je(this.width,this.height,this.data)}static from(t){const{width:i,height:a}=t;let s;if(t instanceof Image){const o=je(i,a,t);o!==null&&(s=o.getContext("2d").getImageData(0,0,i,a).data)}else s=t.data;return new St(i,a,s)}},Li=`"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()});})();
264
+ 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);}`,Fi=class extends C{constructor(e,{blendFunction:t=v.SRC}={}){super("LUT1DEffect",bi,{blendFunction:t,uniforms:new Map([["lut",new r.Uniform$1(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===r.FloatType||e.type===r.HalfFloatType)&&this.defines.set("LUT_PRECISION_HIGH","1")}},wt={SCALE_UP:"lut.scaleup"};function je(e,t,i){const a=document.createElement("canvas"),s=a.getContext("2d");if(a.width=e,a.height=t,i instanceof Image)s.drawImage(i,0,0);else{const o=s.createImageData(e,t);o.data.set(i),s.putImageData(o,0,0)}return a}var Y=class St{constructor(t=0,i=0,a=null){this.width=t,this.height=i,this.data=a}toCanvas(){return typeof document>"u"?null:je(this.width,this.height,this.data)}static from(t){const{width:i,height:a}=t;let s;if(t instanceof Image){const o=je(i,a,t);o!==null&&(s=o.getContext("2d").getImageData(0,0,i,a).data)}else s=t.data;return new St(i,a,s)}},Li=`"use strict";(()=>{var O={SCALE_UP:"lut.scaleup"};var _=[new Float32Array(3),new Float32Array(3)],n=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],Z=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];function d(a,t,r,m){let i=r[0]-t[0],e=r[1]-t[1],y=r[2]-t[2],h=a[0]-t[0],A=a[1]-t[1],w=a[2]-t[2],c=e*w-y*A,l=y*h-i*w,x=i*A-e*h,u=Math.sqrt(c*c+l*l+x*x),b=u*.5,s=c/u,F=l/u,f=x/u,p=-(a[0]*s+a[1]*F+a[2]*f),M=m[0]*s+m[1]*F+m[2]*f;return Math.abs(M+p)*b/3}function V(a,t,r,m,i,e){let y=(r+m*t+i*t*t)*4;e[0]=a[y+0],e[1]=a[y+1],e[2]=a[y+2]}function k(a,t,r,m,i,e){let y=r*(t-1),h=m*(t-1),A=i*(t-1),w=Math.floor(y),c=Math.floor(h),l=Math.floor(A),x=Math.ceil(y),u=Math.ceil(h),b=Math.ceil(A),s=y-w,F=h-c,f=A-l;if(w===y&&c===h&&l===A)V(a,t,y,h,A,e);else{let p;s>=F&&F>=f?p=Z[0]:s>=f&&f>=F?p=Z[1]:f>=s&&s>=F?p=Z[2]:F>=s&&s>=f?p=Z[3]:F>=f&&f>=s?p=Z[4]:f>=F&&F>=s&&(p=Z[5]);let[M,g,X,Y]=p,P=_[0];P[0]=s,P[1]=F,P[2]=f;let o=_[1],L=x-w,S=u-c,U=b-l;o[0]=L*M[0]+w,o[1]=S*M[1]+c,o[2]=U*M[2]+l,V(a,t,o[0],o[1],o[2],n[0]),o[0]=L*g[0]+w,o[1]=S*g[1]+c,o[2]=U*g[2]+l,V(a,t,o[0],o[1],o[2],n[1]),o[0]=L*X[0]+w,o[1]=S*X[1]+c,o[2]=U*X[2]+l,V(a,t,o[0],o[1],o[2],n[2]),o[0]=L*Y[0]+w,o[1]=S*Y[1]+c,o[2]=U*Y[2]+l,V(a,t,o[0],o[1],o[2],n[3]);let T=d(g,X,Y,P)*6,q=d(M,X,Y,P)*6,C=d(M,g,Y,P)*6,E=d(M,g,X,P)*6;n[0][0]*=T,n[0][1]*=T,n[0][2]*=T,n[1][0]*=q,n[1][1]*=q,n[1][2]*=q,n[2][0]*=C,n[2][1]*=C,n[2][2]*=C,n[3][0]*=E,n[3][1]*=E,n[3][2]*=E,e[0]=n[0][0]+n[1][0]+n[2][0]+n[3][0],e[1]=n[0][1]+n[1][1]+n[2][1]+n[3][1],e[2]=n[0][2]+n[1][2]+n[2][2]+n[3][2]}}var v=class{static expand(t,r){let m=Math.cbrt(t.length/4),i=new Float32Array(3),e=new t.constructor(r**3*4),y=t instanceof Uint8Array?255:1,h=r**2,A=1/(r-1);for(let w=0;w<r;++w)for(let c=0;c<r;++c)for(let l=0;l<r;++l){let x=l*A,u=c*A,b=w*A,s=Math.round(l+c*r+w*h)*4;k(t,m,x,u,b,i),e[s+0]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=y}return e}};self.addEventListener("message",a=>{let t=a.data,r=t.data;t.operation===O.SCALE_UP&&(r=v.expand(r,t.size)),postMessage(r,[r.buffer]),close()});})();
265
265
  `,Je=new r.Color,ve=class Se extends r.Data3DTexture{constructor(t,i){super(t,i,i,i),this.type=r.FloatType,this.format=r.RGBAFormat,this.minFilter=r.LinearFilter,this.magFilter=r.LinearFilter,this.wrapS=r.ClampToEdgeWrapping,this.wrapT=r.ClampToEdgeWrapping,this.wrapR=r.ClampToEdgeWrapping,this.unpackAlignment=1,this.needsUpdate=!0,this.colorSpace=r.LinearSRGBColorSpace,this.domainMin=new r.Vector3(0,0,0),this.domainMax=new r.Vector3(1,1,1)}get isLookupTexture3D(){return!0}scaleUp(t,i=!0){const a=this.image;let s;return t<=a.width?s=Promise.reject(new Error("The target size must be greater than the current size")):s=new Promise((o,n)=>{const l=URL.createObjectURL(new Blob([Li],{type:"text/javascript"})),c=new Worker(l);c.addEventListener("error",f=>n(f.error)),c.addEventListener("message",f=>{const h=new Se(f.data,t);this.colorSpace=h.colorSpace,h.type=this.type,h.name=this.name,URL.revokeObjectURL(l),o(h)});const u=i?[a.data.buffer]:[];c.postMessage({operation:wt.SCALE_UP,data:a.data,size:t},u)}),s}applyLUT(t){const i=this.image,a=t.image,s=Math.min(i.width,i.height,i.depth),o=Math.min(a.width,a.height,a.depth);if(s!==o)console.error("Size mismatch");else if(t.type!==r.FloatType||this.type!==r.FloatType)console.error("Both LUTs must be FloatType textures");else if(t.format!==r.RGBAFormat||this.format!==r.RGBAFormat)console.error("Both LUTs must be RGBA textures");else{const n=i.data,l=a.data,c=s,u=c**2,f=c-1;for(let h=0,d=c**3;h<d;++h){const p=h*4,g=n[p+0]*f,m=n[p+1]*f,A=n[p+2]*f,S=Math.round(g+m*c+A*u)*4;n[p+0]=l[S+0],n[p+1]=l[S+1],n[p+2]=l[S+2]}this.needsUpdate=!0}return this}convertToUint8(){if(this.type===r.FloatType){const t=this.image.data,i=new Uint8Array(t.length);for(let a=0,s=t.length;a<s;++a)i[a]=t[a]*255+.5;this.image.data=i,this.type=r.UnsignedByteType,this.needsUpdate=!0}return this}convertToFloat(){if(this.type===r.UnsignedByteType){const t=this.image.data,i=new Float32Array(t.length);for(let a=0,s=t.length;a<s;++a)i[a]=t[a]/255;this.image.data=i,this.type=r.FloatType,this.needsUpdate=!0}return this}convertToRGBA(){return console.warn("LookupTexture","convertToRGBA() is deprecated, LUTs are now RGBA by default"),this}convertLinearToSRGB(){const t=this.image.data;if(this.type===r.FloatType){for(let i=0,a=t.length;i<a;i+=4)Je.fromArray(t,i).convertLinearToSRGB().toArray(t,i);this.colorSpace=r.SRGBColorSpace,this.needsUpdate=!0}else console.error("Color space conversion requires FloatType data");return this}convertSRGBToLinear(){const t=this.image.data;if(this.type===r.FloatType){for(let i=0,a=t.length;i<a;i+=4)Je.fromArray(t,i).convertSRGBToLinear().toArray(t,i);this.colorSpace=r.LinearSRGBColorSpace,this.needsUpdate=!0}else console.error("Color space conversion requires FloatType data");return this}toDataTexture(){const t=this.image.width,i=this.image.height*this.image.depth,a=new r.DataTexture(this.image.data,t,i);return a.name=this.name,a.type=this.type,a.format=this.format,a.minFilter=r.LinearFilter,a.magFilter=r.LinearFilter,a.wrapS=this.wrapS,a.wrapT=this.wrapT,a.generateMipmaps=!1,a.needsUpdate=!0,this.colorSpace=a.colorSpace,a}static from(t){const i=t.image,{width:a,height:s}=i,o=Math.min(a,s);let n;if(i instanceof Image){const u=Y.from(i).data;if(a>s){n=new Uint8Array(u.length);for(let f=0;f<o;++f)for(let h=0;h<o;++h)for(let d=0;d<o;++d){const p=(d+f*o+h*o*o)*4,g=(d+h*o+f*o*o)*4;n[g+0]=u[p+0],n[g+1]=u[p+1],n[g+2]=u[p+2],n[g+3]=u[p+3]}}else n=new Uint8Array(u.buffer)}else n=i.data.slice();const l=new Se(n,o);return l.type=t.type,l.name=t.name,t.colorSpace=l.colorSpace,l}static createNeutral(t){const i=new Float32Array(t**3*4),a=t**2,s=1/(t-1);for(let n=0;n<t;++n)for(let l=0;l<t;++l)for(let c=0;c<t;++c){const u=(n+l*t+c*a)*4;i[u+0]=n*s,i[u+1]=l*s,i[u+2]=c*s,i[u+3]=1}const o=new Se(i,t);return o.name="neutral",o}},Oi=`uniform vec3 scale;uniform vec3 offset;
266
266
  #ifdef CUSTOM_INPUT_DOMAIN
267
267
  uniform vec3 domainMin;uniform vec3 domainMax;
@@ -918,7 +918,7 @@ return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
918
918
  #include <colorspace_fragment>
919
919
  #endif
920
920
  #include <dithering_fragment>
921
- }`,ka="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);}",Nt=class extends r.ShaderMaterial{constructor(e,t,i,a,s=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:r.REVISION.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new r.Uniform$1(null),depthBuffer:new r.Uniform$1(null),resolution:new r.Uniform$1(new r.Vector2),texelSize:new r.Uniform$1(new r.Vector2),cameraNear:new r.Uniform$1(.3),cameraFar:new r.Uniform$1(1e3),aspect:new r.Uniform$1(1),time:new r.Uniform$1(0)},blending:r.NormalBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:s}),e&&this.setShaderParts(e),t&&this.setDefines(t),i&&this.setUniforms(i),this.copyCameraSettings(a)}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=r.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=za.replace(E.FRAGMENT_HEAD,e.get(E.FRAGMENT_HEAD)||"").replace(E.FRAGMENT_MAIN_UV,e.get(E.FRAGMENT_MAIN_UV)||"").replace(E.FRAGMENT_MAIN_IMAGE,e.get(E.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=ka.replace(E.VERTEX_HEAD,e.get(E.VERTEX_HEAD)||"").replace(E.VERTEX_MAIN_SUPPORT,e.get(E.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(e){for(const t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(const t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(const 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 r.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){const i=this.uniforms;i.resolution.value.set(e,t),i.texelSize.value.set(1/e,1/t),i.aspect.value=e/t}static get Section(){return E}},Qa=`#ifdef FRAMEBUFFER_PRECISION_HIGH
921
+ }`,ka="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);}",Nt=class extends r.ShaderMaterial{constructor(e,t,i,a,s=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:r.REVISION.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new r.Uniform$1(null),depthBuffer:new r.Uniform$1(null),resolution:new r.Uniform$1(new r.Vector2),texelSize:new r.Uniform$1(new r.Vector2),cameraNear:new r.Uniform$1(.3),cameraFar:new r.Uniform$1(1e3),aspect:new r.Uniform$1(1),time:new r.Uniform$1(0)},blending:r.NoBlending,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:s}),e&&this.setShaderParts(e),t&&this.setDefines(t),i&&this.setUniforms(i),this.copyCameraSettings(a)}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=r.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=za.replace(E.FRAGMENT_HEAD,e.get(E.FRAGMENT_HEAD)||"").replace(E.FRAGMENT_MAIN_UV,e.get(E.FRAGMENT_MAIN_UV)||"").replace(E.FRAGMENT_MAIN_IMAGE,e.get(E.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=ka.replace(E.VERTEX_HEAD,e.get(E.VERTEX_HEAD)||"").replace(E.VERTEX_MAIN_SUPPORT,e.get(E.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(e){for(const t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(const t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(const 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 r.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){const i=this.uniforms;i.resolution.value.set(e,t),i.texelSize.value.set(1/e,1/t),i.aspect.value=e/t}static get Section(){return E}},Qa=`#ifdef FRAMEBUFFER_PRECISION_HIGH
922
922
  uniform mediump sampler2D inputBuffer;
923
923
  #else
924
924
  uniform lowp sampler2D inputBuffer;
@@ -937,13 +937,13 @@ uniform vec2 kernel[STEPS];varying vec2 vOffset;varying vec2 vUv;void main(){vec
937
937
 
938
938
  `}if(u+=a+`
939
939
  `,s!==null&&(d+=s+`
940
- `),c.set(E.FRAGMENT_HEAD,u),c.set(E.FRAGMENT_MAIN_UV,f),c.set(E.FRAGMENT_MAIN_IMAGE,h),c.set(E.VERTEX_HEAD,d),c.set(E.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(const T of t.extensions)i.extensions.add(T)}}var qa=class extends P{constructor(e,...t){super("EffectPass"),this.fullscreenMaterial=new Nt(null,null,null,e),this.listener=i=>this.handleEvent(i),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(e){for(const t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(const 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){const t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}get alpha(){return this.renderer!==null&&this.renderer.getContext().getContextAttributes().alpha}setEffects(e){for(const t of this.effects)t.removeEventListener("change",this.listener);this.effects=e.sort((t,i)=>i.attributes-t.attributes);for(const t of this.effects)t.addEventListener("change",this.listener)}updateMaterial(){const e=new ut;let t=0;for(const n of this.effects)if(n.blendMode.blendFunction===v.DST)e.attributes|=n.getAttributes()&U.DEPTH;else{if((e.attributes&n.getAttributes()&U.CONVOLUTION)!==0)throw new Error(`Convolution effects cannot be merged (${n.name})`);Ja("e"+t++,n,e)}let i=e.shaderParts.get(E.FRAGMENT_HEAD),a=e.shaderParts.get(E.FRAGMENT_MAIN_IMAGE),s=e.shaderParts.get(E.FRAGMENT_MAIN_UV);const o=/\bblend\b/g;for(const n of e.blendModes.values())i+=n.getShaderCode().replace(o,`blend${n.blendFunction}`)+`
940
+ `),c.set(E.FRAGMENT_HEAD,u),c.set(E.FRAGMENT_MAIN_UV,f),c.set(E.FRAGMENT_MAIN_IMAGE,h),c.set(E.VERTEX_HEAD,d),c.set(E.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(const T of t.extensions)i.extensions.add(T)}}var qa=class extends P{constructor(e,...t){super("EffectPass"),this.fullscreenMaterial=new Nt(null,null,null,e),this.listener=i=>this.handleEvent(i),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(e){for(const t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(const 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){const t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(const t of this.effects)t.removeEventListener("change",this.listener);this.effects=e.sort((t,i)=>i.attributes-t.attributes);for(const t of this.effects)t.addEventListener("change",this.listener)}updateMaterial(){const e=new ut;let t=0;for(const n of this.effects)if(n.blendMode.blendFunction===v.DST)e.attributes|=n.getAttributes()&U.DEPTH;else{if((e.attributes&n.getAttributes()&U.CONVOLUTION)!==0)throw new Error(`Convolution effects cannot be merged (${n.name})`);Ja("e"+t++,n,e)}let i=e.shaderParts.get(E.FRAGMENT_HEAD),a=e.shaderParts.get(E.FRAGMENT_MAIN_IMAGE),s=e.shaderParts.get(E.FRAGMENT_MAIN_UV);const o=/\bblend\b/g;for(const n of e.blendModes.values())i+=n.getShaderCode().replace(o,`blend${n.blendFunction}`)+`
941
941
  `;(e.attributes&U.DEPTH)!==0?(e.readDepth&&(a=`float depth = readDepth(UV);
942
942
 
943
943
  `+a),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,e.colorSpace===r.SRGBColorSpace&&(a+=`color0 = sRGBToLinear(color0);
944
944
  `),e.uvTransformation?(s=`vec2 transformedUv = vUv;
945
945
  `+s,e.defines.set("UV","transformedUv")):e.defines.set("UV","vUv"),e.shaderParts.set(E.FRAGMENT_HEAD,i),e.shaderParts.set(E.FRAGMENT_MAIN_IMAGE,a),e.shaderParts.set(E.FRAGMENT_MAIN_UV,s);for(const[n,l]of e.shaderParts)l!==null&&e.shaderParts.set(n,l.trim().replace(/^#/,`
946
- #`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=r.BasicDepthPacking){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(const i of this.effects)i.setDepthTexture(e,t)}render(e,t,i,a,s){for(const o of this.effects)o.update(e,t,a);if(!this.skipRendering||this.renderToScreen){const o=this.fullscreenMaterial;o.transparent=this.renderToScreen&&this.alpha,o.inputBuffer=t.texture,o.time+=a*this.timeScale,e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(const i of this.effects)i.setSize(e,t)}initialize(e,t,i){this.renderer=e;for(const a of this.effects)a.initialize(e,t,i);this.updateMaterial(),i!==void 0&&i!==r.UnsignedByteType&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const e of this.effects)e.removeEventListener("change",this.listener),e.dispose()}handleEvent(e){e.type==="change"&&this.recompile()}},_a=class extends P{constructor({kernelSize:e=35,iterations:t=1,resolutionScale:i=1,resolutionX:a=x.AUTO_SIZE,resolutionY:s=x.AUTO_SIZE}={}){super("GaussianBlurPass"),this.renderTargetA=new r.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 Ht({kernelSize:e}),this.copyMaterial=new me,this.copyMaterial.inputBuffer=this.renderTargetB.texture;const o=this.resolution=new x(this,a,s,i);o.addEventListener("change",n=>this.setSize(o.baseWidth,o.baseHeight)),this.iterations=t}render(e,t,i,a,s){const o=this.scene,n=this.camera,l=this.renderTargetA,c=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(l),e.render(o,n),u.direction.set(0,1),u.inputBuffer=l.texture,e.setRenderTarget(c),e.render(o,n),h===0&&d>1&&(f=c);this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:i),e.render(o,n)}setSize(e,t){const i=this.resolution;i.setBaseSize(e,t);const a=i.width,s=i.height;this.renderTargetA.setSize(a,s),this.renderTargetB.setSize(a,s),this.blurMaterial.setSize(e,t)}initialize(e,t,i){i!==void 0&&(this.renderTargetA.texture.type=i,this.renderTargetB.texture.type=i,i!==r.UnsignedByteType?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):e!==null&&e.outputColorSpace===r.SRGBColorSpace&&(this.renderTargetA.texture.colorSpace=r.SRGBColorSpace,this.renderTargetB.texture.colorSpace=r.SRGBColorSpace))}},$a=class extends P{constructor(e){super("LambdaPass",null,null),this.needsSwap=!1,this.f=e}render(e,t,i,a,s){this.f()}},es=class extends P{constructor(e,t,{renderTarget:i,resolutionScale:a=1,width:s=x.AUTO_SIZE,height:o=x.AUTO_SIZE,resolutionX:n=s,resolutionY:l=o}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new ge(e,t,new r.MeshNormalMaterial);const c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;const u=c.getClearPass();u.overrideClearColor=new r.Color(7829503),u.overrideClearAlpha=1,this.renderTarget=i,this.renderTarget===void 0&&(this.renderTarget=new r.WebGLRenderTarget(1,1,{minFilter:r.NearestFilter,magFilter:r.NearestFilter}),this.renderTarget.texture.name="NormalPass.Target");const f=this.resolution=new x(this,n,l,a);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,i,a,s){const o=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,o,o)}setSize(e,t){const i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}},tt=[new Float32Array(3),new Float32Array(3)],M=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],$=[[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 De(e,t,i,a){const s=i[0]-t[0],o=i[1]-t[1],n=i[2]-t[2],l=e[0]-t[0],c=e[1]-t[1],u=e[2]-t[2],f=o*u-n*c,h=n*l-s*u,d=s*c-o*l,p=Math.sqrt(f*f+h*h+d*d),g=p*.5,m=f/p,A=h/p,S=d/p,T=-(e[0]*m+e[1]*A+e[2]*S),D=a[0]*m+a[1]*A+a[2]*S;return Math.abs(D+T)*g/3}function ue(e,t,i,a,s,o){const n=(i+a*t+s*t*t)*4;o[0]=e[n+0],o[1]=e[n+1],o[2]=e[n+2]}function ts(e,t,i,a,s,o){const n=i*(t-1),l=a*(t-1),c=s*(t-1),u=Math.floor(n),f=Math.floor(l),h=Math.floor(c),d=Math.ceil(n),p=Math.ceil(l),g=Math.ceil(c),m=n-u,A=l-f,S=c-h;if(u===n&&f===l&&h===c)ue(e,t,n,l,c,o);else{let T;m>=A&&A>=S?T=$[0]:m>=S&&S>=A?T=$[1]:S>=m&&m>=A?T=$[2]:A>=m&&m>=S?T=$[3]:A>=S&&S>=m?T=$[4]:S>=A&&A>=m&&(T=$[5]);const[D,b,G,k]=T,Q=tt[0];Q[0]=m,Q[1]=A,Q[2]=S;const y=tt[1],q=d-u,_=p-f,V=g-h;y[0]=q*D[0]+u,y[1]=_*D[1]+f,y[2]=V*D[2]+h,ue(e,t,y[0],y[1],y[2],M[0]),y[0]=q*b[0]+u,y[1]=_*b[1]+f,y[2]=V*b[2]+h,ue(e,t,y[0],y[1],y[2],M[1]),y[0]=q*G[0]+u,y[1]=_*G[1]+f,y[2]=V*G[2]+h,ue(e,t,y[0],y[1],y[2],M[2]),y[0]=q*k[0]+u,y[1]=_*k[1]+f,y[2]=V*k[2]+h,ue(e,t,y[0],y[1],y[2],M[3]);const X=De(b,G,k,Q)*6,R=De(D,G,k,Q)*6,Ae=De(D,b,k,Q)*6,Be=De(D,b,G,Q)*6;M[0][0]*=X,M[0][1]*=X,M[0][2]*=X,M[1][0]*=R,M[1][1]*=R,M[1][2]*=R,M[2][0]*=Ae,M[2][1]*=Ae,M[2][2]*=Ae,M[3][0]*=Be,M[3][1]*=Be,M[3][2]*=Be,o[0]=M[0][0]+M[1][0]+M[2][0]+M[3][0],o[1]=M[0][1]+M[1][1]+M[2][1]+M[3][1],o[2]=M[0][2]+M[1][2]+M[2][2]+M[3][2]}}var rs=class{static expand(e,t){const i=Math.cbrt(e.length/4),a=new Float32Array(3),s=new e.constructor(t**3*4),o=e instanceof Uint8Array?255:1,n=t**2,l=1/(t-1);for(let c=0;c<t;++c)for(let u=0;u<t;++u)for(let f=0;f<t;++f){const h=f*l,d=u*l,p=c*l,g=Math.round(f+u*t+c*n)*4;ts(e,i,h,d,p,a),s[g+0]=a[0],s[g+1]=a[1],s[g+2]=a[2],s[g+3]=o}return s}},oe=[new Float32Array(2),new Float32Array(2)],ee=16,Re=20,te=30,is=32,Ie=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),rt=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],as=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Gt=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function Te(e,t,i){return e+(t-e)*i}function ss(e){return Math.min(Math.max(e,0),1)}function it(e){const t=oe[0],i=oe[1],a=Math.sqrt(t[0]*2)*.5,s=Math.sqrt(t[1]*2)*.5,o=Math.sqrt(i[0]*2)*.5,n=Math.sqrt(i[1]*2)*.5,l=ss(e/is);t[0]=Te(a,t[0],l),t[1]=Te(s,t[1],l),i[0]=Te(o,i[0],l),i[1]=Te(n,i[1],l)}function I(e,t,i,a,s,o){const n=i-e,l=a-t,c=s,u=s+1,f=t+l*(c-e)/n,h=t+l*(u-e)/n;if(c>=e&&c<i||u>e&&u<=i)if(Math.sign(f)===Math.sign(h)||Math.abs(f)<1e-4||Math.abs(h)<1e-4){const d=(f+h)/2;d<0?(o[0]=Math.abs(d),o[1]=0):(o[0]=0,o[1]=Math.abs(d))}else{const d=-t*n/l+e,p=Math.trunc(d),g=d>e?f*(d-p)/2:0,m=d<i?h*(1-(d-p))/2:0;(Math.abs(g)>Math.abs(m)?g:-m)<0?(o[0]=Math.abs(g),o[1]=Math.abs(m)):(o[0]=Math.abs(m),o[1]=Math.abs(g))}else o[0]=0,o[1]=0;return o}function ns(e,t,i,a,s){const o=oe[0],n=oe[1],l=.5+a,c=.5+a-1,u=t+i+1;switch(e){case 0:{s[0]=0,s[1]=0;break}case 1:{t<=i?I(0,c,u/2,0,t,s):(s[0]=0,s[1]=0);break}case 2:{t>=i?I(u/2,0,u,c,t,s):(s[0]=0,s[1]=0);break}case 3:{I(0,c,u/2,0,t,o),I(u/2,0,u,c,t,n),it(u),s[0]=o[0]+n[0],s[1]=o[1]+n[1];break}case 4:{t<=i?I(0,l,u/2,0,t,s):(s[0]=0,s[1]=0);break}case 5:{s[0]=0,s[1]=0;break}case 6:{Math.abs(a)>0?(I(0,l,u,c,t,o),I(0,l,u/2,0,t,n),I(u/2,0,u,c,t,s),n[0]=n[0]+s[0],n[1]=n[1]+s[1],s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2):I(0,l,u,c,t,s);break}case 7:{I(0,l,u,c,t,s);break}case 8:{t>=i?I(u/2,0,u,l,t,s):(s[0]=0,s[1]=0);break}case 9:{Math.abs(a)>0?(I(0,c,u,l,t,o),I(0,c,u/2,0,t,n),I(u/2,0,u,l,t,s),n[0]=n[0]+s[0],n[1]=n[1]+s[1],s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2):I(0,c,u,l,t,s);break}case 10:{s[0]=0,s[1]=0;break}case 11:{I(0,c,u,l,t,s);break}case 12:{I(0,l,u/2,0,t,o),I(u/2,0,u,l,t,n),it(u),s[0]=o[0]+n[0],s[1]=o[1]+n[1];break}case 13:{I(0,c,u,l,t,s);break}case 14:{I(0,l,u,c,t,s);break}case 15:{s[0]=0,s[1]=0;break}}return s}function os(e,t,i,a,s,o){let n=e===i&&t===a;if(!n){const l=(e+i)/2,c=(t+a)/2,u=a-t,f=e-i;n=u*(s-l)+f*(o-c)>0}return n}function at(e,t,i,a,s,o){let n=0;for(let l=0;l<te;++l)for(let c=0;c<te;++c){const u=c/(te-1),f=l/(te-1);os(e,t,i,a,s+u,o+f)&&++n}return n/(te*te)}function B(e,t,i,a,s,o,n,l){const c=Gt[e],u=c[0],f=c[1];return u>0&&(t+=n[0],i+=n[1]),f>0&&(a+=n[0],s+=n[1]),l[0]=1-at(t,i,a,s,1+o,0+o),l[1]=at(t,i,a,s,1+o,1+o),l}function ls(e,t,i,a,s){const o=oe[0],n=oe[1],l=t+i+1;switch(e){case 0:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 1:{B(e,1,0,0+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 2:{B(e,0,0,1+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 3:{B(e,1,0,1+l,0+l,t,a,s);break}case 4:{B(e,1,1,0+l,0+l,t,a,o),B(e,1,1,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 5:{B(e,1,1,0+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 6:{B(e,1,1,1+l,0+l,t,a,s);break}case 7:{B(e,1,1,1+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 8:{B(e,0,0,1+l,1+l,t,a,o),B(e,1,0,1+l,1+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 9:{B(e,1,0,1+l,1+l,t,a,s),B(e,1,0,1+l,1+l,t,a,s);break}case 10:{B(e,0,0,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 11:{B(e,1,0,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 12:{B(e,1,1,1+l,1+l,t,a,s);break}case 13:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,1+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 14:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,1,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 15:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}}return s}function st(e,t,i){const a=new Float32Array(2);for(let s=0,o=e.length;s<o;++s){const n=e[s],l=n.data,c=n.width;for(let u=0;u<c;++u)for(let f=0;f<c;++f){i?ns(s,f,u,t,a):ls(s,f,u,t,a);const h=(u*c+f)*2;l[h]=a[0]*255,l[h+1]=a[1]*255}}}function nt(e,t,i,a,s,o,n){const l=n.data,c=n.width;for(let u=0,f=i.length;u<f;++u){const h=a[u],d=i[u],p=d.data,g=d.width;for(let m=0;m<s;++m)for(let A=0;A<s;++A){const S=h[0]*s+e+A,D=((h[1]*s+t+m)*c+S)*4,b=o?(m*m*g+A*A)*2:(m*g+A)*2;l[D]=p[b],l[D+1]=p[b+1],l[D+2]=0,l[D+3]=255}}}var cs=class{static generate(){const e=10*ee,t=Ie.length*5*ee,i=new Uint8ClampedArray(e*t*4),a=new Y(e,t,i),s=Math.pow(ee-1,2)+1,o=Re,n=[],l=[];for(let c=3,u=i.length;c<u;c+=4)i[c]=255;for(let c=0;c<16;++c)n.push(new Y(s,s,new Uint8ClampedArray(s*s*2),2)),l.push(new Y(o,o,new Uint8ClampedArray(o*o*2),2));for(let c=0,u=Ie.length;c<u;++c)st(n,Ie[c],!0),nt(0,5*ee*c,n,as,ee,!0,a);for(let c=0,u=rt.length;c<u;++c)st(l,rt[c],!1),nt(5*ee,4*Re*c,l,Gt,Re,!1,a);return a}},us=`"use strict";(()=>{function q(t,a,s){let e=document.createElement("canvas"),n=e.getContext("2d");if(e.width=t,e.height=a,s instanceof Image)n.drawImage(s,0,0);else{let r=n.createImageData(t,a);r.data.set(s),n.putImageData(r,0,0)}return e}var F=class t{constructor(a=0,s=0,e=null){this.width=a,this.height=s,this.data=e}toCanvas(){return typeof document=="undefined"?null:q(this.width,this.height,this.data)}static from(a){let{width:s,height:e}=a,n;if(a instanceof Image){let r=q(s,e,a);r!==null&&(n=r.getContext("2d").getImageData(0,0,s,e).data)}else n=a.data;return new t(s,e,n)}};var M=[new Float32Array(2),new Float32Array(2)],D=16,W=20,I=30,j=32,v=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),N=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],z=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],p=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function C(t,a,s){return t+(a-t)*s}function B(t){return Math.min(Math.max(t,0),1)}function _(t){let a=M[0],s=M[1],e=Math.sqrt(a[0]*2)*.5,n=Math.sqrt(a[1]*2)*.5,r=Math.sqrt(s[0]*2)*.5,o=Math.sqrt(s[1]*2)*.5,c=B(t/j);a[0]=C(e,a[0],c),a[1]=C(n,a[1],c),s[0]=C(r,s[0],c),s[1]=C(o,s[1],c)}function d(t,a,s,e,n,r){let o=s-t,c=e-a,h=n,i=n+1,w=a+c*(h-t)/o,b=a+c*(i-t)/o;if(h>=t&&h<s||i>t&&i<=s)if(Math.sign(w)===Math.sign(b)||Math.abs(w)<1e-4||Math.abs(b)<1e-4){let g=(w+b)/2;g<0?(r[0]=Math.abs(g),r[1]=0):(r[0]=0,r[1]=Math.abs(g))}else{let g=-a*o/c+t,k=Math.trunc(g),m=g>t?w*(g-k)/2:0,U=g<s?b*(1-(g-k))/2:0;(Math.abs(m)>Math.abs(U)?m:-U)<0?(r[0]=Math.abs(m),r[1]=Math.abs(U)):(r[0]=Math.abs(U),r[1]=Math.abs(m))}else r[0]=0,r[1]=0;return r}function J(t,a,s,e,n){let r=M[0],o=M[1],c=.5+e,h=.5+e-1,i=a+s+1;switch(t){case 0:{n[0]=0,n[1]=0;break}case 1:{a<=s?d(0,h,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 2:{a>=s?d(i/2,0,i,h,a,n):(n[0]=0,n[1]=0);break}case 3:{d(0,h,i/2,0,a,r),d(i/2,0,i,h,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 4:{a<=s?d(0,c,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 5:{n[0]=0,n[1]=0;break}case 6:{Math.abs(e)>0?(d(0,c,i,h,a,r),d(0,c,i/2,0,a,o),d(i/2,0,i,h,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,c,i,h,a,n);break}case 7:{d(0,c,i,h,a,n);break}case 8:{a>=s?d(i/2,0,i,c,a,n):(n[0]=0,n[1]=0);break}case 9:{Math.abs(e)>0?(d(0,h,i,c,a,r),d(0,h,i/2,0,a,o),d(i/2,0,i,c,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,h,i,c,a,n);break}case 10:{n[0]=0,n[1]=0;break}case 11:{d(0,h,i,c,a,n);break}case 12:{d(0,c,i/2,0,a,r),d(i/2,0,i,c,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 13:{d(0,h,i,c,a,n);break}case 14:{d(0,c,i,h,a,n);break}case 15:{n[0]=0,n[1]=0;break}}return n}function K(t,a,s,e,n,r){let o=t===s&&a===e;if(!o){let c=(t+s)/2,h=(a+e)/2,i=e-a,w=t-s;o=i*(n-c)+w*(r-h)>0}return o}function G(t,a,s,e,n,r){let o=0;for(let c=0;c<I;++c)for(let h=0;h<I;++h){let i=h/(I-1),w=c/(I-1);K(t,a,s,e,n+i,r+w)&&++o}return o/(I*I)}function A(t,a,s,e,n,r,o,c){let h=p[t],i=h[0],w=h[1];return i>0&&(a+=o[0],s+=o[1]),w>0&&(e+=o[0],n+=o[1]),c[0]=1-G(a,s,e,n,1+r,0+r),c[1]=G(a,s,e,n,1+r,1+r),c}function Q(t,a,s,e,n){let r=M[0],o=M[1],c=a+s+1;switch(t){case 0:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 1:{A(t,1,0,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 2:{A(t,0,0,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 3:{A(t,1,0,1+c,0+c,a,e,n);break}case 4:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 5:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 6:{A(t,1,1,1+c,0+c,a,e,n);break}case 7:{A(t,1,1,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 8:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 9:{A(t,1,0,1+c,1+c,a,e,n),A(t,1,0,1+c,1+c,a,e,n);break}case 10:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 11:{A(t,1,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 12:{A(t,1,1,1+c,1+c,a,e,n);break}case 13:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 14:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 15:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}}return n}function R(t,a,s){let e=new Float32Array(2);for(let n=0,r=t.length;n<r;++n){let o=t[n],c=o.data,h=o.width;for(let i=0;i<h;++i)for(let w=0;w<h;++w){s?J(n,w,i,a,e):Q(n,w,i,a,e);let b=(i*h+w)*2;c[b]=e[0]*255,c[b+1]=e[1]*255}}}function T(t,a,s,e,n,r,o){let c=o.data,h=o.width;for(let i=0,w=s.length;i<w;++i){let b=e[i],g=s[i],k=g.data,m=g.width;for(let U=0;U<n;++U)for(let x=0;x<n;++x){let Z=b[0]*n+t+x,O=((b[1]*n+a+U)*h+Z)*4,L=r?(U*U*m+x*x)*2:(U*m+x)*2;c[O]=k[L],c[O+1]=k[L+1],c[O+2]=0,c[O+3]=255}}}var S=class{static generate(){let a=10*D,s=v.length*5*D,e=new Uint8ClampedArray(a*s*4),n=new F(a,s,e),r=Math.pow(D-1,2)+1,o=W,c=[],h=[];for(let i=3,w=e.length;i<w;i+=4)e[i]=255;for(let i=0;i<16;++i)c.push(new F(r,r,new Uint8ClampedArray(r*r*2),2)),h.push(new F(o,o,new Uint8ClampedArray(o*o*2),2));for(let i=0,w=v.length;i<w;++i)R(c,v[i],!0),T(0,5*D*i,c,z,D,!0,n);for(let i=0,w=N.length;i<w;++i)R(h,N[i],!1),T(5*D,4*W*i,h,p,W,!1,n);return n}};var P=new Map([[y(0,0,0,0),new Float32Array([0,0,0,0])],[y(0,0,0,1),new Float32Array([0,0,0,1])],[y(0,0,1,0),new Float32Array([0,0,1,0])],[y(0,0,1,1),new Float32Array([0,0,1,1])],[y(0,1,0,0),new Float32Array([0,1,0,0])],[y(0,1,0,1),new Float32Array([0,1,0,1])],[y(0,1,1,0),new Float32Array([0,1,1,0])],[y(0,1,1,1),new Float32Array([0,1,1,1])],[y(1,0,0,0),new Float32Array([1,0,0,0])],[y(1,0,0,1),new Float32Array([1,0,0,1])],[y(1,0,1,0),new Float32Array([1,0,1,0])],[y(1,0,1,1),new Float32Array([1,0,1,1])],[y(1,1,0,0),new Float32Array([1,1,0,0])],[y(1,1,0,1),new Float32Array([1,1,0,1])],[y(1,1,1,0),new Float32Array([1,1,1,0])],[y(1,1,1,1),new Float32Array([1,1,1,1])]]);function H(t,a,s){return t+(a-t)*s}function y(t,a,s,e){let n=H(t,a,.75),r=H(s,e,1-.25);return H(n,r,1-.125)}function V(t,a){let s=0;return a[3]===1&&(s+=1),s===1&&a[2]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s}function $(t,a){let s=0;return a[3]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s===1&&a[2]===1&&t[0]!==1&&t[2]!==1&&(s+=1),s}var E=class{static generate(){let o=new Uint8ClampedArray(2178),c=new Uint8ClampedArray(1024*4);for(let h=0;h<33;++h)for(let i=0;i<66;++i){let w=.03125*i,b=.03125*h;if(P.has(w)&&P.has(b)){let g=P.get(w),k=P.get(b),m=h*66+i;o[m]=127*V(g,k),o[m+33]=127*$(g,k)}}for(let h=0,i=17;i<33;++i)for(let w=0;w<64;++w,h+=4)c[h]=o[i*66+w],c[h+3]=255;return new F(64,16,c)}};self.addEventListener("message",t=>{let a=S.generate(),s=E.generate();postMessage({areaImageData:a,searchImageData:s},[a.data.buffer,s.data.buffer]),close()});})();
946
+ #`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=r.BasicDepthPacking){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(const i of this.effects)i.setDepthTexture(e,t)}render(e,t,i,a,s){for(const o of this.effects)o.update(e,t,a);if(!this.skipRendering||this.renderToScreen){const o=this.fullscreenMaterial;o.inputBuffer=t.texture,o.time+=a*this.timeScale,e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(const i of this.effects)i.setSize(e,t)}initialize(e,t,i){this.renderer=e;for(const a of this.effects)a.initialize(e,t,i);this.updateMaterial(),i!==void 0&&i!==r.UnsignedByteType&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const e of this.effects)e.removeEventListener("change",this.listener),e.dispose()}handleEvent(e){e.type==="change"&&this.recompile()}},_a=class extends P{constructor({kernelSize:e=35,iterations:t=1,resolutionScale:i=1,resolutionX:a=x.AUTO_SIZE,resolutionY:s=x.AUTO_SIZE}={}){super("GaussianBlurPass"),this.renderTargetA=new r.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 Ht({kernelSize:e}),this.copyMaterial=new me,this.copyMaterial.inputBuffer=this.renderTargetB.texture;const o=this.resolution=new x(this,a,s,i);o.addEventListener("change",n=>this.setSize(o.baseWidth,o.baseHeight)),this.iterations=t}render(e,t,i,a,s){const o=this.scene,n=this.camera,l=this.renderTargetA,c=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(l),e.render(o,n),u.direction.set(0,1),u.inputBuffer=l.texture,e.setRenderTarget(c),e.render(o,n),h===0&&d>1&&(f=c);this.fullscreenMaterial=this.copyMaterial,e.setRenderTarget(this.renderToScreen?null:i),e.render(o,n)}setSize(e,t){const i=this.resolution;i.setBaseSize(e,t);const a=i.width,s=i.height;this.renderTargetA.setSize(a,s),this.renderTargetB.setSize(a,s),this.blurMaterial.setSize(e,t)}initialize(e,t,i){i!==void 0&&(this.renderTargetA.texture.type=i,this.renderTargetB.texture.type=i,i!==r.UnsignedByteType?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):e!==null&&e.outputColorSpace===r.SRGBColorSpace&&(this.renderTargetA.texture.colorSpace=r.SRGBColorSpace,this.renderTargetB.texture.colorSpace=r.SRGBColorSpace))}},$a=class extends P{constructor(e){super("LambdaPass",null,null),this.needsSwap=!1,this.f=e}render(e,t,i,a,s){this.f()}},es=class extends P{constructor(e,t,{renderTarget:i,resolutionScale:a=1,width:s=x.AUTO_SIZE,height:o=x.AUTO_SIZE,resolutionX:n=s,resolutionY:l=o}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new ge(e,t,new r.MeshNormalMaterial);const c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;const u=c.getClearPass();u.overrideClearColor=new r.Color(7829503),u.overrideClearAlpha=1,this.renderTarget=i,this.renderTarget===void 0&&(this.renderTarget=new r.WebGLRenderTarget(1,1,{minFilter:r.NearestFilter,magFilter:r.NearestFilter}),this.renderTarget.texture.name="NormalPass.Target");const f=this.resolution=new x(this,n,l,a);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,i,a,s){const o=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,o,o)}setSize(e,t){const i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}},tt=[new Float32Array(3),new Float32Array(3)],M=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],$=[[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 De(e,t,i,a){const s=i[0]-t[0],o=i[1]-t[1],n=i[2]-t[2],l=e[0]-t[0],c=e[1]-t[1],u=e[2]-t[2],f=o*u-n*c,h=n*l-s*u,d=s*c-o*l,p=Math.sqrt(f*f+h*h+d*d),g=p*.5,m=f/p,A=h/p,S=d/p,T=-(e[0]*m+e[1]*A+e[2]*S),D=a[0]*m+a[1]*A+a[2]*S;return Math.abs(D+T)*g/3}function ue(e,t,i,a,s,o){const n=(i+a*t+s*t*t)*4;o[0]=e[n+0],o[1]=e[n+1],o[2]=e[n+2]}function ts(e,t,i,a,s,o){const n=i*(t-1),l=a*(t-1),c=s*(t-1),u=Math.floor(n),f=Math.floor(l),h=Math.floor(c),d=Math.ceil(n),p=Math.ceil(l),g=Math.ceil(c),m=n-u,A=l-f,S=c-h;if(u===n&&f===l&&h===c)ue(e,t,n,l,c,o);else{let T;m>=A&&A>=S?T=$[0]:m>=S&&S>=A?T=$[1]:S>=m&&m>=A?T=$[2]:A>=m&&m>=S?T=$[3]:A>=S&&S>=m?T=$[4]:S>=A&&A>=m&&(T=$[5]);const[D,b,G,k]=T,Q=tt[0];Q[0]=m,Q[1]=A,Q[2]=S;const y=tt[1],q=d-u,_=p-f,V=g-h;y[0]=q*D[0]+u,y[1]=_*D[1]+f,y[2]=V*D[2]+h,ue(e,t,y[0],y[1],y[2],M[0]),y[0]=q*b[0]+u,y[1]=_*b[1]+f,y[2]=V*b[2]+h,ue(e,t,y[0],y[1],y[2],M[1]),y[0]=q*G[0]+u,y[1]=_*G[1]+f,y[2]=V*G[2]+h,ue(e,t,y[0],y[1],y[2],M[2]),y[0]=q*k[0]+u,y[1]=_*k[1]+f,y[2]=V*k[2]+h,ue(e,t,y[0],y[1],y[2],M[3]);const X=De(b,G,k,Q)*6,R=De(D,G,k,Q)*6,Ae=De(D,b,k,Q)*6,Be=De(D,b,G,Q)*6;M[0][0]*=X,M[0][1]*=X,M[0][2]*=X,M[1][0]*=R,M[1][1]*=R,M[1][2]*=R,M[2][0]*=Ae,M[2][1]*=Ae,M[2][2]*=Ae,M[3][0]*=Be,M[3][1]*=Be,M[3][2]*=Be,o[0]=M[0][0]+M[1][0]+M[2][0]+M[3][0],o[1]=M[0][1]+M[1][1]+M[2][1]+M[3][1],o[2]=M[0][2]+M[1][2]+M[2][2]+M[3][2]}}var rs=class{static expand(e,t){const i=Math.cbrt(e.length/4),a=new Float32Array(3),s=new e.constructor(t**3*4),o=e instanceof Uint8Array?255:1,n=t**2,l=1/(t-1);for(let c=0;c<t;++c)for(let u=0;u<t;++u)for(let f=0;f<t;++f){const h=f*l,d=u*l,p=c*l,g=Math.round(f+u*t+c*n)*4;ts(e,i,h,d,p,a),s[g+0]=a[0],s[g+1]=a[1],s[g+2]=a[2],s[g+3]=o}return s}},oe=[new Float32Array(2),new Float32Array(2)],ee=16,Re=20,te=30,is=32,Ie=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),rt=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],as=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Gt=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function Te(e,t,i){return e+(t-e)*i}function ss(e){return Math.min(Math.max(e,0),1)}function it(e){const t=oe[0],i=oe[1],a=Math.sqrt(t[0]*2)*.5,s=Math.sqrt(t[1]*2)*.5,o=Math.sqrt(i[0]*2)*.5,n=Math.sqrt(i[1]*2)*.5,l=ss(e/is);t[0]=Te(a,t[0],l),t[1]=Te(s,t[1],l),i[0]=Te(o,i[0],l),i[1]=Te(n,i[1],l)}function I(e,t,i,a,s,o){const n=i-e,l=a-t,c=s,u=s+1,f=t+l*(c-e)/n,h=t+l*(u-e)/n;if(c>=e&&c<i||u>e&&u<=i)if(Math.sign(f)===Math.sign(h)||Math.abs(f)<1e-4||Math.abs(h)<1e-4){const d=(f+h)/2;d<0?(o[0]=Math.abs(d),o[1]=0):(o[0]=0,o[1]=Math.abs(d))}else{const d=-t*n/l+e,p=Math.trunc(d),g=d>e?f*(d-p)/2:0,m=d<i?h*(1-(d-p))/2:0;(Math.abs(g)>Math.abs(m)?g:-m)<0?(o[0]=Math.abs(g),o[1]=Math.abs(m)):(o[0]=Math.abs(m),o[1]=Math.abs(g))}else o[0]=0,o[1]=0;return o}function ns(e,t,i,a,s){const o=oe[0],n=oe[1],l=.5+a,c=.5+a-1,u=t+i+1;switch(e){case 0:{s[0]=0,s[1]=0;break}case 1:{t<=i?I(0,c,u/2,0,t,s):(s[0]=0,s[1]=0);break}case 2:{t>=i?I(u/2,0,u,c,t,s):(s[0]=0,s[1]=0);break}case 3:{I(0,c,u/2,0,t,o),I(u/2,0,u,c,t,n),it(u),s[0]=o[0]+n[0],s[1]=o[1]+n[1];break}case 4:{t<=i?I(0,l,u/2,0,t,s):(s[0]=0,s[1]=0);break}case 5:{s[0]=0,s[1]=0;break}case 6:{Math.abs(a)>0?(I(0,l,u,c,t,o),I(0,l,u/2,0,t,n),I(u/2,0,u,c,t,s),n[0]=n[0]+s[0],n[1]=n[1]+s[1],s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2):I(0,l,u,c,t,s);break}case 7:{I(0,l,u,c,t,s);break}case 8:{t>=i?I(u/2,0,u,l,t,s):(s[0]=0,s[1]=0);break}case 9:{Math.abs(a)>0?(I(0,c,u,l,t,o),I(0,c,u/2,0,t,n),I(u/2,0,u,l,t,s),n[0]=n[0]+s[0],n[1]=n[1]+s[1],s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2):I(0,c,u,l,t,s);break}case 10:{s[0]=0,s[1]=0;break}case 11:{I(0,c,u,l,t,s);break}case 12:{I(0,l,u/2,0,t,o),I(u/2,0,u,l,t,n),it(u),s[0]=o[0]+n[0],s[1]=o[1]+n[1];break}case 13:{I(0,c,u,l,t,s);break}case 14:{I(0,l,u,c,t,s);break}case 15:{s[0]=0,s[1]=0;break}}return s}function os(e,t,i,a,s,o){let n=e===i&&t===a;if(!n){const l=(e+i)/2,c=(t+a)/2,u=a-t,f=e-i;n=u*(s-l)+f*(o-c)>0}return n}function at(e,t,i,a,s,o){let n=0;for(let l=0;l<te;++l)for(let c=0;c<te;++c){const u=c/(te-1),f=l/(te-1);os(e,t,i,a,s+u,o+f)&&++n}return n/(te*te)}function B(e,t,i,a,s,o,n,l){const c=Gt[e],u=c[0],f=c[1];return u>0&&(t+=n[0],i+=n[1]),f>0&&(a+=n[0],s+=n[1]),l[0]=1-at(t,i,a,s,1+o,0+o),l[1]=at(t,i,a,s,1+o,1+o),l}function ls(e,t,i,a,s){const o=oe[0],n=oe[1],l=t+i+1;switch(e){case 0:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 1:{B(e,1,0,0+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 2:{B(e,0,0,1+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 3:{B(e,1,0,1+l,0+l,t,a,s);break}case 4:{B(e,1,1,0+l,0+l,t,a,o),B(e,1,1,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 5:{B(e,1,1,0+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 6:{B(e,1,1,1+l,0+l,t,a,s);break}case 7:{B(e,1,1,1+l,0+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 8:{B(e,0,0,1+l,1+l,t,a,o),B(e,1,0,1+l,1+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 9:{B(e,1,0,1+l,1+l,t,a,s),B(e,1,0,1+l,1+l,t,a,s);break}case 10:{B(e,0,0,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 11:{B(e,1,0,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 12:{B(e,1,1,1+l,1+l,t,a,s);break}case 13:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,1+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 14:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,1,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}case 15:{B(e,1,1,1+l,1+l,t,a,o),B(e,1,0,1+l,0+l,t,a,n),s[0]=(o[0]+n[0])/2,s[1]=(o[1]+n[1])/2;break}}return s}function st(e,t,i){const a=new Float32Array(2);for(let s=0,o=e.length;s<o;++s){const n=e[s],l=n.data,c=n.width;for(let u=0;u<c;++u)for(let f=0;f<c;++f){i?ns(s,f,u,t,a):ls(s,f,u,t,a);const h=(u*c+f)*2;l[h]=a[0]*255,l[h+1]=a[1]*255}}}function nt(e,t,i,a,s,o,n){const l=n.data,c=n.width;for(let u=0,f=i.length;u<f;++u){const h=a[u],d=i[u],p=d.data,g=d.width;for(let m=0;m<s;++m)for(let A=0;A<s;++A){const S=h[0]*s+e+A,D=((h[1]*s+t+m)*c+S)*4,b=o?(m*m*g+A*A)*2:(m*g+A)*2;l[D]=p[b],l[D+1]=p[b+1],l[D+2]=0,l[D+3]=255}}}var cs=class{static generate(){const e=10*ee,t=Ie.length*5*ee,i=new Uint8ClampedArray(e*t*4),a=new Y(e,t,i),s=Math.pow(ee-1,2)+1,o=Re,n=[],l=[];for(let c=3,u=i.length;c<u;c+=4)i[c]=255;for(let c=0;c<16;++c)n.push(new Y(s,s,new Uint8ClampedArray(s*s*2),2)),l.push(new Y(o,o,new Uint8ClampedArray(o*o*2),2));for(let c=0,u=Ie.length;c<u;++c)st(n,Ie[c],!0),nt(0,5*ee*c,n,as,ee,!0,a);for(let c=0,u=rt.length;c<u;++c)st(l,rt[c],!1),nt(5*ee,4*Re*c,l,Gt,Re,!1,a);return a}},us=`"use strict";(()=>{function q(t,a,s){let e=document.createElement("canvas"),n=e.getContext("2d");if(e.width=t,e.height=a,s instanceof Image)n.drawImage(s,0,0);else{let r=n.createImageData(t,a);r.data.set(s),n.putImageData(r,0,0)}return e}var F=class t{constructor(a=0,s=0,e=null){this.width=a,this.height=s,this.data=e}toCanvas(){return typeof document=="undefined"?null:q(this.width,this.height,this.data)}static from(a){let{width:s,height:e}=a,n;if(a instanceof Image){let r=q(s,e,a);r!==null&&(n=r.getContext("2d").getImageData(0,0,s,e).data)}else n=a.data;return new t(s,e,n)}};var M=[new Float32Array(2),new Float32Array(2)],D=16,W=20,I=30,j=32,v=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),N=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],z=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],p=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];function C(t,a,s){return t+(a-t)*s}function B(t){return Math.min(Math.max(t,0),1)}function _(t){let a=M[0],s=M[1],e=Math.sqrt(a[0]*2)*.5,n=Math.sqrt(a[1]*2)*.5,r=Math.sqrt(s[0]*2)*.5,o=Math.sqrt(s[1]*2)*.5,c=B(t/j);a[0]=C(e,a[0],c),a[1]=C(n,a[1],c),s[0]=C(r,s[0],c),s[1]=C(o,s[1],c)}function d(t,a,s,e,n,r){let o=s-t,c=e-a,h=n,i=n+1,w=a+c*(h-t)/o,b=a+c*(i-t)/o;if(h>=t&&h<s||i>t&&i<=s)if(Math.sign(w)===Math.sign(b)||Math.abs(w)<1e-4||Math.abs(b)<1e-4){let g=(w+b)/2;g<0?(r[0]=Math.abs(g),r[1]=0):(r[0]=0,r[1]=Math.abs(g))}else{let g=-a*o/c+t,k=Math.trunc(g),m=g>t?w*(g-k)/2:0,U=g<s?b*(1-(g-k))/2:0;(Math.abs(m)>Math.abs(U)?m:-U)<0?(r[0]=Math.abs(m),r[1]=Math.abs(U)):(r[0]=Math.abs(U),r[1]=Math.abs(m))}else r[0]=0,r[1]=0;return r}function J(t,a,s,e,n){let r=M[0],o=M[1],c=.5+e,h=.5+e-1,i=a+s+1;switch(t){case 0:{n[0]=0,n[1]=0;break}case 1:{a<=s?d(0,h,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 2:{a>=s?d(i/2,0,i,h,a,n):(n[0]=0,n[1]=0);break}case 3:{d(0,h,i/2,0,a,r),d(i/2,0,i,h,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 4:{a<=s?d(0,c,i/2,0,a,n):(n[0]=0,n[1]=0);break}case 5:{n[0]=0,n[1]=0;break}case 6:{Math.abs(e)>0?(d(0,c,i,h,a,r),d(0,c,i/2,0,a,o),d(i/2,0,i,h,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,c,i,h,a,n);break}case 7:{d(0,c,i,h,a,n);break}case 8:{a>=s?d(i/2,0,i,c,a,n):(n[0]=0,n[1]=0);break}case 9:{Math.abs(e)>0?(d(0,h,i,c,a,r),d(0,h,i/2,0,a,o),d(i/2,0,i,c,a,n),o[0]=o[0]+n[0],o[1]=o[1]+n[1],n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2):d(0,h,i,c,a,n);break}case 10:{n[0]=0,n[1]=0;break}case 11:{d(0,h,i,c,a,n);break}case 12:{d(0,c,i/2,0,a,r),d(i/2,0,i,c,a,o),_(i,M),n[0]=r[0]+o[0],n[1]=r[1]+o[1];break}case 13:{d(0,h,i,c,a,n);break}case 14:{d(0,c,i,h,a,n);break}case 15:{n[0]=0,n[1]=0;break}}return n}function K(t,a,s,e,n,r){let o=t===s&&a===e;if(!o){let c=(t+s)/2,h=(a+e)/2,i=e-a,w=t-s;o=i*(n-c)+w*(r-h)>0}return o}function G(t,a,s,e,n,r){let o=0;for(let c=0;c<I;++c)for(let h=0;h<I;++h){let i=h/(I-1),w=c/(I-1);K(t,a,s,e,n+i,r+w)&&++o}return o/(I*I)}function A(t,a,s,e,n,r,o,c){let h=p[t],i=h[0],w=h[1];return i>0&&(a+=o[0],s+=o[1]),w>0&&(e+=o[0],n+=o[1]),c[0]=1-G(a,s,e,n,1+r,0+r),c[1]=G(a,s,e,n,1+r,1+r),c}function Q(t,a,s,e,n){let r=M[0],o=M[1],c=a+s+1;switch(t){case 0:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 1:{A(t,1,0,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 2:{A(t,0,0,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 3:{A(t,1,0,1+c,0+c,a,e,n);break}case 4:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 5:{A(t,1,1,0+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 6:{A(t,1,1,1+c,0+c,a,e,n);break}case 7:{A(t,1,1,1+c,0+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 8:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 9:{A(t,1,0,1+c,1+c,a,e,n),A(t,1,0,1+c,1+c,a,e,n);break}case 10:{A(t,0,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 11:{A(t,1,0,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 12:{A(t,1,1,1+c,1+c,a,e,n);break}case 13:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,1+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 14:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,1,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}case 15:{A(t,1,1,1+c,1+c,a,e,r),A(t,1,0,1+c,0+c,a,e,o),n[0]=(r[0]+o[0])/2,n[1]=(r[1]+o[1])/2;break}}return n}function R(t,a,s){let e=new Float32Array(2);for(let n=0,r=t.length;n<r;++n){let o=t[n],c=o.data,h=o.width;for(let i=0;i<h;++i)for(let w=0;w<h;++w){s?J(n,w,i,a,e):Q(n,w,i,a,e);let b=(i*h+w)*2;c[b]=e[0]*255,c[b+1]=e[1]*255}}}function T(t,a,s,e,n,r,o){let c=o.data,h=o.width;for(let i=0,w=s.length;i<w;++i){let b=e[i],g=s[i],k=g.data,m=g.width;for(let U=0;U<n;++U)for(let x=0;x<n;++x){let Z=b[0]*n+t+x,O=((b[1]*n+a+U)*h+Z)*4,L=r?(U*U*m+x*x)*2:(U*m+x)*2;c[O]=k[L],c[O+1]=k[L+1],c[O+2]=0,c[O+3]=255}}}var S=class{static generate(){let a=10*D,s=v.length*5*D,e=new Uint8ClampedArray(a*s*4),n=new F(a,s,e),r=Math.pow(D-1,2)+1,o=W,c=[],h=[];for(let i=3,w=e.length;i<w;i+=4)e[i]=255;for(let i=0;i<16;++i)c.push(new F(r,r,new Uint8ClampedArray(r*r*2),2)),h.push(new F(o,o,new Uint8ClampedArray(o*o*2),2));for(let i=0,w=v.length;i<w;++i)R(c,v[i],!0),T(0,5*D*i,c,z,D,!0,n);for(let i=0,w=N.length;i<w;++i)R(h,N[i],!1),T(5*D,4*W*i,h,p,W,!1,n);return n}};var P=new Map([[y(0,0,0,0),new Float32Array([0,0,0,0])],[y(0,0,0,1),new Float32Array([0,0,0,1])],[y(0,0,1,0),new Float32Array([0,0,1,0])],[y(0,0,1,1),new Float32Array([0,0,1,1])],[y(0,1,0,0),new Float32Array([0,1,0,0])],[y(0,1,0,1),new Float32Array([0,1,0,1])],[y(0,1,1,0),new Float32Array([0,1,1,0])],[y(0,1,1,1),new Float32Array([0,1,1,1])],[y(1,0,0,0),new Float32Array([1,0,0,0])],[y(1,0,0,1),new Float32Array([1,0,0,1])],[y(1,0,1,0),new Float32Array([1,0,1,0])],[y(1,0,1,1),new Float32Array([1,0,1,1])],[y(1,1,0,0),new Float32Array([1,1,0,0])],[y(1,1,0,1),new Float32Array([1,1,0,1])],[y(1,1,1,0),new Float32Array([1,1,1,0])],[y(1,1,1,1),new Float32Array([1,1,1,1])]]);function H(t,a,s){return t+(a-t)*s}function y(t,a,s,e){let n=H(t,a,.75),r=H(s,e,1-.25);return H(n,r,1-.125)}function V(t,a){let s=0;return a[3]===1&&(s+=1),s===1&&a[2]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s}function $(t,a){let s=0;return a[3]===1&&t[1]!==1&&t[3]!==1&&(s+=1),s===1&&a[2]===1&&t[0]!==1&&t[2]!==1&&(s+=1),s}var E=class{static generate(){let o=new Uint8ClampedArray(2178),c=new Uint8ClampedArray(1024*4);for(let h=0;h<33;++h)for(let i=0;i<66;++i){let w=.03125*i,b=.03125*h;if(P.has(w)&&P.has(b)){let g=P.get(w),k=P.get(b),m=h*66+i;o[m]=127*V(g,k),o[m+33]=127*$(g,k)}}for(let h=0,i=17;i<33;++i)for(let w=0;w<64;++w,h+=4)c[h]=o[i*66+w],c[h+3]=255;return new F(64,16,c)}};self.addEventListener("message",t=>{let a=S.generate(),s=E.generate();postMessage({areaImageData:a,searchImageData:s},[a.data.buffer,s.data.buffer]),close()});})();
947
947
  `;function fs(e=!0){const t=URL.createObjectURL(new Blob([us],{type:"text/javascript"})),i=new Worker(t);return URL.revokeObjectURL(t),new Promise((a,s)=>{i.addEventListener("error",o=>s(o.error)),i.addEventListener("message",o=>{const n=Y.from(o.data.searchImageData),l=Y.from(o.data.areaImageData),c=[n.toCanvas().toDataURL("image/png",1),l.toCanvas().toDataURL("image/png",1)];e&&(localStorage.setItem("smaa-search",c[0]),localStorage.setItem("smaa-area",c[1])),a(c)}),i.postMessage(null)})}var hs=class{constructor(){this.disableCache=!1}setCacheEnabled(e){this.disableCache=!e}generate(){const 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):fs(e)).then(a=>new Promise((s,o)=>{const n=new Image,l=new Image,c=new r.LoadingManager;c.onLoad=()=>s([n,l]),c.onError=o,n.addEventListener("error",u=>c.itemError("smaa-search")),l.addEventListener("error",u=>c.itemError("smaa-area")),n.addEventListener("load",()=>c.itemEnd("smaa-search")),l.addEventListener("load",()=>c.itemEnd("smaa-area")),c.itemStart("smaa-search"),c.itemStart("smaa-area"),n.src=a[0],l.src=a[1]}))}},we=new Map([[F(0,0,0,0),new Float32Array([0,0,0,0])],[F(0,0,0,1),new Float32Array([0,0,0,1])],[F(0,0,1,0),new Float32Array([0,0,1,0])],[F(0,0,1,1),new Float32Array([0,0,1,1])],[F(0,1,0,0),new Float32Array([0,1,0,0])],[F(0,1,0,1),new Float32Array([0,1,0,1])],[F(0,1,1,0),new Float32Array([0,1,1,0])],[F(0,1,1,1),new Float32Array([0,1,1,1])],[F(1,0,0,0),new Float32Array([1,0,0,0])],[F(1,0,0,1),new Float32Array([1,0,0,1])],[F(1,0,1,0),new Float32Array([1,0,1,0])],[F(1,0,1,1),new Float32Array([1,0,1,1])],[F(1,1,0,0),new Float32Array([1,1,0,0])],[F(1,1,0,1),new Float32Array([1,1,0,1])],[F(1,1,1,0),new Float32Array([1,1,1,0])],[F(1,1,1,1),new Float32Array([1,1,1,1])]]);function be(e,t,i){return e+(t-e)*i}function F(e,t,i,a){const s=be(e,t,.75),o=be(i,a,1-.25);return be(s,o,1-.125)}function ds(e,t){let i=0;return t[3]===1&&(i+=1),i===1&&t[2]===1&&e[1]!==1&&e[3]!==1&&(i+=1),i}function ps(e,t){let i=0;return t[3]===1&&e[1]!==1&&e[3]!==1&&(i+=1),i===1&&t[2]===1&&e[0]!==1&&e[2]!==1&&(i+=1),i}var vs=class{static generate(){const o=new Uint8ClampedArray(2178),n=new Uint8ClampedArray(1024*4);for(let l=0;l<33;++l)for(let c=0;c<66;++c){const u=.03125*c,f=.03125*l;if(we.has(u)&&we.has(f)){const h=we.get(u),d=we.get(f),p=l*66+c;o[p]=127*ds(h,d),o[p+33]=127*ps(h,d)}}for(let l=0,c=17;c<33;++c)for(let u=0;u<64;++u,l+=4)n[l]=o[c*66+u],n[l+3]=255;return new Y(64,16,n)}};const ms=Object.freeze(Object.defineProperty({__proto__:null,ASCIIEffect:Gr,ASCIITexture:dt,AdaptiveLuminanceMaterial:bt,AdaptiveLuminancePass:Ft,BlendFunction:v,BlendMode:ht,BloomEffect:At,BlurPass:J,BokehEffect:Jr,BokehMaterial:fe,BoxBlurMaterial:Lt,BoxBlurPass:Wa,BrightnessContrastEffect:_r,ChromaticAberrationEffect:si,CircleOfConfusionMaterial:xt,ClearMaskPass:lt,ClearPass:le,ColorAverageEffect:ei,ColorChannel:Z,ColorDepthEffect:ri,ColorEdgesMaterial:Ne,ConvolutionMaterial:Ee,CopyMaterial:me,CopyPass:pe,DepthComparisonMaterial:Ct,DepthCopyMaterial:Ot,DepthCopyMode:se,DepthCopyPass:ze,DepthDownsamplingMaterial:Pt,DepthDownsamplingPass:Ut,DepthEffect:oi,DepthMaskMaterial:Bt,DepthOfFieldEffect:di,DepthPass:Ye,DepthPickingPass:ja,DepthSavePass:ze,DepthTestStrategy:ne,Disposable:Jt,DotScreenEffect:vi,DownsamplingMaterial:vt,EdgeDetectionMaterial:Ne,EdgeDetectionMode:We,Effect:C,EffectAttribute:U,EffectComposer:er,EffectMaterial:Nt,EffectPass:qa,EffectShaderData:ut,EffectShaderSection:E,FXAAEffect:Ai,GammaCorrectionEffect:Di,GaussKernel:ft,GaussianBlurMaterial:Ht,GaussianBlurPass:_a,GlitchEffect:Si,GlitchMode:re,GodRaysEffect:Bi,GodRaysMaterial:Tt,GridEffect:yi,HueSaturationEffect:Ui,ImmutableTimer:tr,Initializable:rr,KawaseBlurMaterial:Ee,KawaseBlurPass:J,KernelSize:z,LUT1DEffect:Fi,LUT3DEffect:qe,LUT3dlLoader:ba,LUTCubeLoader:Fa,LUTEffect:qe,LUTOperation:wt,LambdaPass:$a,LensDistortionEffect:Ii,LookupTexture:ve,LookupTexture3D:ve,LuminanceMaterial:pt,LuminancePass:Qe,MaskFunction:Ve,MaskMaterial:Dt,MaskPass:ct,MipmapBlurPass:gt,NoiseEffect:Gi,NoiseTexture:Ce,NormalPass:es,OutlineEdgesMaterial:Oe,OutlineEffect:Ki,OutlineMaterial:Oe,OverrideMaterialManager:Le,Pass:P,PixelationEffect:Zi,PredicationMode:Et,RawImageData:Y,RealisticBokehEffect:Ji,RenderPass:ge,Resizable:ir,Resizer:x,Resolution:x,SMAAAreaImageData:cs,SMAAEffect:da,SMAAImageGenerator:hs,SMAAImageLoader:La,SMAAPreset:ie,SMAASearchImageData:vs,SMAAWeightsMaterial:Mt,SSAOEffect:xa,SSAOMaterial:yt,SavePass:pe,ScanlineEffect:_i,Section:E,Selection:ke,SelectiveBloomEffect:aa,SepiaEffect:na,ShaderPass:H,ShockWaveEffect:ra,TetrahedralUpscaler:rs,TextureEffect:wa,TiltShiftBlurMaterial:Rt,TiltShiftBlurPass:It,TiltShiftEffect:Ma,Timer:ot,ToneMappingEffect:Ua,ToneMappingMode:O,UpsamplingMaterial:mt,VignetteEffect:Ia,VignetteTechnique:ae,WebGLExtension:Ni,version:jt},Symbol.toStringTag,{value:"Module"}));class gs extends r.BufferGeometry{boundingSphere=new r.Sphere;constructor(){super(),this.setAttribute("position",new r.BufferAttribute(new Float32Array([-1,-1,3,-1,-1,3]),2)),this.setAttribute("uv",new r.BufferAttribute(new Float32Array([0,0,2,0,0,2]),2))}computeBoundingSphere(){}}const As=new gs,xs=new r.OrthographicCamera;class N{constructor(t){this._mesh=new r.Mesh(As,t),this._mesh.frustumCulled=!1}render(t){t.render(this._mesh,xs)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const zt={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new r.Matrix4},viewMat:{value:new r.Matrix4},projViewMat:{value:new r.Matrix4},projectionMatrixInv:{value:new r.Matrix4},viewMatrixInv:{value:new r.Matrix4},cameraPos:{value:new r.Vector3},resolution:{value:new r.Vector2},biasAdjustment:{value:new r.Vector2},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
948
948
  varying vec2 vUv;
949
949
  void main() {