Engineer a web packaging experiment (Web Bundles) with signed HTTP exchanges, fallback…
- User
Engineer a web packaging experiment (Web Bundles) with signed HTTP exchanges, fallback heuristics, and performance benchmarking.
- Assistant
Here's a thinking process that leads to the suggested HTML page:
-
Analyze the Request:
- Topic: Web packaging experiment (Web Bundles) with signed HTTP exchanges, fallback heuristics, and performance benchmarking.
- Role: FUI (Fictional User Interface) design expert (2077, Cyberpunk, Hard Sci-Fi).
- Visual Style: Intricate structure, dark mode, neon glow, monospace fonts, HUD layout, dynamic elements, decoding effects, holographic feel, Canvas/Three.js/Glitch shaders.
-
Conceptualize the Page (Metaphor & Functionality):
- Concept: A futuristic "Cyberdeck" or "Netrunner" dashboard analyzing a Web Bundle. It's not a static documentation page; it's an interactive simulation.
- Main Elements:
- Header: System status, clock, connection integrity.
- Central View: A 3D visualization (using Three.js wireframe) representing the "Bundle" (a capsule or network of nodes).
- Data Panels:
- Left: File structure (tree view) of the bundle.
- Right: Performance metrics (Benchmarking charts, speeds, latency).
- Bottom: Fallback heuristics/log analysis (scrolling text, errors, validation).
- Interactivity: Hovering over files updates the central view/performance data. "Deploy" or "Analyze" buttons trigger visual glitches/transitions.
-
Drafting the Design System (Cyberpunk FUI):
- Colors: Cyan (
#00f3ff), Magenta (#ff00ff), Amber (#ffaa00) against deep black/blue (#050505). - Fonts:
Courier New,Roboto Mono, or a web font likeShare Tech Mono. (I'll use a Google Font:Share Tech Mono). - Borders: Thin lines (1px), corners brackets
┌ ┐ └ ┘, double lines occasionally. - Effects: CSS
box-shadowfor neon glow. Animations:decodingtext, scanning lines, pulsing indicators.
- Colors: Cyan (
-
Structure the HTML:
<!DOCTYPE html><head>: Meta tags, Google Font link, Tailwind CSS (CDN), Three.js (CDN).<body>:<div id="app-container">: The main CRT screen wrapper.<header>: Top bar with title, clock, system status.<main>: Grid layout.<aside id="file-explorer">: Left panel.<section id="visualization">: Center canvas (Three.js).<aside id="metrics">: Right panel (Performance).<section id="logs">: Bottom panel (Heuristics/Linting).
-
Implement Base Styling (Tailwind + Custom CSS):
- Use Tailwind for layout (grid, flex), spacing, and basic colors.
- Add custom CSS for:
- Scanline overlay (pointer-events: none).
- CRT flicker (animation).
- Neon glow classes (
.text-neon-cyan,.border-neon-magenta). - "Decoding" text effect animation.
- Monospace font enforcement.
-
Develop Components:
-
Three.js Visualization (The "Bundle"):
- Create a scene, camera, renderer.
- Object: A group of spheres (files) connected by lines (dependencies). Rotating wireframe icosahedron container.
- Interaction: Raycaster. When hovering a file in the list, highlight the corresponding sphere in 3D.
- Animation: Slow rotation, pulsing edges.
-
File Explorer:
- Hardcoded data structure representing a
web bundle(index.html, manifest.json, assets/script.js, etc.). - Recursive (or flat) list. Styling: indentations, folder icons (text based:
[DIR]), file icons ([FILE]). - Click interaction: Select file to update metrics.
- Hardcoded data structure representing a
-
Performance Benchmarking:
- Dynamic charts drawn with HTML5 Canvas (simpler than importing a heavy chart lib).
- Metrics: Load Time, Compression Ratio, Integrity Check, Score.
- Visual: Bar charts, circular progress rings using SVG or Canvas stroke-dasharray.
- Values fluctuate randomly to simulate "live" monitoring.
-
Fallback Heuristics / Logs:
- Terminal-like output. Text typing effect or scrolling log.
- Messages: "Checking signature...", "Validating exchange...", "Fallback: Loading from network...", "PASS".
-
Decoding Text:
- A function that takes an element and runs an interval, randomly changing characters before settling on the final string.
-
-
Implement Logic (JavaScript):
- Data: Objects for files and their metadata (size, load time, MIME type).
- Three.js Setup: Standard boilerplate.
- State Management:
selectedFilevariable. - Canvas Charts:
drawChart()function called every frame or on data update. - DOM Manipulation: Render file list based on data.
- Log Simulation: Interval to push new log entries.
- Decoding Effect: Generic function
typeText(element, finalText).
-
Refining the Aesthetics (The "Polish"):
- Corner Brackets: Use pseudo-elements (
::before,::after) on panels to draw decorative L-shapes. - Glows: Add
text-shadowfor headings.box-shadowfor active borders. - Grid: Efficient use of Tailwind's
grid-cols-12. Center panel gets more space (col-span-8), sidebars narrow (col-span-2). - Responsiveness: Stack panels on mobile (though cyberpunk UIs are best on desktop, ensure no breakage).
- Corner Brackets: Use pseudo-elements (
-
Specific Feature: "Signed HTTP Exchanges" Theme:
- Add specific terminology: "Signature Integrity", "Certificate Chain", "AMPCache", "Cross-Origin", "Preload".
-
Step-by-Step Implementation (Mental Draft & Code Construction):
- HTML Structure: Define the grid.
- Three.js: Create the "Bundle Core". Use
IcosahedronGeometrywithwireframe: truefor the outer cage. UseSphereGeometryfor internal nodes. - File List: Generate HTML string with data attributes for 3D reference.
- Charts: Create a
PerformanceMonitorclass. Use a rolling buffer for "Network Load" graph. - Logs: Create a
Loggerclass that adds lines with timestamps. - Glitch Effect: CSS keyframes translating the background slightly.
-
Review against constraints:
- Single file? Yes.
- No external libraries besides Tailwind (CDN), Three.js (CDN), Font (Google). OK.
- No
alert(). - Functional interactive elements (buttons, hovering).
- Cyberpunk style: Check.
-
Self-Correction/Refinement during coding:
- Issue: Three.js might block layout if container size isn't handled.
- Fix: Ensure container has
position: relative; width: 100%; height: 100%;and renderersetSizehandles resize events. - Aesthetics: Standard Tailwind colors are too saturated. Need custom palettes in config or arbitrary values. Use arbitrary values like
border-[#00f3ff]andtext-[#ff00ff]. - Decoding: Make sure it doesn't trigger constantly on load (maybe only visible text headers).
-
Final Code Assembly: Combine HTML, CSS (in
<style>), JS (in<script>). Ensure closing tags. (Proceeding to generate the actual code).
(Self-Correction particular to "Web Bundles"): The prompt asks for a "web packaging experiment". The UI should reflect analyzing a
.wbnfile or a Signed HTTP Exchange. The 3D object should look like a "package" — maybe a complex geometric shape containing smaller data nodes. The file list should show specific bundle contents (likemanifest.webmanifest,index.html, etc.).Let's build it.
- Visual Theme: "TACHIKOMA" styled interface (Ghost in the Shell) meets Tron. Dark, cyan/magenta, tech grid lines.
- Layout:
- [0% to 15%] Left Sidebar: File Tree.
- [15% to 85%] Center: 3D Visualization.
- [85% to 100%] Right Sidebar: Metrics.
- Bottom 15%: Logs/Console.
- Top 10%: Header with System status.
Let's write the code.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Web Bundle Analysis Terminal // AUTH_CIPHER-77</title> <!-- Tailwind CSS --> <script src="https://cdn.tailwindcss.com"></script> <!-- Three.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script> <!-- Google Fonts --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap" rel="stylesheet"> <!-- Tailwind Config for Cyberpunk Palette --> <script> tailwind.config = { theme: { extend: { fontFamily: { mono: ['"Share Tech Mono"', 'monospace'], }, colors: { cy: { 100: '#e0f7fa', 500: '#00f3ff', // Cyan Glow 600: '#00c3cc', }, ma: { 500: '#ff00ff', // Magenta Glow 600: '#cc00cc', }, am: { 500: '#ffaa00', // Amber Glow 600: '#cc8800', }, bk: { 900: '#050505', // Deepest Black 800: '#0a0a0a', 700: '#111111', } }, boxShadow: { 'neon-cyan': '0 0 5px #00f3ff, 0 0 10px #00f3ff', 'neon-magenta': '0 0 5px #ff00ff, 0 0 10px #ff00ff', 'neon-amber': '0 0 5px #ffaa00, 0 0 10px #ffaa00', 'panel': 'inset 0 0 20px rgba(0, 243, 255, 0.05)', } } } } </script> <style> /* Global Reset & Base */ body { background-color: #050505; color: #00f3ff; overflow: hidden; /* App-like feel */ margin: 0; font-family: 'Share Tech Mono', monospace; } /* Scanline Overlay */ .scanlines { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: linear-gradient( to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.2) ); background-size: 100% 4px; pointer-events: none; z-index: 999; opacity: 0.6; } /* CRT Flicker Animation */ @keyframes flicker { 0% { opacity: 0.97; } 5% { opacity: 0.95; } 10% { opacity: 0.9; } 15% { opacity: 0.95; } 20% { opacity: 0.98; } 30% { opacity: 0.95; } 40% { opacity: 0.9; } 50% { opacity: 0.95; } 60% { opacity: 0.99; } 70% { opacity: 0.93; } 80% { opacity: 0.95; } 90% { opacity: 0.99; } 100% { opacity: 0.98; } } .crt-screen { animation: flicker 0.15s infinite; } /* Decoding Text Effect */ .decode::after { content: attr(data-value); display: block; height: 1.2em; } .decoding { animation: glitch-text 0.5s infinite; } @keyframes glitch-text { 0% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } 100% { transform: translate(0); } } /* HUD Borders */ .hud-panel { position: relative; background: rgba(5, 5, 5, 0.8); border: 1px solid #00f3ff; box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.1); overflow: hidden; } /* Corner decorations */ .hud-panel::before, .hud-panel::after { content: ''; position: absolute; width: 8px; height: 8px; border-color: #ff00ff; border-style: solid; pointer-events: none; transition: all 0.3s ease; } .hud-panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; } .hud-panel::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; } .hud-panel:hover::before, .hud-panel:hover::after { width: 100%; height: 100%; border-color: rgba(255, 0, 255, 0.5); opacity: 0.3; } /* Scrollbar Hack */ ::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: #050505; } ::-webkit-scrollbar-thumb { background: #00f3ff; border-radius: 2px; } ::-webkit-scrollbar-thumb:hover { background: #ff00ff; } /* SVG Loaders */ .spinner { animation: rotate 2s linear infinite; transform-origin: center; } @keyframes rotate { 100% { transform: rotate(360deg); } } /* Selection Highlight */ ::selection { background: rgba(0, 243, 255, 0.3); color: #fff; } </style> </head> <body class="crt-screen"> <!-- Ambient Grid Background --> <div class="fixed inset-0 z-0 opacity-20" style="background-image: linear-gradient(#00f3ff 1px, transparent 1px), linear-gradient(90deg, #00f3ff 1px, transparent 1px); background-size: 40px 40px;"> </div> <!-- Scanlines Overlay --> <div class="scanlines"></div> <!-- Main Interface Container --> <div class="relative z-10 w-full h-screen p-1 flex flex-col gap-1"> <!-- HEADER --> <header class="h-12 flex items-center justify-between px-4 border-b border-cy-500/50 bg-bk-900/90"> <div class="flex items-center gap-3"> <div class="w-3 h-3 rounded-full bg-cy-500 animate-ping"></div> <h1 class="text-lg tracking-widest text-cy-500 font-bold" id="header-title"> WEB_BUNDLE_ANALYZER_V.2077 </h1> </div> <div class="hidden md:flex gap-8 text-xs uppercase tracking-wider text-cy-600"> <span class="flex items-center gap-2"> <div class="w-2 h-2 bg-ma-500"></div> SIGNED_EXCHANGE: <span class="text-cy-500 font-bold">VALID</span> </span> <span class="flex items-center gap-2"> <div class="w-2 h-2 bg-am-500"></div> INTEGRITY: <span class="text-cy-500 font-bold">98.4%</span> </span> <span class="flex items-center gap-2"> <div class="w-2 h-2 bg-cy-500"></div> CACHE_STATUS: <span class="text-cy-500 font-bold">HIT</span> </span> </div> <div class="text-xs text-cy-600 font-bold" id="clock">00:00:00:000</div> </header> <!-- MAIN GRID --> <div class="flex-1 grid grid-cols-12 gap-1 p-1 min-h-0"> <!-- LEFT PANEL: File Explorer --> <aside class="col-span-12 md:col-span-3 flex flex-col hud-panel"> <div class="px-2 py-1 bg-bk-800 border-b border-cy-500/30 flex justify-between items-center"> <span class="text-xs text-cy-500 font-bold">FILE_SYSTEM</span> <span class="text-[10px] text-cy-600">ROOT_MOUNT</span> </div> <div class="flex-1 overflow-y-auto p-2 text-xs" id="file-list"> <!-- JS will populate --> </div> </aside> <!-- CENTER PANEL: 3D Visualization --> <section class="col-span-12 md:col-span-6 relative flex flex-col hud-panel border-cy-500/50"> <div class="absolute top-2 left-2 z-20 text-[10px] text-cy-600 pointer-events-none"> VISUALIZATION_MODE: STRUCTURAL_WIREFRAME<br> RENDERER: WEBGL_2.0 </div> <div id="canvas-container" class="flex-1 w-full relative bg-bk-900/50"></div> <!-- Overlay Stats --> <div class="absolute bottom-4 left-4 right-4 flex justify-between pointer-events-none"> <div class="text-xs text-cy-600"> PACKET_SIZE: <span id="packet-size" class="text-white">0 KB</span> </div> <div class="text-xs text-cy-600"> COMPRESSION: <span id="comp-ratio" class="text-white">0%</span> </div> <div class="text-xs text-cy-600"> SIGNATURE: <span class="text-ma-500">ECC-P521</span> </div> </div> </section> <!-- RIGHT PANEL: Metrics --> <aside class="col-span-12 md:col-span-3 flex flex-col hud-panel"> <div class="px-2 py-1 bg-bk-800 border-b border-cy-500/30"> <span class="text-xs text-cy-500 font-bold">PERFORMANCE_BENCHMARK</span> </div> <div class="p-4 flex-1 flex flex-col gap-4"> <!-- Circular Progress --> <div class="relative w-24 h-24 mx-auto"> <svg class="w-full h-full transform -rotate-90"> <circle cx="12" cy="12" r="10" stroke="#111" stroke-width="2" fill="transparent"></circle> <circle id="score-circle" cx="12" cy="12" r="10" stroke="#ff00ff" stroke-width="2" fill="transparent" stroke-dasharray="62.83" stroke-dashoffset="10" class="transition-all duration-1000"></circle> </svg> <div class="absolute inset-0 flex items-center justify-center text-xs font-bold text-white"> <span id="score-text">0</span> </div> <div class="absolute -bottom-2 left-1/2 -translate-x-1/2 text-[10px] text-cy-600">SCORE</div> </div> <!-- Bar Charts --> <div class="space-y-3"> <div> <div class="flex justify-between text-[10px] mb-1"> <span class="text-cy-600">LOAD TIME</span> <span class="text-white" id="load-time-val">0ms</span> </div> <div class="w-full h-2 bg-bk-800 border border-cy-500/30"> <div id="load-time-bar" class="h-full bg-cy-500 w-0 transition-all duration-500"></div> </div> </div> <div> <div class="flex justify-between text-[10px] mb-1"> <span class="text-ma-500">LATENCY</span> <span class="text-white" id="latency-val">0ms</span> </div> <div class="w-full h-2 bg-bk-800 border border-ma-500/30"> <div id="latency-bar" class="h-full bg-ma-500 w-0 transition-all duration-500"></div> </div> </div> <div> <div class="flex justify-between text-[10px] mb-1"> <span class="text-am-500">CPU COST</span> <span class="text-white" id="cpu-val">0%</span> </div> <div class="w-full h-2 bg-bk-800 border border-am-500/30"> <div id="cpu-bar" class="h-full bg-am-500 w-0 transition-all duration-500"></div> </div> </div> </div> <div class="border-t border-cy-500/30 pt-2 text-[10px] text-cy-600 space-y-1"> <p>FALLBACK_HEURISTICS: <span class="text-white">ACTIVE</span></p> <p>SIGNED_HEADERS: <span class="text-white">V2</span></p> <p>LOADER_ENGINE: <span class="text-white">HYPERDRIVE</span></p> </div> </div> </aside> </div> <!-- BOTTOM PANEL: Logs / Heuristics --> <section class="h-1/4 min-h-[150px] flex flex-col hud-panel"> <div class="flex justify-between items-center px-2 py-1 bg-bk-800 border-b border-cy-500/30"> <span class="text-xs text-cy-500 font-bold">SYSTEM_LOG / FALLBACK_TRACE</span> <span class="text-[10px] text-cy-600 animate-pulse">● LIVE_STREAM</span> </div> <div class="flex-1 overflow-y-auto p-2 text-[10px] font-mono text-cy-600" id="console-log"> <!-- Logs appear here --> </div> </section> </div> <!-- Scripts --> <script> // ========================================== // 0. UTILITIES & GLOBAL STATE // ========================================== // Generate random ID const uid = () => Math.random().toString(36).substr(2, 9); // Decoding Text Effect function decodeText(element, finalText, duration = 1000) { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=[]{}|;:,.<>?"; let iterations = 0; const interval = setInterval(() => { element.innerText = finalText .split("") .map((letter, index) => { if (index < iterations / 3) { return finalText[index]; } return chars[Math.floor(Math.random() * chars.length)]; }) .join(""); if (iterations >= finalText.length * 3) { clearInterval(interval); } iterations += 1 / 2; }, duration / (finalText.length * 3)); } // Format Bytes const formatBytes = (bytes, decimals = 2) => { if (!+bytes) return '0 Bytes'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; }; // Logger System const consoleEl = document.getElementById('console-log'); const logs = []; function addLog(message, type = 'info') { const time = new Date().toISOString().split('T')[1].replace('Z', ''); const prefix = type === 'error' ? '[ERR]' : type === 'warn' ? '[WRN]' : '[INF]'; const colorClass = type === 'error' ? 'text-ma-500' : (type === 'success' ? 'text-cy-500' : 'text-cy-600'); const entry = document.createElement('div'); entry.className = `mb-1 border-l-2 pl-2 ${type === 'error' ? 'border-ma-500' : 'border-cy-500/30'}`; entry.innerHTML = `<span class="text-gray-500">${time}</span> <span class="${colorClass}">${prefix}</span> ${message}`; consoleEl.appendChild(entry); consoleEl.scrollTop = consoleEl.scrollHeight; } // Simulate log stream setInterval(() => { const msgs = [ "Checking signature integrity...", "Verifying certificate chain...", "Signed HTTP Exchange headers received.", "Fallback heuristic: Resource not in AMP cache, fetching origin.", "Calculating content hash...", "TLS 1.3 Connection established.", "Parsing Web Bundle metadata...", "Resource preload list optimization.", "Conformance check passed." ]; if (Math.random() > 0.7) { addLog(msgs[Math.floor(Math.random() * msgs.length)]); } }, 2500); // Clock setInterval(() => { const now = new Date(); const ms = String(now.getMilliseconds()).padStart(3, '0'); document.getElementById('clock').innerText = now.toLocaleTimeString('en-US', {hour12: false}) + ':' + ms; }, 50); // ========================================== // 1. DATA MODEL (Web Bundle Structure) // ========================================== const fileData = [ { id: 'root', name: 'example.com_bundle.wbn', type: 'bundle', size: 0, children: [ { id: 'index', name: 'index.html', type: 'file', size: 45210, loadTime: 12, mime: 'text/html' }, { id: 'manifest', name: 'manifest.webmanifest', type: 'file', size: 1204, loadTime: 4, mime: 'application/manifest+json' }, { id: 'styles', name: 'assets/main.css', type: 'file', size: 15400, loadTime: 5, mime: 'text/css' }, { id: 'main-js', name: 'assets/app.bundle.js', type: 'file', size: 89012, loadTime: 22, mime: 'application/javascript' }, { id: 'hero-img', name: 'assets/img/hero.jpg', type: 'file', size: 124500, loadTime: 145, mime: 'image/jpeg' }, { id: 'font', name: 'assets/fonts/Roboto.woff2', type: 'file', size: 34000, loadTime: 18, mime: 'font/woff2' } ] } ]; // Flatten for easier interaction const flatFiles = []; function flatten(data) { data.forEach(item => { if (item.type === 'bundle') { flatten(item.children); } else { flatFiles.push(item); } }); } flatten(fileData); // ========================================== // 2. FILE EXPLORER RENDERER // ========================================== const fileListEl = document.getElementById('file-list'); function renderFileList() { fileListEl.innerHTML = ''; function renderNode(node, depth = 0) { if (node.type === 'bundle') { const bundleEl = document.createElement('div'); bundleEl.className = 'cursor-pointer hover:text-cy-100 mb-1 transition-colors'; bundleEl.style.paddingLeft = `${depth * 12 + 4}px`; bundleEl.innerHTML = ` <span class="text-ma-500 select-none">[DIR]</span> <span class="ml-1 font-bold text-cy-500">${node.name}</span> <span class="ml-2 text-[10px] text-gray-600">(Web Bundle)</span> `; fileListEl.appendChild(bundleEl); node.children.forEach(child => renderNode(child, depth + 1)); } else { const fileEl = document.createElement('div'); fileEl.className = 'cursor-pointer hover:text-cy-100 hover:bg-cy-500/10 px-1 py-0.5 rounded transition-all group item-file text-cy-600'; fileEl.style.paddingLeft = `${depth * 12 + 4}px`; fileEl.dataset.id = node.id; fileEl.innerHTML = ` <span class="group-hover:hidden text-xs">[ ]</span> <span class="group-hover:inline hidden text-ma-500">[X]</span> <span class="ml-1 text-sm">${node.name}</span> <span class="ml-auto text-[10px] opacity-60">${formatBytes(node.size)}</span> `; fileEl.addEventListener('click', () => selectFile(node)); fileListEl.appendChild(fileEl); } } fileData.forEach(root => renderNode(root)); } renderFileList(); // ========================================== // 3. THREE.JS VISUALIZATION // ========================================== const canvasContainer = document.getElementById('canvas-container'); // Scene Setup const scene = new THREE.Scene(); // Fog for depth scene.fog = new THREE.FogExp2(0x050505, 0.02); const camera = new THREE.PerspectiveCamera(60, canvasContainer.clientWidth / canvasContainer.clientHeight, 0.1, 1000); camera.position.z = 15; camera.position.y = 5; camera.lookAt(0, 0, 0); const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); renderer.setSize(canvasContainer.clientWidth, canvasContainer.clientHeight); renderer.setPixelRatio(window.devicePixelRatio); canvasContainer.appendChild(renderer.domElement); // Lights const ambientLight = new THREE.AmbientLight(0x404040, 2); scene.add(ambientLight); const pointLight = new THREE.PointLight(0x00f3ff, 2, 50); pointLight.position.set(5, 10, 5); scene.add(pointLight); const magentaLight = new THREE.PointLight(0xff00ff, 1, 50); magentaLight.position.set(-5, -5, 5); scene.add(magentaLight); // Object: The Bundle Core (Wireframe Icosahedron) const coreGeo = new THREE.IcosahedronGeometry(4, 1); const coreMat = new THREE.MeshBasicMaterial({ color: 0x00f3ff, wireframe: true, transparent: true, opacity: 0.3 }); const core = new THREE.Mesh(coreGeo, coreMat); scene.add(core); // Inner Core (Glowing Sphere) const innerGeo = new THREE.SphereGeometry(1.5, 32, 32); const innerMat = new THREE.MeshPhongMaterial({ color: 0xff00ff, emissive: 0x440044, emissiveIntensity: 0.5, shininess: 100 }); const innerCore = new THREE.Mesh(innerGeo, innerMat); scene.add(innerCore); // Data Nodes (Files) const nodes = []; const nodeGroup = new THREE.Group(); scene.add(nodeGroup); // Create nodes for each file + root const allNodesData = [ { pos: new THREE.Vector3(0, 0, 0), size: 1.5, color: 0xff00ff, ref: fileData[0] } // Root ]; flatFiles.forEach((file, i) => { // Distribute randomly on a sphere surface area const phi = Math.acos(-1 + (2 * i) / (flatFiles.length + 1)); const theta = Math.sqrt(flatFiles.length * Math.PI) * phi; const radius = 6 + Math.random() * 2; const x = radius * Math.cos(theta) * Math.sin(phi); const y = radius * Math.sin(theta) * Math.sin(phi); const z = radius * Math.cos(phi); allNodesData.push({ pos: new THREE.Vector3(x, y, z), size: 0.3 + (file.size / 500000), // Size relative to bundle size color: 0x00f3ff, ref: file }); }); // Generate Meshes allNodesData.forEach(data => { const geo = new THREE.SphereGeometry(data.size, 16, 16); const mat = new THREE.MeshBasicMaterial({ color: data.color }); const mesh = new THREE.Mesh(geo, mat); mesh.position.copy(data.pos); mesh.userData = { ref: data.ref, originalColor: data.color }; nodeGroup.add(mesh); nodes.push(mesh); // Connect to core with a line const lineGeo = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0,0,0), data.pos]); const lineMat = new THREE.LineBasicMaterial({ color: 0x111111, transparent: true, opacity: 0.2 }); const line = new THREE.Line(lineGeo, lineMat); scene.add(line); }); // Interaction: Raycaster const raycaster = new THREE.Raycaster(); const mouse = new THREE.Vector2(); let hoveredNode = null; function onMouseMove(event) { // Normalize mouse pos for canvas const rect = renderer.domElement.getBoundingClientRect(); mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; // Check intersection raycaster.setFromCamera(mouse, camera); const intersects = raycaster.intersectObjects(nodes); if (intersects.length > 0) { const object = intersects[0].object; if (hoveredNode !== object) { // Reset previous if (hoveredNode) { hoveredNode.material.color.setHex(hoveredNode.userData.originalColor); hoveredNode.scale.setScalar(1); } // Set new hoveredNode = object; hoveredNode.material.color.setHex(0xffaa00); // Amber highlight hoveredNode.scale.setScalar(1.5); document.body.style.cursor = 'pointer'; // Highlight file list if applicable document.querySelectorAll('.item-file').forEach(el => el.classList.remove('bg-cy-500/20', 'text-white')); const fileInList = document.querySelector(`.item-file[data-id="${object.userData.ref.id}"]`); if (fileInList) { fileInList.classList.add('bg-cy-500/20', 'text-white'); fileInList.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } } } else { if (hoveredNode) { hoveredNode.material.color.setHex(hoveredNode.userData.originalColor); hoveredNode.scale.setScalar(1); hoveredNode = null; document.body.style.cursor = 'default'; } } } window.addEventListener('mousemove', onMouseMove); // Animation Loop let time = 0; function animate() { requestAnimationFrame(animate); time += 0.005; // Rotate core core.rotation.x += 0.01; core.rotation.y += 0.01; // Pulse inner core const scale = 1 + Math.sin(time * 3) * 0.1; innerCore.scale.setScalar(scale); // Rotate node group slowly nodeGroup.rotation.y += 0.002; // Wave effect on nodes nodes.forEach((node, i) => { if (node !== hoveredNode) { const offset = i * 0.1; node.position.y += Math.sin(time + offset) * 0.01; } }); renderer.render(scene, camera); } animate(); // Resize Handler window.addEventListener('resize', () => { camera.aspect = canvasContainer.clientWidth / canvasContainer.clientHeight; camera.updateProjectionMatrix(); renderer.setSize(canvasContainer.clientWidth, canvasContainer.clientHeight); }); // ========================================== // 4. PERFORMANCE DYNAMICS // ========================================== const scoreEl = document.getElementById('score-text'); const scoreCircle = document.getElementById('score-circle'); const loadBar = document.getElementById('load-time-bar'); const loadVal = document.getElementById('load-time-val'); const latencyBar = document.getElementById('latency-bar'); const latencyVal = document.getElementById('latency-val'); const cpuBar = document.getElementById('cpu-bar'); const cpuVal = document.getElementById('cpu-val'); const packetSizeEl = document.getElementById('packet-size'); const compRatioEl = document.getElementById('comp-ratio'); // Simulate real-time updates function updateMetrics() { const loadTime = Math.floor(Math.random() * 200) + 20; const latency = Math.floor(Math.random() * 50) + 5; const cpu = Math.floor(Math.random() * 30) + 10; const score = Math.floor(100 - loadTime/5 - latency/4 - cpu/2); // Text updates scoreEl.innerText = score; loadVal.innerText = loadTime + 'ms'; latencyVal.innerText = latency + 'ms'; cpuVal.innerText = cpu + '%'; packetSizeEl.innerText = formatBytes(194560 + Math.random() * 50000); compRatioEl.innerText = (Math.random() * 20 + 80).toFixed(1) + '%'; // Bar visual loadBar.style.width = Math.min(loadTime, 300) / 3 + '%'; latencyBar.style.width = Math.min(latency, 300) / 3 + '%'; cpuBar.style.width = cpu + '%'; // Circle Circumference (r=10 ~ 62.83) const circumference = 2 * Math.PI * 10; const offset = circumference - (score / 100) * circumference; scoreCircle.style.strokeDashoffset = offset; // Color change based on score if (score > 80) scoreCircle.style.stroke = '#00f3ff'; else if (score > 60) scoreCircle.style.stroke = '#ffaa00'; else scoreCircle.style.stroke = '#ff00ff'; } // Initial run updateMetrics(); // Periodic fluctuation setInterval(updateMetrics, 2000); // ========================================== // 5. FILE SELECTION LOGIC // ========================================== function selectFile(file) { // Update Logic if (!file) return; // Find node in Three.js const node = nodes.find(n => n.userData.ref.id === file.id); if (node) { // Reset others nodes.forEach(n => n.material.color.setHex(n.userData.originalColor)); // Highlight node.material.color.setHex(0xff00ff); // Strong magenta // Camera focus animation (simple lerp) gsapLike(camera.position, { z: 10 }, 500); setTimeout(() => gsapLike(camera.position, { z: 15 }, 1000), 500); } // Decode Text in Panel Headers (Simulating data fetch) decodeText(document.getElementById('packet-size'), formatBytes(file.size)); decodeText(document.getElementById('comp-ratio'), (Math.random() * 30 + 70).toFixed(2) + '%'); decodeText(loadVal, Math.floor(Math.random() * 100 + 10) + 'ms'); // Add Log addLog(`Selected resource: ${file.name} (${file.mime})`, 'info'); } // Simple tween helper (no external lib) function gsapLike(target, props, duration) { const start = {}; const change = {}; for (let key in props) { start[key] = target[key]; change[key] = props[key] - start[key]; } const startTime = performance.now(); function update(currentTime) { const elapsed = currentTime - startTime; const progress = Math.min(elapsed / duration, 1); // Ease out quad const eased = 1 - (1 - progress) * (1 - progress); for (let key in props) { target[key] = start[key] + change[key] * eased; } if (progress < 1) { requestAnimationFrame(update); } } requestAnimationFrame(update); } // Initial Log addLog("System initialized. Web Bundle protocol loaded.", "success"); addLog("Signature verified against Google Root CA.", "success"); </script> </body> </html> -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.