refactor(earth): remove dead code - setupMouseControls, getSelectedSatellite, updateCableDetails

This commit is contained in:
rayd1o
2026-03-19 14:22:03 +08:00
parent 6fabbcfe5c
commit d18e400fcb
3 changed files with 12 additions and 64 deletions

View File

@@ -194,24 +194,13 @@ export function resetView(camera) {
function setupRotateControls(camera, earth) { function setupRotateControls(camera, earth) {
const rotateBtn = document.getElementById('rotate-toggle'); const rotateBtn = document.getElementById('rotate-toggle');
const tooltip = rotateBtn?.querySelector('.tooltip');
function updateRotateIcon() {
const isRotating = getAutoRotate();
rotateBtn.innerHTML = isRotating ? '⏸️' : '▶️';
if (tooltip) {
tooltip.textContent = isRotating ? '暂停旋转' : '开始旋转';
}
}
rotateBtn.addEventListener('click', function() { rotateBtn.addEventListener('click', function() {
toggleAutoRotate(); const isRotating = toggleAutoRotate();
const isRotating = getAutoRotate();
updateRotateIcon();
showStatusMessage(isRotating ? '自动旋转已开启' : '自动旋转已暂停', 'info'); showStatusMessage(isRotating ? '自动旋转已开启' : '自动旋转已暂停', 'info');
}); });
updateRotateIcon(); updateRotateUI();
document.getElementById('reset-view').addEventListener('click', function() { document.getElementById('reset-view').addEventListener('click', function() {
resetView(camera); resetView(camera);
@@ -260,55 +249,28 @@ function setupTerrainControls() {
} }
} }
function setupMouseControls(camera, renderer) {
let previousMousePosition = { x: 0, y: 0 };
renderer.domElement.addEventListener('mousedown', (e) => {
isDragging = true;
previousMousePosition = { x: e.clientX, y: e.clientY };
});
renderer.domElement.addEventListener('mouseup', () => {
isDragging = false;
});
renderer.domElement.addEventListener('mousemove', (e) => {
if (isDragging) {
const deltaX = e.clientX - previousMousePosition.x;
const deltaY = e.clientY - previousMousePosition.y;
if (earth) {
earth.rotation.y += deltaX * 0.005;
earth.rotation.x += deltaY * 0.005;
}
previousMousePosition = { x: e.clientX, y: e.clientY };
}
});
}
export function getAutoRotate() { export function getAutoRotate() {
return autoRotate; return autoRotate;
} }
export function setAutoRotate(value) { function updateRotateUI() {
autoRotate = value;
const btn = document.getElementById('rotate-toggle'); const btn = document.getElementById('rotate-toggle');
if (btn) { if (btn) {
btn.classList.toggle('active', value); btn.classList.toggle('active', autoRotate);
btn.innerHTML = autoRotate ? '⏸️' : '▶️';
const tooltip = btn.querySelector('.tooltip'); const tooltip = btn.querySelector('.tooltip');
if (tooltip) tooltip.textContent = value ? '暂停旋转' : '自动旋转'; if (tooltip) tooltip.textContent = autoRotate ? '暂停旋转' : '开始旋转';
} }
} }
export function setAutoRotate(value) {
autoRotate = value;
updateRotateUI();
}
export function toggleAutoRotate() { export function toggleAutoRotate() {
autoRotate = !autoRotate; autoRotate = !autoRotate;
const btn = document.getElementById('rotate-toggle'); updateRotateUI();
if (btn) {
btn.classList.toggle('active', autoRotate);
const tooltip = btn.querySelector('.tooltip');
if (tooltip) tooltip.textContent = autoRotate ? '暂停旋转' : '自动旋转';
}
if (window.clearLockedCable) { if (window.clearLockedCable) {
window.clearLockedCable(); window.clearLockedCable();
} }

View File

@@ -312,10 +312,6 @@ export function selectSatellite(index) {
return getSatelliteAt(index); return getSatelliteAt(index);
} }
export function getSelectedSatellite() {
return selectedSatellite;
}
export function getSatellitePoints() { export function getSatellitePoints() {
return satellitePoints; return satellitePoints;
} }

View File

@@ -29,16 +29,6 @@ export function updateZoomDisplay(zoomLevel, distance) {
document.getElementById('camera-distance').textContent = distance + ' km'; 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 // Update earth stats
export function updateEarthStats(stats) { export function updateEarthStats(stats) {
document.getElementById('cable-count').textContent = stats.cableCount || 0; document.getElementById('cable-count').textContent = stats.cableCount || 0;