1import{r,j as Z}from"./index-CVjK7WpQ.js";import{R as J,P as Q,T as $,M as tt}from"./Triangle-GlFcswsc.js";const j=new Uint8Array(4);function H(h){return(h&h-1)===0}let et=1;class it{constructor(t,{image:n,target:e=t.TEXTURE_2D,type:E=t.UNSIGNED_BYTE,format:p=t.RGBA,internalFormat:u=p,wrapS:v=t.CLAMP_TO_EDGE,wrapT:R=t.CLAMP_TO_EDGE,wrapR:P=t.CLAMP_TO_EDGE,generateMipmaps:_=e===(t.TEXTURE_2D||t.TEXTURE_CUBE_MAP),minFilter:M=_?t.NEAREST_MIPMAP_LINEAR:t.LINEAR,magFilter:x=t.LINEAR,premultiplyAlpha:S=!1,unpackAlignment:O=4,flipY:D=e==(t.TEXTURE_2D||t.TEXTURE_3D),anisotropy:A=0,level:F=0,width:U,height:I=U,length:C=1}={}){this.gl=t,this.id=et++,this.image=n,this.target=e,this.type=E,this.format=p,this.internalFormat=u,this.minFilter=M,this.magFilter=x,this.wrapS=v,this.wrapT=R,this.wrapR=P,this.generateMipmaps=_,this.premultiplyAlpha=S,this.unpackAlignment=O,this.flipY=D,this.anisotropy=Math.min(A,this.gl.renderer.parameters.maxAnisotropy),this.level=F,this.width=U,this.height=I,this.length=C,this.texture=this.gl.createTexture(),this.store={image:null},this.glState=this.gl.renderer.state,this.state={},this.state.minFilter=this.gl.NEAREST_MIPMAP_LINEAR,this.state.magFilter=this.gl.LINEAR,this.state.wrapS=this.gl.REPEAT,this.state.wrapT=this.gl.REPEAT,this.state.anisotropy=0}bind(){this.glState.textureUnits[this.glState.activeTextureUnit]!==this.id&&(this.gl.bindTexture(this.target,this.texture),this.glState.textureUnits[this.glState.activeTextureUnit]=this.id)}update(t=0){const n=!(this.image===this.store.image&&!this.needsUpdate);if((n||this.glState.textureUnits[t]!==this.id)&&(this.gl.renderer.activeTexture(t),this.bind()),!!n){if(this.needsUpdate=!1,this.flipY!==this.glState.flipY&&(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,this.flipY),this.glState.flipY=this.flipY),this.premultiplyAlpha!==this.glState.premultiplyAlpha&&(this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),this.glState.premultiplyAlpha=this.premultiplyAlpha),this.unpackAlignment!==this.glState.unpackAlignment&&(this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,this.unpackAlignment),this.glState.unpackAlignment=this.unpackAlignment),this.minFilter!==this.state.minFilter&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,this.minFilter),this.state.minFilter=this.minFilter),this.magFilter!==this.state.magFilter&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,this.magFilter),this.state.magFilter=this.magFilter),this.wrapS!==this.state.wrapS&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,this.wrapS),this.state.wrapS=this.wrapS),this.wrapT!==this.state.wrapT&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,this.wrapT),this.state.wrapT=this.wrapT),this.wrapR!==this.state.wrapR&&(this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_R,this.wrapR),this.state.wrapR=this.wrapR),this.anisotropy&&this.anisotropy!==this.state.anisotropy&&(this.gl.texParameterf(this.target,this.gl.renderer.getExtension("EXT_texture_filter_anisotropic").TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropy),this.state.anisotropy=this.anisotropy),this.image){if(this.image.width&&(this.width=this.image.width,this.height=this.image.height),this.target===this.gl.TEXTURE_CUBE_MAP)for(let e=0;e<6;e++)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+e,this.level,this.internalFormat,this.format,this.type,this.image[e]);else if(ArrayBuffer.isView(this.image))this.target===this.gl.TEXTURE_2D?this.gl.texImage2D(this.target,this.level,this.internalFormat,this.width,this.height,0,this.format,this.type,this.image):(this.target===this.gl.TEXTURE_2D_ARRAY||this.target===this.gl.TEXTURE_3D)&&this.gl.texImage3D(this.target,this.level,this.internalFormat,this.width,this.height,this.length,0,this.format,this.type,this.image);else if(this.image.isCompressedTexture)for(let e=0;e<this.image.length;e++)this.gl.compressedTexImage2D(this.target,e,this.internalFormat,this.image[e].width,this.image[e].height,0,this.image[e].data);else this.target===this.gl.TEXTURE_2D?this.gl.texImage2D(this.target,this.level,this.internalFormat,this.format,this.type,this.image):this.gl.texImage3D(this.target,this.level,this.internalFormat,this.width,this.height,this.length,0,this.format,this.type,this.image);this.generateMipmaps&&(!this.gl.renderer.isWebgl2&&(!H(this.image.width)||!H(this.image.height))?(this.generateMipmaps=!1,this.wrapS=this.wrapT=this.gl.CLAMP_TO_EDGE,this.minFilter=this.gl.LINEAR):this.gl.generateMipmap(this.target)),this.onUpdate&&this.onUpdate()}else if(this.target===this.gl.TEXTURE_CUBE_MAP)for(let e=0;e<6;e++)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,j);else this.width?this.target===this.gl.TEXTURE_2D?this.gl.texImage2D(this.target,this.level,this.internalFormat,this.width,this.height,0,this.format,this.type,null):this.gl.texImage3D(this.target,this.level,this.internalFormat,this.width,this.height,this.length,0,this.format,this.type,null):this.gl.texImage2D(this.target,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,j);this.store.image=this.image}}}const st=`#version 300 es 2in vec2 position; 3in vec2 uv; 4out vec2 vUv; 5void main() { 6 vUv = uv; 7 gl_Position = vec4(position, 0.0, 1.0); 8} 9`,at=`#version 300 es 10precision highp float; 11precision highp int; 12 13out vec4 fragColor; 14 15uniform vec2 uResolution; 16uniform float uTime; 17 18uniform float uIntensity; 19uniform float uSpeed; 20uniform int uAnimType; 21uniform vec2 uMouse; 22uniform int uColorCount; 23uniform float uDistort; 24uniform vec2 uOffset; 25uniform sampler2D uGradient; 26uniform float uNoiseAmount; 27uniform int uRayCount; 28 29float hash21(vec2 p){ 30 p = floor(p); 31 float f = 52.9829189 * fract(dot(p, vec2(0.065, 0.005))); 32 return fract(f); 33} 34 35mat2 rot30(){ return mat2(0.8, -0.5, 0.5, 0.8); } 36 37float layeredNoise(vec2 fragPx){ 38 vec2 p = mod(fragPx + vec2(uTime * 30.0, -uTime * 21.0), 1024.0); 39 vec2 q = rot30() * p; 40 float n = 0.0; 41 n += 0.40 * hash21(q); 42 n += 0.25 * hash21(q * 2.0 + 17.0); 43 n += 0.20 * hash21(q * 4.0 + 47.0); 44 n += 0.10 * hash21(q * 8.0 + 113.0); 45 n += 0.05 * hash21(q * 16.0 + 191.0); 46 return n; 47} 48 49vec3 rayDir(vec2 frag, vec2 res, vec2 offset, float dist){ 50 float focal = res.y * max(dist, 1e-3); 51 return normalize(vec3(2.0 * (frag - offset) - res, focal)); 52} 53 54float edgeFade(vec2 frag, vec2 res, vec2 offset){ 55 vec2 toC = frag - 0.5 * res - offset; 56 float r = length(toC) / (0.5 * min(res.x, res.y)); 57 float x = clamp(r, 0.0, 1.0); 58 float q = x * x * x * (x * (x * 6.0 - 15.0) + 10.0); 59 float s = q * 0.5; 60 s = pow(s, 1.5); 61 float tail = 1.0 - pow(1.0 - s, 2.0); 62 s = mix(s, tail, 0.2); 63 float dn = (layeredNoise(frag * 0.15) - 0.5) * 0.0015 * s; 64 return clamp(s + dn, 0.0, 1.0); 65} 66 67mat3 rotX(float a){ float c = cos(a), s = sin(a); return mat3(1.0,0.0,0.0, 0.0,c,-s, 0.0,s,c); } 68mat3 rotY(float a){ float c = cos(a), s = sin(a); return mat3(c,0.0,s, 0.0,1.0,0.0, -s,0.0,c); } 69mat3 rotZ(float a){ float c = cos(a), s = sin(a); return mat3(c,-s,0.0, s,c,0.0, 0.0,0.0,1.0); } 70 71vec3 sampleGradient(float t){ 72 t = clamp(t, 0.0, 1.0); 73 return texture(uGradient, vec2(t, 0.5)).rgb; 74} 75 76vec2 rot2(vec2 v, float a){ 77 float s = sin(a), c = cos(a); 78 return mat2(c, -s, s, c) * v; 79} 80 81float bendAngle(vec3 q, float t){ 82 float a = 0.8 * sin(q.x * 0.55 + t * 0.6) 83 + 0.7 * sin(q.y * 0.50 - t * 0.5) 84 + 0.6 * sin(q.z * 0.60 + t * 0.7); 85 return a; 86} 87 88void main(){ 89 vec2 frag = gl_FragCoord.xy; 90 float t = uTime * uSpeed; 91 float jitterAmp = 0.1 * clamp(uNoiseAmount, 0.0, 1.0); 92 vec3 dir = rayDir(frag, uResolution, uOffset, 1.0);
93 float marchT = 0.0; 94 vec3 col = vec3(0.0); 95 float n = layeredNoise(frag); 96 vec4 c = cos(t * 0.2 + vec4(0.0, 33.0, 11.0, 0.0)); 97 mat2 M2 = mat2(c.x, c.y, c.z, c.w); 98 float amp = clamp(uDistort, 0.0, 50.0) * 0.15; 99 100 mat3 rot3dMat = mat3(1.0); 101 if(uAnimType == 1){ 102 vec3 ang = vec3(t * 0.31, t * 0.21, t * 0.17); 103 rot3dMat = rotZ(ang.z) * rotY(ang.y) * rotX(ang.x); 104 } 105 mat3 hoverMat = mat3(1.0); 106 if(uAnimType == 2){ 107 vec2 m = uMouse * 2.0 - 1.0; 108 vec3 ang = vec3(m.y * 0.6, m.x * 0.6, 0.0); 109 hoverMat = rotY(ang.y) * rotX(ang.x); 110 } 111 112 for (int i = 0; i < 44; ++i) { 113 vec3 P = marchT * dir; 114 P.z -= 2.0; 115 float rad = length(P); 116 vec3 Pl = P * (10.0 / max(rad, 1e-6)); 117 118 if(uAnimType == 0){ 119 Pl.xz *= M2; 120 } else if(uAnimType == 1){ 121 Pl = rot3dMat * Pl; 122 } else { 123 Pl = hoverMat * Pl; 124 } 125 126 float stepLen = min(rad - 0.3, n * jitterAmp) + 0.1; 127 128 float grow = smoothstep(0.35, 3.0, marchT); 129 float a1 = amp * grow * bendAngle(Pl * 0.6, t); 130 float a2 = 0.5 * amp * grow * bendAngle(Pl.zyx * 0.5 + 3.1, t * 0.9); 131 vec3 Pb = Pl; 132 Pb.xz = rot2(Pb.xz, a1); 133 Pb.xy = rot2(Pb.xy, a2); 134 135 float rayPattern = smoothstep( 136 0.5, 0.7, 137 sin(Pb.x + cos(Pb.y) * cos(Pb.z)) * 138 sin(Pb.z + sin(Pb.y) * cos(Pb.x + t)) 139 ); 140 141 if (uRayCount > 0) { 142 float ang = atan(Pb.y, Pb.x); 143 float comb = 0.5 + 0.5 * cos(float(uRayCount) * ang); 144 comb = pow(comb, 3.0); 145 rayPattern *= smoothstep(0.15, 0.95, comb); 146 } 147 148 // Original colorful spectralDefault: 149 // vec3 spectralDefault = 1.0 + vec3( 150 // cos(marchT * 3.0 + 0.0), 151 // cos(marchT * 3.0 + 1.0), 152 // cos(marchT * 3.0 + 2.0) 153 // ); 154 vec3 spectralDefault = vec3(1.0 + cos(marchT * 3.0)); 155 156 float saw = fract(marchT * 0.25); 157 float tRay = saw * saw * (3.0 - 2.0 * saw); 158 vec3 userGradient = 2.0 * sampleGradient(tRay); 159 vec3 spectral = (uColorCount > 0) ? userGradient : spectralDefault; 160 vec3 base = (0.05 / (0.4 + stepLen)) 161 * smoothstep(5.0, 0.0, rad) 162 * spectral; 163 164 col += base * rayPattern; 165 marchT += stepLen; 166 } 167 168 col *= edgeFade(frag, uResolution, uOffset); 169 col *= uIntensity; 170 171 fragColor = vec4(clamp(col, 0.0, 1.0), 1.0); 172}`,rt=h=>{let t=h.trim();if(t.startsWith("#")&&(t=t.slice(1)),t.length===3){const u=t[0],v=t[1],R=t[2];t=u+u+v+v+R+R}const n=parseInt(t,16);if(isNaN(n)||t.length!==6&&t.length!==8)return[1,1,1];const e=(n>>16&255)/255,E=(n>>8&255)/255,p=(n&255)/255;return[e,E,p]},K=h=>{if(h==null)return 0;if(typeof h=="number")return h;const t=String(h).trim(),n=parseFloat(t.replace("px",""));return isNaN(n)?0:n},ht=({intensity:h=2,speed:t=.5,animationType:n="rotate3d",colors:e,distort:E=0,paused:p=!1,offset:u={x:0,y:0},hoverDampness:v=0,rayCount:R,mixBlendMode:P="lighten"})=>{const _=r.useRef(null),M=r.useRef(null),x=r.useRef(null),S=r.useRef([.5,.5]),O=r.useRef([.5,.5]),D=r.useRef(p),A=r.useRef(null),F=r.useRef(v),U=r.useRef(!0),I=r.useRef(null),C=r.useRef(null);return r.useEffect(()=>{D.current=p},[p]),r.useEffect(()=>{F.current=v},[v]),r.useEffect(()=>{const i=_.current;if(!i)return;const y=Math.min(window.devicePixelRatio||1,2),s=new J({dpr:y,alpha:!1,antialias:!1});x.current=s;const a=s.gl;a.canvas.style.position="absolute",a.canvas.style.inset="0",a.canvas.style.width="100%",a.canvas.style.height="100%",i.appendChild(a.canvas);const B=new Uint8Array([255,255,255,255]),d=new it(a,{image:B,width:1,height:1,generateMipmaps:!1,flipY:!1});d.minFilter=a.LINEAR,d.magFilter=a.LINEAR,d.wrapS=a.CLAMP_TO_EDGE,d.wrapT=a.CLAMP_TO_EDGE,A.current=d;const c=new Q(a,{vertex:st,fragment:at,uniforms:{uResolution:{value:[1,1]},uTime:{value:0},uIntensity:{value:1},uSpeed:{value:1},uAnimType:{value:0},uMouse:{value:[.5,.5]},uColorCount:{value:0},uDistort:{value:0},uOffset:{value:[0,0]},uGradient:{value:d},uNoiseAmount:{value:.8},uRayCount:{value:0}}});M.current=c;
172const f=new $(a),N=new tt(a,{geometry:f,program:c});C.current=f,I.current=N;const g=()=>{const o=i.clientWidth||1,m=i.clientHeight||1;s.setSize(o,m),c.uniforms.uResolution.value=[a.drawingBufferWidth,a.drawingBufferHeight]};let l=null;"ResizeObserver"in window?(l=new ResizeObserver(g),l.observe(i)):window.addEventListener("resize",g),g();const L=o=>{const m=i.getBoundingClientRect(),T=(o.clientX-m.left)/Math.max(m.width,1),z=(o.clientY-m.top)/Math.max(m.height,1);S.current=[Math.min(Math.max(T,0),1),Math.min(Math.max(z,0),1)]};i.addEventListener("pointermove",L,{passive:!0});let w=null;"IntersectionObserver"in window&&(w=new IntersectionObserver(o=>{o[0]&&(U.current=o[0].isIntersecting)},{root:null,threshold:.01}),w.observe(i));const G=()=>{};document.addEventListener("visibilitychange",G);let X=0,q=performance.now(),W=0;const Y=o=>{const m=Math.max(0,o-q)*.001;q=o;const T=U.current&&!document.hidden;if(D.current||(W+=m),!T){X=requestAnimationFrame(Y);return}const z=.02+Math.max(0,Math.min(1,F.current))*.5,k=1-Math.exp(-m/z),V=S.current,b=O.current;b[0]+=(V[0]-b[0])*k,b[1]+=(V[1]-b[1])*k,c.uniforms.uMouse.value=b,c.uniforms.uTime.value=W,s.render({scene:I.current}),X=requestAnimationFrame(Y)};return X=requestAnimationFrame(Y),()=>{var o,m;cancelAnimationFrame(X),i.removeEventListener("pointermove",L),l==null||l.disconnect(),l||window.removeEventListener("resize",g),w==null||w.disconnect(),document.removeEventListener("visibilitychange",G);try{i.removeChild(a.canvas)}catch{}I.current=null,C.current=null,M.current=null;try{const T=(o=x.current)==null?void 0:o.gl;T&&((m=A.current)!=null&&m.texture)&&T.deleteTexture(A.current.texture)}catch{}x.current=null,A.current=null}},[]),r.useEffect(()=>{var y,s;const i=(s=(y=x.current)==null?void 0:y.gl)==null?void 0:s.canvas;i&&(i.style.mixBlendMode=P&&P!=="none"?P:"")},[P]),r.useEffect(()=>{const i=M.current,y=x.current,s=A.current;if(!i||!y||!s)return;i.uniforms.uIntensity.value=h??1,i.uniforms.uSpeed.value=t??1;const a={rotate:0,rotate3d:1,hover:2};i.uniforms.uAnimType.value=a[n??"rotate"],i.uniforms.uDistort.value=typeof E=="number"?E:0;const B=K(u==null?void 0:u.x),d=K(u==null?void 0:u.y);i.uniforms.uOffset.value=[B,d],i.uniforms.uRayCount.value=Math.max(0,Math.floor(R??0));let c=0;if(Array.isArray(e)&&e.length>0){const f=y.gl,N=e.slice(0,64);c=N.length;const g=new Uint8Array(c*4);for(let l=0;l<c;l++){const[L,w,G]=rt(N[l]);g[l*4+0]=Math.round(L*255),g[l*4+1]=Math.round(w*255),g[l*4+2]=Math.round(G*255),g[l*4+3]=255}s.image=g,s.width=c,s.height=1,s.minFilter=f.LINEAR,s.magFilter=f.LINEAR,s.wrapS=f.CLAMP_TO_EDGE,s.wrapT=f.CLAMP_TO_EDGE,s.flipY=!1,s.generateMipmaps=!1,s.format=f.RGBA,s.type=f.UNSIGNED_BYTE,s.needsUpdate=!0}else c=0;i.uniforms.uColorCount.value=c},[h,t,n,e,E,u,R]),Z.jsx("div",{className:"w-full h-full relative overflow-hidden",ref:_})};export{ht as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.