oculus / static /globe.html
jaanya
Initial commit β€” OCULUS cyber intelligence platform
f8656e1
Raw History Blame Contribute Delete
30.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Crect width='32' height='32' rx='4' fill='%23051424'/%3E%3Cpath d='M16 6C13 11 11 16 11 16C11 16 13 21 16 26C19 21 21 16 21 16C21 16 19 11 16 6Z' stroke='%233b82f6' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='16' cy='16' r='2.5' fill='%233b82f6'/%3E%3C/svg%3E">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OCULUS</title>
<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=Alfa+Slab+One&family=Stardos+Stencil:wght@400;700&family=PT+Serif+Caption&family=Abril+Fatface&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<script src="https://unpkg.com/globe.gl@2.27.3/dist/globe.gl.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--void: #030712;
--deep: #060d1f;
--navy: #0a1628;
--blue-dim: #0e2044;
--accent: #3b82f6;
--accent-bright: #60a5fa;
--accent-glow: #1d4ed8;
--text-primary: #f0f6ff;
--text-secondary: #8ba3c7;
--text-muted: #3d5a80;
--green: #10b981;
--yellow: #f59e0b;
--red: #ef4444;
--glass-bg: rgba(10, 22, 40, 0.72);
--glass-border: rgba(59, 130, 246, 0.18);
--font-display: 'Stardos Stencil', monospace;
--font-body: 'PT Serif Caption', serif;
--font-mono: 'Stardos Stencil', monospace;
}
.abril-fatface-regular {
font-family: "Abril Fatface", serif;
font-weight: 400;
font-style: normal;
}
html { scroll-behavior: auto; }
body {
background: var(--void);
color: var(--text-primary);
font-family: var(--font-body);
overflow-x: hidden;
cursor: default;
}
/* ─── STARS CANVAS (background layer, always visible) ─── */
#stars-canvas {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
z-index: 0;
pointer-events: none;
}
/* ─── GLOBE WRAPPER ─── */
#globe-wrapper {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
z-index: 3;
pointer-events: none;
opacity: 0.2;
transition: opacity 0.3s ease;
}
body.globe-active #globe-wrapper {
pointer-events: auto;
}
#globe-wrapper > div,
#globe-wrapper canvas {
width: 100% !important;
height: 100% !important;
background: transparent !important;
}
/* ─── SCROLL CONTAINER ─── */
#scroll-container {
position: relative;
z-index: 10;
pointer-events: none; /* Let clicks pass through to the globe */
}
#hero, #stats-strip {
pointer-events: auto; /* Keep text and UI elements interactive */
}
/* ─── HERO ─── */
#hero {
position: relative;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 0 24px;
}
.hero-eyebrow {
font-family: var(--font-mono);
font-size: 11px;
letter-spacing: 0.35em;
text-transform: uppercase;
color: var(--accent-bright);
opacity: 0;
transform: translateY(12px);
margin-bottom: 24px;
}
.hero-title {
font-family: "Abril Fatface", serif;
font-size: clamp(72px, 12vw, 148px);
font-weight: 400;
letter-spacing: -0.03em;
line-height: 0.92;
opacity: 0;
transform: translateY(20px);
margin-bottom: 28px;
background: linear-gradient(160deg, #f0f6ff 30%, #60a5fa 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.hero-tagline {
font-family: var(--font-display);
font-size: clamp(16px, 2vw, 20px);
font-weight: 300;
color: var(--text-secondary);
letter-spacing: 0.01em;
max-width: 480px;
opacity: 0;
transform: translateY(14px);
margin-bottom: 14px;
}
.hero-desc {
font-size: 13px;
color: var(--text-muted);
max-width: 360px;
line-height: 1.7;
letter-spacing: 0.02em;
opacity: 0;
transform: translateY(10px);
}
.scroll-indicator {
position: absolute;
bottom: 40px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
opacity: 0;
}
.scroll-indicator span {
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.25em;
color: var(--text-muted);
text-transform: uppercase;
}
.scroll-line {
width: 1px;
height: 40px;
background: linear-gradient(to bottom, var(--accent), transparent);
animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse {
0%, 100% { opacity: 0.3; transform: scaleY(1); }
50% { opacity: 1; transform: scaleY(1.15); }
}
/* ─── SPACER ─── */
#spacer {
height: 150vh;
pointer-events: none;
}
/* ─── GLOBE SECTION ─── */
#globe-section {
position: relative;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
/* ─── STATS STRIP ─── */
#stats-strip {
position: relative;
z-index: 20;
display: flex;
align-items: center;
justify-content: center;
gap: 48px;
padding: 18px 40px;
background: rgba(6, 13, 31, 0.6);
border-top: 1px solid var(--glass-border);
border-bottom: 1px solid var(--glass-border);
backdrop-filter: blur(12px);
opacity: 0;
transform: translateY(10px);
}
.stat-item {
display: flex;
align-items: center;
gap: 8px;
font-family: var(--font-mono);
font-size: 11px;
color: var(--text-muted);
letter-spacing: 0.1em;
}
.stat-dot {
width: 6px; height: 6px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 6px var(--green);
animation: statPulse 2s ease-in-out infinite;
}
@keyframes statPulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.stat-item span.val { color: var(--text-secondary); }
/* ─── LEGEND ─── */
#legend {
position: fixed;
bottom: 40px;
left: 40px;
z-index: 100;
display: flex;
flex-direction: column;
gap: 10px;
opacity: 0;
transition: opacity 0.4s ease;
pointer-events: none;
}
#legend.visible { opacity: 1; }
.legend-item {
display: flex;
align-items: center;
gap: 10px;
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.15em;
color: var(--text-secondary);
text-transform: uppercase;
}
.legend-dot {
width: 8px; height: 8px;
border-radius: 50%;
flex-shrink: 0;
}
.legend-dot.high { background: var(--red); box-shadow: 0 0 8px var(--red); }
.legend-dot.med { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.legend-dot.low { background: var(--green); box-shadow: 0 0 8px var(--green); }
/* ─── FILTER PILLS ─── */
#filters {
position: fixed;
top: 32px;
right: 40px;
z-index: 100;
display: flex;
gap: 8px;
opacity: 0;
transition: opacity 0.4s ease;
}
#filters.visible { opacity: 1; }
.filter-pill {
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
padding: 6px 14px;
border-radius: 20px;
border: 1px solid var(--glass-border);
background: rgba(10, 22, 40, 0.6);
color: var(--text-secondary);
cursor: pointer;
backdrop-filter: blur(8px);
transition: all 0.2s ease;
}
.filter-pill:hover,
.filter-pill.active {
border-color: var(--accent);
color: var(--accent-bright);
background: rgba(59, 130, 246, 0.1);
}
/* ─── INCIDENT PANEL ─── */
#incident-panel {
position: fixed;
top: 50%;
right: -420px;
transform: translateY(-50%);
width: 380px;
max-height: 90vh;
overflow-y: auto;
z-index: 200;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: 16px;
backdrop-filter: blur(24px);
-webkit-backdrop-filter: blur(24px);
padding: 28px;
transition: right 0.45s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: 0 24px 64px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}
#incident-panel.open { right: 32px; }
.panel-close {
position: absolute;
top: 16px; right: 16px;
width: 28px; height: 28px;
border-radius: 50%;
background: rgba(255,255,255,0.06);
border: 1px solid var(--glass-border);
color: var(--text-secondary);
cursor: pointer;
display: flex; align-items: center; justify-content: center;
font-size: 14px;
transition: all 0.2s ease;
}
.panel-close:hover { background: rgba(239,68,68,0.15); color: var(--red); }
.panel-sector {
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.2em;
text-transform: uppercase;
color: var(--accent-bright);
margin-bottom: 12px;
}
.panel-title {
font-family: var(--font-display);
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
line-height: 1.35;
margin-bottom: 20px;
}
.panel-meta {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 18px;
}
.meta-row {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 12px;
}
.meta-label {
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--text-muted);
}
.meta-value {
color: var(--text-secondary);
font-weight: 500;
}
.threat-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 3px 10px;
border-radius: 20px;
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.1em;
text-transform: uppercase;
font-weight: 700;
}
.threat-badge.high { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.threat-badge.medium { background: rgba(245,158,11,0.12); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.threat-badge.low { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.panel-divider {
height: 1px;
background: var(--glass-border);
margin: 18px 0;
}
.panel-summary {
font-size: 13px;
line-height: 1.7;
color: var(--text-secondary);
margin-bottom: 24px;
max-height: 200px;
overflow-y: auto;
}
.panel-actions { display: flex; gap: 10px; }
.btn-primary {
flex: 1;
padding: 11px;
background: var(--accent);
color: #fff;
border: none;
border-radius: 8px;
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
cursor: pointer;
transition: all 0.2s ease;
font-weight: 700;
}
.btn-primary:hover { background: var(--accent-bright); transform: translateY(-1px); }
.btn-secondary {
padding: 11px 18px;
background: transparent;
color: var(--accent-bright);
border: 1px solid var(--glass-border);
border-radius: 8px;
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
cursor: pointer;
transition: all 0.2s ease;
font-weight: 700;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(59,130,246,0.08); }
/* ─── TOOLTIP ─── */
#tooltip {
position: fixed;
z-index: 150;
pointer-events: none;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: 8px;
padding: 10px 14px;
backdrop-filter: blur(16px);
opacity: 0;
transform: translateY(4px);
transition: opacity 0.15s ease, transform 0.15s ease;
max-width: 220px;
}
#tooltip.visible { opacity: 1; transform: translateY(0); }
.tooltip-title {
font-family: var(--font-display);
font-size: 12px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 4px;
}
.tooltip-loc {
font-family: var(--font-mono);
font-size: 10px;
color: var(--text-muted);
letter-spacing: 0.08em;
}
/* ─── NOISE OVERLAY ─── */
.noise {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
opacity: 0.025;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
background-size: 200px 200px;
}
/* ─── VIGNETTE ─── */
.vignette {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
background: radial-gradient(ellipse at center, transparent 40%, rgba(3,7,18,0.7) 100%);
}
/* ─── CURSOR DOT ─── */
#cursor {
position: fixed;
width: 6px; height: 6px;
border-radius: 50%;
background: var(--accent-bright);
pointer-events: none;
z-index: 9999;
transform: translate(-50%, -50%);
transition: width 0.2s, height 0.2s, opacity 0.2s;
mix-blend-mode: screen;
}
#cursor.expand { width: 32px; height: 32px; opacity: 0.4; }
</style>
</head>
<body>
<div class="noise"></div>
<div class="vignette"></div>
<div id="cursor"></div>
<!-- STARS BACKGROUND CANVAS -->
<canvas id="stars-canvas"></canvas>
<!-- GLOBE.GL WRAPPER -->
<div id="globe-wrapper"></div>
<!-- SCROLL CONTENT -->
<div id="scroll-container">
<section id="hero">
<div class="hero-eyebrow">Cyber Intelligence Platform</div>
<h1 class="hero-title">OCULUS</h1>
<p class="hero-tagline">The world, within your sight</p>
<p class="hero-desc">Monitor, analyze, and respond to global cyber incidents across critical infrastructure β€” before the damage spreads.</p>
<div class="scroll-indicator">
<span>Scroll to explore</span>
<div class="scroll-line"></div>
</div>
</section>
<div id="spacer"></div>
<section id="globe-section"></section>
<div id="stats-strip">
<div class="stat-item">
<div class="stat-dot"></div>
<span class="val">47</span>&nbsp;incidents tracked
</div>
<div class="stat-item">
<div class="stat-dot" style="background:var(--red);box-shadow:0 0 6px var(--red);animation-delay:0.3s"></div>
<span class="val">12</span>&nbsp;high severity
</div>
<div class="stat-item">
<div class="stat-dot" style="background:var(--accent);box-shadow:0 0 6px var(--accent);animation-delay:0.6s"></div>
Live Β· Updated recently
</div>
</div>
<div style="display:flex;justify-content:center;padding:40px 0 60px;pointer-events:auto;">
<a href="/static/updates.html" style="font-family:var(--font-mono);font-size:11px;letter-spacing:.2em;text-transform:uppercase;padding:14px 36px;border:1px solid var(--glass-border);border-radius:8px;color:var(--accent-bright);background:rgba(10,22,40,0.6);backdrop-filter:blur(12px);text-decoration:none;transition:all .2s;" onmouseover="this.style.borderColor='var(--accent)';this.style.background='rgba(59,130,246,0.1)'" onmouseout="this.style.borderColor='var(--glass-border)';this.style.background='rgba(10,22,40,0.6)'">Explore Real Time Cybersecurity Intel β†’</a>
</div>
</div>
<!-- LEGEND -->
<div id="legend">
<div class="legend-item"><div class="legend-dot high"></div>High Threat</div>
<div class="legend-item"><div class="legend-dot med"></div>Medium Threat</div>
<div class="legend-item"><div class="legend-dot low"></div>Low Threat</div>
</div>
<!-- FILTERS -->
<div id="filters">
<div class="filter-pill active" data-filter="all">All</div>
<div class="filter-pill" data-filter="aviation">Aviation</div>
<div class="filter-pill" data-filter="power">Power Grid</div>
<div class="filter-pill" data-filter="ot">OT / ICS</div>
<div class="filter-pill" data-filter="maritime">Maritime</div>
</div>
<!-- INCIDENT PANEL -->
<div id="incident-panel">
<button class="panel-close" id="panel-close">βœ•</button>
<div class="panel-sector" id="p-sector">Aviation</div>
<div class="panel-title" id="p-title">Incident Title</div>
<div class="panel-meta">
<div class="meta-row">
<span class="meta-label">Location</span>
<span class="meta-value" id="p-location">β€”</span>
</div>
<div class="meta-row">
<span class="meta-label">Threat Level</span>
<span id="p-threat"></span>
</div>
<div class="meta-row">
<span class="meta-label">Date</span>
<span class="meta-value" id="p-date">β€”</span>
</div>
</div>
<div class="panel-divider"></div>
<p class="panel-summary" id="p-summary">Loading incident details…</p>
<div class="panel-actions">
<button class="btn-primary" id="btn-analyze-further">Analyze Further</button>
<button class="btn-secondary" id="btn-ask-ai">Ask AI</button>
</div>
</div>
<!-- TOOLTIP -->
<div id="tooltip">
<div class="tooltip-title" id="tt-title"></div>
<div class="tooltip-loc" id="tt-loc"></div>
</div>
<script>
// ── DATA ───────────────────────────────────────────────────────────────────
let INCIDENTS = [];
let ARC_CONNECTIONS = [];
async function loadIncidents() {
try {
const res = await fetch('/api/incidents');
const data = await res.json();
INCIDENTS = data.filter(inc => inc.lat && inc.lon);
// Generate arcs dynamically between high-threat incidents
const high = INCIDENTS.filter(i => i.threat === 'critical' || i.threat === 'high');
ARC_CONNECTIONS = [];
for (let i = 0; i < Math.min(high.length - 1, 8); i++) {
ARC_CONNECTIONS.push({ srcId: high[i].id, dstId: high[i+1].id });
}
if (globeInstance) {
globeInstance.pointsData(buildPoints()).arcsData(buildArcs());
}
// Update stats strip
document.querySelector('.stat-item .val').textContent = INCIDENTS.length;
const highCount = INCIDENTS.filter(i => i.threat === 'critical' || i.threat === 'high').length;
document.querySelectorAll('.stat-item .val')[1].textContent = highCount;
} catch(e) {
console.error('Failed to load incidents:', e);
}
}
const THREAT_COLORS = { critical:'#ef4444', high:'#ef4444', medium:'#f59e0b', low:'#10b981' };
// ── STARS (Three.js on a dedicated canvas, z-index 0) ─────────────────────
(function initStars() {
const canvas = document.getElementById('stars-canvas');
const renderer = new THREE.WebGLRenderer({ canvas, antialias: false, alpha: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 2000);
camera.position.z = 1;
const starGeo = new THREE.BufferGeometry();
const count = 2200;
const pos = new Float32Array(count * 3);
for (let i = 0; i < count; i++) {
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
const r = 80 + Math.random() * 40;
pos[i*3] = r * Math.sin(phi) * Math.cos(theta);
pos[i*3+1] = r * Math.cos(phi);
pos[i*3+2] = r * Math.sin(phi) * Math.sin(theta);
}
starGeo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
const starMat = new THREE.PointsMaterial({ color: 0x8ba3c7, size: 0.13, sizeAttenuation: true });
const stars = new THREE.Points(starGeo, starMat);
scene.add(stars);
(function loop() {
requestAnimationFrame(loop);
stars.rotation.y += 0.00004;
renderer.render(scene, camera);
})();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
})();
// ── GLOBE STATE ────────────────────────────────────────────────────────────
let globeInstance = null;
let activeFilter = 'all';
let isGlobeActive = false;
function filterMatch(inc, f) {
if (f === 'all') return true;
if (f === 'aviation') return inc.sector === 'Aviation';
if (f === 'power') return inc.sector === 'Power Grid';
if (f === 'ot') return inc.sector === 'OT / ICS';
if (f === 'maritime') return inc.sector === 'Maritime';
return false;
}
function buildPoints() {
return INCIDENTS
.filter(inc => filterMatch(inc, activeFilter))
.map(inc => ({
lat: inc.lat, lng: inc.lon,
size: (inc.threat === 'critical' || inc.threat === 'high') ? 0.55 : inc.threat === 'medium' ? 0.4 : 0.28,
color: THREAT_COLORS[inc.threat],
incident: inc,
}));
}
function buildArcs() {
return ARC_CONNECTIONS.map(a => {
const src = INCIDENTS.find(i => i.id === a.srcId);
const dst = INCIDENTS.find(i => i.id === a.dstId);
if (!src || !dst) return null;
const show = filterMatch(src, activeFilter) || filterMatch(dst, activeFilter);
if (!show) return null;
return {
startLat: src.lat, startLng: src.lon,
endLat: dst.lat, endLng: dst.lon,
color: [THREAT_COLORS[src.threat] + 'cc', THREAT_COLORS[dst.threat] + '22'],
};
}).filter(Boolean);
}
// ── GLOBE INIT ─────────────────────────────────────────────────────────────
function initGlobe() {
const wrapper = document.getElementById('globe-wrapper');
globeInstance = Globe()(wrapper)
.width(window.innerWidth)
.height(window.innerHeight)
.backgroundColor('rgba(0,0,0,0)')
.globeImageUrl('https://unpkg.com/three-globe/example/img/earth-blue-marble.jpg')
.bumpImageUrl('https://unpkg.com/three-globe/example/img/earth-topology.png')
.atmosphereColor('#2266ff')
.atmosphereAltitude(0.15)
.pointsData(buildPoints())
.pointLat('lat')
.pointLng('lng')
.pointColor('color')
.pointAltitude(0.015)
.pointRadius('size')
.pointResolution(16)
.pointsMerge(false)
.arcsData(buildArcs())
.arcStartLat('startLat').arcStartLng('startLng')
.arcEndLat('endLat').arcEndLng('endLng')
.arcColor('color')
.arcAltitudeAutoScale(0.15)
.arcStroke(0.3)
.arcDashLength(0.4)
.arcDashGap(0.18)
.arcDashAnimateTime(3000)
.hexPolygonsData([])
.onPointClick(pt => {
console.log(pt);
if (pt?.incident) openPanel(pt.incident);
})
.onPointHover(pt => {
const tip = document.getElementById('tooltip');
const cur = document.getElementById('cursor');
if (pt?.incident) {
document.getElementById('tt-title').textContent = pt.incident.title;
document.getElementById('tt-loc').textContent = `${pt.incident.sector} Β· ${pt.incident.threat.toUpperCase()} THREAT`;
tip.classList.add('visible');
cur.classList.add('expand');
wrapper.style.cursor = 'pointer';
} else {
tip.classList.remove('visible');
cur.classList.remove('expand');
wrapper.style.cursor = 'grab';
}
});
// Camera & controls
globeInstance.pointOfView({ altitude: 2.0 });
globeInstance.pointOfView({ altitude: 1.8 });
const ctrl = globeInstance.controls();
ctrl.autoRotate = true;
ctrl.autoRotateSpeed = 0.4;
ctrl.enableDamping = true;
ctrl.dampingFactor = 0.05;
ctrl.enableZoom = false; // Disabled to prevent trapping page scroll
ctrl.minDistance = 120;
ctrl.maxDistance = 550;
// Pause auto-rotate while user drags
ctrl.addEventListener('start', () => { ctrl.autoRotate = false; });
ctrl.addEventListener('end', () => {
// resume only if panel is closed
if (!document.getElementById('incident-panel').classList.contains('open')) {
ctrl.autoRotate = true;
}
});
// Restrict OrbitControls drag to ON THE GLOBE ONLY
wrapper.addEventListener('pointerdown', (e) => {
if (!globeInstance) return;
const mouse = new THREE.Vector2();
mouse.x = (e.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(e.clientY / window.innerHeight) * 2 + 1;
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, globeInstance.camera());
// Check if raycast hits any object in the globe scene
const intersects = raycaster.intersectObjects(globeInstance.scene().children, true);
if (intersects.length === 0) {
// Clicked in empty space around the globe -> block OrbitControls
e.stopImmediatePropagation();
}
}, true); // Use capture phase to intercept before OrbitControls
// Resize handler
window.addEventListener('resize', () => {
globeInstance.width(window.innerWidth).height(window.innerHeight);
});
}
// ── SCROLL ─────────────────────────────────────────────────────────────────
window.addEventListener('scroll', () => {
const scrollY = window.scrollY;
const windowH = window.innerHeight;
// Hero fade-out
const heroProgress = Math.min(scrollY / (windowH * 0.6), 1);
document.getElementById('hero').style.opacity = 1 - heroProgress;
// Globe fade-in
const gStart = windowH * 0.1;
const gEnd = windowH * 0.8;
const gp = Math.max(0.2, Math.min((scrollY - gStart) / (gEnd - gStart), 1));
document.getElementById('globe-wrapper').style.opacity = gp;
// Activate interactivity & UI
if (gp > 0.5 && !isGlobeActive) {
isGlobeActive = true;
document.body.classList.add('globe-active');
document.getElementById('legend').classList.add('visible');
document.getElementById('filters').classList.add('visible');
if (globeInstance) globeInstance.controls().autoRotate = true;
} else if (gp <= 0.5 && isGlobeActive) {
isGlobeActive = false;
document.body.classList.remove('globe-active');
document.getElementById('legend').classList.remove('visible');
document.getElementById('filters').classList.remove('visible');
}
});
// ── TOOLTIP MOUSE TRACKING ─────────────────────────────────────────────────
window.addEventListener('mousemove', e => {
document.getElementById('cursor').style.left = e.clientX + 'px';
document.getElementById('cursor').style.top = e.clientY + 'px';
const tip = document.getElementById('tooltip');
if (tip.classList.contains('visible')) {
tip.style.left = (e.clientX + 18) + 'px';
tip.style.top = (e.clientY - 20) + 'px';
}
});
// ── PANEL ──────────────────────────────────────────────────────────────────
function openPanel(inc) {
document.getElementById('p-sector').textContent = inc.sector;
document.getElementById('p-title').textContent = inc.title;
document.getElementById('p-location').textContent = `${inc.lat.toFixed(1)}Β°, ${inc.lon.toFixed(1)}Β°`;
document.getElementById('p-date').textContent = inc.date;
document.getElementById('p-summary').textContent = inc.summary;
const badge = document.getElementById('p-threat');
badge.className = 'threat-badge ' + inc.threat;
badge.innerHTML = `<span style="width:6px;height:6px;border-radius:50%;background:currentColor;display:inline-block"></span> ${inc.threat.charAt(0).toUpperCase() + inc.threat.slice(1)}`;
document.getElementById('incident-panel').classList.add('open');
if (globeInstance) globeInstance.controls().autoRotate = false;
document.getElementById('btn-analyze-further').onclick = () => {
const q = encodeURIComponent(inc.title + '. ' + inc.summary);
window.location.href = `/static/mittar.html?q=${q}`;
};
document.getElementById('btn-ask-ai').onclick = () => {
const q = encodeURIComponent(inc.title + '. ' + inc.summary);
window.location.href = `/static/chatrag.html?q=${q}`;
};
}
document.getElementById('panel-close').addEventListener('click', () => {
document.getElementById('incident-panel').classList.remove('open');
if (globeInstance) globeInstance.controls().autoRotate = true;
});
// ── FILTERS ────────────────────────────────────────────────────────────────
document.querySelectorAll('.filter-pill').forEach(pill => {
pill.addEventListener('click', () => {
document.querySelectorAll('.filter-pill').forEach(p => p.classList.remove('active'));
pill.classList.add('active');
activeFilter = pill.dataset.filter;
if (!globeInstance) return;
globeInstance.pointsData(buildPoints()).arcsData(buildArcs());
});
});
// ── GSAP HERO ENTRANCE ─────────────────────────────────────────────────────
gsap.registerPlugin(ScrollTrigger);
gsap.timeline({ delay: 0.3 })
.to('.hero-eyebrow', { opacity:1, y:0, duration:0.9, ease:'power3.out' })
.to('.hero-title', { opacity:1, y:0, duration:1.0, ease:'power3.out' }, '-=0.5')
.to('.hero-tagline', { opacity:1, y:0, duration:0.8, ease:'power3.out' }, '-=0.6')
.to('.hero-desc', { opacity:1, y:0, duration:0.7, ease:'power3.out' }, '-=0.5')
.to('.scroll-indicator', { opacity:1, duration:0.8, ease:'power2.out' }, '-=0.2');
gsap.to('#stats-strip', {
scrollTrigger: { trigger:'#stats-strip', start:'top 90%', toggleActions:'play none none reverse' },
opacity:1, y:0, duration:0.8, ease:'power3.out',
});
// ── BOOT ───────────────────────────────────────────────────────────────────
(function waitForGlobe() {
if (typeof Globe !== 'undefined') {
initGlobe();
loadIncidents();
}
else { setTimeout(waitForGlobe, 50); }
})();
</script>
</body>
</html>