diff --git a/backend/app/services/terminal_service.py b/backend/app/services/terminal_service.py index 1b8a004..f8bb991 100644 --- a/backend/app/services/terminal_service.py +++ b/backend/app/services/terminal_service.py @@ -389,7 +389,7 @@ class TerminalService: return grouped @staticmethod - def _pick_events(events: List[CelestialEvent], limit: int = 3) -> List[dict]: + def _pick_events(events: List[CelestialEvent], limit: int = 4) -> List[dict]: """Upcoming events first, then the most recent past ones.""" now = datetime.utcnow() upcoming = sorted((e for e in events if e.event_time >= now), key=lambda e: e.event_time) @@ -411,8 +411,8 @@ class TerminalService: # Rockets (平台管理 -> 火箭型号 里启用的那些) # ------------------------------------------------------------------ - #: 详情页右栏一次最多列几条发射任务,屏宽只放得下三行 - _ROCKET_EVENT_LIMIT = 3 + #: 详情页右栏一次最多列几条发射任务(固件详情页现在排四行) + _ROCKET_EVENT_LIMIT = 4 @staticmethod def _kn(newtons) -> Optional[float]: diff --git a/backend/upload/assets/2k_earth_nightrelief.jpg b/backend/upload/assets/2k_earth_nightrelief.jpg new file mode 100644 index 0000000..554eefc Binary files /dev/null and b/backend/upload/assets/2k_earth_nightrelief.jpg differ diff --git a/frontend/src/features/rocket-simulator/RocketFlightScene.tsx b/frontend/src/features/rocket-simulator/RocketFlightScene.tsx index 3c9c1ec..6d799a7 100644 --- a/frontend/src/features/rocket-simulator/RocketFlightScene.tsx +++ b/frontend/src/features/rocket-simulator/RocketFlightScene.tsx @@ -6,7 +6,7 @@ import type { OrbitControls as OrbitControlsImpl } from 'three-stdlib'; import type { RocketConfig, SimulationState } from './types'; import { useOptionalTexture } from '../../hooks/useOptionalTexture'; import { RocketModel } from './RocketModel'; -import { clamp, fogColor, groundDrop, separationAge, skyColor, starOpacity } from './sceneMath'; +import { clamp, fogColor, groundDrop, separationAge, skyColor, starOpacity, stageGeometry } from './sceneMath'; export type CameraMode = 'follow' | 'global'; @@ -22,12 +22,14 @@ interface RocketFlightSceneProps { const EARTH_RADIUS_METERS = 6_371_000; const EARTH_RADIUS = 34; const EARTH_DAY_TEXTURE = '/upload/assets/2k_earth_daymap.jpg'; -const EARTH_NIGHT_TEXTURE = '/upload/assets/2k_earth_nightmap.jpg'; +// 夜间改用「夜半球」合成图:原图只有城市灯光,几乎看不出大陆轮廓, +// 这里叠加了压暗的昼间地表 + 海岸线辉光(生成脚本 scripts/gen_night_earth.py) +const EARTH_NIGHT_TEXTURE = '/upload/assets/2k_earth_nightrelief.jpg'; const EARTH_CENTER = new THREE.Vector3(0, -EARTH_RADIUS, 0); const EARTH_ROTATION = new THREE.Euler(0, -1.25, -0.08); const VIEW_SCALE_CALIBRATION = 0.7; -/** 地球贴图按系统时间取用:06:00-18:00 用昼间图,其余时间用夜间的城市灯光图。 */ +/** 地球贴图按系统时间取用:06:00-18:00 用昼间图,其余时间用带大陆轮廓的夜半球图。 */ function earthTexturePath() { const hour = new Date().getHours(); return hour >= 6 && hour < 18 ? EARTH_DAY_TEXTURE : EARTH_NIGHT_TEXTURE; @@ -81,105 +83,236 @@ function globalFlightFrame(altitude: number, downrange: number, targetAltitude: }; } -/** 发射场:混凝土地坪 + 导流槽 + 发射台 + 服务塔 + 避雷塔。 */ -function LaunchPadStructure() { - const towerHeight = 13; +/** + * 场坪上的一根杆件:在 XY 平面内从 from 连到 to。 + * 服务塔与灯杆的桁架都用它拼,避免每根梁都手写一次长度和角度。 + */ +function Beam({ from, to, size = 0.13, color = '#5b666d' }: { + from: [number, number]; + to: [number, number]; + size?: number; + color?: string; +}) { + const dx = to[0] - from[0]; + const dy = to[1] - from[1]; + return ( + + + + + ); +} + +/** + * 服务塔:四根立柱 + 各层等间距水平横杆,只有水平与竖直两种杆件, + * 顶部一块平台与避雷针,另有两根笔直的摆杆(加注/脐带臂)伸向箭体。 + * 整塔高约 15,略高于星舰一级。 + */ +function ServiceTower({ height = 15 }: { height?: number }) { + const half = 1.15; + const levels = Array.from({ length: 6 }, (_, index) => 1.3 + index * ((height - 2.2) / 5)); return ( - {/* 混凝土地坪 */} - - - - - - - - - {/* 尾焰熏黑区域 */} - - - - - - {/* 发射台 + 导流槽 */} - - - - - - - - - {/* 导流锥 */} - - - - - {/* 压紧机构 */} - {[[-2.6, -2.6], [2.6, -2.6], [-2.6, 2.6], [2.6, 2.6]].map(([x, z]) => ( - - - - + {[-half, half].map((z) => ( + + {/* 桁架片:两根立柱 + 各层水平横撑,只保留水平与竖直两种杆件 */} + + + {levels.map((y) => ( + + ))} + + ))} + {/* 首尾两道沿 Z 的系杆,把两片桁架连成一个方正的塔架 */} + {[0.2, height].map((y) => ( + + {[-half, half].map((x) => ( + + + + + ))} + ))} - {/* 服务塔 */} - - {[-1.2, 1.2].map((offset) => ( - - - - - ))} - {[3.2, 6.4, 9.6, 12.2].map((y) => ( - - - - - ))} - {/* 摆杆 / 加注臂 */} - {[5.4, 9.4].map((y, index) => ( - - - - - ))} - {/* 塔顶工作平台(避雷针只装在四周的避雷塔上) */} - - - - - {[-1.55, 1.55].map((offset) => ( - - - - - ))} - - - - - - - {/* 避雷塔(四根柱子顶部的避雷针) */} - {[[-14, -9], [14, -9], [-14, 9], [14, 9]].map(([x, z]) => ( - - - - - - - - + {/* 摆杆:靠箭一侧的加注/脐带臂,水平伸到箭体根部外侧 */} + {[6.2, 10.6].map((y) => ( + + + + ))} - {/* 场坪编号,让地坪有尺度参照 */} - - - + {/* 塔顶平台与避雷针 */} + + + + + + + + + ); +} + +/** 避雷塔:锥形钢杆 + 塔尖避雷针。 */ +function LightningMast({ position, height = 17 }: { position: [number, number, number]; height?: number }) { + return ( + + + + + + + + + + + ); +} + +/** + * 发射场:场坪 + 环形消防道 + 发射台与导流槽 + 喷水环 + 服务塔 + 避雷塔 + * + 灯杆 / 掩体 / 水罐,尽量让镜头拉远时仍认得出是一座发射场。 + */ +function LaunchPadStructure() { + const masts: [number, number][] = [[-13, -9.5], [13, -9.5], [-13, 9.5], [13, 9.5]]; + return ( + + {/* 场坪外围:草地尽量铺远,靠雾自然收边,避免圆盘边缘悬在空中 */} + + + + + {/* 环形消防车道 */} + + + + + {/* 混凝土场坪(分两块错开色差,模拟分仓浇筑的伸缩缝) */} + + + + + + + + + {/* 安全标线:白色警戒环 + 尾焰熏黑区 */} + + + + + + + + + + + + + + {/* 发射台:左右两块台板中间留出一道导流槽口 */} + {[-3.6, 3.6].map((x) => ( + + + + + ))} + {/* 导流槽:槽口下方的深井(只画内壁)+ 井底导流锥,进深与台板一致,不外露 */} + + + + + + + + + + {/* 喷水降音环:一圈带喷嘴的管道,点火瞬间由 PadExhaust 接管视觉效果 */} + + + + + {Array.from({ length: 16 }, (_, index) => { + const angle = (index / 16) * Math.PI * 2; + return ( + + + + + ); + })} + + + + + + {masts.map(([x, z]) => ( + + ))} + + {/* 高杆灯:灯头用自发光,夜间不至于全黑 */} + {[[-16, 25], [16, 25], [0, -28]].map(([x, z]) => ( + + + + + + + + + + + ))} + + {/* 掩体与储罐:给场坪外围一点尺度参照 */} + + + + + + + + + + + + + + + + + + + + + + + + {[0, 1, 2, 3].map((index) => ( + + + + + ))} + ); } @@ -233,7 +366,7 @@ function PadExhaust({ state }: { state: SimulationState }) { } /** 地面场景容器:随飞行高度下移、随射程后移。 */ -function LaunchRack({ state }: { state: SimulationState }) { +function LaunchRack({ state, scale }: { state: SimulationState; scale: number }) { const groupRef = useRef(null); useFrame(() => { @@ -246,13 +379,20 @@ function LaunchRack({ state }: { state: SimulationState }) { return ( - - + {/* 场坪尺寸按箭体粗细缩放:细箭(电子号)不该站在星舰那么大的台子上 */} + + + + ); } -function EarthSurface({ texture, state }: { texture: THREE.Texture | null; state?: SimulationState }) { +/** + * 高空/轨道视角下的地球。夜半球图本身已经把「月光下的地表 + 海岸辉光 + 城市灯光」 + * 烘进贴图,因此不再受方向光影响(否则背对光源的那一面会整片死黑,看不出大陆)。 + */ +function EarthSurface({ texture, state, unlit }: { texture: THREE.Texture | null; state?: SimulationState; unlit?: boolean }) { const highAltitude = state ? state.altitude >= 9_000 : true; if (!highAltitude) return null; @@ -264,7 +404,11 @@ function EarthSurface({ texture, state }: { texture: THREE.Texture | null; state - + {unlit ? ( + + ) : ( + + )} @@ -329,7 +473,7 @@ function FlightPath({ state, targetAltitude, launchSite }: { state: SimulationSt return ; } -function GlobalEarthView({ rocket, state, texture }: { rocket: RocketConfig; state: SimulationState; texture: THREE.Texture | null }) { +function GlobalEarthView({ rocket, state, texture, unlit }: { rocket: RocketConfig; state: SimulationState; texture: THREE.Texture | null; unlit: boolean }) { const targetAltitude = rocket.target_orbit_km * 1000; const launchSite = launchSiteForRocket(rocket); const frame = globalFlightFrame(state.altitude, state.downrange, targetAltitude, launchSite); @@ -342,7 +486,7 @@ function GlobalEarthView({ rocket, state, texture }: { rocket: RocketConfig; sta return ( <> - + @@ -469,7 +613,11 @@ function Atmosphere({ state, mode }: { state: SimulationState; mode: CameraMode function SceneContents({ rocket, state, cameraMode, viewScale, viewScaleResetTrigger, onViewScaleChange }: RocketFlightSceneProps) { // 只在挂载时取一次小时数,免得一次飞行中途跨过 6/18 点导致贴图来回跳。 - const earthTexture = useOptionalTexture(useMemo(() => earthTexturePath(), [])); + // 星舰(场景半径约 0.55)用满尺寸场坪,细箭按同比例缩小 + const padScale = useMemo(() => clamp(stageGeometry(rocket).radius / 0.55, 0.4, 1), [rocket]); + const earthPath = useMemo(() => earthTexturePath(), []); + const nightEarth = earthPath === EARTH_NIGHT_TEXTURE; + const earthTexture = useOptionalTexture(earthPath); const manualCameraRef = useRef(false); const orbitControlsRef = useRef(null); const manualDistanceRef = useRef(null); @@ -520,12 +668,12 @@ function SceneContents({ rocket, state, cameraMode, viewScale, viewScaleResetTri {cameraMode === 'follow' ? ( <> - - + + ) : ( - + )} ); diff --git a/frontend/src/pages/RocketSimulator.tsx b/frontend/src/pages/RocketSimulator.tsx index 85fd661..1c044ed 100644 --- a/frontend/src/pages/RocketSimulator.tsx +++ b/frontend/src/pages/RocketSimulator.tsx @@ -632,7 +632,7 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {