PageSourceSearch

https://cognichip-website.vercel.app/assets/CybercabTunnelBg-DveiPoft.js

js cognichip-website.vercel.app collected 2026-10-03 05:17:59 UTC 8,342 bytes, 155 lines download raw bytes

1import{r as d,j as O}from"./vendor-react-DLhum4v_.js";const V=`
2  attribute vec2 aPosition;
3  void main() { gl_Position = vec4(aPosition, 0.0, 1.0); }
4`,U=`
5  precision highp float;
6  uniform float uTime;
7  uniform vec2  uResolution;
8  uniform float uSpeed;
9  uniform float uGlowIntensity;
10  uniform float uStripeWidth;
11  uniform float uStripeSpacing;
12  uniform vec3  uPrimaryColor;
13  uniform vec3  uSecondaryColor;
14  uniform vec3  uAccentColor;
15  uniform float uFogDensity;
16  uniform float uTunnelWidth;
17  uniform float uTunnelHeight;
18  uniform float uTopScale;
19  uniform float uSkew;
20
21  const float CAM_Y     = -0.12;
22  const float FOCAL_LEN = 1.4;
23
24  float hash(float n) { return fract(sin(n * 127.1) * 43758.5453); }
25
26  float milkyGlow(float d) {
27    float core  = smoothstep(0.35, 0.0, d);
28    float inner = exp(-d * d * 22.0);
29    float mid   = exp(-d * d * 6.0);
30    float spill = exp(-d * d * 1.8);
31    return core * 0.55 + inner * 0.30 + mid * 0.12 + spill * 0.03;
32  }
33
34  float stripeDistance(float w, float z) {
35    float diag = w + z;
36    float cell = mod(diag + uStripeSpacing * 0.5, uStripeSpacing) - uStripeSpacing * 0.5;
37    return abs(cell);
38  }
39
40  float stripeVar(float w, float z) {
41    float diag = w + z;
42    float idx  = floor((diag + uStripeSpacing * 0.5) / uStripeSpacing);
43    return 0.85 + 0.15 * hash(idx);
44  }
45
46  vec3 shadeSurface(
47    float w, float z, float t,
48    vec3 surfColor, float intensityMul,
49    float edgeParam, float ambientLvl
50  ) {
51    float dist = stripeDistance(w, z);
52    float norm = dist / max(uStripeWidth, 0.001);
53    float glow = milkyGlow(norm)
54               * stripeVar(w, z)
55               * (1.0 + 0.02 * sin(uTime * 0.7))
56               * uGlowIntensity * intensityMul;
57    float cw = smoothstep(0.25, 0.0, norm);
58    vec3 lit  = mix(surfColor, vec3(1.0), cw * 0.85);
59    float fog = exp(-t * uFogDensity);
60    float eDist = min(edgeParam, 1.0 - edgeParam);
61    float edge  = exp(-eDist * eDist * 600.0) * 0.04;
62    return (lit * glow + ambientLvl + edge * surfColor * 0.5) * fog;
63  }
64
65  void main() {
66    vec2 aspect = uResolution / min(uResolution.x, uResolution.y);
67    vec2 screen = (gl_FragCoord.xy / uResolution - 0.5) * aspect;
68    vec3 ro = vec3(0.0, CAM_Y, 0.0);
69    vec3 rd = normalize(vec3(screen, FOCAL_LEN));
70
71    float halfW = uTunnelWidth * 0.5;
72    float halfH = uTunnelHeight * 0.5;
73    float h2    = 2.0 * halfH;
74    float motion = uTime * uSpeed;
75
76    float tlX = -halfW * uTopScale + uSkew;
77    float trX =  halfW * uTopScale + uSkew;
78    float lSlope = (tlX + halfW) / h2;
79    float rSlope = (trX - halfW) / h2;
80
81    float rwLen = length(vec2(trX - halfW, h2));
82    float cLen  = max(trX - tlX, 0.01);
83    float lwLen = length(vec2(tlX + halfW, h2));
84    float fLen  = 2.0 * halfW;
85
86    vec3  color = vec3(0.0);
87    float tBest = 1e6;
88    float t; vec3 p;
89
90    /* RIGHT WALL */
91    { float denom = rd.x - rSlope * rd.y;
92      if (abs(denom) > 1e-6) {
93        t = (halfW + rSlope * (ro.y + halfH) - ro.x) / denom;
94        if (t > 0.01 && t < tBest) { p = ro + t * rd;
95          if (p.y > -halfH && p.y < halfH) { tBest = t;
96            float param = (p.y + halfH) / h2;
97            color = shadeSurface(param * rwLen, p.z + motion, t,
98              mix(uPrimaryColor, uSecondaryColor, 0.25), 1.0, param, 0.001);
99    }}}}
100
101    /* CEILING */
102    if (rd.y > 1e-6) {
103      t = (halfH - ro.y) / rd.y;
104      if (t > 0.01 && t < tBest) { p = ro + t * rd;
105        if (p.x > tlX && p.x < trX) { tBest = t;
106          float param = (trX - p.x) / cLen;
107          color = shadeSurface(rwLen + param * cLen, p.z + motion, t,
108            mix(uPrimaryColor, uAccentColor, 0.15), 1.05, param, 0.001);
109    }}}
110
111    /* LEFT WALL */
112    { float denom = rd.x - lSlope * rd.y;
113      if (abs(denom) > 1e-6) {
114        t = (-halfW + lSlope * (ro.y + halfH) - ro.x) / denom;
115        if (t > 0.01 && t < tBest) { p = ro + t * rd;
116          if (p.y > -halfH && p.y < halfH) { tBest = t;
117            float param = (halfH - p.y) / h2;
118            color = shadeSurface(rwLen + cLen + param * lwLen, p.z + motion, t,
119              mix(uPrimaryColor, uSecondaryColor, 0.30), 1.0, param, 0.001);
120    }}}}
121
122    /* FLOOR */
123    if (rd.y < -1e-6) {
124      t = (-halfH - ro.y) / rd.y;
125      if (t > 0.01 && t < tBest) { p = ro + t * rd;
126        if (p.x > -halfW && p.x < halfW) { tBest = t;
127          float param = (p.x + halfW) / fLen;
128          float w = rwLen + cLen + lwLen + param * fLen;
129          float z = p.z + motion;
130          vec3 surfCol = mix(uPrimaryColor, uSecondaryColor, 0.4);
131          vec3 floorC = shadeSurface(w, z, t, surfCol, 0.3, param, 0.0005);
132          float ceilParam = clamp((trX - p.x) / cLen, 0.0, 1.0);
133          float ceilW = rwLen + ceilParam * cLen;
134          float rDist = stripeDistance(ceilW, z);
135          float rNorm = rDist / max(uStripeWidth * 1.5, 0.001);
136          float refl  = milkyGlow(rNorm) * 0.12 * uGlowIntensity;
137          float fog   = exp(-t * uFogDensity);
138          color = floorC + surfCol * refl * fog;
139    }}}
140
141    /* Vanishing-point glow */
142    vec2  vpOff  = screen - vec2(0.0, CAM_Y * 0.3);
143    float vpDist = length(vpOff);
144    color += mix(uPrimaryColor, uAccentColor, 0.5) * exp(-vpDist * vpDist * 10.0) * 0.06 * uGlowIntensity;
145
146    /* Atmospheric haze */
147    if (tBest < 1e5) color += uPrimaryColor * (1.0 - exp(-tBest * uFogDensity * 0.2)) * 0.015;
148
149    /* Filmic tone-map (bakes in gamma) */
150    vec3 x = max(vec3(0.0), color - 0.004);
151    color = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
152
153    gl_FragColor = vec4(color, 1.0);
154  }
155`;function z(o,a,f){const r=o.createShader(a);return r?(o.shaderSource(r,f),o.compileShader(r),o.getShaderParameter(r,o.COMPILE_STATUS)?r:(console.error(o.getShaderInfoLog(r)),o.deleteShader(r),null)):null}function Y(o,a,f){const r=z(o,o.VERTEX_SHADER,a),u=z(o,o.FRAGMENT_SHADER,f);if(!r||!u)return null;const n=o.createProgram();return o.attachShader(n,r),o.attachShader(n,u),o.linkProgram(n),o.getProgramParameter(n,o.LINK_STATUS)?(o.deleteShader(r),o.deleteShader(u),n):(console.error(o.getProgramInfoLog(n)),null)}function S(o){const a=o.replace("#","");return[parseInt(a.slice(0,2),16)/255,parseInt(a.slice(2,4),16)/255,parseInt(a.slice(4,6),16)/255]}function q({speed:o=.3,glowIntensity:a=1.95,stripeWidth:f=.725,stripeSpacing:r=2.2,primaryColor:u="#FF01AA",secondaryColor:n="#FF5101",accentColor:y="#ffcc44",fogDensity:g=.1,tunnelWidth:w=3,tunnelHeight:x=1.7,topScale:v=1,skew:C=0,className:H=""}){const L=d.useRef(null),h=d.useRef(0);return d.useEffect(()=>{const i=L.current;if(!i)return;const e=i.getContext("webgl",{antialias:!1,alpha:!1,powerPreference:"high-performance"});if(!e)return;const m=Y(e,V,U);if(!m)return;e.useProgram(m);const I=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,I),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),e.STATIC_DRAW);const A=e.getAttribLocation(m,"aPosition");e.enableVertexAttribArray(A),e.vertexAttribPointer(A,2,e.FLOAT,!1,0,0);const _=["uTime","uResolution","uSpeed","uGlowIntensity","uStripeWidth","uStripeSpacing","uPrimaryColor","uSecondaryColor","uAccentColor","uFogDensity","uTunnelWidth","uTunnelHeight","uTopScale","uSkew"],t={};for(const l of _)t[l]=e.getUniformLocation(m,l);let R=0,T=0;const P=()=>{const l=Math.min(window.devicePixelRatio||1,2),p=i.getBoundingClientRect(),c=Math.round(p.width*l),s=Math.round(p.height*l);(c!==R||s!==T)&&(R=c,T=s,i.width=c,i.height=s,e.viewport(0,0,c,s))},F=new ResizeObserver(P);F.observe(i),P();let W=0,b=performance.now();const D=l=>{const p=Math.min((l-b)/1e3,.05);b=l,W+=p,e.uniform1f(t.uTime,W),e.uniform2f(t.uResolution,i.width,i.height),e.uniform1f(t.uSpeed,o),e.uniform1f(t.uGlowIntensity,a),e.uniform1f(t.uStripeWidth,f),e.uniform1f(t.uStripeSpacing,r),e.uniform1f(t.uFogDensity,g),e.uniform1f(t.uTunnelWidth,w),e.uniform1f(t.uTunnelHeight,x),e.uniform1f(t.uTopScale,v),e.uniform1f(t.uSkew,C);const[c,s,B]=S(u);e.uniform3f(t.uPrimaryColor,c,s,B);const[E,G,X]=S(n);e.uniform3f(t.uSecondaryColor,E,G,X);const[k,M,N]=S(y);e.uniform3f(t.uAccentColor,k,M,N),e.drawArrays(e.TRIANGLE_STRIP,0,4),h.current=requestAnimationFrame(D)};
155return h.current=requestAnimationFrame(D),()=>{cancelAnimationFrame(h.current),F.disconnect()}},[o,a,f,r,u,n,y,g,w,x,v,C]),O.jsx("canvas",{ref:L,className:H,style:{width:"100%",height:"100%",display:"block"}})}export{q as CybercabTunnelBg};

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.