refactor(earth): remove dead code - setupMouseControls, getSelectedSatellite, updateCableDetails
This commit is contained in:
62
frontend/public/earth/js/controls.js
vendored
62
frontend/public/earth/js/controls.js
vendored
@@ -194,24 +194,13 @@ export function resetView(camera) {
|
||||
|
||||
function setupRotateControls(camera, earth) {
|
||||
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() {
|
||||
toggleAutoRotate();
|
||||
const isRotating = getAutoRotate();
|
||||
updateRotateIcon();
|
||||
const isRotating = toggleAutoRotate();
|
||||
showStatusMessage(isRotating ? '自动旋转已开启' : '自动旋转已暂停', 'info');
|
||||
});
|
||||
|
||||
updateRotateIcon();
|
||||
updateRotateUI();
|
||||
|
||||
document.getElementById('reset-view').addEventListener('click', function() {
|
||||
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() {
|
||||
return autoRotate;
|
||||
}
|
||||
|
||||
export function setAutoRotate(value) {
|
||||
autoRotate = value;
|
||||
function updateRotateUI() {
|
||||
const btn = document.getElementById('rotate-toggle');
|
||||
if (btn) {
|
||||
btn.classList.toggle('active', value);
|
||||
btn.classList.toggle('active', autoRotate);
|
||||
btn.innerHTML = autoRotate ? '⏸️' : '▶️';
|
||||
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() {
|
||||
autoRotate = !autoRotate;
|
||||
const btn = document.getElementById('rotate-toggle');
|
||||
if (btn) {
|
||||
btn.classList.toggle('active', autoRotate);
|
||||
const tooltip = btn.querySelector('.tooltip');
|
||||
if (tooltip) tooltip.textContent = autoRotate ? '暂停旋转' : '自动旋转';
|
||||
}
|
||||
updateRotateUI();
|
||||
if (window.clearLockedCable) {
|
||||
window.clearLockedCable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user