Build an Arctic sea ice thickness mapping: altimetry, snow depth, and drift corrections.
- User
Build an Arctic sea ice thickness mapping: altimetry, snow depth, and drift corrections.
Assistant
Build an Arctic sea ice thickness mapping: altimetry, snow depth, and drift corrections.
The user wants a visualization for Arctic sea ice thickness mapping that includes:
This is a scientific visualization related to cryosphere/climate science. Let me create an interactive 3D visualization that shows:
I'll use Three.js for this since it involves 3D mapping. The visualization will include:
Let me design this with:
I'll create procedural data for:
Key features:
Let me build this comprehensively. This is a fascinating scientific visualization challenge! I'll create an interactive Arctic sea ice thickness mapping tool that visualizes altimetry data, snow depth layers, and ice drift corrections.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arctic Sea Ice Thickness Mapping</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Space+Grotesk:wght@400;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0f14;
--bg-secondary: #111920;
--fg: #e4eaf0;
--muted: #6b7d8f;
--accent: #00d4aa;
--accent-dim: #00a080;
--ice-thin: #1a3a5c;
--ice-mid: #2d6a8f;
--ice-thick: #4aa4c7;
--snow: #c8e0f0;
--warning: #ff6b4a;
--card: rgba(17, 25, 32, 0.85);
--border: rgba(107, 125, 143, 0.3);
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
margin: 0;
overflow-x: hidden;
}
.mono {
font-family: 'IBM Plex Mono', monospace;
}
.glass {
background: var(--card);
backdrop-filter: blur(12px);
border: 1px solid var(--border);
}
#canvas-container {
position: relative;
width: 100%;
height: 100vh;
}
#mainCanvas {
display: block;
width: 100%;
height: 100%;
}
.control-panel {
position: absolute;
top: 20px;
left: 20px;
width: 320px;
z-index: 100;
}
.data-panel {
position: absolute;
top: 20px;
right: 20px;
width: 280px;
z-index: 100;
}
.legend-panel {
position: absolute;
bottom: 20px;
left: 20px;
z-index: 100;
}
.timeline-panel {
position: absolute;
bottom: 20px;
right: 20px;
width: 400px;
z-index: 100;
}
.toggle-btn {
transition: all 0.2s ease;
}
.toggle-btn.active {
background: var(--accent);
color: var(--bg);
}
.toggle-btn:not(.active):hover {
background: rgba(0, 212, 170, 0.15);
}
.range-slider {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 6px;
border-radius: 3px;
background: var(--bg);
outline: none;
}
.range-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
transition: transform 0.15s ease;
}
.range-slider::-webkit-slider-thumb:hover {
transform: scale(1.2);
}
.stat-card {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: 0 8px 24px rgba(0, 212, 170, 0.15);
}
.legend-gradient {
height: 16px;
border-radius: 4px;
}
.ice-gradient {
background: linear-gradient(90deg, #0d2840 0%, #1a5070 25%, #2d8090 50%, #4ab0c0 75%, #7ae0f0 100%);
}
.snow-gradient {
background: linear-gradient(90deg, #1a3050 0%, #3a6080 50%, #c8e0f0 100%);
}
.drift-gradient {
background: linear-gradient(90deg, #00a080 0%, #00d4aa 50%, #40ffcc 100%);
}
@keyframes pulse {
0%, 100% { opacity: 0.6; }
50% { opacity: 1; }
}
.satellite-marker {
animation: pulse 2s ease-in-out infinite;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.4s ease-out forwards;
}
.fade-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.3s; opacity: 0; }
.fade-in-delay-4 { animation-delay: 0.4s; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
.fade-in, .satellite-marker {
animation: none;
opacity: 1;
}
}
@media (max-width: 768px) {
.control-panel, .data-panel, .timeline-panel {
width: calc(100% - 40px);
left: 20px;
right: 20px;
}
.data-panel { top: auto; bottom: 180px; }
.timeline-panel { bottom: 20px; }
}
</style>
</head>
<body>
<div id="canvas-container">
<canvas id="mainCanvas"></canvas>
<!-- Control Panel -->
<div class="control-panel glass rounded-xl p-5 fade-in">
<h1 class="text-xl font-bold mb-1 flex items-center gap-2">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>
</svg>
Arctic Sea Ice Mapping
</h1>
<p class="text-sm text-[var(--muted)] mb-5">Altimetry, Snow Depth, and Drift Corrections</p>
<!-- Layer Toggles -->
<div class="mb-5">
<h2 class="text-xs uppercase tracking-wider text-[var(--muted)] mb-3 mono">Data Layers</h2>
<div class="flex flex-wrap gap-2">
<button id="toggleIce" class="toggle-btn active px-3 py-2 rounded-lg text-sm font-medium border border-[var(--border)]">
Ice Thickness
</button>
<button id="toggleSnow" class="toggle-btn active px-3 py-2 rounded-lg text-sm font-medium border border-[var(--border)]">
Snow Depth
</button>
<button id="toggleDrift" class="toggle-btn active px-3 py-2 rounded-lg text-sm font-medium border border-[var(--border)]">
Ice Drift
</button>
<button id="toggleAltimetry" class="toggle-btn active px-3 py-2 rounded-lg text-sm font-medium border border-[var(--border)]">
Altimetry Tracks
</button>
</div>
</div>
<!-- Correction Factors -->
<div class="mb-5">
<h2 class="text-xs uppercase tracking-wider text-[var(--muted)] mb-3 mono">Correction Factors</h2>
<div class="mb-4">
<div class="flex justify-between text-sm mb-2">
<span>Snow Density Correction</span>
<span id="snowDensityValue" class="mono text-[var(--accent)]">1.0x</span>
</div>
<input type="range" id="snowDensity" class="range-slider" min="0.8" max="1.2" step="0.01" value="1.0">
</div>
<div class="mb-4">
<div class="flex justify-between text-sm mb-2">
<span>Drift Velocity Scale</span>
<span id="driftScaleValue" class="mono text-[var(--accent)]">1.0x</span>
</div>
<input type="range" id="driftScale" class="range-slider" min="0.5" max="2.0" step="0.1" value="1.0">
</div>
<div>
<div class="flex justify-between text-sm mb-2">
<span>Freeboard Adjustment</span>
<span id="freeboardValue" class="mono text-[var(--accent)]">0 cm</span>
</div>
<input type="range" id="freeboard" class="range-slider" min="-10" max="10" step="1" value="0">
</div>
</div>
<!-- Animation Control -->
<div>
<h2 class="text-xs uppercase tracking-wider text-[var(--muted)] mb-3 mono">Simulation</h2>
<div class="flex gap-2">
<button id="playPause" class="flex-1 py-2 rounded-lg bg-[var(--accent)] text-[var(--bg)] font-medium text-sm hover:opacity-90 transition-opacity">
Pause
</button>
<button id="resetView" class="px-4 py-2 rounded-lg border border-[var(--border)] text-sm hover:bg-[var(--bg-secondary)] transition-colors">
Reset
</button>
</div>
</div>
</div>
<!-- Data Panel -->
<div class="data-panel glass rounded-xl p-5 fade-in fade-in-delay-1">
<h2 class="text-xs uppercase tracking-wider text-[var(--muted)] mb-4 mono">Current Readings</h2>
<div class="space-y-3">
<div class="stat-card glass rounded-lg p-3">
<div class="text-xs text-[var(--muted)] mb-1">Ice Thickness</div>
<div class="flex items-baseline gap-2">
<span id="iceThickness" class="text-2xl font-bold mono">2.34</span>
<span class="text-sm text-[var(--muted)]">meters</span>
</div>
</div>
<div class="stat-card glass rounded-lg p-3">
<div class="text-xs text-[var(--muted)] mb-1">Snow Depth</div>
<div class="flex items-baseline gap-2">
<span id="snowDepth" class="text-2xl font-bold mono">0.28</span>
<span class="text-sm text-[var(--muted)]">meters</span>
</div>
</div>
<div class="stat-card glass rounded-lg p-3">
<div class="text-xs text-[var(--muted)] mb-1">Drift Velocity</div>
<div class="flex items-baseline gap-2">
<span id="driftVelocity" class="text-2xl font-bold mono">5.2</span>
<span class="text-sm text-[var(--muted)]">cm/s</span>
</div>
</div>
<div class="stat-card glass rounded-lg p-3">
<div class="text-xs text-[var(--muted)] mb-1">Freeboard Height</div>
<div class="flex items-baseline gap-2">
<span id="freeboardHeight" class="text-2xl font-bold mono">0.41</span>
<span class="text-sm text-[var(--muted)]">meters</span>
</div>
</div>
</div>
<div class="mt-4 pt-4 border-t border-[var(--border)]">
<div class="flex items-center gap-2 text-sm">
<span class="satellite-marker w-2 h-2 rounded-full bg-[var(--accent)]"></span>
<span class="text-[var(--muted)]">CryoSat-2 Pass</span>
<span id="satelliteStatus" class="mono text-[var(--accent)] ml-auto">ACTIVE</span>
</div>
</div>
</div>
<!-- Legend Panel -->
<div class="legend-panel glass rounded-xl p-4 fade-in fade-in-delay-2">
<div class="space-y-3">
<div>
<div class="flex justify-between text-xs mb-1">
<span class="text-[var(--muted)]">Ice Thickness</span>
<span class="mono">0 - 5m</span>
</div>
<div class="legend-gradient ice-gradient"></div>
</div>
<div>
<div class="flex justify-between text-xs mb-1">
<span class="text-[var(--muted)]">Snow Depth</span>
<span class="mono">0 - 50cm</span>
</div>
<div class="legend-gradient snow-gradient"></div>
</div>
<div>
<div class="flex justify-between text-xs mb-1">
<span class="text-[var(--muted)]">Drift Speed</span>
<span class="mono">0 - 15cm/s</span>
</div>
<div class="legend-gradient drift-gradient"></div>
</div>
</div>
</div>
<!-- Timeline Panel -->
<div class="timeline-panel glass rounded-xl p-4 fade-in fade-in-delay-3">
<div class="flex items-center justify-between mb-3">
<h2 class="text-xs uppercase tracking-wider text-[var(--muted)] mono">Timeline: January 2024</h2>
<span id="currentDay" class="mono text-sm">Day 15</span>
</div>
<input type="range" id="timeline" class="range-slider" min="1" max="31" value="15">
<div class="flex justify-between text-xs text-[var(--muted)] mt-2 mono">
<span>Jan 1</span>
<span>Jan 15</span>
<span>Jan 31</span>
</div>
</div>
</div>
<script>
// Initialize all state variables first
const state = {
showIce: true,
showSnow: true,
showDrift: true,
showAltimetry: true,
snowDensity: 1.0,
driftScale: 1.0,
freeboard: 0,
playing: true,
time: 0,
mouseX: 0,
mouseY: 0,
hoveredCell: null,
day: 15
};
// Data grids
const GRID_SIZE = 100;
const GRID_RES = 5;
// Initialize grids with default values
const iceThicknessGrid = [];
const snowDepthGrid = [];
const driftGrid = [];
const driftAngleGrid = [];
// Initialize grids before any functions use them
for (let i = 0; i < GRID_SIZE; i++) {
iceThicknessGrid[i] = [];
snowDepthGrid[i] = [];
driftGrid[i] = [];
driftAngleGrid[i] = [];
for (let j = 0; j < GRID_SIZE; j++) {
const x = (i - GRID_SIZE / 2) / GRID_SIZE;
const y = (j - GRID_SIZE / 2) / GRID_SIZE;
const dist = Math.sqrt(x * x + y * y);
// Ice thickness: thicker near Canadian Arctic (right side), thinner near Siberian coast
const baseThickness = Math.max(0, 3.5 * (1 - dist * 0.8) + 1.5 * (1 - y) * 0.5);
const noise = (Math.sin(i * 0.3) * Math.cos(j * 0.25) + Math.sin(i * 0.1 + j * 0.15)) * 0.5;
iceThicknessGrid[i][j] = Math.max(0.1, baseThickness + noise);
// Snow depth: correlates with ice thickness but with variation
snowDepthGrid[i][j] = Math.max(0.05, iceThicknessGrid[i][j] * 0.12 + Math.random() * 0.15);
// Drift: Beaufort Gyre (clockwise) and Transpolar Drift
const angle = Math.atan2(y, x) + Math.PI / 2;
driftAngleGrid[i][j] = angle + (Math.random() - 0.5) * 0.5;
driftGrid[i][j] = 3 + Math.random() * 8 * (1 - dist * 0.5);
}
}
// Canvas setup
const canvas = document.getElementById('mainCanvas');
const ctx = canvas.getContext('2d');
let width = 0;
let height = 0;
let centerX = 0;
let centerY = 0;
let mapRadius = 0;
// Altimetry track data
const altimetryTracks = [];
const NUM_TRACKS = 6;
function initAltimetryTracks() {
altimetryTracks.length = 0;
for (let t = 0; t < NUM_TRACKS; t++) {
const angle = (t / NUM_TRACKS) * Math.PI * 2 + Math.random() * 0.3;
altimetryTracks.push({
angle: angle,
progress: Math.random(),
speed: 0.003 + Math.random() * 0.002,
points: []
});
}
}
function resize() {
const dpr = window.devicePixelRatio || 1;
width = window.innerWidth;
height = window.innerHeight;
canvas.width = width * dpr;
canvas.height = height * dpr;
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
ctx.scale(dpr, dpr);
centerX = width / 2;
centerY = height / 2;
mapRadius = Math.min(width, height) * 0.38;
}
// Color functions
function getIceColor(thickness) {
const t = Math.min(1, Math.max(0, thickness / 5));
if (t < 0.25) {
return `rgb(${Math.floor(13 + t * 4 * 13)}, ${Math.floor(40 + t * 4 * 40)}, ${Math.floor(64 + t * 4 * 48)})`;
} else if (t < 0.5) {
const s = (t - 0.25) * 4;
return `rgb(${Math.floor(26 + s * 20)}, ${Math.floor(80 + s * 50)}, ${Math.floor(112 + s * 30)})`;
} else if (t < 0.75) {
const s = (t - 0.5) * 4;
return `rgb(${Math.floor(46 + s * 28)}, ${Math.floor(130 + s * 40)}, ${Math.floor(142 + s * 50)})`;
} else {
const s = (t - 0.75) * 4;
return `rgb(${Math.floor(74 + s * 48)}, ${Math.floor(170 + s * 54)}, ${Math.floor(192 + s * 48)})`;
}
}
function getSnowColor(depth) {
const d = Math.min(1, Math.max(0, depth / 0.5));
return `rgba(${Math.floor(200 + d * 55)}, ${Math.floor(224 + d * 31)}, ${Math.floor(240 + d * 15)}, ${0.3 + d * 0.4})`;
}
function getDriftColor(speed) {
const s = Math.min(1, Math.max(0, speed / 15));
const r = Math.floor(0 + s * 64);
const g = Math.floor(160 + s * 52);
const b = Math.floor(128 + s * 74);
return `rgb(${r}, ${g}, ${b})`;
}
// Drawing functions
function drawBackground() {
// Deep ocean background
const bgGrad = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, mapRadius * 1.5);
bgGrad.addColorStop(0, '#0d1f2d');
bgGrad.addColorStop(0.6, '#0a1520');
bgGrad.addColorStop(1, '#060c12');
ctx.fillStyle = bgGrad;
ctx.fillRect(0, 0, width, height);
// Subtle grid pattern
ctx.strokeStyle = 'rgba(107, 125, 143, 0.08)';
ctx.lineWidth = 1;
for (let i = 0; i < 20; i++) {
const r = mapRadius * (i / 20);
ctx.beginPath();
ctx.arc(centerX, centerY, Math.max(1, r), 0, Math.PI * 2);
ctx.stroke();
}
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(centerX + Math.cos(angle) * mapRadius, centerY + Math.sin(angle) * mapRadius);
ctx.stroke();
}
}
function drawIceMap() {
if (!state.showIce) return;
ctx.save();
ctx.beginPath();
ctx.arc(centerX, centerY, mapRadius, 0, Math.PI * 2);
ctx.clip();
const cellSize = (mapRadius * 2) / GRID_SIZE;
const startX = centerX - mapRadius;
for (let i = 0; i < GRID_SIZE; i++) {
for (let j = 0; j < GRID_SIZE; j++) {
const x = (i - GRID_SIZE / 2) / GRID_SIZE;
const y = (j - GRID_SIZE / 2) / GRID_SIZE;
const dist = Math.sqrt(x * x + y * y);
if (dist > 0.95) continue;
const thickness = iceThicknessGrid[i][j] * state.snowDensity;
const adjustedThickness = Math.max(0.1, thickness + state.freeboard * 0.01);
ctx.fillStyle = getIceColor(adjustedThickness);
ctx.fillRect(startX + i * cellSize, centerY - mapRadius + j * cellSize, cellSize + 1, cellSize + 1);
}
}
ctx.restore();
}
function drawSnowOverlay() {
if (!state.showSnow) return;
ctx.save();
ctx.beginPath();
ctx.arc(centerX, centerY, mapRadius, 0, Math.PI * 2);
ctx.clip();
const cellSize = (mapRadius * 2) / GRID_SIZE;
const startX = centerX - mapRadius;
for (let i = 0; i < GRID_SIZE; i += 2) {
for (let j = 0; j < GRID_SIZE; j += 2) {
const x = (i - GRID_SIZE / 2) / GRID_SIZE;
const y = (j - GRID_SIZE / 2) / GRID_SIZE;
const dist = Math.sqrt(x * x + y * y);
if (dist > 0.95) continue;
const depth = snowDepthGrid[i][j] * state.snowDensity;
ctx.fillStyle = getSnowColor(depth);
ctx.fillRect(startX + i * cellSize, centerY - mapRadius + j * cellSize, cellSize * 2, cellSize * 2);
}
}
ctx.restore();
}
function drawDriftVectors() {
if (!state.showDrift) return;
ctx.save();
ctx.beginPath();
ctx.arc(centerX, centerY, mapRadius, 0, Math.PI * 2);
ctx.clip();
const spacing = mapRadius / 15;
const time = state.time * 0.5;
for (let i = 0; i < GRID_SIZE; i += GRID_RES) {
for (let j = 0; j < GRID_SIZE; j += GRID_RES) {
const x = (i - GRID_SIZE / 2) / GRID_SIZE;
const y = (j - GRID_SIZE / 2) / GRID_SIZE;
const dist = Math.sqrt(x * x + y * y);
if (dist > 0.9 || dist < 0.1) continue;
const screenX = centerX + x * mapRadius * 2;
const screenY = centerY + y * mapRadius * 2;
const speed = driftGrid[i][j] * state.driftScale;
let angle = driftAngleGrid[i][j] + Math.sin(time + i * 0.1) * 0.1;
const len = Math.max(5, speed * 2);
const endX = screenX + Math.cos(angle) * len;
const endY = screenY + Math.sin(angle) * len;
ctx.strokeStyle = getDriftColor(speed);
ctx.lineWidth = 1.5;
ctx.lineCap = 'round';
ctx.beginPath();
ctx.moveTo(screenX, screenY);
ctx.lineTo(endX, endY);
ctx.stroke();
// Arrow head
const headLen = 4;
const headAngle = 0.5;
ctx.beginPath();
ctx.moveTo(endX, endY);
ctx.lineTo(endX - headLen * Math.cos(angle - headAngle), endY - headLen * Math.sin(angle - headAngle));
ctx.moveTo(endX, endY);
ctx.lineTo(endX - headLen * Math.cos(angle + headAngle), endY - headLen * Math.sin(angle + headAngle));
ctx.stroke();
}
}
ctx.restore();
}
function drawAltimetryTracks() {
if (!state.showAltimetry) return;
ctx.save();
ctx.beginPath();
ctx.arc(centerX, centerY, mapRadius, 0, Math.PI * 2);
ctx.clip();
altimetryTracks.forEach((track, tIndex) => {
// Update track progress
if (state.playing) {
track.progress += track.speed;
if (track.progress > 1) {
track.progress = 0;
track.angle = Math.random() * Math.PI * 2;
track.points = [];
}
}
// Draw satellite path
const satAngle = track.angle + state.time * 0.02;
const startX = centerX + Math.cos(satAngle) * mapRadius;
const startY = centerY + Math.sin(satAngle) * mapRadius;
const endX = centerX - Math.cos(satAngle) * mapRadius;
const endY = centerY - Math.sin(satAngle) * mapRadius;
// Track line
ctx.strokeStyle = 'rgba(0, 212, 170, 0.3)';
ctx.lineWidth = 1;
ctx.setLineDash([5, 5]);
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(endX, endY);
ctx.stroke();
ctx.setLineDash([]);
// Satellite position
const satX = startX + (endX - startX) * track.progress;
const satY = startY + (endY - startY) * track.progress;
// Glow effect
const glowGrad = ctx.createRadialGradient(satX, satY, 0, satX, satY, 20);
glowGrad.addColorStop(0, 'rgba(0, 212, 170, 0.6)');
glowGrad.addColorStop(0.5, 'rgba(0, 212, 170, 0.2)');
glowGrad.addColorStop(1, 'rgba(0, 212, 170, 0)');
ctx.fillStyle = glowGrad;
ctx.beginPath();
ctx.arc(satX, satY, 20, 0, Math.PI * 2);
ctx.fill();
// Satellite dot
ctx.fillStyle = '#00d4aa';
ctx.beginPath();
ctx.arc(satX, satY, 4, 0, Math.PI * 2);
ctx.fill();
// Measurement points trail
if (state.playing) {
track.points.push({ x: satX, y: satY, time: state.time });
if (track.points.length > 30) track.points.shift();
}
track.points.forEach((pt, idx) => {
const alpha = idx / track.points.length * 0.5;
ctx.fillStyle = `rgba(0, 212, 170, ${alpha})`;
ctx.beginPath();
ctx.arc(pt.x, pt.y, 2, 0, Math.PI * 2);
ctx.fill();
});
});
ctx.restore();
}
function drawMapBorder() {
// Arctic circle border
ctx.strokeStyle = 'rgba(107, 125, 143, 0.5)';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(centerX, centerY, mapRadius, 0, Math.PI * 2);
ctx.stroke();
// Geographic labels
ctx.font = '11px "IBM Plex Mono", monospace';
ctx.fillStyle = 'rgba(107, 125, 143, 0.8)';
ctx.textAlign = 'center';
const labels = [
{ text: 'BEAUFORT SEA', angle: -Math.PI * 0.7 },
{ text: 'GREENLAND', angle: -Math.PI * 0.3 },
{ text: 'SIBERIAN COAST', angle: Math.PI * 0.1 },
{ text: 'NORTH POLE', angle: 0, offset: 0 }
];
labels.forEach(label => {
const x = centerX + Math.cos(label.angle) * (mapRadius + 25);
const y = centerY + Math.sin(label.angle) * (mapRadius + 25);
if (label.text === 'NORTH POLE') {
ctx.fillText(label.text, centerX, centerY - 10);
// North pole marker
ctx.strokeStyle = 'rgba(255, 107, 74, 0.8)';
ctx.lineWidth = 1.5;
ctx.beginPath();
ctx.moveTo(centerX - 8, centerY);
ctx.lineTo(centerX + 8, centerY);
ctx.moveTo(centerX, centerY - 8);
ctx.lineTo(centerX, centerY + 8);
ctx.stroke();
} else {
ctx.fillText(label.text, x, y);
}
});
}
function drawHoverInfo() {
if (!state.hoveredCell) return;
const { i, j, screenX, screenY } = state.hoveredCell;
const x = (i - GRID_SIZE / 2) / GRID_SIZE;
const y = (j - GRID_SIZE / 2) / GRID_SIZE;
const dist = Math.sqrt(x * x + y * y);
if (dist > 0.95) return;
const thickness = iceThicknessGrid[i][j];
const snow = snowDepthGrid[i][j];
const drift = driftGrid[i][j];
// Highlight cell
ctx.strokeStyle = 'rgba(0, 212, 170, 0.8)';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(screenX, screenY, 15, 0, Math.PI * 2);
ctx.stroke();
// Update UI values
document.getElementById('iceThickness').textContent = thickness.toFixed(2);
document.getElementById('snowDepth').textContent = snow.toFixed(2);
document.getElementById('driftVelocity').textContent = drift.toFixed(1);
document.getElementById('freeboardHeight').textContent = (thickness * 0.15).toFixed(2);
}
function updateHoveredCell(e) {
const rect = canvas.getBoundingClientRect();
const mouseX = e.clientX - rect.left;
const mouseY = e.clientY - rect.top;
const dx = mouseX - centerX;
const dy = mouseY - centerY;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < mapRadius) {
const x = dx / (mapRadius * 2);
const y = dy / (mapRadius * 2);
const i = Math.floor((x + 0.5) * GRID_SIZE);
const j = Math.floor((y + 0.5) * GRID_SIZE);
if (i >= 0 && i < GRID_SIZE && j >= 0 && j < GRID_SIZE) {
state.hoveredCell = { i, j, screenX: mouseX, screenY: mouseY };
return;
}
}
state.hoveredCell = null;
}
function render() {
ctx.clearRect(0, 0, width, height);
drawBackground();
drawIceMap();
drawSnowOverlay();
drawDriftVectors();
drawAltimetryTracks();
drawMapBorder();
drawHoverInfo();
if (state.playing) {
state.time += 0.016;
}
requestAnimationFrame(render);
}
// Event handlers
function setupEventHandlers() {
// Layer toggles
document.getElementById('toggleIce').addEventListener('click', function() {
state.showIce = !state.showIce;
this.classList.toggle('active');
});
document.getElementById('toggleSnow').addEventListener('click', function() {
state.showSnow = !state.showSnow;
this.classList.toggle('active');
});
document.getElementById('toggleDrift').addEventListener('click', function() {
state.showDrift = !state.showDrift;
this.classList.toggle('active');
});
document.getElementById('toggleAltimetry').addEventListener('click', function() {
state.showAltimetry = !state.showAltimetry;
this.classList.toggle('active');
});
// Sliders
document.getElementById('snowDensity').addEventListener('input', function() {
state.snowDensity = parseFloat(this.value);
document.getElementById('snowDensityValue').textContent = state.snowDensity.toFixed(2) + 'x';
});
document.getElementById('driftScale').addEventListener('input', function() {
state.driftScale = parseFloat(this.value);
document.getElementById('driftScaleValue').textContent = state.driftScale.toFixed(1) + 'x';
});
document.getElementById('freeboard').addEventListener('input', function() {
state.freeboard = parseInt(this.value);
document.getElementById('freeboardValue').textContent = state.freeboard + ' cm';
});
// Timeline
document.getElementById('timeline').addEventListener('input', function() {
state.day = parseInt(this.value);
document.getElementById('currentDay').textContent = 'Day ' + state.day;
});
// Play/Pause
document.getElementById('playPause').addEventListener('click', function() {
state.playing = !state.playing;
this.textContent = state.playing ? 'Pause' : 'Play';
});
// Reset
document.getElementById('resetView').addEventListener('click', function() {
state.snowDensity = 1.0;
state.driftScale = 1.0;
state.freeboard = 0;
state.day = 15;
state.playing = true;
document.getElementById('snowDensity').value = 1.0;
document.getElementById('driftScale').value = 1.0;
document.getElementById('freeboard').value = 0;
document.getElementById('timeline').value = 15;
document.getElementById('snowDensityValue').textContent = '1.00x';
document.getElementById('driftScaleValue').textContent = '1.0x';
document.getElementById('freeboardValue').textContent = '0 cm';
document.getElementById('currentDay').textContent = 'Day 15';
document.getElementById('playPause').textContent = 'Pause';
initAltimetryTracks();
});
// Mouse tracking
canvas.addEventListener('mousemove', updateHoveredCell);
canvas.addEventListener('mouseleave', () => { state.hoveredCell = null; });
// Resize
window.addEventListener('resize', resize);
}
// Initialize
function init() {
resize();
initAltimetryTracks();
setupEventHandlers();
render();
}
init();
</script>
</body>
</html>
The visualization uses realistic patterns: