feat(earth): satellite dot rendering with hover/lock rings, dim cables when satellite locked

- Change satellite points from squares to circular dots
- Add hover ring (white) and lock ring (yellow) for satellites
- Fix satellite hover/lock ring state management
- Dim all cables when satellite is locked
- Increase MAX_SATELLITES to 2000
- Fix satIntersects scoping bug
This commit is contained in:
rayd1o
2026-03-19 17:41:53 +08:00
parent 0ecc1bc537
commit bb6b18fe3b
3 changed files with 191 additions and 9 deletions

View File

@@ -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 } from './cables.js';
import { createSatellites, loadSatellites, updateSatellitePositions, toggleSatellites, toggleTrails, getShowSatellites, selectSatellite, getSatelliteData, getSatellitePoints } from './satellites.js';
import { createSatellites, loadSatellites, updateSatellitePositions, toggleSatellites, toggleTrails, getShowSatellites, selectSatellite, getSatelliteData, getSatellitePoints, setSatelliteRingState, updateLockedRingPosition, updateHoverRingPosition, getSatellitePositions } from './satellites.js';
import { setupControls, getAutoRotate, getShowTerrain, zoomLevel, setAutoRotate, toggleAutoRotate, resetView } from './controls.js';
import { initInfoCard, showInfoCard, hideInfoCard, getCurrentType, setInfoCardNoBorder } from './info-card.js';
@@ -24,8 +24,10 @@ let isDragging = false;
let previousMousePosition = { x: 0, y: 0 };
let hoveredCable = null;
let hoveredSatellite = null;
let hoveredSatelliteIndex = null;
let cableLockedData = null;
let lockedSatellite = null;
let lockedSatelliteIndex = null;
let lockedObject = null;
let lockedObjectType = null;
let dragStartTime = 0;
@@ -33,10 +35,14 @@ let isLongDrag = false;
function clearLockedObject() {
hoveredCable = null;
hoveredSatellite = null;
hoveredSatelliteIndex = null;
clearAllCableStates();
setSatelliteRingState(null, 'none', null);
lockedObject = null;
lockedObjectType = null;
lockedSatellite = null;
lockedSatelliteIndex = null;
cableLockedData = null;
}
@@ -95,7 +101,7 @@ function applyCableVisualState() {
break;
case CABLE_STATE.NORMAL:
default:
if (lockedObjectType === 'cable' && lockedObject) {
if ((lockedObjectType === 'cable' && lockedObject) || (lockedObjectType === 'satellite' && lockedSatellite)) {
c.material.opacity = CABLE_CONFIG.otherOpacity;
const origColor = c.userData.originalColor;
const brightness = CABLE_CONFIG.otherBrightness;
@@ -271,13 +277,14 @@ function onMouseMove(event, camera) {
const hasHoveredCable = intersects.length > 0;
let hoveredSat = null;
let hoveredSatIndexFromIntersect = null;
if (getShowSatellites()) {
const satPoints = getSatellitePoints();
if (satPoints) {
const satIntersects = raycaster.intersectObject(satPoints);
if (satIntersects.length > 0) {
const index = satIntersects[0].index;
hoveredSat = selectSatellite(index);
hoveredSatIndexFromIntersect = satIntersects[0].index;
hoveredSat = selectSatellite(hoveredSatIndexFromIntersect);
}
}
}
@@ -292,6 +299,13 @@ function onMouseMove(event, camera) {
}
}
if (hoveredSatelliteIndex !== null && hoveredSatelliteIndex !== hoveredSatIndexFromIntersect) {
if (hoveredSatelliteIndex !== lockedSatelliteIndex) {
setSatelliteRingState(hoveredSatelliteIndex, 'none', null);
}
hoveredSatelliteIndex = null;
}
if (hasHoveredCable) {
const cable = intersects[0].object;
if (!isSameCable(cable, lockedObject)) {
@@ -306,11 +320,24 @@ function onMouseMove(event, camera) {
hideTooltip();
} else if (hasHoveredSatellite) {
hoveredSatellite = hoveredSat;
hoveredSatelliteIndex = hoveredSatIndexFromIntersect;
if (hoveredSatelliteIndex !== lockedSatelliteIndex) {
const satPositions = getSatellitePositions();
if (satPositions && satPositions[hoveredSatelliteIndex]) {
setSatelliteRingState(hoveredSatelliteIndex, 'hover', satPositions[hoveredSatelliteIndex].current);
}
}
showSatelliteInfo(hoveredSat.properties);
setInfoCardNoBorder(true);
} else if (lockedObjectType === 'cable' && lockedObject) {
showCableInfo(lockedObject);
} else if (lockedObjectType === 'satellite' && lockedSatellite) {
if (lockedSatelliteIndex !== null && lockedSatelliteIndex !== undefined) {
const satPositions = getSatellitePositions();
if (satPositions && satPositions[lockedSatelliteIndex]) {
setSatelliteRingState(lockedSatelliteIndex, 'locked', satPositions[lockedSatelliteIndex].current);
}
}
showSatelliteInfo(lockedSatellite.properties);
} else {
hideInfoCard();
@@ -399,8 +426,14 @@ function onClick(event, camera, renderer) {
lockedObject = sat;
lockedObjectType = 'satellite';
lockedSatellite = sat;
lockedSatelliteIndex = index;
setAutoRotate(false);
const satPositions = getSatellitePositions();
if (satPositions && satPositions[index]) {
setSatelliteRingState(index, 'locked', satPositions[index].current);
}
const props = sat.properties;
const meanMotion = props.mean_motion || 0;
@@ -444,6 +477,16 @@ function animate() {
updateSatellitePositions(16);
const satPositions = getSatellitePositions();
if (lockedObjectType === 'satellite' && lockedSatelliteIndex !== null) {
if (satPositions && satPositions[lockedSatelliteIndex]) {
updateLockedRingPosition(satPositions[lockedSatelliteIndex].current);
}
} else if (hoveredSatelliteIndex !== null && satPositions && satPositions[hoveredSatelliteIndex]) {
updateHoverRingPosition(satPositions[hoveredSatelliteIndex].current);
}
renderer.render(scene, camera);
}