<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CONSENT LINEAGE // NEXUS-7</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- OrbitControls -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/controls/OrbitControls.min.js"></script>
<!-- Tween.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/18.6.4/tween.umd.js"></script>
<!-- GSAP for UI animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<style>
/* --- RESET & BASE --- */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');
body {
margin: 0;
overflow: hidden;
background-color: #050505;
font-family: 'JetBrains Mono', monospace;
color: #a5f3fc; /* Cyan-200 */
}
/* --- CRT / SCANLINE EFFECT --- */
.scanlines {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
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;
animation: scrolllines 10s linear infinite;
}
.vignette {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 40;
background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
}
@keyframes scrolllines {
0% { background-position: 0 0; }
100% { background-position: 0 100%; }
}
/* --- CYBERPUNK UI UTILITIES --- */
.neon-text-cyan {
text-shadow: 0 0 5px rgba(34, 211, 238, 0.8), 0 0 10px rgba(34, 211, 238, 0.5);
}
.neon-text-magenta {
text-shadow: 0 0 5px rgba(232, 121, 249, 0.8), 0 0 10px rgba(232, 121, 249, 0.5);
}
.neon-text-amber {
text-shadow: 0 0 5px rgba(251, 191, 36, 0.8), 0 0 10px rgba(251, 191, 36, 0.5);
}
.hud-panel {
background: rgba(5, 5, 5, 0.85);
border: 1px solid rgba(34, 211, 238, 0.4);
backdrop-filter: blur(4px);
position: relative;
/* Corner decorations */
box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}
.hud-panel::before, .hud-panel::after {
content: '';
position: absolute;
width: 8px;
height: 8px;
border: 2px solid #22d3ee;
transition: all 0.3s ease;
}
.hud-panel::before { top: -1px; left: -1px; border-bottom: none; border-right: none; }
.hud-panel::after { bottom: -1px; right: -1px; border-top: none; border-left: none; }
.hud-panel:hover::before, .hud-panel:hover::after {
width: 100%;
height: 100%;
opacity: 0.3;
}
/* --- SCROLLBARS --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #22d3ee; }
/* --- LOADING OVERLAY --- */
#loader {
position: fixed;
inset: 0;
background: #000;
z-index: 100;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.loader-bar {
width: 400px;
height: 2px;
background: #111;
margin-top: 20px;
position: relative;
overflow: hidden;
}
.loader-progress {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 0%;
background: #22d3ee;
box-shadow: 0 0 10px #22d3ee;
transition: width 0.1s;
}
/* --- DECODING ANIMATION CLASS --- */
.decode-text::after {
content: " ";
animation: glitch-anim 2s infinite linear alternate-reverse;
}
@keyframes glitch-anim {
0% { opacity: 0.8; }
20% { opacity: 0.5; }
40% { opacity: 0.9; }
60% { opacity: 0.2; }
80% { opacity: 0.7; }
100% { opacity: 0.4; }
}
</style>
</head>
<body>
<!-- Loading / Boot Sequence -->
<div id="loader">
<h2 class="text-cyan-400 tracking-[0.5em] text-sm mb-2 blink">SYSTEM INITIALIZING</h2>
<div class="loader-bar">
<div class="loader-progress" id="progress-bar"></div>
</div>
<p class="text-cyan-900 text-xs mt-2 font-mono" id="loader-text">LOADING NEURAL NET...</p>
</div>
<!-- CRT Overlays -->
<div class="scanlines"></div>
<div class="vignette"></div>
<!-- 3D Canvas Container -->
<div id="canvas-container" class="absolute inset-0 z-0"></div>
<!-- HUD UI LAYER -->
<div class="absolute inset-0 z-10 pointer-events-none p-6 flex flex-col justify-between">
<!-- Header -->
<header class="flex justify-between items-start pointer-events-auto">
<div class="hud-panel p-4 w-96">
<div class="flex justify-between items-center border-b border-cyan-900 pb-2 mb-2">
<h1 class="text-cyan-300 text-lg font-bold tracking-widest uppercase decode-text" data-text="Consent Lineage">CONSENT LINEAGE</h1>
<div class="text-xs text-cyan-700 font-mono">SYS.VER.7.3.2</div>
</div>
<div class="text-xs text-cyan-500 space-y-1 font-mono leading-relaxed">
<div>SECURE CONNECTION: <span class="text-green-400">ESTABLISHED</span></div>
<div>USER ID: <span class="text-white" id="ui-user-id">...loading</span></div>
<div>SESSION: <span class="text-white" id="ui-session-id">...loading</span></div>
</div>
</div>
<div class="hidden md:block text-right">
<div class="text-cyan-600 text-xs font-mono">NETWORK TIME</div>
<div class="text-cyan-200 text-2xl tracking-widest" id="clock">00:00:00</div>
</div>
</header>
<!-- Main Content Wrapper (Empty to let 3D show through, panels positioned absolutely) -->
<!-- LEFT PANEL: TELEMETRY / Metrics -->
<div class="absolute top-40 left-6 w-72 pointer-events-auto hud-panel p-4 flex flex-col gap-4">
<h3 class="text-cyan-400 text-sm border-b border-cyan-900 pb-1 font-bold uppercase">Consent Metrics</h3>
<div class="space-y-3">
<div>
<div class="flex justify-between text-xs text-cyan-500 mb-1">
<span>GRANTED</span>
<span id="count-granted" class="text-cyan-300">0</span>
</div>
<div class="w-full h-1 bg-gray-900 relative overflow-hidden">
<div id="bar-granted" class="h-full bg-cyan-400 shadow-[0_0_10px_#22d3ee]" style="width: 0%"></div>
</div>
</div>
<div>
<div class="flex justify-between text-xs text-cyan-500 mb-1">
<span>DENIED</span>
<span id="count-denied" class="text-fuchsia-300">0</span>
</div>
<div class="w-full h-1 bg-gray-900 relative overflow-hidden">
<div id="bar-denied" class="h-full bg-fuchsia-500 shadow-[0_0_10px_#e879f9]" style="width: 0%"></div>
</div>
</div>
<div>
<div class="flex justify-between text-xs text-cyan-500 mb-1">
<span>PENDING</span>
<span id="count-pending" class="text-amber-300">0</span>
</div>
<div class="w-full h-1 bg-gray-900 relative overflow-hidden">
<div id="bar-pending" class="h-full bg-amber-400 shadow-[0_0_10px_#fbbf24]" style="width: 0%"></div>
</div>
</div>
</div>
<div class="pt-2 border-t border-cyan-900">
<div class="text-xs text-cyan-600 mb-1">SYSTEM LATENCY</div>
<div class="flex items-end gap-2">
<div class="text-2xl font-bold text-cyan-200 morphology-real" id="latency-val">12</div>
<div class="text-sm text-green-400">ms</div>
</div>
</div>
</div>
<!-- RIGHT PANEL: NODE DETAILS / LINEAGE -->
<div id="details-panel" class="absolute top-40 right-6 w-80 pointer-events-auto hud-panel p-4 transition-opacity duration-300 opacity-100">
<div class="flex justify-between items-center border-b border-cyan-900 pb-2 mb-2">
<h3 class="text-fuchsia-400 text-sm font-bold uppercase" id="detail-title">SELECT NODE</h3>
<div class="w-2 h-2 rounded-full bg-fuchsia-500 animate-pulse"></div>
</div>
<div id="detail-content" class="text-sm font-mono space-y-3 text-gray-300 min-h-[200px]">
<p class="text-cyan-700 italic">// Click or hover a node in the network to view its full lineage, storage dependencies, and consent status history.</p>
<!-- Dynamic Content Will Be Injected Here -->
<div id="dynamic-content" class="hidden">
<div class="bg-cyan-900/20 p-2 rounded border border-cyan-800/50 mb-2">
<span class="text-xs text-cyan-500 uppercase">Current Status</span>
<div id="detail-status" class="text-lg font-bold mt-1"></div>
</div>
<div class="mb-2">
<span class="text-xs text-cyan-500 uppercase">Lineage Origin</span>
<p id="detail-origin" class="text-xs text-cyan-200 mt-1 leading-tight"></p>
</div>
<div class="mb-2">
<span class="text-xs text-cyan-500 uppercase">Storage Path</span>
<div id="detail-storage" class="text-xs text-cyan-200 mt-1 font-mono space-y-1">
<!-- List of storage keys -->
</div>
</div>
<div>
<span class="text-xs text-cyan-500 uppercase">Timestamp</span>
<p id="detail-ts" class="text-xs text-cyan-200"></p>
</div>
</div>
</div>
</div>
<!-- BOTTOM: TIMELINE / LOGS -->
<div class="w-full pointer-events-auto">
<div class="hud-panel p-2 mb-2">
<h3 class="text-amber-400 text-xs font-bold uppercase mb-1 flex items-center gap-2">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
RECENT CONSENT EVENTS STREAM
</h3>
<div id="event-log" class="h-24 overflow-y-auto font-mono text-xs space-y-1 p-2 bg-black/60 border border-cyan-900/50">
<!-- Log items injected by JS -->
</div>
</div>
</div>
</div>
<!-- JAVASCRIPT LOGIC -->
<script>
// --- CONFIG & CONSTANTS ---
const COLORS = {
cyan: 0x22d3ee,
magenta: 0xe879f9,
amber: 0xfbbf24,
dark: 0x050505,
gray: 0x444444,
white: 0xffffff
};
const STATUS = {
GRANTED: 'GRANTED',
DENIED: 'DENIED',
PENDING: 'PENDING'
};
// --- DATA MODEL ---
// In a real app, this would come from an API. We simulate a rich dataset.
const generateData = () => {
return {
user: {
id: 'USR-8X-299',
name: 'K. Leung',
consentVersion: '2.4',
region: 'HK-4',
lastLogin: new Date().toISOString()
},
features: [
{ id: 'feat_analytics', name: 'Behavioral Analytics', status: STATUS.GRANTED, type: 'core' },
{ id: 'feat_ads', name: 'Personalized Ads', status: STATUS.DENIED, type: 'monetization' },
{ id: 'feat_location', name: 'Precise Location', status: STATUS.GRANTED, type: 'sensor' },
{ id: 'feat_biometrics', name: 'Biometrics Auth', status: STATUS.PENDING, type: 'security' },
{ id: 'feat_social', name: 'Social Graph', status: STATUS.GRANTED, type: 'graph' },
{ id: 'feat_ml', name: 'ML Training', status: STATUS.DENIED, type: 'research' }
],
storage: [
{ id: 'db_userprofile', name: 'User Profile (PG)', type: 'primary' },
{ id: 'redis_consents', name: 'Consent Cache (Redis)', type: 'cache' },
{ id: 's3_logs', name: 'Interaction Logs (S3)', type: 'cold' },
{ id: 'warehouse', name: 'Analytics Warehouse', type: 'bi' },
{ id: 'audit_ledger', name: 'Audit Ledger', type: 'immutable' }
],
events: [
{ id: 'evt_001', type: 'CLICK', uiElement: 'btn_accept_all', ts: '2077-10-24T08:12:00Z', payload: 'GRANT_ALL' },
{ id: 'evt_002', type: 'TOGGLE', uiElement: 'switch_ads', ts: '2077-10-24T08:15:22Z', payload: 'DENY' },
{ id: 'evt_003', type: 'TIMEOUT', uiElement: 'session_auto', ts: '2077-10-25T02:00:00Z', payload: 'GRANT' }, // Auto-renew
{ id: 'evt_004', type: 'API_CALL', uiElement: 'app_fedeo', ts: '2077-10-26T14:45:10Z', payload: 'DENY' },
{ id: 'evt_005', type: 'WITHDRAW', uiElement: 'settings_menu', ts: '2077-10-27T09:30:00Z', payload: 'DENY' }
]
};
};
const data = generateData();
// --- UI HELPERS ---
const $ = (id) => document.getElementById(id);
function formatDate(isoString) {
const d = new Date(isoString);
return d.toLocaleDateString('en-GB') + ' ' + d.toLocaleTimeString('en-GB', {hour12: false});
}
function getStatusColor(status) {
if(status === STATUS.GRANTED) return 'text-cyan-400';
if(status === STATUS.DENIED) return 'text-fuchsia-400';
return 'text-amber-400';
}
function getStatusHex(status) {
if(status === STATUS.GRANTED) return COLORS.cyan;
if(status === STATUS.DENIED) return COLORS.magenta;
return COLORS.amber;
}
function decodeText(element, finalText, speed=30) {
// Simple glitch decode effect
let iterations = 0;
const originalText = finalText;
// We'll just replace innerHTML with random chars
const interval = setInterval(() => {
element.innerText = originalText
.split("")
.map((letter, index) => {
if(index < iterations) {
return originalText[index];
}
return String.fromCharCode(65 + Math.floor(Math.random() * 26));
})
.join("");
if(iterations >= originalText.length) clearInterval(interval);
iterations += 1 / 2; // Speed
}, speed);
}
// --- THREE.JS SETUP ---
const container = $('canvas-container');
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(COLORS.dark, 0.0025); // Add depth
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 15, 30);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.maxDistance = 50;
controls.minDistance = 10;
controls.autoRotate = true;
controls.autoRotateSpeed = 0.5;
// --- FORCE DIRECTED LAYOUT (Simple Manual Layout) ---
// We'll place nodes in concentric spheres/rings for a HUD look rather than random physics.
// Layer 0: User (Center)
// Layer 1: Features (Sphere around User)
// Layer 2: Storage (Larger sphere around Features)
const nodeRadius = 0.8;
const layers = {
user: 0,
feature: 6,
storage: 12
};
const objects = []; // All meshes for raycasting
const nodes = []; // Graph nodes data structure
const edges = []; // Edge meshes
function createNode(layer, id, label, status, type, customPos) {
let pos;
if(customPos) {
pos = new THREE.Vector3(customPos.x, customPos.y, customPos.z);
} else {
// Place on a sphere with some randomness
const radius = layers[layer];
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos((Math.random() * 2) - 1);
pos = new THREE.Vector3(
radius * Math.sin(phi) * Math.cos(theta),
radius * Math.sin(phi) * Math.sin(theta),
radius * Math.cos(phi)
);
}
// Geometry & Material
const geometry = new THREE.IcosahedronGeometry(nodeRadius, 0);
// Color based on layer and status
let color;
if(layer === 'user') color = COLORS.white;
else color = getStatusHex(status);
const material = new THREE.MeshBasicMaterial({
color: color,
wireframe: true,
transparent: true,
opacity: 0.8
});
// Core solid sphere to block background lines (optional)
const coreMat = new THREE.MeshBasicMaterial({ color: color });
const core = new THREE.Mesh(new THREE.SphereGeometry(nodeRadius * 0.6, 16, 16), coreMat);
const mesh = new THREE.Group();
mesh.add(geometry);
mesh.add(core);
mesh.position.copy(pos);
mesh.userData = { id, layer, label, status, type, originalScale: 1, neighbors: [] };
scene.add(mesh);
objects.push(mesh);
nodes.push(mesh);
// Add floating text label (using HTML canvas texture might be better, but for simplicity we use DOM overlay or just skip 3D text)
// We will rely on the side panel for details.
return mesh;
}
function createEdge(sourceNode, targetNode, status, type) {
let color;
if(type === 'active') color = getStatusHex(status);
else color = 0x333333; // Dim gray for inactive/blocked
const material = new THREE.LineBasicMaterial({
color: color,
transparent: true,
opacity: type === 'active' ? 0.6 : 0.1,
blending: THREE.AdditiveBlending
});
const points = [
sourceNode.position,
targetNode.position
];
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.Line(geometry, material);
scene.add(line);
edges.push(line);
// Store reference for highlighting later
sourceNode.userData.neighbors.push({ to: targetNode, line: line, type });
targetNode.userData.neighbors.push({ to: sourceNode, line: line, type });
}
// --- BUILD GRAPH ---
// 1. Create User Node
const userNode = createNode('user', data.user.id, 'User', null, 'user');
userNode.scale.set(1.5, 1.5, 1.5);
// 2. Create Feature Nodes
data.features.forEach((feat, i) => {
// Spread features out more evenly along a band to avoid overlap
const angle = (i / data.features.length) * Math.PI * 2;
const x = Math.cos(angle) * layers.feature;
const z = Math.sin(angle) * layers.feature;
const y = (Math.random() - 0.5) * 4; // Slight vertical spread
const node = createNode('feature', feat.id, feat.name, feat.status, 'feature', {x, y, z});
// Link User -> Feature (Active link only if status is not PENDING? Actually pending means no flow)
const linkType = (feat.status === STATUS.DENIED) ? 'inactive' : 'active';
createEdge(userNode, node, feat.status, linkType);
// Store storage links mapping
feat.storageLinks = [];
// 3. Link to Storage Nodes randomly based on logic
data.storage.forEach((store) => {
// Logic: Critical storage like Audit Ledger always logs.
// If Denied, link is inactive.
let isEssential = store.id.includes('audit') || store.id.includes('cache');
let shouldLink = isEssential || Math.random() > 0.3; // 70% chance to link
let linkType = 'active';
if(feat.status === STATUS.DENIED) {
if(isEssential) {
linkType = 'blocked'; // Shows the denial breach
} else {
shouldLink = false; // No edge
}
}
if(shouldLink) {
// Find or create storage node (we will create all storage nodes first loop)
// We'll handle storage creation separately to avoid double creation
}
feat.storageLinks.push({ storeId: store.id, linkType });
});
});
// 4. Create Storage Nodes (outer ring)
data.storage.forEach((store, i) => {
const angle = (i / data.storage.length) * Math.PI * 2 + 0.5; // Offset
const r = layers.storage + (Math.random() * 2);
const x = Math.cos(angle) * r;
const z = Math.sin(angle) * r;
const y = (Math.random() - 0.5) * 4;
const node = createNode('storage', store.id, store.name, STATUS.GRANTED, 'storage', {x, y, z});
// Storage nodes are always "active" in terms of existing, but edges highlight consent impact
// Connect Features that map to this storage
data.features.forEach(feat => {
const link = feat.storageLinks.find(l => l.storeId === store.id);
if(link) {
// Find feature node by ID
const featNode = nodes.find(n => n.userData.id === feat.id);
if(featNode) {
createEdge(featNode, node, feat.status, link.linkType);
}
}
});
});
// 5. Background Particles (Starfield/ Dust)
const particlesGeom = new THREE.BufferGeometry();
const particleCount = 1500;
const posArray = new Float32Array(particleCount * 3);
for(let i=0; i<particleCount*3; i++) {
posArray[i] = (Math.random() - 0.5) * 80; // Spread wide
}
particlesGeom.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const particlesMat = new THREE.PointsMaterial({
size: 0.05,
color: COLORS.cyan,
transparent: true,
opacity: 0.4,
blending: THREE.AdditiveBlending
});
const particlesMesh = new THREE.Points(particlesGeom, particlesMat);
scene.add(particlesMesh);
// --- INTERACTION & HOVER ---
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
let hoveredNode = null;
let selectedNode = null;
function onMouseMove(event) {
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
}
window.addEventListener('mousemove', onMouseMove, false);
// UI Updates
function updateMetrics() {
const counts = { GRANTED: 0, DENIED: 0, PENDING: 0 };
data.features.forEach(f => counts[f.status]++);
const total = data.features.length;
// Animate numbers
gsap.to($('#count-granted'), { innerText: counts.GRANTED, duration: 0.5, snap: {innerText: 1} });
gsap.to($('#count-denied'), { innerText: counts.DENIED, duration: 0.5, snap: {innerText: 1} });
gsap.to($('#count-pending'), { innerText: counts.PENDING, duration: 0.5, snap: {innerText: 1} });
$('#bar-granted').style.width = (counts.GRANTED / total * 100) + '%';
$('#bar-denied').style.width = (counts.DENIED / total * 100) + '%';
$('#bar-pending').style.width = (counts.PENDING / total * 100) + '%';
}
function updateDetailsPanel(nodeMesh) {
const data = nodeMesh.userData;
const panel = $('details-panel');
const title = $('detail-title');
const statusDiv = $('detail-status');
const originP = $('detail-origin');
const storageDiv = $('detail-storage');
const tsP = $('detail-ts');
const dynamic = $('dynamic-content');
const fallback = $('detail-content').querySelector('p'); // The instruction text
// Reset
panel.classList.remove('opacity-0');
dynamic.classList.remove('hidden');
fallback.classList.add('hidden');
// Title
title.innerText = data.layer.toUpperCase() + ' // ' + data.label;
title.style.color = data.layer === 'user' ? '#fff' : (data.layer === 'feature' ? '#e879f9' : '#22d3ee');
// Status
if(data.layer === 'user') {
statusDiv.innerText = 'ACTIVE ENTITY';
statusDiv.className = 'text-sm font-bold text-white';
originP.innerText = 'System Root / Human Subject';
storageDiv.innerHTML = '<span class="text-xs text-gray-500">N/A (Central Identity)</span>';
tsP.innerText = 'created: 2077-01-01';
} else if (data.layer === 'feature') {
statusDiv.innerText = data.status;
statusDiv.className = `text-sm font-bold ${getStatusColor(data.status)} neon-text-${data.status.toLowerCase()}`;
// Find the event that set this status (simplified: just last event that touched it)
// In a real app we'd query based on feature ID. We'll match name heuristically or link by ID.
const relatedEvent = data.events && data.events[0] || null;
if(relatedEvent) {
originP.innerHTML = `<span class="text-cyan-600">Event ID:</span> ${relatedEvent.id}<br>
<span class="text-cyan-600">SourceUI:</span> [${relatedEvent.uiElement}]<br>
<span class="text-cyan-600">Action:</span> ${relatedEvent.type} / ${relatedEvent.payload}`;
tsP.innerText = formatDate(relatedEvent.ts);
} else {
originP.innerText = 'Default system state (pre-regulation)';
tsP.innerText = 'Unknown';
}
// Storage links
storageDiv.innerHTML = '';
// We need to find which storage nodes are connected via active edges
const connections = nodeMesh.userData.neighbors.filter(n => n.to.userData.layer === 'storage' && n.type === 'active');
if(connections.length === 0) {
storageDiv.innerHTML = '<span class="text-xs text-gray-500">No active storage linkage (consent denied).</span>';
} else {
connections.forEach(conn => {
const s = conn.to.userData;
const el = document.createElement('div');
el.className = 'flex items-center gap-2';
el.innerHTML = `<span class="w-2 h-2 rounded-full bg-cyan-500"></span>
<span class="text-cyan-200">${s.label}</span>
<span class="text-gray-600 text-[10px]">(${s.id})</span>`;
storageDiv.appendChild(el);
});
}
} else if (data.layer === 'storage') {
statusDiv.innerText = 'ENABLED'; // Storage always enabled but depends on upstream
statusDiv.className = 'text-sm font-bold text-white';
originP.innerText = 'Physical / Virtual Data Sink';
tsP.innerText = 'Provisioned: 2077-03-15';
storageDiv.innerHTML = '';
const connections = nodeMesh.userData.neighbors.filter(n => n.to.userData.layer === 'feature');
if(connections.length === 0) {
storageDiv.innerHTML = '<span class="text-xs text-gray-500">Orphaned storage node (unused).</span>';
} else {
connections.forEach(conn => {
const f = conn.to.userData;
const color = f.status === STATUS.GRANTED ? 'text-cyan-400' : (f.status === STATUS.DENIED ? 'text-gray-500' : 'text-amber-400');
const el = document.createElement('div');
el.className = 'flex items-center gap-2';
el.innerHTML = `<span class="w-2 h-2 rounded-full bg-${f.status==='GRANTED'?'cyan':'gray'}-500"></span>
<span class="${color}">${f.label}</span>
<span class="text-gray-600 text-[10px]">${conn.type}</span>`;
storageDiv.appendChild(el);
});
}
}
}
function raycast() {
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(objects);
if (intersects.length > 0) {
// If we have an intersection
const object = intersects[0].object.parent || intersects[0].object;
if (hoveredNode !== object) {
// Reset previous
if (hoveredNode) {
gsap.to(hoveredNode.scale, { x: hoveredNode.userData.originalScale, y: hoveredNode.userData.originalScale, z: hoveredNode.userData.originalScale, duration: 0.3 });
// Reset colors of edges
hoveredNode.userData.neighbors.forEach(n => {
n.line.material.opacity = n.type === 'active' ? 0.6 : 0.1;
});
}
hoveredNode = object;
gsap.to(hoveredNode.scale, { x: hoveredNode.userData.originalScale * 1.5, y: hoveredNode.userData.originalScale * 1.5, z: hoveredNode.userData.originalScale * 1.5, duration: 0.3, ease: "back.out(1.7)" });
// Highlight edges
hoveredNode.userData.neighbors.forEach(n => {
n.line.material.opacity = 1;
n.line.material.linewidth = 2; // Note: WebGL limitation, often doesn't work unless using wideLines
});
// Change cursor
document.body.style.cursor = 'crosshair';
// Update panel
updateDetailsPanel(hoveredNode);
}
} else {
if (hoveredNode) {
gsap.to(hoveredNode.scale, { x: hoveredNode.userData.originalScale, y: hoveredNode.userData.originalScale, z: hoveredNode.userData.originalScale, duration: 0.3 });
hoveredNode.userData.neighbors.forEach(n => {
n.line.material.opacity = n.type === 'active' ? 0.6 : 0.1;
});
hoveredNode = null;
document.body.style.cursor = 'default';
// Optionally keep panel showing last or clear it. We keep last.
}
}
}
// --- ANIMATION LOOP ---
function animate(time) {
requestAnimationFrame(animate);
TWEEN.update(time);
controls.update();
raycast();
// Subtle particle rotation
particlesMesh.rotation.y = time * 0.00005;
particlesMesh.rotation.x = time * 0.00002;
// Pulse effect for nodes with recent events (simulated by scaling sine wave on slightly larger wireframe)
nodes.forEach(node => {
const u = node.userData;
if(u.id === data.features[2].id) { // location slightly pulse
const s = 1.05 + Math.sin(time * 0.003) * 0.03;
node.children[0].scale.set(s,s,s);
}
});
renderer.render(scene, camera);
}
// --- LOG GENERATION ---
function populateLog() {
const logContainer = $('event-log');
const template = (ev, idx) => `
<div class="flex gap-4 text-xs border-b border-gray-900 pb-1 animate-[fadein_0.5s_ease-out]">
<span class="text-cyan-700 w-24">[${ev.ts.split('T')[1].split('Z')[0]}]</span>
<span class="w-16 ${getStatusColor(ev.payload === 'GRANT'||ev.payload==='GRANT_ALL'?'GRANTED':'DENIED')}">${ev.type}</span>
<span class="text-gray-300">${ev.uiElement}</span>
<span class="text-right ${getStatusColor(ev.payload === 'GRANT'||ev.payload==='GRANT_ALL'?'GRANTED':'DENIED')}">${ev.payload}</span>
</div>
`;
data.events.slice().reverse().forEach((ev, i) => {
logContainer.insertAdjacentHTML('afterbegin', template(ev, i));
});
}
// --- CLOCK ---
function updateClock() {
const now = new Date();
const timeStr = now.toISOString().split('T')[1].split('.')[0];
const dateStr = now.toISOString().split('T')[0];
$('clock').innerText = timeStr;
// also date maybe
}
// --- INITIALIZATION ---
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// --- BOOT SEQUENCE ---
window.onload = () => {
simulateBoot();
};
function simulateBoot() {
const progress = $('progress-bar');
const loaderText = $('loader-text');
const loader = $('loader');
const steps = [
"Loading Neural Net...",
"Establishing Secure Handshake...",
"Decrypting Consent Schema...",
"Rendering Holograph...",
"System Ready."
];
let p = 0;
const interval = setInterval(() => {
p += Math.random() * 15;
if(p >= 100) {
p = 100;
clearInterval(interval);
setTimeout(() => {
loader.style.opacity = 0;
setTimeout(() => loader.remove(), 800);
// Decode UI texts
decodeText($('ui-user-id'), data.user.id);
decodeText($('ui-session-id'), 'SESS-' + Math.random().toString(36).substr(2,9).toUpperCase());
// Populate rest
updateMetrics();
populateLog();
setInterval(updateClock, 1000);
updateClock();
// Start 3D canvas
animate();
// Trigger initial metrics animation
gsap.from('.hud-panel', { x: -50, opacity: 0, stagger: 0.1, duration: 0.8, ease: "power2.out" });
}, 500);
}
progress.style.width = p + '%';
// Update text based on
const stepIdx = Math.min(Math.floor(p / (100/steps.length)), steps.length-1);
loaderText.innerText = steps[stepIdx];
}, 100);
}
</script>
</body>
</html>