The showcase prompt, round 3, Gemini 4 Carbon
agent (cont.)
+51:42read_file{"EndLine":3164,"Path":"~/run/index.html","StartLine":2401}
input
{ "EndLine": 3164, "Path": "~/run/index.html", "StartLine": 2401 }result, 765 lines
Showing lines 2401-3164 of 3164 2401: const G = 28; 2402: const stagePts = new Array((G + 1) * (G + 1)); 2403: for (let j = 0; j <= G; j++) { 2404: const ps = -0.92 + (1.84 * j) / G; 2405: for (let i = 0; i <= G; i++) { 2406: const px = -0.92 + (1.84 * i) / G; 2407: stagePts[j * (G + 1) + i] = traceSingleRay3D(px, ps, focalZ, nIOR); 2408: } 2409: } 2410: for (let j = 0; j <= G; j++) { 2411: for (let i = 0; i <= G; i++) { 2412: const a = stagePts[j * (G + 1) + i]; 2413: if (!a) continue; 2414: if (i < G) { 2415: const b = stagePts[j * (G + 1) + i + 1]; 2416: if (b) { 2417: seg(a.top[0], a.top[1] + 0.002, a.top[2], b.top[0], b.top[1] + 0.002, b.top[2], 0.5, 0.85, 0.98, 0.14, 0.14); 2418: seg(a.stage[0], 0.005, a.stage[2], b.stage[0], 0.005, b.stage[2], 0.48, 0.86, 0.98, 0.26, 0.26); 2419: } 2420: } 2421: if (j < G) { 2422: const b = stagePts[(j + 1) * (G + 1) + i]; 2423: if (b) { 2424: seg(a.top[0], a.top[1] + 0.002, a.top[2], b.top[0], b.top[1] + 0.002, b.top[2], 0.5, 0.85, 0.98, 0.14, 0.14); 2425: seg(a.stage[0], 0.005, a.stage[2], b.stage[0], 0.005, b.stage[2], 0.48, 0.86, 0.98, 0.26, 0.26); 2426: } 2427: } 2428: } 2429: } 2430: } 2431: 2432: gl.bindBuffer(gl.ARRAY_BUFFER, lineVBO); 2433: gl.bufferSubData(gl.ARRAY_BUFFER, 0, lineData.subarray(0, ptr)); 2434: return ptr / 7; 2435: } 2436: 2437: // ============================================================================ 2438: // 10. UI CONTROLS, POINTER DIRECT MANIPULATION & LIVE SKETCHING 2439: // ============================================================================ 2440: const presetOrder = ["astrolabe", "nautilus", "saturn", "crane", "lorenz"]; 2441: const presetBtns = document.querySelectorAll("#presetGroup button[data-preset]"); 2442: const loupeCard = document.getElementById("loupeCard"); 2443: 2444: function selectPreset(name, fromAuto = false) { 2445: state.preset = name; 2446: presetBtns.forEach((b) => b.classList.toggle("active", b.dataset.preset === name)); 2447: if (name === "custom") { 2448: loupeCard.classList.remove("collapsed"); 2449: loupeCard.classList.add("expanded"); 2450: document.getElementById("btnToggleLoupe").textContent = "–"; 2451: state.loupeTab = "target"; 2452: document.getElementById("tabTarget").classList.add("active"); 2453: document.getElementById("tabHeight").classList.remove("active"); 2454: renderPadCanvas(); 2455: return; 2456: } 2457: loupeCard.classList.remove("expanded"); 2458: if (!fromAuto) markUserInteracted(); 2459: state.target256 = PRESETS[name](); 2460: uploadTargetTexture(); 2461: renderPadCanvas(); 2462: requestLensSolve(state.target256); 2463: } 2464: 2465: presetBtns.forEach((btn) => { 2466: btn.addEventListener("click", () => selectPreset(btn.dataset.preset, false)); 2467: }); 2468: 2469: function markUserInteracted() { 2470: if (!state.userInteracted) { 2471: state.userInteracted = true; 2472: document.getElementById("gestureHint").classList.add("hidden"); 2473: } 2474: state.autoChoreo = false; 2475: } 2476: 2477: // Camera View Presets 2478: const camBtns = document.querySelectorAll("button[data-cam]"); 2479: function setCameraPreset(mode) { 2480: camBtns.forEach((b) => b.classList.toggle("active", b.dataset.cam === mode)); 2481: if (mode === "studio") { 2482: state.camTargetYaw = 0.36; state.camTargetPitch = 0.42; state.camTargetDist = 7.55; state.camTargetCenterY = 1.72; 2483: } else if (mode === "profile") { 2484: state.camTargetYaw = 0.16; state.camTargetPitch = 0.10; state.camTargetDist = 4.55; state.camTargetCenterY = 1.65; 2485: } else if (mode === "top") { 2486: state.camTargetYaw = 0.0; state.camTargetPitch = 1.51; state.camTargetDist = 5.15; state.camTargetCenterY = 0.10; 2487: } 2488: } 2489: camBtns.forEach((btn) => btn.addEventListener("click", () => { 2490: markUserInteracted(); 2491: setCameraPreset(btn.dataset.cam); 2492: })); 2493: 2494: // Focal Height Slider 2495: const focalSlider = document.getElementById("focalSlider"); 2496: const focalVal = document.getElementById("focalVal"); 2497: focalSlider.addEventListener("input", () => { 2498: markUserInteracted(); 2499: let v = parseFloat(focalSlider.value); 2500: if (Math.abs(v - 1.0) < 0.022) { v = 1.0; focalSlider.value = "1.00"; } // subtle magnetic detent at exact focus! 2501: state.focalRatio = v; 2502: focalVal.textContent = `${Math.round(v * 86)} mm`; 2503: }); 2504: 2505: // Glass Material Selector 2506: const glassSelect = document.getElementById("glassSelect"); 2507: glassSelect.addEventListener("change", () => { 2508: markUserInteracted(); 2509: state.selectedGlass = glassSelect.value; 2510: // Show "Re-grind" button when viewing an existing lens made for a different index of refraction! 2511: // (Lets physicists observe Lensmaker focal-shift f ~ 1/(n-1) first, then re-grind on demand!) 2512: btnRegrind.style.display = (state.selectedGlass !== state.carvedForGlass) ? "inline-flex" : "none"; 2513: }); 2514: 2515: btnRegrind.addEventListener("click", () => { 2516: markUserInteracted(); 2517: requestLensSolve(state.target256); 2518: }); 2519: 2520: // Diagnostic Toggles 2521: const btnRays = document.getElementById("btnRays"); 2522: const btnGrid = document.getElementById("btnGrid"); 2523: const btnInterf = document.getElementById("btnInterf"); 2524: const btnCompare = document.getElementById("btnCompare"); 2525: 2526: btnRays.addEventListener("click", () => { 2527: state.showRays = !state.showRays; 2528: btnRays.classList.toggle("cyan-active", state.showRays); 2529: }); 2530: btnGrid.addEventListener("click", () => { 2531: state.showGrid = !state.showGrid; 2532: btnGrid.classList.toggle("cyan-active", state.showGrid); 2533: }); 2534: btnInterf.addEventListener("click", () => { 2535: state.showInterf = !state.showInterf; 2536: btnInterf.classList.toggle("cyan-active", state.showInterf); 2537: }); 2538: btnCompare.addEventListener("click", () => { 2539: state.compareMask = !state.compareMask; 2540: btnCompare.classList.toggle("active", state.compareMask); 2541: }); 2542: 2543: // Top Utility Buttons 2544: document.getElementById("btnAlign").addEventListener("click", () => { 2545: state.autoChoreo = false; 2546: state.lampTargetX = 0.0; 2547: state.lampTargetS = 0.0; 2548: state.focalRatio = 1.0; 2549: focalSlider.value = "1.00"; 2550: focalVal.textContent = "86 mm"; 2551: }); 2552: 2553: const btnAudio = document.getElementById("btnAudio"); 2554: btnAudio.addEventListener("click", () => { 2555: const on = synth.toggle(); 2556: btnAudio.textContent = on ? "♪ Sound On" : "♪ Sound Off"; 2557: btnAudio.classList.toggle("active", on); 2558: }); 2559: 2560: document.getElementById("btnStl").addEventListener("click", () => { 2561: exportBinarySTL(state.hSolved, state.minH, state.preset); 2562: }); 2563: 2564: // Loupe Pad Tabs & Live Brush / Typography Sculpting 2565: const tabTarget = document.getElementById("tabTarget"); 2566: const tabHeight = document.getElementById("tabHeight"); 2567: const padBadge = document.getElementById("padBadge"); 2568: tabTarget.addEventListener("click", () => { 2569: state.loupeTab = "target"; 2570: tabTarget.classList.add("active"); tabHeight.classList.remove("active"); 2571: padBadge.textContent = "Draw to carve lens"; 2572: renderPadCanvas(); 2573: }); 2574: tabHeight.addEventListener("click", () => { 2575: state.loupeTab = "height"; 2576: tabHeight.classList.add("active"); tabTarget.classList.remove("active"); 2577: padBadge.textContent = "Smooth C² surface"; 2578: renderPadCanvas(); 2579: }); 2580: 2581: const btnToggleLoupe = document.getElementById("btnToggleLoupe"); 2582: btnToggleLoupe.addEventListener("click", () => { 2583: const col = loupeCard.classList.toggle("collapsed"); 2584: btnToggleLoupe.textContent = col ? "✎ Pad" : "–"; 2585: }); 2586: 2587: const btnBrushDraw = document.getElementById("btnBrushDraw"); 2588: const btnBrushErase = document.getElementById("btnBrushErase"); 2589: btnBrushDraw.addEventListener("click", () => { 2590: state.brushMode = "draw"; 2591: btnBrushDraw.classList.add("active"); btnBrushErase.classList.remove("active"); 2592: }); 2593: btnBrushErase.addEventListener("click", () => { 2594: state.brushMode = "erase"; 2595: btnBrushErase.classList.add("active"); btnBrushDraw.classList.remove("active"); 2596: }); 2597: 2598: document.getElementById("btnPadClear").addEventListener("click", () => { 2599: markUserInteracted(); 2600: state.preset = "custom"; 2601: presetBtns.forEach((b) => b.classList.toggle("active", b.dataset.preset === "custom")); 2602: state.target256.fill(0.032); 2603: // Tiny central alignment spark so empty target still has non-degenerate mass 2604: state.target256[128 * 256 + 128] = 0.35; 2605: state.loupeTab = "target"; 2606: tabTarget.classList.add("active"); tabHeight.classList.remove("active"); 2607: uploadTargetTexture(); 2608: renderPadCanvas(); 2609: }); 2610: 2611: // Carve Custom Typography onto Target Grid 2612: const glyphInput = document.getElementById("glyphInput"); 2613: function carveCustomText() { 2614: const txt = (glyphInput.value || "LUX").trim().toUpperCase(); 2615: if (!txt) return; 2616: markUserInteracted(); 2617: state.preset = "custom"; 2618: presetBtns.forEach((b) => b.classList.toggle("active", b.dataset.preset === "custom")); 2619: state.loupeTab = "target"; 2620: tabTarget.classList.add("active"); tabHeight.classList.remove("active"); 2621: 2622: const off = document.createElement("canvas"); 2623: off.width = N_GRID; off.height = N_GRID; 2624: const ctx = off.getContext("2d"); 2625: ctx.fillStyle = "#000"; 2626: ctx.fillRect(0, 0, N_GRID, N_GRID); 2627: ctx.fillStyle = "#fff"; 2628: ctx.textAlign = "center"; 2629: ctx.textBaseline = "middle"; 2630: const fontSize = Math.min(108, Math.floor(215 / Math.max(1.4, txt.length * 0.62))); 2631: ctx.font = `600 ${fontSize}px Georgia, "Times New Roman", serif`; 2632: ctx.fillText(txt, N_GRID / 2, N_GRID / 2 + 2); 2633: 2634: // Subtle decorative framing arcs above and below text 2635: ctx.strokeStyle = "rgba(255,255,255,0.65)"; 2636: ctx.lineWidth = 3.2; 2637: ctx.beginPath(); ctx.arc(128, 128, 98, -0.78 * Math.PI, -0.22 * Math.PI); ctx.stroke(); 2638: ctx.beginPath(); ctx.arc(128, 128, 98, 0.22 * Math.PI, 0.78 * Math.PI); ctx.stroke(); 2639: 2640: const img = ctx.getImageData(0, 0, N_GRID, N_GRID).data; 2641: // Slight 3x3 Gaussian soften for silky caustic strokes 2642: const raw = new Float32Array(N_GRID * N_GRID); 2643: for (let y = 0; y < N_GRID; y++) { 2644: const sy = N_GRID - 1 - y; 2645: for (let x = 0; x < N_GRID; x++) { 2646: raw[y * N_GRID + x] = img[(sy * N_GRID + x) * 4] / 255.0; 2647: } 2648: } 2649: for (let y = 0; y < N_GRID; y++) { 2650: for (let x = 0; x < N_GRID; x++) { 2651: let sum = 0, wSum = 0; 2652: for (let dy = -2; dy <= 2; dy++) { 2653: const yy = Math.max(0, Math.min(255, y + dy)); 2654: for (let dx = -2; dx <= 2; dx++) { 2655: const xx = Math.max(0, Math.min(255, x + dx)); 2656: const w = Math.exp(-(dx * dx + dy * dy) / 2.6); 2657: sum += raw[yy * N_GRID + xx] * w; wSum += w; 2658: } 2659: } 2660: state.target256[y * N_GRID + x] = 0.032 + 1.18 * (sum / wSum); 2661: } 2662: } 2663: uploadTargetTexture(); 2664: renderPadCanvas(); 2665: requestLensSolve(state.target256); 2666: state.lampTargetX = 0; state.lampTargetS = 0; 2667: } 2668: 2669: document.getElementById("btnCarveText").addEventListener("click", carveCustomText); 2670: glyphInput.addEventListener("keydown", (e) => { if (e.key === "Enter") carveCustomText(); }); 2671: 2672: // Interactive Freehand Drawing on Loupe Pad (throttled live 160ms PDE re-carve!) 2673: let padDrawing = false, lastPadPos = null, liveSolveTimer = null; 2674: function getPadCoords(e) { 2675: const r = padCanvas.getBoundingClientRect(); 2676: const u = Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)); 2677: const v = Math.max(0, Math.min(1, 1.0 - (e.clientY - r.top) / r.height)); 2678: return [u * N_GRID, v * N_GRID]; 2679: } 2680: 2681: function paintStroke(x0, y0, x1, y1) { 2682: const dist = Math.hypot(x1 - x0, y1 - y0); 2683: const steps = Math.max(1, Math.ceil(dist * 0.75)); 2684: const rad = state.brushMode === "erase" ? 11.0 : 5.2; 2685: for (let s = 0; s <= steps; s++) { 2686: const t = s / steps; 2687: const cx = x0 + (x1 - x0) * t, cy = y0 + (y1 - y0) * t; 2688: // Keep inside clean optical aperture [18..238] 2689: const px = Math.max(18, Math.min(238, cx)), py = Math.max(18, Math.min(238, cy)); 2690: const rPix = Math.ceil(rad * 2.4); 2691: const ix0 = Math.max(0, Math.floor(px - rPix)), ix1 = Math.min(255, Math.ceil(px + rPix)); 2692: const iy0 = Math.max(0, Math.floor(py - rPix)), iy1 = Math.min(255, Math.ceil(py + rPix)); 2693: for (let y = iy0; y <= iy1; y++) { 2694: for (let x = ix0; x <= ix1; x++) { 2695: const d2 = ((x + 0.5 - px) ** 2 + (y + 0.5 - py) ** 2) / (rad * rad); 2696: if (d2 > 6.0) continue; 2697: const idx = y * N_GRID + x; 2698: if (state.brushMode === "erase") { 2699: state.target256[idx] = 0.032 + (state.target256[idx] - 0.032) * (1 - 0.85 * Math.exp(-d2)); 2700: } else { 2701: const v = 0.032 + 1.18 * Math.exp(-d2); 2702: if (v > state.target256[idx]) state.target256[idx] = v; 2703: } 2704: } 2705: } 2706: } 2707: uploadTargetTexture(); 2708: renderPadCanvas(); 2709: if (!liveSolveTimer) { 2710: liveSolveTimer = setTimeout(() => { 2711: liveSolveTimer = null; 2712: if (!state.solving) requestLensSolve(state.target256); 2713: }, 170); 2714: } 2715: } 2716: 2717: padCanvas.addEventListener("pointerdown", (e) => { 2718: markUserInteracted(); 2719: padCanvas.setPointerCapture(e.pointerId); 2720: if (state.loupeTab !== "target") { 2721: state.loupeTab = "target"; 2722: tabTarget.classList.add("active"); tabHeight.classList.remove("active"); 2723: } 2724: if (state.preset !== "custom") { 2725: // First stroke on a preset transitions smoothly into Custom Sculpt mode! 2726: state.preset = "custom"; 2727: presetBtns.forEach((b) => b.classList.toggle("active", b.dataset.preset === "custom")); 2728: } 2729: padDrawing = true; 2730: lastPadPos = getPadCoords(e); 2731: paintStroke(lastPadPos[0], lastPadPos[1], lastPadPos[0], lastPadPos[1]); 2732: state.lampTargetX = 0; state.lampTargetS = 0; 2733: }); 2734: 2735: padCanvas.addEventListener("pointermove", (e) => { 2736: if (!padDrawing) return; 2737: const cur = getPadCoords(e); 2738: paintStroke(lastPadPos[0], lastPadPos[1], cur[0], cur[1]); 2739: lastPadPos = cur; 2740: }); 2741: 2742: function finishPadStroke() { 2743: if (!padDrawing) return; 2744: padDrawing = false; 2745: if (liveSolveTimer) { clearTimeout(liveSolveTimer); liveSolveTimer = null; } 2746: requestLensSolve(state.target256); 2747: } 2748: padCanvas.addEventListener("pointerup", finishPadStroke); 2749: padCanvas.addEventListener("pointercancel", finishPadStroke); 2750: 2751: // ============================================================================ 2752: // 11. MAIN 3D VIEWPORT POINTER CONTROLS (Dual-Zone: Steer Lamp OR Orbit 3D!) 2753: // ============================================================================ 2754: let dragMode = null; // "lamp" | "orbit" | "slice" 2755: let dragLastX = 0, dragLastY = 0; 2756: let currentVP = new Float32Array(16); 2757: 2758: canvas.addEventListener("pointerdown", (e) => { 2759: markUserInteracted(); 2760: canvas.setPointerCapture(e.pointerId); 2761: dragLastX = e.clientX; 2762: dragLastY = e.clientY; 2763: 2764: const w = canvas.clientWidth, h = canvas.clientHeight; 2765: const lampScr = projectToScreen(currentVP, state.lampX, state.lampZ, -state.lampS, w, h); 2766: const stageCenterScr = projectToScreen(currentVP, 0, 0, 0, w, h); 2767: 2768: if (e.button === 2 || e.altKey) { 2769: dragMode = "orbit"; 2770: } else if (lampScr && Math.hypot(e.clientX - lampScr[0], e.clientY - lampScr[1]) < 64) { 2771: dragMode = "lamp"; 2772: } else if (stageCenterScr && e.clientY > h * 0.48) { 2773: // Dragging on the lower stage half steers the 3D light rays tactilely! 2774: dragMode = "lamp"; 2775: } else { 2776: dragMode = "orbit"; 2777: } 2778: canvas.classList.toggle("dragging-lamp", dragMode === "lamp"); 2779: canvas.classList.toggle("dragging-orbit", dragMode === "orbit"); 2780: }); 2781: 2782: canvas.addEventListener("pointermove", (e) => { 2783: if (!dragMode) return; 2784: const dx = e.clientX - dragLastX, dy = e.clientY - dragLastY; 2785: dragLastX = e.clientX; dragLastY = e.clientY; 2786: 2787: if (dragMode === "lamp") { 2788: // Convert screen delta into camera-aligned horizontal lamp motion 2789: const scale = 0.0075; 2790: const cosY = Math.cos(state.camYaw), sinY = Math.sin(state.camYaw); 2791: // Right vector in world XZ is (cosY, -sinY); Forward in world XZ is (-sinY, -cosY) 2792: const dWorldX = dx * cosY * scale + dy * sinY * scale; 2793: const dWorldZ = -dx * sinY * scale + dy * cosY * scale; 2794: state.lampTargetX = Math.max(-3.0, Math.min(3.0, state.lampTargetX + dWorldX)); 2795: state.lampTargetS = Math.max(-3.0, Math.min(3.0, state.lampTargetS - dWorldZ)); 2796: // Gentle magnetic sweet-spot detent right near exact (0,0) optical axis! 2797: if (Math.hypot(state.lampTargetX, state.lampTargetS) < 0.065) { 2798: state.lampTargetX *= 0.65; 2799: state.lampTargetS *= 0.65;365 more lines not shown.
read_file{"Path":"~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch/inspect_playwright.js"}
input
{ "Path": "~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch/inspect_playwright.js" }result, 81 lines
Showing lines 1-80 of 80 1: // Automated Visual Inspection & Console Error Audit via Playwright + Chromium 2: const fs = require('fs'); 3: const path = require('path'); 4: 5: // Locate playwright module 6: const pwPaths = [ 7: '/usr/local/share/.cache/yarn/v6/npm-playwright-1.47.2-155688aa06491ee21fb3e7555b748b525f86eb20-integrity/node_modules/playwright', 8: 'playwright' 9: ]; 10: let pw = null; 11: for (const p of pwPaths) { 12: try { pw = require(p); break; } catch (_) {} 13: } 14: if (!pw) { 15: // Fallback search 16: const { execSync } = require('child_process'); 17: const found = execSync('find / -path "*/node_modules/playwright/index.js" 2>/dev/null | head -n 1').toString().trim(); 18: pw = require(path.dirname(found)); 19: } 20: 21: (async () => { 22: const outDir = '~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch'; 23: const browser = await pw.chromium.launch({ 24: executablePath: '/opt/ms-playwright/chromium-1248/chrome-linux64/chrome', 25: headless: true, 26: args: ['--no-sandbox', '--use-gl=angle', '--use-angle=swiftshader', '--enable-webgl'] 27: }); 28: 29: const page = await browser.newPage({ viewport: { width: 1200, height: 760 }, deviceScaleFactor: 1 }); 30: const errors = []; 31: page.on('console', (msg) => { 32: if (msg.type() === 'error' || msg.type() === 'warning') { 33: errors.push(`[${msg.type()}] ${msg.text()}`); 34: } 35: }); 36: page.on('pageerror', (err) => errors.push(`[pageerror] ${err.message}`)); 37: 38: await page.goto('file://~/run/index.html'); 39: // Wait for PDE solver to finish & glass morph + focus lock to settle! 40: await page.waitForTimeout(2600); 41: await page.screenshot({ path: path.join(outDir, 'view_studio_astrolabe.png') }); 42: 43: // Overhead Loupe View 44: await page.click('button[data-cam="top"]'); 45: await page.waitForTimeout(1200); 46: await page.screenshot({ path: path.join(outDir, 'view_overhead_astrolabe.png') }); 47: 48: // Glass Profile View + Interferogram 49: await page.click('button[data-cam="profile"]'); 50: await page.click('#btnInterf'); 51: await page.waitForTimeout(1200); 52: await page.screenshot({ path: path.join(outDir, 'view_profile_interf.png') }); 53: 54: // Back to 3D Studio, test Nautilus + Optimal Transport Grid 55: await page.click('#btnInterf'); 56: await page.click('button[data-cam="studio"]'); 57: await page.click('button[data-preset="nautilus"]'); 58: await page.click('#btnGrid'); 59: await page.waitForTimeout(1800); 60: await page.screenshot({ path: path.join(outDir, 'view_nautilus_grid.png') }); 61: 62: // Test Custom Text Carving ("OPTICS") 63: await page.click('#btnGrid'); 64: await page.fill('#glyphInput', 'LUX'); 65: await page.click('#btnCarveText'); 66: await page.waitForTimeout(1800); 67: await page.screenshot({ path: path.join(outDir, 'view_custom_lux.png') }); 68: 69: // Test Mask vs Lens split comparison on Crane 70: await page.click('button[data-preset="crane"]'); 71: await page.click('#btnCompare'); 72: await page.waitForTimeout(1800); 73: await page.screenshot({ path: path.join(outDir, 'view_crane_compare.png') }); 74: 75: const telemetry = await page.textContent('#telemetryBar'); 76: console.log('TELEMETRY:', telemetry.replace(/\s+/g, ' ').trim()); 77: console.log('CONSOLE ERRORS/WARNINGS:', errors.length ? errors.join('\n') : 'NONE'); 78: 79: await browser.close(); 80: })();read_file{"Path":"~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch/record_preview_video.js"}
input
{ "Path": "~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch/record_preview_video.js" }result, 81 lines
Showing lines 1-80 of 80 1: // Deterministic 60fps Frame-by-Frame Capture -> High-Bitrate H.264 MP4 + Poster PNG 2: // Overrides performance.now & requestAnimationFrame so even software SwiftShader renders 3: // a buttery-smooth, exact 60.0 fps video of the optical caustic convergence & morphing! 4: 5: const fs = require('fs'); 6: const path = require('path'); 7: const { execSync } = require('child_process'); 8: 9: const pwPath = '/usr/local/share/.cache/yarn/v6/npm-playwright-1.47.2-155688aa06491ee21fb3e7555b748b525f86eb20-integrity/node_modules/playwright'; 10: const pw = require(pwPath); 11: 12: (async () => { 13: const framesDir = '~/.gemini/antigravity-cli/brain/57c10734-2a82-45f0-9144-4789a69869c1/scratch/frames'; 14: fs.mkdirSync(framesDir, { recursive: true }); 15: 16: const browser = await pw.chromium.launch({ 17: executablePath: '/opt/ms-playwright/chromium-1248/chrome-linux64/chrome', 18: headless: true, 19: args: ['--no-sandbox', '--use-gl=angle', '--use-angle=swiftshader', '--enable-webgl'] 20: }); 21: 22: const context = await browser.newContext({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: 1 }); 23: await context.addInitScript(() => { 24: let virtualNow = 1000.0; 25: const rafCallbacks = []; 26: window.__advanceFrame = (dtMs) => { 27: virtualNow += dtMs; 28: const cbs = rafCallbacks.splice(0, rafCallbacks.length); 29: for (const cb of cbs) cb(virtualNow); 30: }; 31: performance.now = () => virtualNow; 32: window.requestAnimationFrame = (cb) => { 33: rafCallbacks.push(cb); 34: return rafCallbacks.length; 35: }; 36: }); 37: 38: const page = await context.newPage(); 39: await page.goto('file://~/run/index.html'); 40: // Let initial Web Worker PDE solve complete in real wall time (~250ms) 41: await page.waitForFunction(() => { 42: const el = document.getElementById('statSolve'); 43: return el && el.textContent.includes('ms'); 44: }, { timeout: 10000 }); 45: 46: // Warm up 6 steps so hCurrent morphs halfway, then capture 8.5s @ 30fps (255 frames) 47: for (let w = 0; w < 8; w++) await page.evaluate(() => window.__advanceFrame(16.666)); 48: 49: const FPS = 30; 50: const TOTAL_FRAMES = 240; // 8.0 seconds: chaotic rainbow sweep -> Astrolabe focus -> morph to Nautilus focus! 51: for (let f = 0; f < TOTAL_FRAMES; f++) { 52: if (f === 120) { 53: // Halfway through video, click Nautilus so viewers see the glass morph live! 54: await page.click('button[data-preset="nautilus"]'); 55: await page.waitForFunction(() => { 56: const el = document.getElementById('statSolve'); 57: return el && el.textContent.includes('ms'); 58: }, { timeout: 10000 }); 59: // Re-enable gentle shimmer 60: await page.evaluate(() => { 61: const btn = document.getElementById('btnAlign'); 62: if (btn) btn.click(); 63: }); 64: } 65: await page.evaluate((dt) => window.__advanceFrame(dt), 1000 / FPS); 66: const frameFile = path.join(framesDir, `f_${String(f).padStart(4, '0')}.png`); 67: await page.screenshot({ path: frameFile }); 68: if (f === 75) { 69: fs.copyFileSync(frameFile, '~/run/caustic-poster.png'); 70: } 71: } 72: 73: await browser.close(); 74: 75: execSync( 76: `ffmpeg -y -loglevel error -framerate ${FPS} -i "${framesDir}/f_%04d.png" ` + 77: `-c:v libx264 -pix_fmt yuv420p -crf 18 -preset slow -movflags +faststart ~/run/caustic-preview.mp4` 78: ); 79: console.log('Rendered ~/run/caustic-preview.mp4 and ~/run/caustic-poster.png!'); 80: })();