refactor: 提取地球坐标常量到EARTH_CONFIG
- 添加tilt、chinaLat、chinaLon、latCoefficient等常量 - earth.js和controls.js使用常量替代硬编码 - 离开地球时隐藏tooltip
This commit is contained in:
14
frontend/public/earth/js/controls.js
vendored
14
frontend/public/earth/js/controls.js
vendored
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user