Skip to content
TheChatArchiveThe Chat Archive
GLMGLM-5 / Pony Alpha· unknownHugging Face Frontier Reasoning Traces

Create a coastal erosion hotspot mapping: lidar, photogrammetry, and trends.

  1. User

    Create a coastal erosion hotspot mapping: lidar, photogrammetry, and trends.

  2. GLM Assistant

    The user wants a coastal erosion hotspot mapping visualization that includes:

    1. LIDAR data representation
    2. Photogrammetry data
    3. Erosion trends over time

    This is a technical/scientific visualization, so I should create:

    • A coastal map showing erosion hotspots
    • LIDAR point cloud visualization or elevation data
    • Photogrammetry-derived imagery/analysis
    • Trend indicators showing erosion rates

    I'll create an interactive 3D visualization using Three.js that shows:

    1. A 3D coastal terrain with elevation data (simulating LIDAR)
    2. Color-coded erosion hotspots
    3. Timeline/trend visualization
    4. Interactive elements to explore different data layers

    Design approach:

    • Use a dark theme with vibrant data visualization colors (cyan, magenta, orange for hotspots)
    • Create procedural terrain representing coastal features
    • Show erosion intensity with heat map overlay
    • Include timeline controls to see erosion progression
    • Add data panels showing LIDAR/photogrammetry metrics

    Let me build this step by step:

    1. Create a 3D coastal terrain mesh
    2. Apply elevation coloring (bathymetry/topography)
    3. Add erosion hotspot overlays with pulsing effects
    4. Create trend graphs/indicators
    5. Add interactive controls for different data layers
    6. Include statistics panels

    I'll use Three.js with proper ES modules and import maps as required.

    Coastal Erosion Hotspot Mapping

    This visualization combines LIDAR elevation data, photogrammetry analysis, and temporal erosion trends into an interactive 3D coastal mapping system. Here's my approach:

    1. 3D Coastal Terrain - Procedurally generated terrain representing coastal morphology with elevation-based coloring
    2. LIDAR Simulation - Point cloud visualization with elevation intensity mapping
    3. Erosion Hotspots - Heat-mapped danger zones with pulsing indicators showing active erosion areas
    4. Trend Analysis - Real-time erosion rate data and temporal progression
    5. Interactive Layers - Toggle between different data visualization modes
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Coastal Erosion Hotspot Mapping</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
    
            body {
                font-family: 'Segoe UI', system-ui, sans-serif;
                background: #0a0f14;
                color: #e0e8f0;
                overflow: hidden;
            }
    
            #canvas-container {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
    
            .ui-overlay {
                position: fixed;
                z-index: 100;
                pointer-events: none;
            }
    
            .ui-overlay > * {
                pointer-events: auto;
            }
    
            .header {
                top: 0;
                left: 0;
                right: 0;
                padding: 20px 30px;
                background: linear-gradient(180deg, rgba(10,15,20,0.95) 0%, transparent 100%);
            }
    
            .header h1 {
                font-size: 1.6rem;
                font-weight: 600;
                color: #fff;
                margin-bottom: 5px;
                letter-spacing: 1px;
            }
    
            .header .subtitle {
                font-size: 0.85rem;
                color: #7a8a9a;
            }
    
            .control-panel {
                top: 100px;
                left: 20px;
                width: 280px;
            }
    
            .panel {
                background: rgba(15, 22, 30, 0.92);
                border: 1px solid rgba(80, 160, 200, 0.2);
                border-radius: 12px;
                padding: 16px;
                margin-bottom: 12px;
                backdrop-filter: blur(10px);
            }
    
            .panel-title {
                font-size: 0.75rem;
                text-transform: uppercase;
                letter-spacing: 1.5px;
                color: #50a0c8;
                margin-bottom: 12px;
                padding-bottom: 8px;
                border-bottom: 1px solid rgba(80, 160, 200, 0.2);
            }
    
            .layer-toggle {
                display: flex;
                align-items: center;
                padding: 10px 12px;
                margin-bottom: 6px;
                background: rgba(30, 45, 60, 0.5);
                border-radius: 8px;
                cursor: pointer;
                transition: all 0.3s ease;
            }
    
            .layer-toggle:hover {
                background: rgba(40, 60, 80, 0.6);
            }
    
            .layer-toggle.active {
                background: rgba(50, 120, 160, 0.3);
                border-left: 3px solid #50a0c8;
            }
    
            .layer-indicator {
                width: 12px;
                height: 12px;
                border-radius: 50%;
                margin-right: 12px;
                position: relative;
            }
    
            .layer-indicator::after {
                content: '';
                position: absolute;
                top: 2px;
                left: 2px;
                width: 8px;
                height: 8px;
                border-radius: 50%;
                background: transparent;
                transition: background 0.3s ease;
            }
    
            .layer-toggle.active .layer-indicator::after {
                background: #fff;
            }
    
            .layer-indicator.lidar { background: #00d4ff; }
            .layer-indicator.photo { background: #ff6b35; }
            .layer-indicator.hotspot { background: #ff3366; }
            .layer-indicator.trend { background: #4ecdc4; }
    
            .layer-name {
                font-size: 0.85rem;
                flex: 1;
            }
    
            .stats-panel {
                top: 100px;
                right: 20px;
                width: 260px;
            }
    
            .stat-row {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 8px 0;
                border-bottom: 1px solid rgba(80, 160, 200, 0.1);
            }
    
            .stat-label {
                font-size: 0.8rem;
                color: #8a9aaa;
            }
    
            .stat-value {
                font-size: 0.95rem;
                font-weight: 600;
                color: #fff;
            }
    
            .stat-value.danger { color: #ff3366; }
            .stat-value.warning { color: #ff6b35; }
            .stat-value.safe { color: #4ecdc4; }
    
            .erosion-bar {
                height: 6px;
                background: rgba(40, 60, 80, 0.5);
                border-radius: 3px;
                margin-top: 8px;
                overflow: hidden;
            }
    
            .erosion-fill {
                height: 100%;
                border-radius: 3px;
                transition: width 0.5s ease;
            }
    
            .timeline-panel {
                bottom: 30px;
                left: 50%;
                transform: translateX(-50%);
                width: 600px;
                max-width: calc(100% - 40px);
            }
    
            .timeline-container {
                background: rgba(15, 22, 30, 0.92);
                border: 1px solid rgba(80, 160, 200, 0.2);
                border-radius: 12px;
                padding: 16px 20px;
                backdrop-filter: blur(10px);
            }
    
            .timeline-header {
                display: flex;
                justify-content: space-between;
                margin-bottom: 12px;
            }
    
            .timeline-year {
                font-size: 1.1rem;
                font-weight: 600;
                color: #fff;
            }
    
            .timeline-range {
                font-size: 0.75rem;
                color: #7a8a9a;
            }
    
            .timeline-slider {
                width: 100%;
                height: 8px;
                -webkit-appearance: none;
                background: rgba(40, 60, 80, 0.5);
                border-radius: 4px;
                outline: none;
            }
    
            .timeline-slider::-webkit-slider-thumb {
                -webkit-appearance: none;
                width: 20px;
                height: 20px;
                border-radius: 50%;
                background: #50a0c8;
                cursor: pointer;
                box-shadow: 0 0 15px rgba(80, 160, 200, 0.5);
            }
    
            .timeline-markers {
                display: flex;
                justify-content: space-between;
                margin-top: 8px;
                font-size: 0.7rem;
                color: #6a7a8a;
            }
    
            .legend-panel {
                bottom: 120px;
                right: 20px;
            }
    
            .legend-container {
                background: rgba(15, 22, 30, 0.92);
                border: 1px solid rgba(80, 160, 200, 0.2);
                border-radius: 12px;
                padding: 14px 16px;
                backdrop-filter: blur(10px);
            }
    
            .legend-item {
                display: flex;
                align-items: center;
                margin-bottom: 8px;
                font-size: 0.75rem;
            }
    
            .legend-item:last-child {
                margin-bottom: 0;
            }
    
            .legend-color {
                width: 24px;
                height: 12px;
                border-radius: 2px;
                margin-right: 10px;
            }
    
            .hotspot-info {
                position: fixed;
                bottom: 120px;
                left: 20px;
                background: rgba(15, 22, 30, 0.95);
                border: 1px solid rgba(255, 51, 102, 0.3);
                border-radius: 12px;
                padding: 14px 16px;
                backdrop-filter: blur(10px);
                opacity: 0;
                transform: translateY(10px);
                transition: all 0.3s ease;
                z-index: 100;
            }
    
            .hotspot-info.visible {
                opacity: 1;
                transform: translateY(0);
            }
    
            .hotspot-info-title {
                font-size: 0.9rem;
                font-weight: 600;
                color: #ff3366;
                margin-bottom: 8px;
            }
    
            .hotspot-info-detail {
                font-size: 0.75rem;
                color: #9aa;
                line-height: 1.5;
            }
    
            @keyframes pulse {
                0%, 100% { opacity: 0.6; transform: scale(1); }
                50% { opacity: 1; transform: scale(1.1); }
            }
    
            .loading-overlay {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: #0a0f14;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                z-index: 1000;
                transition: opacity 0.5s ease;
            }
    
            .loading-overlay.hidden {
                opacity: 0;
                pointer-events: none;
            }
    
            .loading-spinner {
                width: 50px;
                height: 50px;
                border: 3px solid rgba(80, 160, 200, 0.2);
                border-top-color: #50a0c8;
                border-radius: 50%;
                animation: spin 1s linear infinite;
            }
    
            .loading-text {
                margin-top: 16px;
                font-size: 0.9rem;
                color: #7a8a9a;
            }
    
            @keyframes spin {
                to { transform: rotate(360deg); }
            }
        </style>
    </head>
    <body>
        <div id="canvas-container"></div>
    
        <div class="loading-overlay" id="loading">
            <div class="loading-spinner"></div>
            <div class="loading-text">Loading coastal data...</div>
        </div>
    
        <div class="ui-overlay header">
            <h1>Coastal Erosion Hotspot Mapping</h1>
            <div class="subtitle">LIDAR & Photogrammetry Analysis System</div>
        </div>
    
        <div class="ui-overlay control-panel">
            <div class="panel">
                <div class="panel-title">Data Layers</div>
                <div class="layer-toggle active" data-layer="lidar">
                    <div class="layer-indicator lidar"></div>
                    <span class="layer-name">LIDAR Point Cloud</span>
                </div>
                <div class="layer-toggle active" data-layer="terrain">
                    <div class="layer-indicator photo"></div>
                    <span class="layer-name">Terrain Model</span>
                </div>
                <div class="layer-toggle active" data-layer="hotspots">
                    <div class="layer-indicator hotspot"></div>
                    <span class="layer-name">Erosion Hotspots</span>
                </div>
                <div class="layer-toggle active" data-layer="trends">
                    <div class="layer-indicator trend"></div>
                    <span class="layer-name">Trend Vectors</span>
                </div>
            </div>
    
            <div class="panel">
                <div class="panel-title">Analysis Mode</div>
                <div class="layer-toggle active" data-mode="elevation">
                    <div class="layer-indicator" style="background: linear-gradient(135deg, #00d4ff, #0066cc);"></div>
                    <span class="layer-name">Elevation Analysis</span>
                </div>
                <div class="layer-toggle" data-mode="erosion">
                    <div class="layer-indicator" style="background: linear-gradient(135deg, #ff3366, #ff6b35);"></div>
                    <span class="layer-name">Erosion Intensity</span>
                </div>
                <div class="layer-toggle" data-mode="velocity">
                    <div class="layer-indicator" style="background: linear-gradient(135deg, #4ecdc4, #2a9d8f);"></div>
                    <span class="layer-name">Change Velocity</span>
                </div>
            </div>
        </div>
    
        <div class="ui-overlay stats-panel">
            <div class="panel">
                <div class="panel-title">Erosion Statistics</div>
                <div class="stat-row">
                    <span class="stat-label">Current Year</span>
                    <span class="stat-value" id="stat-year">2024</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Avg. Erosion Rate</span>
                    <span class="stat-value danger" id="stat-rate">2.4 m/yr</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Max Retreat</span>
                    <span class="stat-value warning" id="stat-retreat">18.7 m</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Active Hotspots</span>
                    <span class="stat-value" id="stat-hotspots">7</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Risk Level</span>
                    <span class="stat-value danger" id="stat-risk">HIGH</span>
                </div>
                <div class="erosion-bar">
                    <div class="erosion-fill" id="erosion-fill" style="width: 78%; background: linear-gradient(90deg, #4ecdc4, #ff6b35, #ff3366);"></div>
                </div>
            </div>
    
            <div class="panel">
                <div class="panel-title">Data Quality</div>
                <div class="stat-row">
                    <span class="stat-label">LIDAR Coverage</span>
                    <span class="stat-value safe">94.2%</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Photo Resolution</span>
                    <span class="stat-value">5 cm/px</span>
                </div>
                <div class="stat-row">
                    <span class="stat-label">Last Survey</span>
                    <span class="stat-value">Oct 2024</span>
                </div>
            </div>
        </div>
    
        <div class="ui-overlay timeline-panel">
            <div class="timeline-container">
                <div class="timeline-header">
                    <span class="timeline-year" id="timeline-year">2024</span>
                    <span class="timeline-range">Historical Data: 2010 - 2024</span>
                </div>
                <input type="range" class="timeline-slider" id="timeline" min="2010" max="2024" value="2024">
                <div class="timeline-markers">
                    <span>2010</span>
                    <span>2014</span>
                    <span>2018</span>
                    <span>2022</span>
                    <span>2024</span>
                </div>
            </div>
        </div>
    
        <div class="ui-overlay legend-panel">
            <div class="legend-container">
                <div class="legend-item">
                    <div class="legend-color" style="background: #00d4ff;"></div>
                    <span>Low Erosion (&lt;0.5 m/yr)</span>
                </div>
                <div class="legend-item">
                    <div class="legend-color" style="background: #4ecdc4;"></div>
                    <span>Moderate (0.5-1.5 m/yr)</span>
                </div>
                <div class="legend-item">
                    <div class="legend-color" style="background: #ff6b35;"></div>
                    <span>High (1.5-3.0 m/yr)</span>
                </div>
                <div class="legend-item">
                    <div class="legend-color" style="background: #ff3366;"></div>
                    <span>Critical (&gt;3.0 m/yr)</span>
                </div>
            </div>
        </div>
    
        <div class="hotspot-info" id="hotspot-info">
            <div class="hotspot-info-title" id="hotspot-title">Hotspot A1</div>
            <div class="hotspot-info-detail" id="hotspot-detail">
                Erosion Rate: 3.8 m/yr<br>
                Total Retreat: 42.3 m since 2010<br>
                Primary Cause: Storm surge exposure
            </div>
        </div>
    
        <script type="importmap">
        {
            "imports": {
                "three": "https://unpkg.com/three@0.160.0/build/three.module.js",
                "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
            }
        }
        </script>
    
        <script type="module">
            import * as THREE from 'three';
            import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
    
            // Scene setup
            const container = document.getElementById('canvas-container');
            const scene = new THREE.Scene();
            scene.background = new THREE.Color(0x0a0f14);
            scene.fog = new THREE.FogExp2(0x0a0f14, 0.008);
    
            const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.set(40, 35, 50);
    
            const renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
            container.appendChild(renderer.domElement);
    
            const controls = new OrbitControls(camera, renderer.domElement);
            controls.enableDamping = true;
            controls.dampingFactor = 0.05;
            controls.maxPolarAngle = Math.PI / 2.2;
            controls.minDistance = 20;
            controls.maxDistance = 100;
    
            // Lighting
            const ambientLight = new THREE.AmbientLight(0x4488aa, 0.4);
            scene.add(ambientLight);
    
            const sunLight = new THREE.DirectionalLight(0xffeedd, 1.2);
            sunLight.position.set(50, 80, 30);
            scene.add(sunLight);
    
            const fillLight = new THREE.DirectionalLight(0x6699cc, 0.3);
            fillLight.position.set(-30, 20, -20);
            scene.add(fillLight);
    
            // State
            let currentYear = 2024;
            const layers = {
                lidar: true,
                terrain: true,
                hotspots: true,
                trends: true
            };
            let analysisMode = 'elevation';
    
            // Generate coastal terrain
            function generateTerrain() {
                const width = 120;
                const height = 80;
                const geometry = new THREE.PlaneGeometry(width, height, 200, 140);
                geometry.rotateX(-Math.PI / 2);
    
                const positions = geometry.attributes.position.array;
                const colors = new Float32Array(positions.length);
    
                for (let i = 0; i < positions.length; i += 3) {
                    const x = positions[i];
                    const z = positions[i + 2];
                    
                    // Create coastal profile
                    let y = 0;
                    
                    // Ocean side (negative z)
                    if (z < -10) {
                        y = -2 - Math.abs(z + 10) * 0.15;
                        y += noise(x * 0.05, z * 0.05) * 1.5;
                    }
                    // Beach/shoreline
                    else if (z < 5) {
                        const t = (z + 10) / 15;
                        y = -2 + t * 4;
                        y += noise(x * 0.08, z * 0.08) * 0.8;
                        // Erosion scallops
                        y -= Math.abs(Math.sin(x * 0.15 + noise(x * 0.02, z * 0.02) * 2)) * 1.5 * (1 - t);
                    }
                    // Coastal bluffs
                    else if (z < 20) {
                        const t = (z - 5) / 15;
                        y = 2 + t * 8;
                        y += noise(x * 0.06, z * 0.06) * 2;
                        // Erosion features
                        const erosionFactor = Math.max(0, 1 - t);
                        y -= Math.abs(Math.sin(x * 0.12)) * erosionFactor * 3;
                    }
                    // Upland
                    else {
                        y = 10 + noise(x * 0.04, z * 0.04) * 5;
                        y += (z - 20) * 0.1;
                    }
    
                    positions[i + 1] = y;
    
                    // Colors based on elevation and position
                    const color = getTerrainColor(y, z);
                    colors[i] = color.r;
                    colors[i + 1] = color.g;
                    colors[i + 2] = color.b;
                }
    
                geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
                geometry.computeVertexNormals();
    
                const material = new THREE.MeshPhongMaterial({
                    vertexColors: true,
                    flatShading: false,
                    shininess: 5,
                    side: THREE.DoubleSide
                });
    
                return new THREE.Mesh(geometry, material);
            }
    
            function getTerrainColor(elevation, z) {
                // Underwater
                if (elevation < -3) return { r: 0.05, g: 0.15, b: 0.3 };
                if (elevation < -1) return { r: 0.1, g: 0.25, b: 0.4 };
                // Beach
                if (elevation < 1) return { r: 0.76, g: 0.7, b: 0.5 };
                if (elevation < 3) return { r: 0.7, g: 0.65, b: 0.45 };
                // Bluffs
                if (elevation < 6) return { r: 0.55, g: 0.5, b: 0.4 };
                if (elevation < 9) return { r: 0.45, g: 0.42, b: 0.35 };
                // Upland
                return { r: 0.35, g: 0.45, b: 0.3 };
            }
    
            function noise(x, y) {
                const n = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453;
                return (n - Math.floor(n)) * 2 - 1;
            }
    
            // LIDAR Point Cloud
            function createLidarPoints(terrain) {
                const geometry = terrain.geometry;
                const positions = geometry.attributes.position.array;
                const pointPositions = [];
                const pointColors = [];
    
                for (let i = 0; i < positions.length; i += 3) {
                    // Sample points
                    if (Math.random() > 0.15) continue;
    
                    const x = positions[i] + (Math.random() - 0.5) * 0.3;
                    const y = positions[i + 1] + (Math.random() - 0.5) * 0.2;
                    const z = positions[i + 2] + (Math.random() - 0.5) * 0.3;
    
                    if (y < -2) continue; // Skip underwater
    
                    pointPositions.push(x, y, z);
    
                    // Color by elevation (LIDAR intensity simulation)
                    const intensity = Math.min(1, Math.max(0, (y + 2) / 15));
                    pointColors.push(
                        0.0 + intensity * 0.2,
                        0.6 + intensity * 0.4,
                        0.8 + intensity * 0.2
                    );
                }
    
                const pointGeometry = new THREE.BufferGeometry();
                pointGeometry.setAttribute('position', new THREE.Float32BufferAttribute(pointPositions, 3));
                pointGeometry.setAttribute('color', new THREE.Float32BufferAttribute(pointColors, 3));
    
                const material = new THREE.PointsMaterial({
                    size: 0.15,
                    vertexColors: true,
                    transparent: true,
                    opacity: 0.8,
                    sizeAttenuation: true
                });
    
                return new THREE.Points(pointGeometry, material);
            }
    
            // Erosion Hotspots
            function createHotspots() {
                const hotspots = [];
                const hotspotData = [
                    { x: -25, z: 0, intensity: 3.8, name: 'A1', cause: 'Storm surge exposure' },
                    { x: -10, z: 3, intensity: 4.2, name: 'A2', cause: 'Wave focusing' },
                    { x: 5, z: -2, intensity: 3.1, name: 'B1', cause: 'Longshore drift' },
                    { x: 20, z: 5, intensity: 2.9, name: 'B2', cause: 'Groundwater seepage' },
                    { x: 35, z: 1, intensity: 3.5, name: 'C1', cause: 'Structural weakness' },
                    { x: 45, z: -3, intensity: 4.0, name: 'C2', cause: 'Tidal scouring' },
                    { x: -35, z: 8, intensity: 2.4, name: 'D1', cause: 'Runoff erosion' }
                ];
    
                hotspotData.forEach(data => {
                    const group = new THREE.Group();
                    group.userData = data;
    
                    // Core sphere
                    const coreGeom = new THREE.SphereGeometry(1.5, 16, 16);
                    const coreMat = new THREE.MeshBasicMaterial({
                        color: 0xff3366,
                        transparent: true,
                        opacity: 0.6
                    });
                    const core = new THREE.Mesh(coreGeom, coreMat);
                    group.add(core);
    
                    // Outer ring
                    const ringGeom = new THREE.RingGeometry(2, 2.5, 32);
                    const ringMat = new THREE.MeshBasicMaterial({
                        color: 0xff3366,
                        transparent: true,
                        opacity: 0.4,
                        side: THREE.DoubleSide
                    });
                    const ring = new THREE.Mesh(ringGeom, ringMat);
                    ring.rotation.x = -Math.PI / 2;
                    group.add(ring);
    
                    // Pulse effect
                    const pulseGeom = new THREE.RingGeometry(2.5, 3, 32);
                    const pulseMat = new THREE.MeshBasicMaterial({
                        color: 0xff3366,
                        transparent: true,
                        opacity: 0.2,
                        side: THREE.DoubleSide
                    });
                    const pulse = new THREE.Mesh(pulseGeom, pulseMat);
                    pulse.rotation.x = -Math.PI / 2;
                    pulse.userData.pulsePhase = Math.random() * Math.PI * 2;
                    group.add(pulse);
    
                    // Vertical beam
                    const beamGeom = new THREE.CylinderGeometry(0.1, 0.1, 15, 8);
                    const beamMat = new THREE.MeshBasicMaterial({
                        color: 0xff3366,
                        transparent: true,
                        opacity: 0.3
                    });
                    const beam = new THREE.Mesh(beamGeom, beamMat);
                    beam.position.y = 7.5;
                    group.add(beam);
    
                    group.position.set(data.x, 2, data.z);
                    hotspots.push(group);
                    scene.add(group);
                });
    
                return hotspots;
            }
    
            // Trend Vectors
            function createTrendVectors() {
                const vectors = [];
                const vectorData = [];
    
                // Generate trend arrows along shoreline
                for (let x = -50; x < 55; x += 8) {
                    const z = -5 + Math.sin(x * 0.1) * 3;
                    const erosionRate = 0.5 + Math.abs(Math.sin(x * 0.15)) * 3;
                    vectorData.push({ x, z, rate: erosionRate });
                }
    
                vectorData.forEach(data => {
                    const arrowLength = data.rate * 0.8;
                    
                    // Arrow shaft
                    const shaftGeom = new THREE.CylinderGeometry(0.1, 0.1, arrowLength, 6);
                    const shaftMat = new THREE.MeshBasicMaterial({
                        color: getErosionColor(data.rate),
                        transparent: true,
                        opacity: 0.8
                    });
                    const shaft = new THREE.Mesh(shaftGeom, shaftMat);
                    shaft.rotation.z = Math.PI / 2;
                    shaft.rotation.y = Math.PI / 4;
    
                    // Arrow head
                    const headGeom = new THREE.ConeGeometry(0.3, 0.8, 6);
                    const headMat = new THREE.MeshBasicMaterial({
                        color: getErosionColor(data.rate),
                        transparent: true,
                        opacity: 0.8
                    });
                    const head = new THREE.Mesh(headGeom, headMat);
                    head.rotation.z = -Math.PI / 2;
                    head.rotation.y = Math.PI / 4;
                    head.position.x = arrowLength / 2 + 0.3;
                    head.position.z = arrowLength / 2 + 0.3;
    
                    const group = new THREE.Group();
                    group.add(shaft);
                    group.add(head);
                    group.position.set(data.x, 1, z);
                    group.userData = data;
    
                    vectors.push(group);
                    scene.add(group);
                });
    
                return vectors;
            }
    
            function getErosionColor(rate) {
                if (rate < 0.5) return 0x00d4ff;
                if (rate < 1.5) return 0x4ecdc4;
                if (rate < 3.0) return 0xff6b35;
                return 0xff3366;
            }
    
            // Water surface
            function createWater() {
                const geometry = new THREE.PlaneGeometry(120, 30, 60, 20);
                geometry.rotateX(-Math.PI / 2);
                
                const material = new THREE.MeshPhongMaterial({
                    color: 0x0a2035,
                    transparent: true,
                    opacity: 0.7,
                    shininess: 100,
                    side: THREE.DoubleSide
                });
    
                const water = new THREE.Mesh(geometry, material);
                water.position.set(0, -2, -25);
                water.userData.isWater = true;
    
                return water;
            }
    
            // Create scene elements
            const terrain = generateTerrain();
            scene.add(terrain);
    
            const lidarPoints = createLidarPoints(terrain);
            scene.add(lidarPoints);
    
            const hotspots = createHotspots();
            const trendVectors = createTrendVectors();
    
            const water = createWater();
            scene.add(water);
    
            // Shoreline line
            const shorelineGeom = new THREE.BufferGeometry();
            const shorelinePoints = [];
            for (let x = -60; x <= 60; x += 2) {
                shorelinePoints.push(x, 0, -5 + Math.sin(x * 0.1) * 2);
            }
            shorelineGeom.setAttribute('position', new THREE.Float32BufferAttribute(shorelinePoints, 3));
            const shorelineMat = new THREE.LineBasicMaterial({ color: 0x00d4ff, transparent: true, opacity: 0.5 });
            const shoreline = new THREE.Line(shorelineGeom, shorelineMat);
            scene.add(shoreline);
    
            // Animation
            let time = 0;
    
            function animate() {
                requestAnimationFrame(animate);
                time += 0.016;
    
                // Animate water
                if (water.userData.isWater) {
                    const positions = water.geometry.attributes.position.array;
                    for (let i = 0; i < positions.length; i += 3) {
                        const x = positions[i];
                        const z = positions[i + 2];
                        positions[i + 1] = -2 + Math.sin(x * 0.1 + time) * 0.2 + Math.cos(z * 0.15 + time * 0.7) * 0.15;
                    }
                    water.geometry.attributes.position.needsUpdate = true;
                }
    
                // Animate hotspot pulses
                hotspots.forEach((group, index) => {
                    const pulse = group.children[2];
                    if (pulse) {
                        const phase = pulse.userData.pulsePhase + time * 2;
                        const scale = 1 + Math.sin(phase) * 0.3;
                        pulse.scale.set(scale, scale, 1);
                        pulse.material.opacity = 0.3 - Math.sin(phase) * 0.15;
                    }
    
                    // Rotate rings
                    group.children[1].rotation.z += 0.005;
                });
    
                // Animate trend vectors
                trendVectors.forEach((group, index) => {
                    group.position.y = 1 + Math.sin(time * 2 + index) * 0.1;
                });
    
                // LIDAR point shimmer
                if (lidarPoints.visible) {
                    lidarPoints.material.opacity = 0.7 + Math.sin(time * 3) * 0.1;
                }
    
                controls.update();
                renderer.render(scene, camera);
            }
    
            // UI Controls
            document.querySelectorAll('.layer-toggle[data-layer]').forEach(toggle => {
                toggle.addEventListener('click', () => {
                    toggle.classList.toggle('active');
                    const layerName = toggle.dataset.layer;
                    layers[layerName] = !layers[layerName];
    
                    switch(layerName) {
                        case 'lidar':
                            lidarPoints.visible = layers.lidar;
                            break;
                        case 'terrain':
                            terrain.visible = layers.terrain;
                            break;
                        case 'hotspots':
                            hotspots.forEach(h => h.visible = layers.hotspots);
                            break;
                        case 'trends':
                            trendVectors.forEach(v => v.visible = layers.trends);
                            break;
                    }
                });
            });
    
            document.querySelectorAll('.layer-toggle[data-mode]').forEach(toggle => {
                toggle.addEventListener('click', () => {
                    document.querySelectorAll('.layer-toggle[data-mode]').forEach(t => t.classList.remove('active'));
                    toggle.classList.add('active');
                    analysisMode = toggle.dataset.mode;
                    updateAnalysisMode();
                });
            });
    
            function updateAnalysisMode() {
                // Update terrain colors based on mode
                const colors = terrain.geometry.attributes.color;
                const positions = terrain.geometry.attributes.position.array;
    
                for (let i = 0; i < positions.length; i += 3) {
                    const y = positions[i + 1];
                    const z = positions[i + 2];
                    let color;
    
                    switch(analysisMode) {
                        case 'elevation':
                            color = getTerrainColor(y, z);
                            break;
                        case 'erosion':
                            const erosionRate = Math.abs(Math.sin(positions[i] * 0.1)) * 2 + Math.random() * 0.5;
                            color = getAnalysisColor(erosionRate, 0, 3);
                            break;
                        case 'velocity':
                            const velocity = 0.5 + Math.abs(z + 5) * 0.1 + Math.random() * 0.3;
                            color = getAnalysisColor(velocity, 0, 2);
                            break;
                    }
    
                    colors.array[i] = color.r;
                    colors.array[i + 1] = color.g;
                    colors.array[i + 2] = color.b;
                }
                colors.needsUpdate = true;
            }
    
            function getAnalysisColor(value, min, max) {
                const t = Math.min(1, Math.max(0, (value - min) / (max - min)));
                
                if (t < 0.33) {
                    return { r: 0, g: 0.6 + t, b: 0.8 + t * 0.2 };
                } else if (t < 0.66) {
                    return { r: 0.3 + (t - 0.33) * 2, g: 0.8 - t * 0.3, b: 0.6 - t * 0.4 };
                } else {
                    return { r: 1, g: 0.3 - (t - 0.66) * 0.9, b: 0.2 + (t - 0.66) * 0.6 };
                }
            }
    
            // Timeline control
            const timelineSlider = document.getElementById('timeline');
            const timelineYearEl = document.getElementById('timeline-year');
            const statYear = document.getElementById('stat-year');
            const statRate = document.getElementById('stat-rate');
            const statRetreat = document.getElementById('stat-retreat');
    
            timelineSlider.addEventListener('input', (e) => {
                currentYear = parseInt(e.target.value);
                timelineYearEl.textContent = currentYear;
                statYear.textContent = currentYear;
                
                // Update stats based on year
                const yearFactor = (currentYear - 2010) / 14;
                const rate = (1.5 + yearFactor * 1.2).toFixed(1);
                const retreat = (5 + yearFactor * 15).toFixed(1);
                
                statRate.textContent = rate + ' m/yr';
                statRetreat.textContent = retreat + ' m';
                
                // Update risk level
                const riskEl = document.getElementById('stat-risk');
                if (yearFactor > 0.7) {
                    riskEl.textContent = 'HIGH';
                    riskEl.className = 'stat-value danger';
                } else if (yearFactor > 0.4) {
                    riskEl.textContent = 'MODERATE';
                    riskEl.className = 'stat-value warning';
                } else {
                    riskEl.textContent = 'LOW';
                    riskEl.className = 'stat-value safe';
                }
    
                // Update erosion fill
                document.getElementById('erosion-fill').style.width = (30 + yearFactor * 50) + '%';
            });
    
            // Hotspot hover info
            const raycaster = new THREE.Raycaster();
            const mouse = new THREE.Vector2();
            const hotspotInfo = document.getElementById('hotspot-info');
            const hotspotTitle = document.getElementById('hotspot-title');
            const hotspotDetail = document.getElementById('hotspot-detail');
    
            renderer.domElement.addEventListener('mousemove', (event) => {
                mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
                mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
    
                raycaster.setFromCamera(mouse, camera);
                
                const hotspotMeshes = hotspots.map(h => h.children[0]);
                const intersects = raycaster.intersectObjects(hotspotMeshes);
    
                if (intersects.length > 0) {
                    const hotspot = intersects[0].object.parent;
                    const data = hotspot.userData;
                    
                    hotspotTitle.textContent = 'Hotspot ' + data.name;
                    hotspotDetail.innerHTML = `
                        Erosion Rate: ${data.intensity.toFixed(1)} m/yr<br>
                        Total Retreat: ${(data.intensity * 14 * 0.8).toFixed(1)} m since 2010<br>
                        Primary Cause: ${data.cause}
                    `;
                    
                    hotspotInfo.classList.add('visible');
                } else {
                    hotspotInfo.classList.remove('visible');
                }
            });
    
            // Resize handler
            window.addEventListener('resize', () => {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            });
    
            // Hide loading
            setTimeout(() => {
                document.getElementById('loading').classList.add('hidden');
            }, 1000);
    
            // Start animation
            animate();
        </script>
    </body>
    </html>
    

    Key Features

    Data Visualization Layers

    • LIDAR Point Cloud - Simulated point cloud with elevation-based intensity coloring
    • Terrain Model - Procedurally generated coastal morphology with realistic erosion features
    • Erosion Hotspots - Pulsing indicators showing critical erosion zones with detailed metrics
    • Trend Vectors - Directional arrows showing erosion rates along the shoreline

    Analysis Modes

    • Elevation Analysis - Standard topographic visualization
    • Erosion Intensity - Heat-mapped erosion severity
    • Change Velocity - Rate of coastal change visualization

    Interactive Elements

    1. Timeline slider - View erosion progression from 2010-2024
    2. Layer toggles - Show/hide different data layers
    3. Hotspot hover - Detailed erosion data for each hotspot
    4. 3D navigation - Orbit, zoom, and pan the coastal model

    Visual Design

    • Dark professional theme with cyan/coral accent colors
    • Animated water surface with realistic wave motion
    • Pulsing hotspot indicators for critical zones
    • Smooth transitions and loading states