fix(satellites): fix ring size attenuation and breathing animation
- Add sizeAttenuation: false to sprite materials for fixed ring size - Move breathing animation parameters to SATELLITE_CONFIG constants - Export updateBreathingPhase function to avoid ES module binding issues - Adjust breathing speed and amplitude for better visual effect
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
} from './ui.js';
|
||||
import { createEarth, createClouds, createTerrain, createStars, createGridLines, toggleTerrain, getEarth } from './earth.js';
|
||||
import { loadGeoJSONFromPath, loadLandingPoints, handleCableClick, clearCableSelection, getCableLines, getCablesById, lockedCable as cableLocked, getCableState, setCableState, clearAllCableStates, applyLandingPointVisualState, resetLandingPointVisualState, getAllLandingPoints, getShowCables } from './cables.js';
|
||||
import { createSatellites, loadSatellites, updateSatellitePositions, toggleSatellites, toggleTrails, getShowSatellites, getSatelliteCount, selectSatellite, getSatelliteData, getSatellitePoints, setSatelliteRingState, updateLockedRingPosition, updateHoverRingPosition, getSatellitePositions, showPredictedOrbit, hidePredictedOrbit } from './satellites.js';
|
||||
import { createSatellites, loadSatellites, updateSatellitePositions, toggleSatellites, toggleTrails, getShowSatellites, getSatelliteCount, selectSatellite, getSatelliteData, getSatellitePoints, setSatelliteRingState, updateLockedRingPosition, updateHoverRingPosition, getSatellitePositions, showPredictedOrbit, hidePredictedOrbit, updateBreathingPhase } from './satellites.js';
|
||||
import { setupControls, getAutoRotate, getShowTerrain, zoomLevel, setAutoRotate, toggleAutoRotate, resetView } from './controls.js';
|
||||
import { initInfoCard, showInfoCard, hideInfoCard, getCurrentType, setInfoCardNoBorder } from './info-card.js';
|
||||
|
||||
@@ -32,6 +32,9 @@ let lockedObject = null;
|
||||
let lockedObjectType = null;
|
||||
let dragStartTime = 0;
|
||||
let isLongDrag = false;
|
||||
let lastSatClickTime = 0;
|
||||
let lastSatClickIndex = 0;
|
||||
let lastSatClickPos = { x: 0, y: 0 };
|
||||
|
||||
export function clearLockedObject() {
|
||||
hidePredictedOrbit();
|
||||
@@ -44,6 +47,7 @@ export function clearLockedObject() {
|
||||
lockedObjectType = null;
|
||||
lockedSatellite = null;
|
||||
lockedSatelliteIndex = null;
|
||||
window.lockedSatelliteIndex = null;
|
||||
cableLockedData = null;
|
||||
}
|
||||
|
||||
@@ -135,6 +139,7 @@ export function init() {
|
||||
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||
camera.position.z = CONFIG.defaultCameraZ;
|
||||
window.camera = camera;
|
||||
|
||||
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, powerPreference: 'high-performance' });
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
@@ -430,8 +435,26 @@ function onClick(event, camera, renderer) {
|
||||
setAutoRotate(false);
|
||||
handleCableClick(clickedCable);
|
||||
} else if (satIntersects.length > 0) {
|
||||
const index = satIntersects[0].index;
|
||||
const sat = selectSatellite(index);
|
||||
const now = Date.now();
|
||||
const clickX = event.clientX;
|
||||
const clickY = event.clientY;
|
||||
|
||||
let selectedIndex;
|
||||
if (satIntersects.length > 1 &&
|
||||
now - lastSatClickTime < 500 &&
|
||||
Math.abs(clickX - lastSatClickPos.x) < 30 &&
|
||||
Math.abs(clickY - lastSatClickPos.y) < 30) {
|
||||
const currentIdx = satIntersects.findIndex(s => s.index === lastSatClickIndex);
|
||||
selectedIndex = satIntersects[(currentIdx + 1) % satIntersects.length].index;
|
||||
} else {
|
||||
selectedIndex = satIntersects[0].index;
|
||||
}
|
||||
|
||||
lastSatClickTime = now;
|
||||
lastSatClickIndex = selectedIndex;
|
||||
lastSatClickPos = { x: clickX, y: clickY };
|
||||
|
||||
const sat = selectSatellite(selectedIndex);
|
||||
|
||||
if (sat && sat.properties) {
|
||||
clearLockedObject();
|
||||
@@ -439,13 +462,14 @@ function onClick(event, camera, renderer) {
|
||||
lockedObject = sat;
|
||||
lockedObjectType = 'satellite';
|
||||
lockedSatellite = sat;
|
||||
lockedSatelliteIndex = index;
|
||||
lockedSatelliteIndex = selectedIndex;
|
||||
window.lockedSatelliteIndex = selectedIndex;
|
||||
showPredictedOrbit(sat);
|
||||
setAutoRotate(false);
|
||||
|
||||
const satPositions = getSatellitePositions();
|
||||
if (satPositions && satPositions[index]) {
|
||||
setSatelliteRingState(index, 'locked', satPositions[index].current);
|
||||
if (satPositions && satPositions[selectedIndex]) {
|
||||
setSatelliteRingState(selectedIndex, 'locked', satPositions[selectedIndex].current);
|
||||
}
|
||||
|
||||
const props = sat.properties;
|
||||
@@ -501,6 +525,9 @@ function animate() {
|
||||
|
||||
const satPositions = getSatellitePositions();
|
||||
|
||||
// 更新呼吸动画相位
|
||||
updateBreathingPhase();
|
||||
|
||||
if (lockedObjectType === 'satellite' && lockedSatelliteIndex !== null) {
|
||||
if (satPositions && satPositions[lockedSatelliteIndex]) {
|
||||
updateLockedRingPosition(satPositions[lockedSatelliteIndex].current);
|
||||
|
||||
Reference in New Issue
Block a user