refactor: 提取地球坐标常量到EARTH_CONFIG

- 添加tilt、chinaLat、chinaLon、latCoefficient等常量
- earth.js和controls.js使用常量替代硬编码
- 离开地球时隐藏tooltip
This commit is contained in:
rayd1o
2026-03-19 12:42:08 +08:00
parent 777891f865
commit 82f7aa29a6
3 changed files with 22 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
// controls.js - Zoom, rotate and toggle controls
import { CONFIG } from './constants.js';
import { CONFIG, EARTH_CONFIG } from './constants.js';
import { updateZoomDisplay, showStatusMessage } from './ui.js';
import { toggleTerrain } from './earth.js';
import { reloadData } from './main.js';
@@ -153,13 +153,9 @@ function animateValue(start, end, duration, onUpdate, onComplete) {
export function resetView(camera) {
if (!earthObj) return;
const chinaLat = 40;
const chinaLon = -154;
const baseTilt = 23.5 * Math.PI / 180;
const latRot = chinaLat * Math.PI / 180;
const targetRotX = baseTilt + latRot * 0.5;
const targetRotY = -(chinaLon * Math.PI / 180);
const latRot = EARTH_CONFIG.chinaLat * Math.PI / 180;
const targetRotX = EARTH_CONFIG.tiltRad + latRot * EARTH_CONFIG.latCoefficient;
const targetRotY = -(EARTH_CONFIG.chinaRotLon * Math.PI / 180);
const startRotX = earthObj.rotation.x;
const startRotY = earthObj.rotation.y;
@@ -176,7 +172,7 @@ export function resetView(camera) {
updateZoomDisplay(zoomLevel, camera.position.z.toFixed(0));
}, () => {
zoomLevel = 1.0;
showStatusMessage('视角已重置到中国', 'info');
showStatusMessage('视角已重置', 'info');
});
if (typeof window.clearLockedCable === 'function') {