feat(earth): Modularize 3D Earth page with ES Modules
## Changelog ### New Features - Modularized 3D earth HTML page from single 1918-line file into ES Modules - Split CSS into separate module files (base, info-panel, coordinates-display, legend, earth-stats) - Split JS into separate modules (constants, utils, ui, earth, cables, controls, main) ### 3D Earth Rendering - Use Three.js r128 (via esm.sh CDN) for color consistency with original - Earth with 8K satellite texture and proper material settings - Cloud layer with transparency and additive blending - Starfield background (8000 stars) - Latitude/longitude grid lines that rotate with Earth ### Cable System - Load cable data from geo.json with great circle path calculation - Support for MultiLineString and LineString geometry types - Cable color from geo.json properties.color field - Landing points loading from landing-point-geo.geojson ### User Interactions - Mouse hover: highlight cable and show details - Mouse click: lock cable with pulsing glow effect - Click cable to pause rotation, click elsewhere to resume - Click rotation toggle button to resume rotation and clear highlight - Reset view with smooth animation (800ms cubic ease-out) - Mouse wheel zoom support - Drag to rotate Earth ### UI/UX Improvements - Tooltip shows latitude, longitude, and altitude - Prevent tooltip text selection during drag - Hide tooltip during drag operation - Blue border tooltip styling matching original - Cursor changes to grabbing during drag - Front-facing cable detection (only detect cables facing camera) ### Bug Fixes - Grid lines now rotate with Earth (added as Earth child) - Reset view button now works correctly - Fixed camera reference in reset view - Fixed autoRotate state management when clearing locked cable ### Original HTML - Copied original 3dearthmult.html to public folder for reference
This commit is contained in:
79
frontend/public/earth/js/ui.js
Normal file
79
frontend/public/earth/js/ui.js
Normal file
@@ -0,0 +1,79 @@
|
||||
// ui.js - UI update functions
|
||||
|
||||
// Show status message
|
||||
export function showStatusMessage(message, type = 'info') {
|
||||
const statusEl = document.getElementById('status-message');
|
||||
statusEl.textContent = message;
|
||||
statusEl.className = `status-message ${type}`;
|
||||
statusEl.style.display = 'block';
|
||||
|
||||
setTimeout(() => {
|
||||
statusEl.style.display = 'none';
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Update coordinates display
|
||||
export function updateCoordinatesDisplay(lat, lon, alt = 0) {
|
||||
document.getElementById('longitude-value').textContent = lon.toFixed(2) + '°';
|
||||
document.getElementById('latitude-value').textContent = lat.toFixed(2) + '°';
|
||||
document.getElementById('mouse-coords').textContent =
|
||||
`鼠标: ${lat.toFixed(2)}°, ${lon.toFixed(2)}°`;
|
||||
}
|
||||
|
||||
// Update zoom display
|
||||
export function updateZoomDisplay(zoomLevel, distance) {
|
||||
document.getElementById('zoom-value').textContent = zoomLevel.toFixed(1) + 'x';
|
||||
document.getElementById('zoom-level').textContent = '缩放: ' + zoomLevel.toFixed(1) + 'x';
|
||||
document.getElementById('zoom-slider').value = zoomLevel;
|
||||
document.getElementById('camera-distance').textContent = distance + ' km';
|
||||
}
|
||||
|
||||
// Update cable details
|
||||
export function updateCableDetails(cable) {
|
||||
document.getElementById('cable-name').textContent = cable.name || 'Unknown';
|
||||
document.getElementById('cable-owner').textContent = cable.owner || '-';
|
||||
document.getElementById('cable-status').textContent = cable.status || '-';
|
||||
document.getElementById('cable-length').textContent = cable.length || '-';
|
||||
document.getElementById('cable-coords').textContent = cable.coords || '-';
|
||||
document.getElementById('cable-rfs').textContent = cable.rfs || '-';
|
||||
}
|
||||
|
||||
// Update earth stats
|
||||
export function updateEarthStats(stats) {
|
||||
document.getElementById('cable-count').textContent = stats.cableCount || 0;
|
||||
document.getElementById('landing-point-count').textContent = stats.landingPointCount || 0;
|
||||
document.getElementById('terrain-status').textContent = stats.terrainOn ? '开启' : '关闭';
|
||||
document.getElementById('texture-quality').textContent = stats.textureQuality || '8K 卫星图';
|
||||
}
|
||||
|
||||
// Show/hide loading
|
||||
export function setLoading(loading) {
|
||||
const loadingEl = document.getElementById('loading');
|
||||
loadingEl.style.display = loading ? 'block' : 'none';
|
||||
}
|
||||
|
||||
// Show tooltip
|
||||
export function showTooltip(x, y, content) {
|
||||
const tooltip = document.getElementById('tooltip');
|
||||
tooltip.innerHTML = content;
|
||||
tooltip.style.left = x + 'px';
|
||||
tooltip.style.top = y + 'px';
|
||||
tooltip.style.display = 'block';
|
||||
}
|
||||
|
||||
// Hide tooltip
|
||||
export function hideTooltip() {
|
||||
document.getElementById('tooltip').style.display = 'none';
|
||||
}
|
||||
|
||||
// Show error message
|
||||
export function showError(message) {
|
||||
const errorEl = document.getElementById('error-message');
|
||||
errorEl.textContent = message;
|
||||
errorEl.style.display = 'block';
|
||||
}
|
||||
|
||||
// Hide error message
|
||||
export function hideError() {
|
||||
document.getElementById('error-message').style.display = 'none';
|
||||
}
|
||||
Reference in New Issue
Block a user