The showcase prompt, round 3, Gemini 4 Carbon
agent (cont.)
+51:34read_file{"EndLine":1600,"Path":"~/run/index.html","StartLine":801}
input
{ "EndLine": 1600, "Path": "~/run/index.html", "StartLine": 801 }result, 801 lines
Showing lines 801-1600 of 3164 801: const ix = px | 0, iy = py | 0, fx = px - ix, fy = py - iy; 802: const base = iy * N + ix; 803: Isim[base] += wSub * (1 - fx) * (1 - fy); 804: Isim[base + 1] += wSub * fx * (1 - fy); 805: Isim[base + N] += wSub * (1 - fx) * fy; 806: Isim[base + N + 1] += wSub * fx * fy; 807: } 808: } 809: } 810: } 811: let s = 0; 812: for (let i = 0; i < N * N; i++) s += Isim[i]; 813: if (s > 0) { const sc = sumRho0 / s; for (let i = 0; i < N * N; i++) Isim[i] *= sc; } 814: } 815: 816: function bSample(arr, N, gxPos, gyPos) { 817: const px = Math.max(0, Math.min(N - 1.001, gxPos - 0.5)); 818: const py = Math.max(0, Math.min(N - 1.001, gyPos - 0.5)); 819: const ix = px | 0, iy = py | 0, fx = px - ix, fy = py - iy; 820: const row = iy * N + ix; 821: return (1 - fx) * (1 - fy) * arr[row] + fx * (1 - fy) * arr[row + 1] + 822: (1 - fx) * fy * arr[row + N] + fx * fy * arr[row + N + 1]; 823: } 824: 825: const lv128 = createLevel(128); 826: const lv256 = createLevel(256); 827: 828: self.onmessage = (e) => { 829: const { id, target256, F, T_glass, nGlass, Z_light } = e.data; 830: const t0 = performance.now(); 831: updateIncidentRays(lv128, F, T_glass, nGlass, Z_light); 832: updateIncidentRays(lv256, F, T_glass, nGlass, Z_light); 833: 834: const N = 128; 835: const targ128 = new Float32Array(N * N); 836: let sumT128 = 0; 837: for (let y = 0; y < N; y++) { 838: for (let x = 0; x < N; x++) { 839: const i0 = (2 * y) * 256 + (2 * x); 840: // Enforce clean C^2 ambient floor & soft aperture margin so boundary stays diffeomorphic 841: const u = (x + 0.5) / N * 2 - 1, v = (y + 0.5) / N * 2 - 1; 842: const edge = Math.max(Math.abs(u), Math.abs(v)); 843: const wEdge = edge > 0.85 ? Math.max(0, 1 - (edge - 0.85) / 0.13) : 1.0; 844: let raw = 0.25 * (target256[i0] + target256[i0 + 1] + target256[i0 + 256] + target256[i0 + 257]); 845: raw = 0.032 + Math.max(0, raw - 0.032) * (wEdge * wEdge); 846: targ128[y * N + x] = raw; 847: sumT128 += raw; 848: } 849: } 850: const sc128 = lv128.sumRho0 / sumT128; 851: for (let i = 0; i < N * N; i++) targ128[i] *= sc128; 852: 853: const h128 = new Float32Array(N * N); 854: for (let y = 0; y < N; y++) { 855: for (let x = 0; x < N; x++) { 856: lv128.desX[y * N + x] = x + 0.5; 857: lv128.desY[y * N + x] = y + 0.5; 858: } 859: } 860: solveInverseSnellH(lv128, lv128.desX, lv128.desY, h128); 861: solveInverseSnellH(lv128, lv128.desX, lv128.desY, h128); 862: 863: const sigmas = [7.0, 4.2, 2.5, 1.4, 0.7, 0.0, 0.0, 0.0, 0.0]; 864: const meanI = lv128.sumRho0 / (N * N); 865: for (let iter = 0; iter < sigmas.length; iter++) { 866: const sig = sigmas[iter]; 867: lv128.dct.gaussianBlur(targ128, lv128.targBlur, sig); 868: traceSplatFast(lv128, h128); 869: if (sig > 0.2) lv128.dct.gaussianBlur(lv128.Isim, lv128.Isim, sig * 0.45); 870: for (let i = 0; i < N * N; i++) lv128.rhs[i] = lv128.Isim[i] - lv128.targBlur[i]; 871: lv128.dct.solvePoisson(lv128.rhs, lv128.psi); 872: for (let y = 0; y < N; y++) { 873: const ym = Math.max(0, y - 1), yp = Math.min(N - 1, y + 1), dyS = yp - ym; 874: for (let x = 0; x < N; x++) { 875: const xm = Math.max(0, x - 1), xp = Math.min(N - 1, x + 1), dxS = xp - xm; 876: lv128.gpX[y * N + x] = (lv128.psi[y * N + xp] - lv128.psi[y * N + xm]) / dxS; 877: lv128.gpY[y * N + x] = (lv128.psi[yp * N + x] - lv128.psi[ym * N + x]) / dyS; 878: } 879: } 880: for (let i = 0; i < N * N; i++) { 881: const rx = lv128.rX[i], ry = lv128.rY[i]; 882: const denom = Math.max(0.08 * meanI, 0.5 * (bSample(lv128.Isim, N, rx, ry) + bSample(lv128.targBlur, N, rx, ry))); 883: lv128.desX[i] = Math.max(0.5, Math.min(N - 0.5, rx + 0.80 * (bSample(lv128.gpX, N, rx, ry) / denom))); 884: lv128.desY[i] = Math.max(0.5, Math.min(N - 0.5, ry + 0.80 * (bSample(lv128.gpY, N, rx, ry) / denom))); 885: } 886: solveInverseSnellH(lv128, lv128.desX, lv128.desY, h128); 887: } 888: 889: const N2 = 256; 890: const h256 = new Float32Array(N2 * N2); 891: for (let y = 0; y < N2; y++) { 892: const gy = (y + 0.5) * 0.5; 893: for (let x = 0; x < N2; x++) { 894: h256[y * N2 + x] = bSample(h128, N, (x + 0.5) * 0.5, gy); 895: } 896: } 897: const targ256 = new Float32Array(N2 * N2); 898: let sumT2 = 0; 899: for (let y = 0; y < N2; y++) { 900: const v = (y + 0.5) / N2 * 2 - 1; 901: for (let x = 0; x < N2; x++) { 902: const u = (x + 0.5) / N2 * 2 - 1; 903: const edge = Math.max(Math.abs(u), Math.abs(v)); 904: const wEdge = edge > 0.85 ? Math.max(0, 1 - (edge - 0.85) / 0.13) : 1.0; 905: const idx = y * N2 + x; 906: const raw = 0.032 + Math.max(0, target256[idx] - 0.032) * (wEdge * wEdge); 907: targ256[idx] = raw; 908: sumT2 += raw; 909: } 910: } 911: const sc2 = lv256.sumRho0 / sumT2; 912: for (let i = 0; i < N2 * N2; i++) targ256[i] *= sc2; 913: const meanI2 = lv256.sumRho0 / (N2 * N2); 914: 915: for (let iter = 0; iter < 3; iter++) { 916: traceSplatFast(lv256, h256); 917: for (let i = 0; i < N2 * N2; i++) lv256.rhs[i] = lv256.Isim[i] - targ256[i]; 918: lv256.dct.solvePoisson(lv256.rhs, lv256.psi); 919: for (let y = 0; y < N2; y++) { 920: const ym = Math.max(0, y - 1), yp = Math.min(N2 - 1, y + 1), dyS = yp - ym; 921: for (let x = 0; x < N2; x++) { 922: const xm = Math.max(0, x - 1), xp = Math.min(N2 - 1, x + 1), dxS = xp - xm; 923: lv256.gpX[y * N2 + x] = (lv256.psi[y * N2 + xp] - lv256.psi[y * N2 + xm]) / dxS; 924: lv256.gpY[y * N2 + x] = (lv256.psi[yp * N2 + x] - lv256.psi[ym * N2 + x]) / dyS; 925: } 926: } 927: for (let i = 0; i < N2 * N2; i++) { 928: const rx = lv256.rX[i], ry = lv256.rY[i]; 929: const denom = Math.max(0.06 * meanI2, 0.5 * (bSample(lv256.Isim, N2, rx, ry) + bSample(targ256, N2, rx, ry))); 930: lv256.desX[i] = Math.max(0.5, Math.min(N2 - 0.5, rx + 0.75 * (bSample(lv256.gpX, N2, rx, ry) / denom))); 931: lv256.desY[i] = Math.max(0.5, Math.min(N2 - 0.5, ry + 0.75 * (bSample(lv256.gpY, N2, rx, ry) / denom))); 932: } 933: solveInverseSnellH(lv256, lv256.desX, lv256.desY, h256); 934: } 935: 936: let minH = Infinity, maxH = -Infinity; 937: for (let i = 0; i < N2 * N2; i++) { 938: if (h256[i] < minH) minH = h256[i]; 939: if (h256[i] > maxH) maxH = h256[i]; 940: } 941: const solveMs = performance.now() - t0; 942: self.postMessage({ 943: id, 944: h256, 945: minH, 946: maxH, 947: reliefMm: (maxH - minH) * 50.0, // 2.0 normalized units == 100mm physical width 948: solveMs 949: }, [h256.buffer]); 950: }; 951: `; 952: 953: // ============================================================================ 954: // 2. OPTICAL CONSTANTS & PROCEDURAL TARGET ARTWORKS (256 x 256) 955: // ============================================================================ 956: const N_GRID = 256; 957: const DESIGN_F = 1.72; // 86 mm design focal distance (1.0 unit = 50 mm) 958: const T_GLASS = 0.24; // 12 mm base optical crystal thickness 959: const DESIGN_Z_LIGHT = 4.55; // 228 mm lamp zenith height (framed directly in studio view!) 960: 961: const MATERIALS = { 962: bk7: { name: "Crown BK7", nD: 1.517, disp: 0.011, tint: [0.92, 0.98, 0.97] }, 963: silica: { name: "Fused Silica", nD: 1.458, disp: 0.008, tint: [0.96, 0.98, 1.00] }, 964: flint: { name: "Dense Flint", nD: 1.785, disp: 0.032, tint: [0.98, 0.96, 0.88] }, 965: diamond: { name: "Diamond", nD: 2.417, disp: 0.052, tint: [0.93, 0.96, 1.00] } 966: }; 967: 968: function sdSegment(px, py, ax, ay, bx, by) { 969: const vx = px - ax, vy = py - ay, ux = bx - ax, uy = by - ay; 970: const h = Math.max(0, Math.min(1, (vx * ux + vy * uy) / (ux * ux + uy * uy + 1e-9))); 971: return Math.hypot(vx - ux * h, vy - uy * h); 972: } 973: 974: const PRESETS = { 975: astrolabe(N = N_GRID) { 976: const t = new Float32Array(N * N); 977: for (let y = 0; y < N; y++) { 978: const v = (y + 0.5) / N * 2 - 1; 979: for (let x = 0; x < N; x++) { 980: const u = (x + 0.5) / N * 2 - 1; 981: const r = Math.hypot(u, v), th = Math.atan2(v, u); 982: let val = 0.032; 983: // Outer degree ring + graduations 984: val += 1.05 * Math.exp(-Math.pow((r - 0.73) / 0.017, 2)); 985: if (r > 0.67 && r < 0.74) { 986: const ticks = Math.pow(Math.abs(Math.cos(18 * th)), 28); 987: val += 0.45 * ticks * Math.exp(-Math.pow((r - 0.70) / 0.028, 2)); 988: } 989: // Equator & Tropic rings 990: val += 0.78 * Math.exp(-Math.pow((r - 0.49) / 0.014, 2)); 991: // Off-center ecliptic zodiac circle (astrolabe rete) 992: const re = Math.hypot(u - 0.13, v - 0.11); 993: val += 0.98 * Math.exp(-Math.pow((re - 0.41) / 0.016, 2)); 994: // 8-point compass spider lines 995: const star = Math.abs(Math.sin(4 * th)) * r; 996: if (r < 0.73 && r > 0.10) { 997: val += 0.78 * Math.exp(-Math.pow(star / 0.0135, 2)) * (1 - 0.32 * r); 998: } 999: // Central sun ring & pinpoint core 1000: val += 1.22 * Math.exp(-Math.pow((r - 0.115) / 0.015, 2)); 1001: val += 0.95 * Math.exp(-Math.pow(r / 0.032, 2)); 1002: t[y * N + x] = Math.min(1.4, val); 1003: } 1004: } 1005: return t; 1006: }, 1007: 1008: nautilus(N = N_GRID) { 1009: const t = new Float32Array(N * N); 1010: t.fill(0.032); 1011: const a = 0.033, b = 0.174; 1012: const pts = []; 1013: for (let th = 0; th <= 5.42 * Math.PI; th += 0.011) { 1014: const r = a * Math.exp(b * th); 1015: if (r > 0.74) break; 1016: pts.push([r * Math.cos(th) - 0.06, r * Math.sin(th) - 0.02, 0.015 + 0.008 * (r / 0.74), 1.18]); 1017: } 1018: for (let k = 10; k <= 33; k++) { 1019: const th = k * 0.50; 1020: const rOut = a * Math.exp(b * th); 1021: const rIn = a * Math.exp(b * (th - 2 * Math.PI)); 1022: if (rOut > 0.73 || rIn < 0.024) continue; 1023: for (let s = 0; s <= 1; s += 0.035) { 1024: const rr = rIn + (rOut - rIn) * s; 1025: const ang = th - 0.23 * Math.sin(Math.PI * s); 1026: pts.push([rr * Math.cos(ang) - 0.06, rr * Math.sin(ang) - 0.02, 0.012, 0.78]); 1027: } 1028: } 1029: for (const [cx, cy, rad, inten] of pts) { 1030: const gx = (cx * 0.5 + 0.5) * N, gy = (cy * 0.5 + 0.5) * N; 1031: const sig = rad * 0.5 * N, rPix = Math.ceil(sig * 2.8); 1032: const x0 = Math.max(0, Math.floor(gx - rPix)), x1 = Math.min(N - 1, Math.ceil(gx + rPix)); 1033: const y0 = Math.max(0, Math.floor(gy - rPix)), y1 = Math.min(N - 1, Math.ceil(gy + rPix)); 1034: for (let y = y0; y <= y1; y++) { 1035: for (let x = x0; x <= x1; x++) { 1036: const d2 = ((x + 0.5 - gx) ** 2 + (y + 0.5 - gy) ** 2) / (sig * sig); 1037: if (d2 < 7.5) { 1038: const v = 0.032 + inten * Math.exp(-d2); 1039: if (v > t[y * N + x]) t[y * N + x] = Math.min(1.4, v); 1040: } 1041: } 1042: } 1043: } 1044: return t; 1045: }, 1046: 1047: saturn(N = N_GRID) { 1048: const t = new Float32Array(N * N); 1049: const tilt = -0.40, cs = Math.cos(tilt), sn = Math.sin(tilt); 1050: const Rplanet = 0.225; 1051: for (let y = 0; y < N; y++) { 1052: const py = (y + 0.5) / N * 2 - 1; 1053: for (let x = 0; x < N; x++) { 1054: const px = (x + 0.5) / N * 2 - 1; 1055: const rx = px * cs - py * sn, ry = px * sn + py * cs; 1056: const rp = Math.hypot(rx, ry / 0.90); 1057: let val = 0.032; 1058: const rRing = Math.hypot(rx, ry / 0.28); 1059: const inFront = ry < 0; 1060: const behindPlanet = (rp < Rplanet * 0.98) && !inFront; 1061: const inShadow = (ry > 0) && (rx > 0.04) && (Math.abs(ry - 0.16 * rx) < 0.155); 1062: 1063: if (!behindPlanet && !inShadow) { 1064: if (rRing > 0.31 && rRing < 0.50) { 1065: const w = Math.sin(Math.PI * (rRing - 0.31) / 0.19); 1066: val += 1.08 * Math.pow(Math.max(0, w), 0.55) * (0.86 + 0.14 * Math.sin(rRing * 95)); 1067: } 1068: if (rRing > 0.535 && rRing < 0.685) { 1069: const w = Math.sin(Math.PI * (rRing - 0.535) / 0.15); 1070: val += 0.85 * Math.pow(Math.max(0, w), 0.5); 1071: } 1072: } 1073: const occByFront = inFront && (rRing > 0.31 && rRing < 0.685); 1074: if (rp <= Rplanet * 1.04 && !occByFront) { 1075: const limb = Math.exp(-Math.pow((rp - Rplanet * 0.94) / 0.020, 2)); 1076: const body = rp < Rplanet ? (0.42 * (1 - 0.45 * rp / Rplanet) * (0.82 + 0.22 * Math.cos(ry * 28)) * Math.max(0.15, 0.65 - 1.2 * rx)) : 0; 1077: val = Math.max(val, 0.032 + 1.16 * limb + body); 1078: } 1079: const dTitan = Math.hypot(px + 0.60, py - 0.46); 1080: const dEnc = Math.hypot(px - 0.52, py + 0.44); 1081: val += 1.05 * Math.exp(-(dTitan * dTitan) / (0.019 * 0.019)); 1082: val += 0.82 * Math.exp(-(dEnc * dEnc) / (0.015 * 0.015)); 1083: t[y * N + x] = Math.min(1.38, val); 1084: } 1085: } 1086: return t; 1087: }, 1088: 1089: crane(N = N_GRID) { 1090: const t = new Float32Array(N * N); 1091: const segs = [ 1092: // Sweeping origami upper wings 1093: [-0.03, 0.06, -0.71, 0.52, 1.18, 0.016], 1094: [-0.71, 0.52, -0.28, -0.09, 1.12, 0.015], 1095: [-0.28, -0.09, -0.03, 0.06, 0.86, 0.013], 1096: [-0.71, 0.52, -0.14, 0.18, 0.64, 0.012], 1097: [0.06, 0.10, 0.70, 0.46, 1.18, 0.016], 1098: [0.70, 0.46, 0.23, -0.07, 1.08, 0.015], 1099: [0.23, -0.07, 0.06, 0.10, 0.82, 0.013], 1100: [0.70, 0.46, 0.17, 0.17, 0.60, 0.012], 1101: // Central origami body facets 1102: [-0.03, 0.06, 0.06, 0.10, 0.96, 0.014], 1103: [-0.03, 0.06, -0.02, -0.27, 1.02, 0.014], 1104: [0.06, 0.10, -0.02, -0.27, 1.02, 0.014], 1105: [-0.28, -0.09, -0.02, -0.27, 0.94, 0.014], 1106: [0.23, -0.07, -0.02, -0.27, 0.94, 0.014], 1107: // Poised rising neck & folded head/beak 1108: [0.23, -0.07, 0.43, -0.44, 1.16, 0.015], 1109: [0.07, -0.19, 0.43, -0.44, 0.98, 0.014], 1110: [0.43, -0.44, 0.65, -0.35, 1.22, 0.014], 1111: [0.36, -0.35, 0.65, -0.35, 0.96, 0.013], 1112: // Elegant tapered tail spire 1113: [-0.28, -0.09, -0.54, -0.58, 1.16, 0.015], 1114: [-0.02, -0.27, -0.54, -0.58, 1.04, 0.014] 1115: ]; 1116: for (let y = 0; y < N; y++) { 1117: const py = (y + 0.5) / N * 2 - 1; 1118: for (let x = 0; x < N; x++) { 1119: const px = (x + 0.5) / N * 2 - 1; 1120: let val = 0.032; 1121: for (const [ax, ay, bx, by, inten, w] of segs) { 1122: const d = sdSegment(px, py, ax, ay, bx, by); 1123: const g = inten * Math.exp(-(d * d) / (w * w)); 1124: if (0.032 + g > val) val = 0.032 + g; 1125: } 1126: t[y * N + x] = val; 1127: } 1128: } 1129: return t; 1130: }, 1131: 1132: lorenz(N = N_GRID) { 1133: const t = new Float32Array(N * N); 1134: t.fill(0.032); 1135: let x = 0.1, y = 0.0, z = 0.0; 1136: const dt = 0.0035, sigma = 10, rho = 28, beta = 8 / 3; 1137: for (let i = 0; i < 16500; i++) { 1138: const dx = sigma * (y - x), dy = x * (rho - z) - y, dz = x * y - beta * z; 1139: x += dx * dt; y += dy * dt; z += dz * dt; 1140: if (i < 400) continue; 1141: const px = (x / 24.0) * 0.74; 1142: const py = ((z - 25.5) / 23.5) * 0.72; 1143: const gx = (px * 0.5 + 0.5) * N, gy = (py * 0.5 + 0.5) * N; 1144: const ix0 = Math.max(0, Math.floor(gx - 3)), ix1 = Math.min(N - 1, Math.ceil(gx + 3)); 1145: const iy0 = Math.max(0, Math.floor(gy - 3)), iy1 = Math.min(N - 1, Math.ceil(gy + 3)); 1146: for (let yy = iy0; yy <= iy1; yy++) { 1147: for (let xx = ix0; xx <= ix1; xx++) { 1148: const d2 = ((xx + 0.5 - gx) ** 2 + (yy + 0.5 - gy) ** 2) / (1.85 * 1.85); 1149: t[yy * N + xx] += 0.042 * Math.exp(-d2); 1150: } 1151: } 1152: } 1153: for (let i = 0; i < N * N; i++) t[i] = Math.min(1.38, t[i]); 1154: return t; 1155: } 1156: }; 1157: 1158: // ============================================================================ 1159: // 3. CRYSTALLINE OPTICAL MODAL SYNTHESIZER (WebAudio — Muted by Default) 1160: // ============================================================================ 1161: class GlassHarmonicaSynth { 1162: constructor() { 1163: this.ctx = null; 1164: this.enabled = false; 1165: this.voices = []; 1166: this.master = null; 1167: this.lastLockPing = 0; 1168: } 1169: 1170: toggle() { 1171: if (!this.ctx) { 1172: const AC = window.AudioContext || window.webkitAudioContext; 1173: if (!AC) return false; 1174: this.ctx = new AC(); 1175: this.master = this.ctx.createGain(); 1176: this.master.gain.value = 0.0; 1177: this.master.connect(this.ctx.destination); 1178: 1179: // 5 crystalline Lydian glass partials (C5, G5, D6, F#6, A6) 1180: const baseFreqs = [523.25, 783.99, 1174.66, 1479.98, 1760.0]; 1181: for (let i = 0; i < baseFreqs.length; i++) { 1182: const osc = this.ctx.createOscillator(); 1183: const gain = this.ctx.createGain(); 1184: osc.type = "sine"; 1185: osc.frequency.value = baseFreqs[i]; 1186: gain.gain.value = 0.0; 1187: osc.connect(gain); 1188: gain.connect(this.master); 1189: osc.start(); 1190: this.voices.push({ osc, gain, base: baseFreqs[i], idx: i }); 1191: } 1192: } 1193: this.enabled = !this.enabled; 1194: if (this.enabled && this.ctx.state === "suspended") this.ctx.resume(); 1195: const now = this.ctx.currentTime; 1196: this.master.gain.setTargetAtTime(this.enabled ? 0.14 : 0.0, now, 0.08); 1197: return this.enabled; 1198: } 1199:401 more lines not shown.