The showcase prompt, Gemini 4 Carbon
agent (cont.)
+17:04read_file{"EndLine":1160,"Path":"~/run/index.html","StartLine":816}
input
{ "EndLine": 1160, "Path": "~/run/index.html", "StartLine": 816 }result, 346 lines
Showing lines 816-1160 of 3336 816: } 817: 818: float sdBoxFrame(vec3 p, vec3 b, float e) { 819: p = abs(p) - b; 820: vec3 q = abs(p + e) - e; 821: return min(min( 822: length(max(vec3(p.x, q.y, q.z), 0.0)) + min(max(p.x, max(q.y, q.z)), 0.0), 823: length(max(vec3(q.x, p.y, q.z), 0.0)) + min(max(q.x, max(p.y, q.z)), 0.0)), 824: length(max(vec3(q.x, q.y, p.z), 0.0)) + min(max(q.x, max(q.y, p.z)), 0.0)); 825: } 826: 827: float sdMachinedRing(vec3 p, float r, float halfW, float halfH) { 828: vec2 d = abs(vec2(length(p.xz) - r, p.y)) - vec2(halfW, halfH); 829: return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - 0.012; 830: } 831: 832: // Returns vec2(distance, materialID) 833: // matID: 1=Basalt Frame, 2=Refractive Crystal Core, 3=Solar Brass Gimbal, 4=Laser Cut Face, 5=Metrology Floor 834: vec2 mapScene(vec3 p) { 835: // Architectural basalt outer cage 836: vec3 pf = p; 837: pf.xz *= rot(0.22 * sin(u_time * 0.35)); 838: float cage = sdBoxFrame(pf, vec3(0.86), 0.072) - 0.012; 839: float cornerTrim = sdOctahedron(pf, 1.52); 840: cage = max(cage, cornerTrim); 841: // Bore precision apertures along axes 842: vec3 ap = abs(pf); 843: float bores = min(min(length(ap.xy), length(ap.yz)), length(ap.xz)) - 0.30; 844: cage = max(cage, -bores); 845: 846: // Counter-rotating machined brass gimbals 847: vec3 pg1 = p; 848: pg1.xy *= rot(0.62); 849: pg1.xz *= rot(u_time * 0.55); 850: float ring1 = sdMachinedRing(pg1, 0.68, 0.036, 0.055); 851: float ticks1 = sin(atan(pg1.z, pg1.x) * 24.0) * 0.004; 852: ring1 += ticks1; 853: 854: vec3 pg2 = p; 855: pg2.yz *= rot(-0.78); 856: pg2.xz *= rot(-u_time * 0.72); 857: float ring2 = sdMachinedRing(pg2, 0.53, 0.030, 0.044); 858: 859: float gimbals = min(ring1, ring2); 860: 861: // Inner dispersive crystal polyhedron 862: vec3 pc = p; 863: pc.xz *= rot(-u_time * 0.42); 864: pc.xy *= rot(u_time * 0.29); 865: float core = max(sdRoundBox(pc, vec3(0.33), 0.025), sdOctahedron(pc, 0.52)); 866: 867: // Combine solid assembly 868: vec2 res = vec2(cage, 1.0); 869: if (gimbals < res.x) res = vec2(gimbals, 3.0); 870: if (core < res.x) res = vec2(core, 2.0); 871: 872: // Interactive CSG cross-section plane 873: vec3 cutN = normalize(vec3(0.62, 0.52, 0.58)); 874: float dSlice = dot(p, cutN) - u_slice; 875: if (dSlice > res.x) { 876: res = vec2(dSlice, 4.0); 877: } else if (abs(dSlice - res.x) < 0.016 && dSlice > -0.02) { 878: res.y = 4.0; 879: } 880: 881: // Metrology studio floor 882: float floorD = p.y + 1.22; 883: if (floorD < res.x) res = vec2(floorD, 5.0); 884: 885: return res; 886: } 887: 888: vec3 calcNormal(vec3 p) { 889: const vec2 e = vec2(0.0012, -0.0012); 890: return normalize( 891: e.xyy * mapScene(p + e.xyy).x + 892: e.yyx * mapScene(p + e.yyx).x + 893: e.yxy * mapScene(p + e.yxy).x + 894: e.xxx * mapScene(p + e.xxx).x 895: ); 896: } 897: 898: float calcAO(vec3 pos, vec3 nor) { 899: float occ = 0.0; 900: float sca = 1.0; 901: for (int i = 0; i < 5; i++) { 902: float h = 0.02 + 0.11 * float(i) / 4.0; 903: float d = mapScene(pos + h * nor).x; 904: occ += (h - d) * sca; 905: sca *= 0.72; 906: } 907: return clamp(1.0 - 2.4 * occ, 0.0, 1.0); 908: } 909: 910: float calcSoftShadow(vec3 ro, vec3 rd) { 911: float res = 1.0; 912: float t = 0.04; 913: for (int i = 0; i < 24; i++) { 914: float h = mapScene(ro + rd * t).x; 915: res = min(res, 10.0 * h / t); 916: t += clamp(h, 0.025, 0.18); 917: if (res < 0.005 || t > 3.5) break; 918: } 919: return clamp(res, 0.0, 1.0); 920: } 921: 922: vec3 envDome(vec3 rd) { 923: float up = clamp(rd.y * 0.5 + 0.5, 0.0, 1.0); 924: vec3 col = mix(vec3(0.025, 0.03, 0.042), vec3(0.09, 0.105, 0.14), up); 925: // Warm solar studio strip 926: float strip1 = pow(max(dot(rd, normalize(vec3(0.7, 0.55, 0.4))), 0.0), 18.0); 927: // Cool verdigris rim strip 928: float strip2 = pow(max(dot(rd, normalize(vec3(-0.75, 0.35, -0.5))), 0.0), 14.0); 929: col += vec3(1.0, 0.42, 0.16) * strip1 * 1.35; 930: col += vec3(0.22, 0.85, 0.72) * strip2 * 0.85; 931: return col; 932: } 933: 934: vec3 renderOptics(vec2 uv) { 935: float yaw = u_camRot.x; 936: float pitch = clamp(u_camRot.y, -1.05, 1.05); 937: float dist = 3.35; 938: vec3 ro = vec3(sin(yaw) * cos(pitch), sin(pitch) * 0.85 + 0.18, cos(yaw) * cos(pitch)) * dist; 939: vec3 ta = vec3(0.0, -0.08, 0.0); 940: vec3 ww = normalize(ta - ro); 941: vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0))); 942: vec3 vv = cross(uu, ww); 943: vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.85 * ww); 944: 945: vec3 bg = vec3(0.028, 0.032, 0.044) + 0.03 * max(0.0, 1.0 - length(uv) * 0.75); 946: 947: // Bounding check: sphere radius 1.75 around origin OR floor y = -1.22 948: float b = dot(ro, rd); 949: float c = dot(ro, ro) - 3.15; 950: float disc = b * b - c; 951: bool hitFloorPossible = (rd.y < -0.001 && ro.y > -1.22); 952: if (disc < 0.0 && !hitFloorPossible) { 953: return bg; 954: } 955: 956: float t = 0.2; 957: float mat = -1.0; 958: float glowAcc = 0.0; 959: for (int i = 0; i < 68; i++) { 960: vec3 p = ro + rd * t; 961: vec2 h = mapScene(p); 962: // Subtle volumetric caustics near crystal core 963: float coreProx = length(p); 964: glowAcc += 0.0032 / (0.09 + coreProx * coreProx * 3.5); 965: if (h.x < 0.0014) { 966: mat = h.y; 967: break; 968: } 969: t += h.x * 0.92; 970: if (t > 7.5) break; 971: } 972: 973: vec3 col = bg; 974: if (mat > 0.0) { 975: vec3 p = ro + rd * t; 976: vec3 n = calcNormal(p); 977: float ao = calcAO(p, n); 978: 979: if (u_pass > 0.5 && u_pass < 1.5) { 980: // Pass 1: World-space Normal + Fresnel Inspection 981: float fres = pow(1.0 - max(dot(-rd, n), 0.0), 3.0); 982: col = (n * 0.5 + 0.5) * (0.65 + 0.35 * ao) + fres * 0.25; 983: return pow(clamp(col, 0.0, 1.0), vec3(0.85)); 984: } 985: 986: if (u_pass >= 1.5 && u_pass < 2.5) { 987: // Pass 2: Signed-Distance Iso-Contour Metrology Pass 988: float iso = abs(fract(length(p) * 14.0 - u_time * 0.6) - 0.5); 989: float lines = smoothstep(0.08, 0.015, iso); 990: float wire = smoothstep(0.03, 0.005, abs(fract((p.x + p.y + p.z) * 9.0) - 0.5)); 991: col = vec3(0.05, 0.07, 0.09) * ao; 992: col += vec3(0.22, 0.83, 0.70) * lines * 0.85; 993: col += vec3(1.0, 0.36, 0.14) * wire * 0.45; 994: return col; 995: } 996: 997: if (u_pass >= 2.5) { 998: // Pass 3: Architectural Clay + Studio AO Pass 999: vec3 keyL = normalize(vec3(0.65, 0.75, 0.38)); 1000: float dif = max(dot(n, keyL), 0.0); 1001: float sh = (mat < 4.5) ? calcSoftShadow(p + n * 0.01, keyL) : 1.0; 1002: vec3 clay = vec3(0.84, 0.81, 0.76); 1003: col = clay * (0.22 * ao + 0.78 * dif * sh * ao); 1004: if (mat > 4.5) { 1005: float rGrid = abs(fract(length(p.xz) * 2.5) - 0.5); 1006: col *= mix(0.22, 0.34, smoothstep(0.02, 0.06, rGrid)) * exp(-0.28 * length(p.xz)); 1007: } 1008: return pow(clamp(col, 0.0, 1.0), vec3(0.9)); 1009: } 1010: 1011: // Pass 0: Full Studio PBR + 3-Wavelength Chromatic Dispersion 1012: vec3 keyDir = normalize(vec3(0.68, 0.66, 0.32)); 1013: vec3 rimDir = normalize(vec3(-0.72, 0.35, -0.58)); 1014: float dif = max(dot(n, keyDir), 0.0); 1015: float rim = max(dot(n, rimDir), 0.0); 1016: float fres = pow(1.0 - max(dot(-rd, n), 0.0), 4.0); 1017: 1018: if (mat > 4.5) { 1019: // Metrology Turntable Floor 1020: float sh = calcSoftShadow(p + n * 0.015, keyDir); 1021: float rad = length(p.xz); 1022: float ringLine = 1.0 - smoothstep(0.0, 0.015, abs(fract(rad * 2.0) - 0.5) - 0.485); 1023: float axisLine = 1.0 - smoothstep(0.0, 0.012, min(abs(p.x), abs(p.z))); 1024: vec3 baseF = vec3(0.032, 0.036, 0.048) * (0.4 + 0.6 * sh) * ao; 1025: baseF += vec3(0.22, 0.25, 0.30) * (ringLine * 0.28 + axisLine * 0.22) * exp(-0.55 * rad); 1026: // Glossy reflection hint 1027: vec3 refl = envDome(reflect(rd, n)); 1028: col = mix(baseF, refl * sh, 0.14) * exp(-0.18 * rad * rad) + bg * (1.0 - exp(-0.18 * rad * rad)); 1029: } else if (mat > 1.5 && mat < 2.5) { 1030: // Dispersive Crystal Core (RGB split IOR) 1031: vec3 rR = envDome(refract(rd, n, 1.0 / 1.41)); 1032: vec3 rG = envDome(refract(rd, n, 1.0 / 1.49)); 1033: vec3 rB = envDome(refract(rd, n, 1.0 / 1.58)); 1034: vec3 refracted = vec3(rR.r, rG.g, rB.b) * 1.75; 1035: // Internal incandescent solar heart 1036: float heart = exp(-5.0 * length(p)); 1037: refracted += vec3(1.0, 0.40, 0.12) * heart * 1.4 + vec3(0.22, 0.85, 0.72) * (1.0 - heart) * 0.22; 1038: vec3 refl = envDome(reflect(rd, n)); 1039: col = mix(refracted, refl * 1.3, 0.22 + 0.68 * fres); 1040: col += vec3(1.0, 0.82, 0.55) * pow(max(dot(reflect(-keyDir, n), -rd), 0.0), 42.0) * 1.2; 1041: } else if (mat > 2.5 && mat < 3.5) { 1042: // Anodized Solar Brass Gimbal Rings 1043: float sh = calcSoftShadow(p + n * 0.01, keyDir); 1044: vec3 alb = vec3(0.92, 0.58, 0.22); 1045: vec3 h = normalize(keyDir - rd); 1046: float spec = pow(max(dot(n, h), 0.0), 36.0); 1047: col = alb * (0.14 * ao + 0.75 * dif * sh) + alb * spec * 1.4 * sh + vec3(0.22, 0.83, 0.70) * rim * 0.25 * ao; 1048: col += envDome(reflect(rd, n)) * (0.18 + 0.45 * fres); 1049: } else if (mat > 3.5 && mat < 4.5) { 1050: // Machined CSG Cross-Section Face (diagonal metrology hatch + heated laser rim) 1051: float hatch = smoothstep(-0.2, 0.2, sin((p.x - p.y + p.z) * 85.0)); 1052: vec3 faceCol = mix(vec3(0.10, 0.11, 0.14), vec3(0.24, 0.22, 0.20), hatch) * (0.5 + 0.5 * ao); 1053: // Outer boundary laser heat glow 1054: vec3 pOff = p - normalize(vec3(0.62, 0.52, 0.58)) * 0.018; 1055: float edgeProx = abs(mapScene(pOff).x); 1056: float rimHeat = exp(-42.0 * edgeProx); 1057: col = faceCol + vec3(1.0, 0.36, 0.10) * rimHeat * 1.65; 1058: } else { 1059: // Etched Basalt Titanium Outer Frame 1060: float sh = calcSoftShadow(p + n * 0.01, keyDir); 1061: vec3 alb = vec3(0.14, 0.155, 0.19); 1062: vec3 h = normalize(keyDir - rd); 1063: float spec = pow(max(dot(n, h), 0.0), 28.0); 1064: col = alb * (0.20 * ao + 0.85 * dif * sh) + vec3(0.95, 0.88, 0.80) * spec * 0.55 * sh; 1065: col += vec3(0.22, 0.83, 0.70) * rim * 0.22 * ao + envDome(reflect(rd, n)) * (0.10 + 0.35 * fres); 1066: } 1067: } 1068: 1069: col += vec3(1.0, 0.38, 0.14) * glowAcc * 0.28; 1070: return col; 1071: } 1072: 1073: void main() { 1074: vec2 uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y); 1075: 1076: // Subtle architectural background grid across all modes 1077: vec2 gUV = uv * 9.0; 1078: vec2 grid = abs(fract(gUV - 0.5) - 0.5) / fwidth(gUV); 1079: float line = 1.0 - min(min(grid.x, grid.y), 1.0); 1080: vec3 base = vec3(0.027, 0.031, 0.043) + vec3(0.025, 0.028, 0.036) * line * 0.45; 1081: 1082: vec3 total = vec3(0.0); 1083: 1084: // 01: Raymarched 3D Optics (evaluated only while visible) 1085: if (u_weights.x > 0.004) { 1086: total += renderOptics(uv) * u_weights.x; 1087: } 1088: 1089: // 02: Spacetime Potential Lensing for Continuum Physics 1090: if (u_weights.y > 0.004) { 1091: vec3 cCol = base; 1092: float pot = 0.0; 1093: for (int i = 0; i < 4; i++) { 1094: vec4 w = u_wells[i]; 1095: if (abs(w.z) > 0.01) { 1096: float d = length(uv - w.xy); 1097: pot += w.z * 0.045 / (d + 0.055); 1098: float ring = exp(-28.0 * abs(d - 0.09 - 0.02 * sin(u_time * 4.0 + float(i)))); 1099: cCol += (w.z > 0.0 ? vec3(1.0, 0.35, 0.14) : vec3(0.22, 0.83, 0.70)) * ring * 0.45; 1100: } 1101: } 1102: float equipot = abs(fract(pot * 4.5 - u_time * 0.25) - 0.5); 1103: cCol += vec3(0.16, 0.32, 0.36) * (1.0 - smoothstep(0.0, 0.06, equipot)) * 0.35; 1104: if (u_shock.z > 0.001 && u_shock.z < 2.2) { 1105: float sd = abs(length(uv - u_shock.xy) - u_shock.z); 1106: cCol += vec3(1.0, 0.62, 0.24) * exp(-36.0 * sd) * (1.0 - u_shock.z / 2.2) * 0.9; 1107: } 1108: total += cCol * u_weights.y; 1109: } 1110: 1111: // 03: Studio Depth Halo for Talos-06 Automaton 1112: if (u_weights.z > 0.004) { 1113: float d = length(uv - vec2(0.0, 0.04)); 1114: vec3 pCol = base; 1115: vec3 aura = mix(vec3(0.22, 0.83, 0.70), vec3(1.0, 0.35, 0.14), clamp(u_arousal.y, 0.0, 1.0)); 1116: aura = mix(aura, vec3(0.95, 0.70, 0.25), clamp(u_arousal.x * 0.6, 0.0, 1.0)); 1117: pCol += aura * exp(-4.2 * d * d) * 0.20; 1118: float reticle = abs(fract(d * 7.0 - u_time * 0.18) - 0.5); 1119: pCol += aura * (1.0 - smoothstep(0.0, 0.025, reticle)) * exp(-2.5 * d) * 0.08; 1120: total += pCol * u_weights.z; 1121: } 1122: 1123: // 04: Harmonic Wavefront Ripples for Euclidean Synth 1124: if (u_weights.w > 0.004) { 1125: float r = length(uv - vec2(0.0, 0.03)); 1126: vec3 hCol = base; 1127: float radii[4] = float[4](0.36, 0.275, 0.195, 0.12); 1128: vec3 cols[4] = vec3[4]( 1129: vec3(0.95, 0.70, 0.25), 1130: vec3(0.22, 0.83, 0.70), 1131: vec3(0.94, 0.92, 0.88), 1132: vec3(1.00, 0.35, 0.14) 1133: ); 1134: float pulses[4] = float[4](u_pulse.x, u_pulse.y, u_pulse.z, u_pulse.w); 1135: for (int i = 0; i < 4; i++) { 1136: float wave = exp(-34.0 * abs(r - radii[i])) * (0.12 + 0.95 * pulses[i]); 1137: hCol += cols[i] * wave * 0.45; 1138: } 1139: total += hCol * u_weights.w; 1140: } 1141: 1142: // 05: Citadel Architectural Schematic Field 1143: if (u_w4 > 0.004) { 1144: vec3 sCol = base * 0.92; 1145: float scan = exp(-18.0 * abs(uv.x - (mod(u_time * 0.28, 2.4) - 1.2))); 1146: sCol += vec3(1.0, 0.36, 0.14) * scan * 0.045; 1147: total += sCol * u_w4; 1148: } 1149: 1150: // Subtle vignette & ACES-inspired filmic curve 1151: float vig = 1.0 - 0.28 * dot(uv, uv); 1152: total *= clamp(vig, 0.55, 1.0); 1153: total = (total * (2.51 * total + 0.03)) / (total * (2.43 * total + 0.59) + 0.14); 1154: fragColor = vec4(pow(clamp(total, 0.0, 1.0), vec3(0.92)), 1.0); 1155: } 1156: </script> 1157: 1158: <script> 1159: (() => { 1160: 'use strict';read_file{"EndLine":2300,"Path":"~/run/index.html","StartLine":1500}
input
{ "EndLine": 2300, "Path": "~/run/index.html", "StartLine": 1500 }result, 801 lines
Showing lines 1500-2299 of 3336 1500: gl.attachShader(glProg, vs); 1501: gl.attachShader(glProg, fs); 1502: gl.linkProgram(glProg); 1503: if (gl.getProgramParameter(glProg, gl.LINK_STATUS)) { 1504: gl.useProgram(glProg); 1505: const buf = gl.createBuffer(); 1506: gl.bindBuffer(gl.ARRAY_BUFFER, buf); 1507: gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW); 1508: const loc = gl.getAttribLocation(glProg, 'a_pos'); 1509: gl.enableVertexAttribArray(loc); 1510: gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0); 1511: 1512: ['u_res', 'u_time', 'u_mouse', 'u_weights', 'u_w4', 'u_camRot', 'u_slice', 'u_pass', 'u_shock', 'u_arousal', 'u_pulse'].forEach(n => { 1513: glUni[n] = gl.getUniformLocation(glProg, n); 1514: }); 1515: glUni.u_wells = []; 1516: for (let i = 0; i < 4; i++) glUni.u_wells.push(gl.getUniformLocation(glProg, `u_wells[${i}]`)); 1517: } else { 1518: console.error('Link error:', gl.getProgramInfoLog(glProg)); 1519: glProg = null; 1520: } 1521: } 1522: } 1523: 1524: function resize() { 1525: W = window.innerWidth; 1526: H = window.innerHeight; 1527: DPR = Math.min(window.devicePixelRatio || 1, 2); 1528: // Slight cap on raymarch DPI for huge 4K monitors to guarantee locked 60fps 1529: const glScale = Math.min(DPR, (W * H > 1400000) ? 1.35 : 1.75); 1530: glCanvas.width = Math.max(1, Math.floor(W * glScale)); 1531: glCanvas.height = Math.max(1, Math.floor(H * glScale)); 1532: hudCanvas.width = Math.max(1, Math.floor(W * DPR)); 1533: hudCanvas.height = Math.max(1, Math.floor(H * DPR)); 1534: if (gl) gl.viewport(0, 0, glCanvas.width, glCanvas.height); 1535: layoutCitadelNodes(); 1536: } 1537: window.addEventListener('resize', resize); 1538: 1539: /* ========================================================================= 1540: 3. MODE 01 STATE: 3D OPTICS & PIPELINE TELEMETRY 1541: ========================================================================= */ 1542: const optics = { 1543: yaw: 0.58, 1544: pitch: 0.34, 1545: vYaw: 0.0035, 1546: vPitch: 0, 1547: slice: 0.28, 1548: userSliced: false, 1549: pass: 0 1550: }; 1551: 1552: function projectOpticsPin(p3) { 1553: const yaw = optics.yaw; 1554: const pitch = Math.max(-1.05, Math.min(1.05, optics.pitch)); 1555: const dist = 3.35; 1556: const ro = [Math.sin(yaw) * Math.cos(pitch) * dist, Math.sin(pitch) * 0.85 * dist + 0.18 * dist, Math.cos(yaw) * Math.cos(pitch) * dist]; 1557: const ta = [0, -0.08, 0]; 1558: const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]; 1559: const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; 1560: const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]; 1561: const norm = a => { const l = Math.hypot(a[0], a[1], a[2]) || 1; return [a[0] / l, a[1] / l, a[2] / l]; }; 1562: const ww = norm(sub(ta, ro)); 1563: const uu = norm(cross(ww, [0, 1, 0])); 1564: const vv = cross(uu, ww); 1565: const rel = sub(p3, ro); 1566: const z = dot(rel, ww); 1567: if (z <= 0.2) return null; 1568: const ux = (dot(rel, uu) / z) * 1.85; 1569: const uy = (dot(rel, vv) / z) * 1.85; 1570: const minDim = Math.min(W, H); 1571: return { 1572: x: W * 0.5 + ux * minDim, 1573: y: H * 0.5 - uy * minDim 1574: }; 1575: } 1576: 1577: /* ========================================================================= 1578: 4. MODE 02 ENGINE: 3,200-BODY LAGRANGIAN VORTEX CONTINUUM 1579: ========================================================================= */ 1580: const PARTICLE_COUNT = 3200; 1581: const pX = new Float32Array(PARTICLE_COUNT); 1582: const pY = new Float32Array(PARTICLE_COUNT); 1583: const pVX = new Float32Array(PARTICLE_COUNT); 1584: const pVY = new Float32Array(PARTICLE_COUNT); 1585: const pPX = new Float32Array(PARTICLE_COUNT); 1586: const pPY = new Float32Array(PARTICLE_COUNT); 1587: 1588: function initParticles() { 1589: for (let i = 0; i < PARTICLE_COUNT; i++) { 1590: const a = Math.random() * Math.PI * 2; 1591: const r = Math.sqrt(Math.random()) * 0.72; 1592: pX[i] = pPX[i] = Math.cos(a) * r * (W / Math.min(W, H)); 1593: pY[i] = pPY[i] = Math.sin(a) * r; 1594: pVX[i] = -Math.sin(a) * 0.004; 1595: pVY[i] = Math.cos(a) * 0.004; 1596: } 1597: } 1598: 1599: const continuum = { 1600: flowMode: 0, // 0:Accretion, 1:Curl Turbulence, 2:Dipole Lattice 1601: wells: [ 1602: { x: -0.26, y: 0.04, s: 1.0, age: 0 }, 1603: { x: 0.26, y: -0.04, s: -0.9, age: 1.5 }, 1604: { x: 0, y: 0, s: 0, age: 0 }, 1605: { x: 0, y: 0, s: 0, age: 0 } 1606: ], 1607: wellCursor: 2, 1608: shock: { x: 0, y: 0, r: 9.0 }, 1609: kineticEnergy: 0 1610: }; 1611: 1612: function stepPhysics(dt, time) { 1613: const aspect = W / Math.min(W, H); 1614: const hBound = H / Math.min(W, H) * 0.52; 1615: const wBound = aspect * 0.52; 1616: 1617: if (autoReel && activeMode === 1) { 1618: continuum.wells[0].x = Math.cos(time * 0.75) * 0.28; 1619: continuum.wells[0].y = Math.sin(time * 0.75) * 0.16; 1620: continuum.wells[0].s = 1.05; 1621: continuum.wells[1].x = -continuum.wells[0].x; 1622: continuum.wells[1].y = -continuum.wells[0].y; 1623: continuum.wells[1].s = -0.95; 1624: } 1625: 1626: if (continuum.shock.r < 2.5) { 1627: continuum.shock.r += dt * 1.95; 1628: } 1629: 1630: let keSum = 0; 1631: const fm = continuum.flowMode; 1632: const hasPtr = pointer.inside; 1633: const mx = pointer.nx, my = pointer.ny; 1634: const mvx = pointer.vx, mvy = pointer.vy; 1635: const sr = continuum.shock.r; 1636: const sx = continuum.shock.x, sy = continuum.shock.y; 1637: 1638: for (let i = 0; i < PARTICLE_COUNT; i++) { 1639: let x = pX[i], y = pY[i]; 1640: let vx = pVX[i], vy = pVY[i]; 1641: pPX[i] = x; 1642: pPY[i] = y; 1643: 1644: // Analytic divergence-free curl potential 1645: const sc = fm === 1 ? 5.2 : 3.1; 1646: const cx = Math.sin(y * sc + time * 0.7) + Math.cos((x + y) * sc * 0.7 - time * 0.45); 1647: const cy = Math.cos(x * sc - time * 0.65) - Math.sin((x - y) * sc * 0.7 + time * 0.5); 1648: const curlAmt = fm === 1 ? 0.00052 : 0.00021; 1649: vx += cx * curlAmt; 1650: vy += cy * curlAmt; 1651: 1652: if (fm === 2) { 1653: // Magnetic dipole field lines 1654: const r2 = x * x + y * y + 0.035; 1655: const r5 = Math.pow(r2, 1.8); 1656: vx += (3 * x * y) / r5 * 0.00009; 1657: vy += (2 * y * y - x * x) / r5 * 0.00009; 1658: } 1659: 1660: // Coupled vortex + accretion singularities 1661: for (let w = 0; w < 4; w++) { 1662: const well = continuum.wells[w]; 1663: if (Math.abs(well.s) < 0.01) continue; 1664: const dx = well.x - x; 1665: const dy = well.y - y; 1666: const d2 = dx * dx + dy * dy + 0.0045; 1667: const inv = 0.00026 / d2; 1668: // Swirl + gentle inward pull 1669: vx += (-dy * well.s * 1.35 + dx * 0.42) * inv; 1670: vy += (dx * well.s * 1.35 + dy * 0.42) * inv; 1671: } 1672: 1673: // Cursor momentum shear wake 1674: if (hasPtr) { 1675: const dx = x - mx; 1676: const dy = y - my; 1677: const d2 = dx * dx + dy * dy + 0.006; 1678: if (d2 < 0.12) { 1679: const inf = (0.12 - d2) * 0.14; 1680: vx += mvx * inf - dy * 0.0018 * inf; 1681: vy += mvy * inf + dx * 0.0018 * inf; 1682: } 1683: } 1684: 1685: // Expanding shockwave ring 1686: if (sr < 2.2) { 1687: const dx = x - sx, dy = y - sy; 1688: const dist = Math.sqrt(dx * dx + dy * dy) || 0.001; 1689: const band = Math.abs(dist - sr); 1690: if (band < 0.09) { 1691: const push = (1.0 - band / 0.09) * 0.0055; 1692: vx += (dx / dist) * push; 1693: vy += (dy / dist) * push; 1694: } 1695: } 1696: 1697: vx *= 0.982; 1698: vy *= 0.982; 1699: x += vx; 1700: y += vy; 1701: 1702: // Respawn escaped filaments gracefully near outer perimeter 1703: if (x < -wBound || x > wBound || y < -hBound || y > hBound) { 1704: const a = Math.random() * Math.PI * 2; 1705: x = pPX[i] = Math.cos(a) * 0.42 * aspect; 1706: y = pPY[i] = Math.sin(a) * 0.42; 1707: vx = -Math.sin(a) * 0.004; 1708: vy = Math.cos(a) * 0.004; 1709: } 1710: 1711: pX[i] = x; pY[i] = y; 1712: pVX[i] = vx; pVY[i] = vy; 1713: keSum += vx * vx + vy * vy; 1714: } 1715: continuum.kineticEnergy = keSum * 1000; 1716: } 1717: 1718: function drawContinuum(alpha) { 1719: const minDim = Math.min(W, H); 1720: const cx = W * 0.5, cy = H * 0.5; 1721: ctx.save(); 1722: ctx.globalCompositeOperation = 'lighter'; 1723: 1724: // Batch 3,200 filaments into 4 velocity-temperature paths (4 GPU draw calls total) 1725: const paths = [new Path2D(), new Path2D(), new Path2D(), new Path2D()]; 1726: for (let i = 0; i < PARTICLE_COUNT; i++) { 1727: const x1 = cx + pPX[i] * minDim; 1728: const y1 = cy - pPY[i] * minDim; 1729: const vx = pVX[i] * minDim; 1730: const vy = -pVY[i] * minDim; 1731: const x2 = cx + pX[i] * minDim + vx * 1.35; 1732: const y2 = cy - pY[i] * minDim + vy * 1.35; 1733: const sp2 = pVX[i] * pVX[i] + pVY[i] * pVY[i]; 1734: const bucket = sp2 > 0.00018 ? 3 : (sp2 > 0.000085 ? 2 : (sp2 > 0.000032 ? 1 : 0)); 1735: paths[bucket].moveTo(x1, y1); 1736: paths[bucket].lineTo(x2, y2); 1737: } 1738: 1739: const styles = [ 1740: `rgba(38, 152, 134, ${0.42 * alpha})`, 1741: `rgba(56, 212, 179, ${0.58 * alpha})`, 1742: `rgba(243, 179, 64, ${0.72 * alpha})`, 1743: `rgba(255, 96, 42, ${0.88 * alpha})` 1744: ]; 1745: ctx.lineCap = 'round'; 1746: for (let b = 0; b < 4; b++) { 1747: ctx.lineWidth = b === 3 ? 1.7 : 1.25; 1748: ctx.strokeStyle = styles[b]; 1749: ctx.stroke(paths[b]); 1750: } 1751: ctx.restore(); 1752: 1753: // Crisp vector reticles on active vortex wells 1754: ctx.save(); 1755: ctx.globalAlpha = alpha; 1756: ctx.font = '500 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono'); 1757: for (let w = 0; w < 4; w++) { 1758: const well = continuum.wells[w]; 1759: if (Math.abs(well.s) < 0.01) continue; 1760: const wx = cx + well.x * minDim; 1761: const wy = cy - well.y * minDim; 1762: ctx.strokeStyle = well.s > 0 ? 'rgba(255, 89, 36, 0.7)' : 'rgba(56, 212, 179, 0.7)'; 1763: ctx.lineWidth = 1; 1764: ctx.beginPath(); 1765: ctx.arc(wx, wy, 9, 0, Math.PI * 2); 1766: ctx.moveTo(wx - 14, wy); ctx.lineTo(wx - 5, wy); 1767: ctx.moveTo(wx + 5, wy); ctx.lineTo(wx + 14, wy); 1768: ctx.moveTo(wx, wy - 14); ctx.lineTo(wx, wy - 5); 1769: ctx.moveTo(wx, wy + 5); ctx.lineTo(wx, wy + 14); 1770: ctx.stroke(); 1771: ctx.fillStyle = 'rgba(239, 236, 228, 0.65)'; 1772: ctx.fillText(well.s > 0 ? `+Γ${w + 1}` : `-Γ${w + 1}`, wx + 13, wy - 9); 1773: } 1774: ctx.restore(); 1775: } 1776: 1777: /* ========================================================================= 1778: 5. MODE 03 ENGINE: TALOS-06 24-DOF PROCEDURAL EXPRESSION RIG 1779: ========================================================================= */ 1780: const talos = { 1781: preset: 'auto', // auto | curious | skeptical | startled | delighted 1782: yaw: 0, pitch: 0, roll: 0, zLean: 0, 1783: vYaw: 0, vPitch: 0, vRoll: 0, 1784: gazeX: 0, gazeY: 0, 1785: saccX: 0, saccY: 0, nextSaccade: 0, 1786: pupil: 0.48, 1787: blink: 0, nextBlink: 1.8, 1788: browL: 0, browR: 0, browTiltL: 0, browTiltR: 0, 1789: smile: 0, squintL: 0, squintR: 0, 1790: curiosity: 0.4, startle: 0, skepticism: 0.1, 1791: statusTag: 'OPTIC: CALIBRATING', 1792: boopTimer: 0 1793: }; 1794: 1795: function stepTalos(dt, time) { 1796: // Biological micro-saccades 1797: if (time > talos.nextSaccade) { 1798: talos.saccX = (Math.random() - 0.5) * 0.09; 1799: talos.saccY = (Math.random() - 0.5) * 0.06; 1800: talos.nextSaccade = time + 0.45 + Math.random() * 1.15; 1801: } 1802: // Natural blink rhythm 1803: if (time > talos.nextBlink) { 1804: talos.blink = 1.0; 1805: talos.nextBlink = time + 2.4 + Math.random() * 3.2; 1806: } 1807: talos.blink = Math.max(0, talos.blink - dt * 7.5); 1808: if (talos.boopTimer > 0) talos.boopTimer = Math.max(0, talos.boopTimer - dt); 1809: 1810: let tYaw = 0, tPitch = 0, tRoll = 0, tLean = 0; 1811: let tPupil = 0.48, tBrowL = 0, tBrowR = 0, tTiltL = 0, tTiltR = 0; 1812: let tSmile = 0.08, tSqL = 0, tSqR = 0; 1813: let tGX = 0, tGY = 0; 1814: 1815: let mode = talos.preset; 1816: if (mode === 'auto') { 1817: if (talos.boopTimer > 0.1) { 1818: mode = 'skeptical'; 1819: } else if (pointer.inside) { 1820: if (pointer.speed > 0.045) { 1821: talos.startle = Math.min(1, talos.startle + dt * 5.5); 1822: } else { 1823: talos.startle = Math.max(0, talos.startle - dt * 1.8); 1824: } 1825: const dist = Math.hypot(pointer.nx, pointer.ny); 1826: talos.curiosity = dist < 0.36 && pointer.speed < 0.02 ? Math.min(1, talos.curiosity + dt * 2.2) : Math.max(0.2, talos.curiosity - dt * 1.2); 1827: } else { 1828: // Expressive autonomous choreography during passive viewing 1829: const phase = (time * 0.65) % 4.0; 1830: if (phase < 1.1) mode = 'curious'; 1831: else if (phase < 2.2) mode = 'skeptical'; 1832: else if (phase < 3.1) mode = 'delighted'; 1833: else mode = 'auto_idle'; 1834: } 1835: } 1836: 1837: if (pointer.inside && talos.preset === 'auto' && talos.boopTimer <= 0.1) { 1838: tGX = Math.max(-0.85, Math.min(0.85, pointer.nx * 1.75)); 1839: tGY = Math.max(-0.75, Math.min(0.75, -pointer.ny * 1.75)); 1840: tYaw = tGX * 0.36; 1841: tPitch = tGY * 0.28; 1842: tRoll = tGX * 0.09 + Math.max(-0.28, Math.min(0.28, pointer.orbitAccum * 0.04)); 1843: 1844: if (Math.abs(pointer.orbitAccum) > 4.2) { 1845: tPupil = 0.68; 1846: tSmile = 0.65; 1847: tSqL = 0.35; tSqR = 0.35; 1848: talos.statusTag = 'STATE: DIZZY / AMUSED'; 1849: } else if (talos.startle > 0.45) { 1850: tPupil = 0.23; 1851: tBrowL = 0.75; tBrowR = 0.75; 1852: tTiltL = -0.32; tTiltR = -0.32; 1853: tLean = -0.22; 1854: talos.statusTag = 'REFLEX: HIGH VELOCITY'; 1855: } else if (talos.curiosity > 0.62) { 1856: tPupil = 0.68; 1857: tBrowL = 0.28; tBrowR = 0.28; 1858: tLean = 0.18; 1859: tRoll += 0.11; 1860: tSmile = 0.32; 1861: talos.statusTag = 'STATE: CURIOUS LOCK'; 1862: } else { 1863: talos.statusTag = 'OPTIC: SMOOTH PURSUIT'; 1864: } 1865: } else if (mode === 'curious') { 1866: tGX = Math.sin(time * 1.3) * 0.25; 1867: tGY = -0.08; 1868: tYaw = 0.16; tPitch = -0.06; tRoll = 0.14; tLean = 0.20; 1869: tPupil = 0.68; tBrowL = 0.35; tBrowR = 0.35; tSmile = 0.25; 1870: talos.curiosity = 0.85; talos.startle = 0; 1871: talos.statusTag = 'STATE: INQUISITIVE'; 1872: } else if (mode === 'skeptical') { 1873: tGX = pointer.inside ? pointer.nx * 1.2 : -0.22; 1874: tGY = 0.05; 1875: tYaw = -0.14; tPitch = 0.06; tRoll = -0.09; 1876: tPupil = 0.36; 1877: tBrowL = -0.35; tBrowR = 0.68; // Signature single-brow critic arch 1878: tTiltL = 0.28; tTiltR = -0.22; 1879: tSqL = 0.48; tSqR = 0.05; 1880: tSmile = -0.22; 1881: talos.skepticism = 0.92; talos.startle = 0; 1882: talos.statusTag = 'VERDICT: UNCONVINCED'; 1883: } else if (mode === 'startled') { 1884: tGX = (Math.random() - 0.5) * 0.16; 1885: tGY = -0.12; 1886: tPitch = -0.12; tLean = -0.26; 1887: tPupil = 0.21; 1888: tBrowL = 0.85; tBrowR = 0.85; 1889: tTiltL = -0.35; tTiltR = -0.35; 1890: tSmile = -0.35; 1891: talos.startle = 0.95; 1892: talos.statusTag = 'ALERT: APERTURE f/11'; 1893: } else if (mode === 'delighted') { 1894: tYaw = Math.sin(time * 2.1) * 0.09; 1895: tPitch = -0.08; tRoll = Math.sin(time * 2.1) * 0.08; tLean = 0.14; 1896: tPupil = 0.74; 1897: tBrowL = 0.42; tBrowR = 0.42; 1898: tSqL = 0.58; tSqR = 0.58;401 more lines not shown.