<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus AI | Model Comparator</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- 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=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400&display=swap" rel="stylesheet">
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- ECharts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js"></script>
<!-- Three.js (ES Module via Import Map for clean usage) -->
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js"
}
}
</script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
'deep-black': '#050505',
'card-bg': 'rgba(20, 20, 25, 0.6)',
'accent-cyan': '#00f0ff',
'accent-purple': '#bd00ff',
'accent-green': '#00ff94',
'accent-red': '#ff2a2a',
},
backdropBlur: {
xs: '2px',
}
}
}
}
</script>
<style>
body {
background-color: #050505;
color: #ffffff;
overflow: hidden; /* App-like feel */
}
/* Tactile Noise Texture */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.04;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Glassmorphism */
.glass-panel {
background: rgba(20, 20, 25, 0.45);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}
.glass-panel:hover {
border-color: rgba(255, 255, 255, 0.2);
background: rgba(25, 25, 30, 0.55);
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: rgba(255,255,255,0.05);
}
::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 4px;
}
/* Magnetic Button Effect */
.magnetic-btn {
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Chart Containers */
.chart-container {
width: 100%;
height: 100%;
min-height: 200px;
}
</style>
</head>
<body class="antialiased h-screen w-screen flex flex-col p-0 m-0 selection:bg-accent-cyan selection:text-black">
<!-- 3D Background -->
<div id="three-container" class="absolute inset-0 z-0 pointer-events-none opacity-60"></div>
<!-- Noise Overlay -->
<div class="noise-overlay"></div>
<!-- Main UI Layer -->
<div class="relative z-10 flex flex-col h-full p-6 md:p-8 gap-6 max-w-[1600px] mx-auto w-full">
<!-- HEADER -->
<header class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 shrink-0">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded bg-gradient-to-br from-accent-cyan to-accent-purple flex items-center justify-center text-black font-serif font-bold text-lg shadow-[0_0_15px_rgba(0,240,255,0.4)]">
N
</div>
<div>
<h1 class="text-2xl font-serif font-medium tracking-tight text-white">Nexus <span class="text-accent-cyan">Comparator</span></h1>
<p class="text-xs text-neutral-400 uppercase tracking-widest">Model Analysis Dashboard</p>
</div>
</div>
<!-- Version Switcher (Magnetic Integration) -->
<div class="flex items-center gap-4 bg-black/30 p-1 rounded-lg border border-white/10 backdrop-blur-md">
<button id="btn-v1" class="magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 bg-white/10 text-white shadow-sm ring-1 ring-transparent">
Model v1.0
</button>
<button id="btn-v2" class="magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 text-neutral-400 hover:text-white ring-1 ring-transparent">
Model v2.0
</button>
</div>
</header>
<!-- DASHBOARD GRID (Bento) -->
<main class="grid grid-cols-12 grid-rows-5 gap-4 md:gap-5 flex-1 min-h-0">
<!-- ROW 1: KEY METRICS (Spanning 4 cols each) -->
<div class="col-span-12 md:col-span-3 glass-panel rounded-2xl p-5 flex flex-col justify-center relative overflow-hidden group transition-all duration-300">
<div class="absolute -right-4 -top-4 w-24 h-24 bg-accent-cyan/10 rounded-full blur-2xl group-hover:bg-accent-cyan/20 transition-all"></div>
<p class="text-neutral-400 text-xs uppercase tracking-wider mb-1">Overall Accuracy</p>
<div class="flex items-baseline gap-2">
<span id="metric-accuracy" class="text-4xl font-serif font-medium text-white">94.2</span>
<span id="delta-accuracy" class="text-sm font-medium text-accent-green flex items-center">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path></svg>
+2.1%
</span>
</div>
</div>
<div class="col-span-12 md:col-span-3 glass-panel rounded-2xl p-5 flex flex-col justify-center relative overflow-hidden group transition-all duration-300">
<div class="absolute -right-4 -top-4 w-24 h-24 bg-accent-purple/10 rounded-full blur-2xl group-hover:bg-accent-purple/20 transition-all"></div>
<p class="text-neutral-400 text-xs uppercase tracking-wider mb-1">F1 Score (Macro)</p>
<div class="flex items-baseline gap-2">
<span id="metric-f1" class="text-4xl font-serif font-medium text-white">0.89</span>
<span id="delta-f1" class="text-sm font-medium text-accent-green flex items-center">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path></svg>
+0.04
</span>
</div>
</div>
<div class="col-span-12 md:col-span-3 glass-panel rounded-2xl p-5 flex flex-col justify-center relative overflow-hidden group transition-all duration-300">
<div class="absolute -right-4 -top-4 w-24 h-24 bg-accent-red/10 rounded-full blur-2xl group-hover:bg-accent-red/20 transition-all"></div>
<p class="text-neutral-400 text-xs uppercase tracking-wider mb-1">Inference Latency (p99)</p>
<div class="flex items-baseline gap-2">
<span id="metric-latency" class="text-4xl font-serif font-medium text-white">124</span>
<span class="text-neutral-500 text-sm">ms</span>
<span id="delta-latency" class="text-sm font-medium text-accent-green flex items-center">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path></svg>
-12ms
</span>
</div>
</div>
<div class="col-span-12 md:col-span-3 glass-panel rounded-2xl p-5 flex flex-col justify-center relative overflow-hidden group transition-all duration-300">
<div class="absolute -right-4 -top-4 w-24 h-24 bg-amber-400/10 rounded-full blur-2xl group-hover:bg-amber-400/20 transition-all"></div>
<p class="text-neutral-400 text-xs uppercase tracking-wider mb-1">Inference Cost / 1k</p>
<div class="flex items-baseline gap-2">
<span id="metric-cost" class="text-4xl font-serif font-medium text-white">$1.24</span>
<span id="delta-cost" class="text-sm font-medium text-accent-red flex items-center">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 17h8m0 0V9m0 8l-8-8-4 4-6-6"></path></svg>
+8%
</span>
</div>
</div>
<!-- ROW 2: VISUALIZATION -->
<!-- Radar Chart (Fairness) -->
<div class="col-span-12 md:col-span-4 row-span-2 glass-panel rounded-2xl p-5 flex flex-col">
<div class="flex justify-between items-center mb-4">
<h3 class="font-sans font-medium text-sm text-neutral-300">Capability Radar</h3>
<div class="flex gap-2">
<div class="w-2 h-2 rounded-full bg-accent-cyan"></div>
<span class="text-xs text-neutral-500" id="label-radar-v">v2.0</span>
</div>
</div>
<div id="radarChart" class="flex-1 chart-container"></div>
</div>
<!-- Line Chart (Training Loss / Telemetry) -->
<div class="col-span-12 md:col-span-8 glass-panel rounded-2xl p-5 flex flex-col">
<div class="flex justify-between items-center mb-4">
<h3 class="font-sans font-medium text-sm text-neutral-300">Training Convergence & Loss</h3>
<div class="px-2 py-0.5 rounded bg-white/5 text-xs font-mono border border-white/10">EPOCHS 1-100</div>
</div>
<div id="lineChart" class="flex-1 chart-container"></div>
</div>
<!-- ROW 3: FAIRNESS HEATMAP & TELEMETRY DELTAS -->
<!-- Fairness Heatmap -->
<div class="col-span-12 md:col-span-6 glass-panel rounded-2xl p-5 flex flex-col overflow-hidden">
<h3 class="font-sans font-medium text-sm text-neutral-300 mb-4">Fairness Heatmap (Prediction Disparity)</h3>
<div class="flex-1 overflow-y-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="text-xs text-neutral-500 border-b border-white/10">
<th class="py-2 font-normal">Group / Metric</th>
<th class="py-2 font-normal text-center">Selection Rate</th>
<th class="py-2 font-normal text-center">TPR</th>
<th class="py-2 font-normal text-center">FPR</th>
<th class="py-2 font-normal text-center">Bias Score</th>
</tr>
</thead>
<tbody id="fairness-table" class="text-sm">
<!-- Populated by JS -->
</tbody>
</table>
</div>
</div>
<!-- Telemetry Deltas -->
<div class="col-span-12 md:col-span-6 glass-panel rounded-2xl p-5 flex flex-col overflow-hidden">
<h3 class="font-sans font-medium text-sm text-neutral-300 mb-4">Telemetry Deltas (v1.0 → v2.0)</h3>
<div class="space-y-3 flex-1 overflow-y-auto pr-2" id="deltas-list">
<!-- Populated JS -->
</div>
</div>
</main>
</div>
<!-- MAIN SCRIPT -->
<script type="module">
import * as THREE from 'three';
// ==========================================
// 1. MOCK DATA STORE
// ==========================================
const DATA = {
v1: {
accuracy: 92.1,
f1: 0.85,
latency: 136,
cost: 1.15,
radar: [85, 80, 70, 90, 75], // Accuracy, Robustness, Fairness, Scalability, Privacy
loss: Array.from({length: 100}, () => 0.8 - Math.random()*0.01 + Math.random()*0.1), // Simulated trend
fairness: [
{ group: 'Asian', sel: 0.62, tpr: 0.91, fpr: 0.12, score: 0.92 },
{ group: 'Black', sel: 0.48, tpr: 0.78, fpr: 0.15, score: 0.76 },
{ group: 'Hispanic', sel: 0.51, tpr: 0.81, fpr: 0.14, score: 0.79 },
{ group: 'White', sel: 0.65, tpr: 0.92, fpr: 0.11, score: 0.95 },
{ group: 'Other', sel: 0.55, tpr: 0.84, fpr: 0.13, score: 0.82 }
],
deltas: [
{ name: "Training Time", val: "+2h", type: "neg", desc: "Increased training duration due to larger ensemble." },
{ name: "Cold Start", val: "-15%", type: "pos", desc: "Optimized model loading sequence." },
{ name: "Hallucination Rate", val: "-0.8pp", type: "pos", desc: "Significant reduction in out-of-scope generation." },
{ name: "Context Window", val: "4k -> 8k", type: "pos", desc: "Extended token capacity." },
{ name: "Parameter Count", val: "7B -> 13B", type: "neg", desc: "Larger base model for reasoning." }
]
},
v2: {
accuracy: 94.2,
f1: 0.89,
latency: 124,
cost: 1.24,
radar: [95, 92, 83, 88, 80],
loss: Array.from({length: 100}, () => 0.6 - Math.random()*0.01 + Math.random()*0.08),
fairness: [
{ group: 'Asian', sel: 0.64, tpr: 0.93, fpr: 0.11, score: 0.95 },
{ group: 'Black', sel: 0.53, tpr: 0.84, fpr: 0.12, score: 0.86 },
{ group: 'Hispanic', sel: 0.54, tpr: 0.85, fpr: 0.12, score: 0.87 },
{ group: 'White', sel: 0.64, tpr: 0.92, fpr: 0.10, score: 0.96 },
{ group: 'Other', sel: 0.56, tpr: 0.86, fpr: 0.12, score: 0.88 }
],
deltas: [
{ name: "Training Time", val: "-1h", type: "pos", desc: "Improved data pipelines." },
{ name: "Cold Start", val: "-5%", type: "pos", desc: "Minimal regressions." },
{ name: "Hallucination Rate", val: "-0.2pp", type: "pos", desc: "Further tuned safety guardrails." },
{ name: "Context Window", val: "8k -> 16k", type: "pos", desc: "Long-context optimization." },
{ name: "Parameter Count", val: "13B -> 34B", type: "neg", desc: "MoE architecture for efficiency." }
]
}
};
// State
let activeVersion = 'v2';
let charts = { radar: null, line: null };
let threeScene = null, threeMesh = null;
// ==========================================
// 2. UI UTILITIES (GSAP)
// ==========================================
// Animate numbers smoothly
function animateValue(id, end, decimals = 0) {
gsap.to({}, {
duration: 1,
ease: "power2.out",
onUpdate: function() {
const progress = this.progress();
const start = parseFloat(document.getElementById(id).innerText);
// If starting point is empty or not a number, set to 0 or use different logic
const current = start + (end - start) * this.progress();
document.getElementById(id).innerText = current.toFixed(decimals);
}
});
}
// Update deltas and heatmap
function updateStaticElements(versionKey) {
const data = DATA[versionKey];
// Delta Badges
const deltaMapping = {
'metric-accuracy': versionKey === 'v2' ? '+2.1%' : '-0.5%',
'delta-accuracy': versionKey === 'v2' ? 'text-accent-green' : 'text-accent-red',
'delta-f1': versionKey === 'v2' ? 'text-accent-green' : 'text-accent-red',
'delta-latency': versionKey === 'v2' ? 'text-accent-green' : 'text-accent-red',
'delta-cost': versionKey === 'v2' ? 'text-accent-red' : 'text-accent-green' // Cost lower is better for v1?
};
// Simple handling for demo (V2 better cost? actually code says V2 cost is higher, so V2 red)
// For demo we'll keep logical mapping based on data structure below
// Let's rely on generated HTML structure where possible
// Since we are re-rendering some parts, easier to just update text content
// 1. Fairness Table
const tbody = document.getElementById('fairness-table');
tbody.innerHTML = '';
data.fairness.forEach(row => {
tr = document.createElement('tr');
tr.className = "border-b border-white/5 hover:bg-white/5 transition-colors";
const biasColor = row.score > 0.85 ? 'text-accent-green' : row.score > 0.7 ? 'text-yellow-500' : 'text-accent-red';
tr.innerHTML = `
<td class="py-3 font-medium text-neutral-200">${row.group}</td>
<td class="py-3 text-center text-neutral-400">${row.sel.toFixed(2)}</td>
<td class="py-3 text-center text-neutral-400">${row.tpr.toFixed(2)}</td>
<td class="py-3 text-center text-neutral-400">${row.fpr.toFixed(2)}</td>
<td class="py-3 text-center font-mono font-medium ${biasColor}">${row.score.toFixed(3)}</td>
`;
tbody.appendChild(tr);
});
// 2. Deltas List
const deltasContainer = document.getElementById('deltas-list');
deltasContainer.innerHTML = '';
data.deltas.forEach(item => {
div = document.createElement('div');
div.className = "flex items-start gap-3 p-3 rounded-lg bg-white/[0.03] border border-white/5";
const icon = item.type === 'pos'
? `<svg class="w-5 h-5 text-accent-green flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>`
: `<svg class="w-5 h-5 text-amber-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>`;
div.innerHTML = `
${icon}
<div>
<div class="flex items-center gap-2">
<span class="font-medium text-sm text-white">${item.name}</span>
<span class="text-xs font-mono px-1.5 py-0.5 rounded ${item.type === 'pos' ? 'bg-accent-green/10 text-accent-green' : 'bg-amber-500/10 text-amber-500'}">${item.val}</span>
</div>
<p class="text-xs text-neutral-500 mt-0.5">${item.desc}</p>
</div>
`;
deltasContainer.appendChild(div);
});
}
// Update Charts
function updateCharts(versionKey) {
const data = DATA[versionKey];
const colorPrimary = versionKey === 'v2' ? '#00f0ff' : '#bd00ff'; // Cyan vs Purple
// --- RADAR CHART ---
const radarOption = {
backgroundColor: 'transparent',
tooltip: { trigger: 'item' },
radar: {
indicator: [
{ name: 'Accuracy', max: 100 },
{ name: 'Robustness', max: 100 },
{ name: 'Fairness', max: 100 },
{ name: 'Scalability', max: 100 },
{ name: 'Privacy', max: 100 }
],
splitArea: { show: false },
splitLine: { lineStyle: { color: 'rgba(255,255,255,0.1)' } },
axisName: { color: '#999', fontFamily: 'Inter' }
},
series: [{
name: 'Model Stats',
type: 'radar',
data: [{
value: data.radar,
name: activeVersion === 'v2' ? 'v2.0' : 'v1.0',
areaStyle: { color: versionKey === 'v2' ? 'rgba(0,240,255,0.3)' : 'rgba(189,0,255,0.3)', opacity: 0.6 },
lineStyle: { color: versionKey === 'v2' ? '#00f0ff' : '#bd00ff', width: 2 },
itemStyle: { color: versionKey === 'v2' ? '#00f0ff' : '#bd00ff' }
}]
}]
};
charts.radar.setOption(radarOption);
// --- LINE CHART (Loss) ---
// Smooth out data
const lineData = data.loss.map(y => parseFloat(y.toFixed(4)));
const lineOption = {
backgroundColor: 'transparent',
tooltip: { trigger: 'axis' },
grid: { top: 30, right: 20, bottom: 20, left: 40, show: true, borderColor: 'rgba(255,255,255,0.05)' },
xAxis: {
type: 'category',
show: false,
data: Array.from({length: 100}, (_, i) => i)
},
yAxis: {
type: 'value',
splitLine: { lineStyle: { color: 'rgba(255,255,255,0.05)' } },
axisLabel: { color: '#666' }
},
series: [{
data: lineData,
type: 'line',
smooth: true,
showSymbol: false,
lineStyle: { color: colorPrimary, width: 2, shadowColor: colorPrimary, shadowBlur: 10 },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: versionKey === 'v2' ? 'rgba(0,240,255,0.4)' : 'rgba(189,0,255,0.4)' },
{ offset: 1, color: 'rgba(0,0,0,0)' }
])
}
}]
};
charts.line.setOption(lineOption);
}
// ==========================================
// 3. THREE.JS BACKGROUND (Atmospheric)
// ==========================================
function initThreeJS() {
const container = document.getElementById('three-container');
const scene = new THREE.Scene();
// Fog to blend into background
scene.fog = new THREE.FogExp2(0x050505, 0.002);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
// Particle System (Stars/Dust)
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 700;
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 25;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const material = new THREE.PointsMaterial({
size: 0.03,
color: 0x00f0ff,
transparent: true,
opacity: 0.6,
blending: THREE.AdditiveBlending
});
const particlesMesh = new THREE.Points(particlesGeometry, material);
scene.add(particlesMesh);
// Central Geometric Object (Icosahedron Wireframe)
const geometry = new THREE.IcosahedronGeometry(2, 1);
const wireframe = new THREE.WireframeGeometry(geometry);
const lineMaterial = new THREE.LineBasicMaterial({ color: 0xbd00ff, transparent: true, opacity: 0.15 });
const sphereLines = new THREE.LineSegments(wireframe, lineMaterial);
scene.add(sphereLines);
// Animation Loop
let mouseX = 0;
let mouseY = 0;
document.addEventListener('mousemove', (event) => {
mouseX = event.clientX / window.innerWidth - 0.5;
mouseY = event.clientY / window.innerHeight - 0.5;
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
// Rotate elements
particlesMesh.rotation.y = time * 0.05;
particlesMesh.rotation.x = mouseY * 0.2;
sphereLines.rotation.y = time * 0.02;
sphereLines.rotation.x += 0.002;
sphereLines.rotation.z += 0.001;
// Parallax movement based on mouse
sphereLines.position.x = mouseX * 0.2;
sphereLines.position.y = -mouseY * 0.2;
// Color pulse (optional, match active version)
// If active version is v2 (cyan), gradually shift purple to cyan over time?
// Keep simple for now: fixed colors.
renderer.render(scene, camera);
}
animate();
// Handle Resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
}
// ==========================================
// 4. MAGNETIC BUTTON EFFECT
// ==========================================
function initMagneticButtons() {
const btns = document.querySelectorAll('.magnetic-btn');
btns.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(btn, {
duration: 0.3,
x: x * 0.3,
y: y * 0.3,
ease: "power2.out"
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, {
duration: 0.5,
x: 0,
y: 0,
ease: "elastic.out(1, 0.3)"
});
});
});
}
// ==========================================
// 5. INITIALIZATION
// ==========================================
window.onload = function() {
// Init Charts
charts.radar = echarts.init(document.getElementById('radarChart'));
charts.line = echarts.init(document.getElementById('lineChart'));
// Init 3D
initThreeJS();
// Initial Render
updateStaticElements(activeVersion);
updateCharts(activeVersion);
initMagneticButtons();
// Event Listeners for Version Switch
document.getElementById('btn-v1').addEventListener('click', () => switchVersion('v1'));
document.getElementById('btn-v2').addEventListener('click', () => switchVersion('v2'));
// Responsive Charts
window.addEventListener('resize', () => {
charts.radar.resize();
charts.line.resize();
});
};
function switchVersion(newVersion) {
if (newVersion === activeVersion) return;
// UI State Update
const btnV1 = document.getElementById('btn-v1');
const btnV2 = document.getElementById('btn-v2');
// Visual Button State
if (newVersion === 'v1') {
btnV1.className = "magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 bg-white text-black font-bold shadow-sm ring-1 ring-accent-cyan";
btnV2.className = "magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 text-neutral-400 hover:text-white ring-1 ring-transparent";
} else {
btnV2.className = "magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 bg-white text-black font-bold shadow-sm ring-1 ring-accent-purple";
btnV1.className = "magnetic-btn px-5 py-2 rounded-md text-sm font-medium transition-all duration-300 text-neutral-400 hover:text-white ring-1 ring-transparent";
}
// Animate Transition: Out
const tl = gsap.timeline();
// Fade out key metrics slightly
tl.to(['#metric-accuracy', '#metric-f1', '#metric-latency', '#metric-cost'], {
opacity: 0.3,
duration: 0.2,
onComplete: () => {
activeVersion = newVersion;
// Update Content
const data = DATA[newVersion];
// Update Numbers
document.getElementById('metric-accuracy').innerText = data.accuracy.toFixed(1);
document.getElementById('metric-f1').innerText = data.f1.toFixed(2);
document.getElementById('metric-latency').innerText = data.latency;
document.getElementById('metric-cost').innerText = `$${data.cost.toFixed(2)}`;
// Update Charts
updateCharts(newVersion);
updateStaticElements(newVersion);
}
})
// Fade back in
.to(['#metric-accuracy', '#metric-f1', '#metric-latency', '#metric-cost'], {
opacity: 1,
duration: 0.4,
ease: "back.out(1.7)"
});
// Sync Charts with new data
// The update calls inside onComplete handle it.
}
</script>
</body>
</html>