一级发动机按芯级与助推器分组绘制,新增芯级发动机数外观字段
parent
1846250acf
commit
71148ab06c
|
|
@ -31,6 +31,9 @@ class RocketAppearance(BaseModel):
|
|||
|
||||
booster_count: int | None = Field(default=None, ge=0, le=8, description="捆绑助推器/侧芯级数量,0 为单芯级")
|
||||
engines_per_booster: int | None = Field(default=None, ge=1, le=33, description="每个助推器的发动机数量")
|
||||
core_engine_count: int | None = Field(
|
||||
default=None, ge=1, le=33, description="芯级一级发动机数量;stage_1.engine_count 仍是含助推器的总数"
|
||||
)
|
||||
booster_diameter_ratio: float | None = Field(default=None, gt=0, le=1, description="助推器直径 / 芯级直径")
|
||||
grid_fins: bool | None = Field(default=None, description="一级顶部栅格翼(回收构型)")
|
||||
fairing: bool | None = Field(default=None, description="是否有载荷整流罩;false 表示二级自身带头锥与襟翼(星舰)")
|
||||
|
|
|
|||
|
|
@ -305,42 +305,49 @@ ROCKET_APPEARANCES: dict[str, dict[str, Any]] = {
|
|||
"falcon-heavy": {
|
||||
"booster_count": 2,
|
||||
"engines_per_booster": 9,
|
||||
"core_engine_count": 9,
|
||||
"booster_diameter_ratio": 1.0,
|
||||
"grid_fins": True,
|
||||
},
|
||||
"long-march-2f": {
|
||||
"booster_count": 4,
|
||||
"engines_per_booster": 1,
|
||||
"core_engine_count": 4,
|
||||
"booster_diameter_ratio": 0.67,
|
||||
"grid_fins": False,
|
||||
},
|
||||
"long-march-7": {
|
||||
"booster_count": 4,
|
||||
"engines_per_booster": 2,
|
||||
"core_engine_count": 2,
|
||||
"booster_diameter_ratio": 0.67,
|
||||
"grid_fins": False,
|
||||
},
|
||||
"long-march-6a": {
|
||||
"booster_count": 4,
|
||||
"engines_per_booster": 2,
|
||||
"core_engine_count": 2,
|
||||
"booster_diameter_ratio": 0.79,
|
||||
"grid_fins": False,
|
||||
},
|
||||
"long-march-8": {
|
||||
"booster_count": 2,
|
||||
"engines_per_booster": 2,
|
||||
"core_engine_count": 2,
|
||||
"booster_diameter_ratio": 0.67,
|
||||
"grid_fins": False,
|
||||
},
|
||||
"soyuz-2": {
|
||||
"booster_count": 4,
|
||||
"engines_per_booster": 1,
|
||||
"core_engine_count": 1,
|
||||
"booster_diameter_ratio": 0.75,
|
||||
"grid_fins": False,
|
||||
},
|
||||
"ariane-6": {
|
||||
"booster_count": 2,
|
||||
"engines_per_booster": 1,
|
||||
"core_engine_count": 2,
|
||||
"booster_diameter_ratio": 0.56,
|
||||
"grid_fins": False,
|
||||
},
|
||||
|
|
@ -351,7 +358,8 @@ async def ensure_rocket_appearance(db: AsyncSession) -> list[str]:
|
|||
"""按 ROCKET_APPEARANCES 补写外观构型。
|
||||
|
||||
型号预置只补插缺失的型号,早已入库的型号不会带上 appearance,因此这里做一次
|
||||
幂等回填:仅处理库里 appearance 仍为空的行,管理端填过的值一律不动。
|
||||
幂等回填:逐字段补齐库里还没有的 key,管理端填过的值(含显式 null)一律不动。
|
||||
新增预置字段因此能在下次启动时自动补上,无需手工维护数据。
|
||||
"""
|
||||
presets = ROCKET_APPEARANCES
|
||||
# 部署时 up -d 早于 upgrade_db.py,列可能还没加上;这里跳过而不是让服务起不来
|
||||
|
|
@ -362,16 +370,17 @@ async def ensure_rocket_appearance(db: AsyncSession) -> list[str]:
|
|||
if column.first() is None:
|
||||
logger.warning("rocket_configs.appearance 列不存在,跳过外观构型回填(执行 upgrade_db.py --apply 后重启生效)")
|
||||
return []
|
||||
result = await db.execute(
|
||||
select(RocketConfig.code).where(RocketConfig.appearance.is_(None), RocketConfig.code.in_(presets))
|
||||
)
|
||||
codes = list(result.scalars().all())
|
||||
result = await db.execute(select(RocketConfig).where(RocketConfig.code.in_(presets)))
|
||||
|
||||
updated: list[str] = []
|
||||
for code in codes:
|
||||
rocket = (await db.execute(select(RocketConfig).where(RocketConfig.code == code))).scalar_one()
|
||||
rocket.appearance = dict(presets[code])
|
||||
updated.append(code)
|
||||
for rocket in result.scalars().all():
|
||||
current = dict(rocket.appearance or {})
|
||||
missing = {key: value for key, value in presets[rocket.code].items() if key not in current}
|
||||
if not missing:
|
||||
continue
|
||||
current.update(missing)
|
||||
rocket.appearance = current
|
||||
updated.append(rocket.code)
|
||||
|
||||
if updated:
|
||||
await db.flush()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,16 @@ import { useMemo, useRef } from 'react';
|
|||
import { useFrame } from '@react-three/fiber';
|
||||
import * as THREE from 'three';
|
||||
import type { RocketConfig, SimulationState } from './types';
|
||||
import { boosterAngle, engineLayout, engineState, separationAge, separationTransform, stageGeometry } from './sceneMath';
|
||||
import {
|
||||
boosterAngle,
|
||||
engineLayout,
|
||||
engineState,
|
||||
separationAge,
|
||||
separationTransform,
|
||||
stage1EngineGroups,
|
||||
stageGeometry,
|
||||
type EngineGroup,
|
||||
} from './sceneMath';
|
||||
|
||||
/*
|
||||
* 运载火箭 3D 模型
|
||||
|
|
@ -332,30 +341,34 @@ function GridFins({ radius, y, color }: { radius: number; y: number; color: stri
|
|||
}
|
||||
|
||||
/**
|
||||
* 捆绑助推器 / 侧芯级:并联在芯级四周,自带头锥、涂装、发动机与尾段。
|
||||
* diameterRatio 是它与芯级的直径比(长征五号 0.45、猎鹰重型 1.0 等直径),
|
||||
* 捆绑助推器 / 侧芯级:并联在芯级四周,自带头锥、涂装、发动机与尾焰。
|
||||
* group 是它在一级发动机分组里的那一项(stage1EngineGroups 产出),
|
||||
* radius / offset 分别是它与芯级的直径比和圆心距(芯级半径的倍数),
|
||||
* 两者相切布置,因此猎鹰重型能画出真实的「三根并排芯级」。
|
||||
* 尾焰放在助推器节点内,分离散开时会跟着一起翻滚。
|
||||
*/
|
||||
function StrapOnBooster({
|
||||
radius,
|
||||
height,
|
||||
color,
|
||||
engines,
|
||||
angle,
|
||||
diameterRatio,
|
||||
group,
|
||||
throttle,
|
||||
active,
|
||||
running,
|
||||
}: {
|
||||
radius: number;
|
||||
height: number;
|
||||
color: string;
|
||||
engines: number;
|
||||
angle: number;
|
||||
diameterRatio: number;
|
||||
group: EngineGroup;
|
||||
throttle: number;
|
||||
active: boolean;
|
||||
running: boolean;
|
||||
}) {
|
||||
const bodyRadius = radius * diameterRatio;
|
||||
const offset = radius * (1 + diameterRatio);
|
||||
const bodyRadius = radius * group.radius;
|
||||
const offset = radius * group.offset;
|
||||
const noseHeight = height * 0.22;
|
||||
return (
|
||||
<group position={[Math.cos(angle) * offset, 0, Math.sin(angle) * offset]}>
|
||||
<group position={[Math.cos(group.angle) * offset, 0, Math.sin(group.angle) * offset]}>
|
||||
{/* 助推器箭体 */}
|
||||
<mesh position={[0, height * 0.5, 0]} castShadow>
|
||||
<cylinderGeometry args={[bodyRadius, bodyRadius, height, 28]} />
|
||||
|
|
@ -376,10 +389,20 @@ function StrapOnBooster({
|
|||
<cylinderGeometry args={[radius * 0.06, radius * 0.06, radius * 0.34, 10]} />
|
||||
<meshStandardMaterial color={DARK} metalness={0.6} roughness={0.45} />
|
||||
</mesh>
|
||||
{/* 助推器发动机 */}
|
||||
<group position={[0, -radius * 0.08, 0]}>
|
||||
<EngineCluster radius={bodyRadius * 1.08} count={engines} bellColor={shade(METAL, -0.15)} showActuators={false} />
|
||||
{/* 助推器发动机舱:只画本机自己的喷管,不借用一级总数 */}
|
||||
<group position={[0, -bodyRadius * 0.08, 0]}>
|
||||
<EngineCluster radius={bodyRadius} count={group.engines} bellColor={shade(METAL, -0.15)} showActuators={false} />
|
||||
</group>
|
||||
{/* 助推器尾焰 */}
|
||||
<EnginePlume
|
||||
radius={bodyRadius}
|
||||
length={bodyRadius * 10}
|
||||
nozzleY={-bodyRadius * 0.7}
|
||||
throttle={throttle}
|
||||
active={active}
|
||||
running={running}
|
||||
spread={1 + group.engines * 0.04}
|
||||
/>
|
||||
</group>
|
||||
);
|
||||
}
|
||||
|
|
@ -665,6 +688,11 @@ interface RocketModelProps {
|
|||
export function RocketModel({ rocket, state }: RocketModelProps) {
|
||||
const geo = useMemo(() => stageGeometry(rocket), [rocket]);
|
||||
const engines = engineState(state);
|
||||
// 一级发动机分组:芯级与每个助推器各自的机数与平面位置
|
||||
const boosterGroups = useMemo(
|
||||
() => stage1EngineGroups(geo).filter((group) => group.kind === 'booster'),
|
||||
[geo],
|
||||
);
|
||||
const age = separationAge(state);
|
||||
const sep = separationTransform(age);
|
||||
const deployEvent = state.events.find((event) => event.id === 'deploy');
|
||||
|
|
@ -851,22 +879,23 @@ export function RocketModel({ rocket, state }: RocketModelProps) {
|
|||
radius={geo.radius}
|
||||
height={geo.stage1Height}
|
||||
color={rocket.color}
|
||||
engineCount={geo.layout === 'boosters' ? geo.coreEngines : geo.stage1Engines}
|
||||
engineCount={geo.coreEngines}
|
||||
label={firstStageLabel}
|
||||
gridFins={geo.gridFins}
|
||||
/>
|
||||
{/* 捆绑助推器:先于芯级分离,分离后向四周散开 */}
|
||||
{geo.layout === 'boosters' && (
|
||||
{boosterGroups.length > 0 && (
|
||||
<group ref={boosterRef}>
|
||||
{Array.from({ length: geo.boosterCount }, (_, index) => (
|
||||
{boosterGroups.map((group, index) => (
|
||||
<group key={index}>
|
||||
<StrapOnBooster
|
||||
radius={geo.radius}
|
||||
height={geo.stage1Height * 0.86}
|
||||
color={shade(rocket.color, -0.06)}
|
||||
engines={geo.enginesPerBooster}
|
||||
angle={boosterAngle(index, geo.boosterCount)}
|
||||
diameterRatio={geo.boosterDiameterRatio}
|
||||
group={group}
|
||||
throttle={state.throttle}
|
||||
active={engines.stage1 && boosterAge === null}
|
||||
running={state.isRunning}
|
||||
/>
|
||||
</group>
|
||||
))}
|
||||
|
|
@ -879,7 +908,7 @@ export function RocketModel({ rocket, state }: RocketModelProps) {
|
|||
throttle={state.throttle}
|
||||
active={engines.stage1}
|
||||
running={state.isRunning}
|
||||
spread={1 + geo.stage1Engines * 0.04}
|
||||
spread={1 + geo.coreEngines * 0.04}
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
|
|
|
|||
|
|
@ -1101,23 +1101,35 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
/* 发动机示意图容器:本身不画圆,圆由每个发动机舱(.sx-engine-group)画出 */
|
||||
.sx-engine-ring {
|
||||
--engine-radius: 20px;
|
||||
position: relative;
|
||||
width: 62px;
|
||||
height: 62px;
|
||||
width: 66px;
|
||||
height: 66px;
|
||||
margin: 0 auto;
|
||||
border: 2.5px solid rgba(235, 240, 238, 0.78);
|
||||
}
|
||||
|
||||
/* 一组发动机 = 一个发动机舱;--gx/--gy 是舱心相对芯级轴心的平面位置 */
|
||||
.sx-engine-group {
|
||||
--group-radius: 26px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: calc(var(--group-radius) * 2);
|
||||
height: calc(var(--group-radius) * 2);
|
||||
box-sizing: border-box;
|
||||
border: 2px solid rgba(235, 240, 238, 0.6);
|
||||
border-radius: 50%;
|
||||
box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.06);
|
||||
transform: translate(-50%, -50%) translate(var(--gx, 0px), var(--gy, 0px));
|
||||
}
|
||||
|
||||
.sx-engine-ring i {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
width: var(--dot, 8px);
|
||||
height: var(--dot, 8px);
|
||||
border: 1px solid #6a726f;
|
||||
border-radius: 50%;
|
||||
background: #232827;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export interface VehicleLayoutInfo {
|
|||
boosterCount: number;
|
||||
/** 每个助推器的发动机数量 */
|
||||
enginesPerBooster: number;
|
||||
/** 芯级发动机数量 */
|
||||
/** 芯级一级发动机数量(不含助推器) */
|
||||
coreEngines: number;
|
||||
/** 一级顶部是否画栅格翼(回收构型特征件) */
|
||||
gridFins: boolean;
|
||||
|
|
@ -70,15 +70,20 @@ export function resolveVehicleLayout(
|
|||
};
|
||||
}
|
||||
|
||||
// 4 个助推器时可按一级发动机数反推每台助推器的发动机数,其余构型需要登记
|
||||
// 每台助推器的机数:4 助推器构型可按一级总数反推,其余构型需要登记
|
||||
const inferredPerBooster = boosterCount === 4 ? (stage1Engines - 2) / 4 : 1;
|
||||
const enginesPerBooster = Math.max(1, Math.round(appearance.engines_per_booster ?? inferredPerBooster));
|
||||
// 芯级机数优先用登记的 core_engine_count,没登记才用「一级总数 − 助推器机数」推算
|
||||
const coreEngines = Math.max(
|
||||
1,
|
||||
Math.round(appearance.core_engine_count ?? stage1Engines - boosterCount * enginesPerBooster),
|
||||
);
|
||||
|
||||
return {
|
||||
layout: 'boosters',
|
||||
boosterCount,
|
||||
enginesPerBooster,
|
||||
coreEngines: Math.max(1, stage1Engines - boosterCount * enginesPerBooster),
|
||||
coreEngines,
|
||||
gridFins: appearance.grid_fins ?? false,
|
||||
boosterDiameterRatio: clamp(appearance.booster_diameter_ratio ?? DEFAULT_BOOSTER_DIAMETER_RATIO, 0.2, 1),
|
||||
};
|
||||
|
|
@ -93,6 +98,42 @@ export function boosterAngle(index: number, count: number): number {
|
|||
return (index / Math.max(1, count)) * Math.PI * 2 + base;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一级发动机分组:芯级 + 每个助推器,含各自的发动机舱半径与平面位置。
|
||||
* 3D 喷管/尾焰与仪表盘示意图都从这里取数,避免各处各自按总数画一团火焰。
|
||||
*/
|
||||
export interface EngineGroup {
|
||||
kind: 'core' | 'booster';
|
||||
/** 该组发动机数量 */
|
||||
engines: number;
|
||||
/** 发动机舱半径(与 offset 同一单位:芯级半径的倍数) */
|
||||
radius: number;
|
||||
/** 相对芯级轴心的水平距离 */
|
||||
offset: number;
|
||||
/** 平面布置角 */
|
||||
angle: number;
|
||||
}
|
||||
|
||||
export function stage1EngineGroups(layout: VehicleLayoutInfo): EngineGroup[] {
|
||||
const groups: EngineGroup[] = [
|
||||
{ kind: 'core', engines: layout.coreEngines, radius: 1, offset: 0, angle: 0 },
|
||||
];
|
||||
if (layout.layout !== 'boosters') return groups;
|
||||
|
||||
const radius = layout.boosterDiameterRatio;
|
||||
const offset = 1 + layout.boosterDiameterRatio;
|
||||
for (let index = 0; index < layout.boosterCount; index += 1) {
|
||||
groups.push({
|
||||
kind: 'booster',
|
||||
engines: layout.enginesPerBooster,
|
||||
radius,
|
||||
offset,
|
||||
angle: boosterAngle(index, layout.boosterCount),
|
||||
});
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
/** 便捷入口:直接由火箭配置判断布局(供物理模拟与仪表盘复用)。 */
|
||||
export function layoutForRocket(rocket: RocketConfig) {
|
||||
const heightM = Math.max(1, rocket.height_m);
|
||||
|
|
@ -185,8 +226,8 @@ export interface EnginePlacement {
|
|||
|
||||
/**
|
||||
* 按真实发动机数量排布喷管:
|
||||
* 1 台居中;2~4 台对称;5~9 台为「1 台中心 + 外圈」;
|
||||
* 10 台及以上为「2 台中心 + 外圈」(长征五号 10 台 = 2 台芯级 + 8 台助推)。
|
||||
* 1 台居中;2~4 台对称;5~9 台为「1 台中心 + 外圈」;10 台以上再加中心机。
|
||||
* count 是「一组(芯级或某个助推器)」的机数,不是整箭总数。
|
||||
*/
|
||||
export function engineLayout(count: number, radius: number): EnginePlacement[] {
|
||||
const total = Math.max(1, Math.round(count));
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ export interface RocketStage {
|
|||
export interface RocketAppearance {
|
||||
/** 捆绑助推器 / 侧芯级数量,0 为单芯级 */
|
||||
booster_count?: number | null;
|
||||
/** 芯级一级发动机数量;stage_1.engine_count 是含助推器的一级总数 */
|
||||
core_engine_count?: number | null;
|
||||
/** 每个助推器的发动机数量 */
|
||||
engines_per_booster?: number | null;
|
||||
/** 助推器直径 / 芯级直径 */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,13 @@ import { PHASE_LABELS, type FlightEvent, type FlightPhase, type RocketConfig } f
|
|||
import { useRocketSimulation } from '../features/rocket-simulator/useRocketSimulation';
|
||||
import { RocketFlightScene, type CameraMode } from '../features/rocket-simulator/RocketFlightScene';
|
||||
import { TelemetryChart } from '../features/rocket-simulator/TelemetryChart';
|
||||
import { engineLayout, layoutForRocket, stageGeometry } from '../features/rocket-simulator/sceneMath';
|
||||
import {
|
||||
engineLayout,
|
||||
layoutForRocket,
|
||||
stage1EngineGroups,
|
||||
stageGeometry,
|
||||
type EngineGroup,
|
||||
} from '../features/rocket-simulator/sceneMath';
|
||||
import '../features/rocket-simulator/rocket-simulator.css';
|
||||
|
||||
/**
|
||||
|
|
@ -242,6 +248,11 @@ function StackDiagram({ rocket }: { rocket: RocketConfig }) {
|
|||
|
||||
function VehiclePanel({ rocket, mode, stage1FuelPct, stage2FuelPct }: { rocket: RocketConfig; mode: StackMode; stage1FuelPct: number; stage2FuelPct: number }) {
|
||||
const meta = mode === 'payload' && rocket.appearance?.fairing === false ? SHIP_MODE_LABEL : STACK_MODE_LABEL[mode];
|
||||
// 两级半构型把「芯级 + 助推器」的机数合并登记在一级上,规格里拆开写才看得懂
|
||||
const layout = layoutForRocket(rocket);
|
||||
const stage1Engines = layout.layout === 'boosters'
|
||||
? `${layout.coreEngines}+${layout.boosterCount}×${layout.enginesPerBooster}`
|
||||
: `${rocket.stage_1.engine_count}`;
|
||||
return (
|
||||
<div className="sx-vehicle">
|
||||
<div className="sx-panel-title"><span>VEHICLE</span><b>运载器状态</b></div>
|
||||
|
|
@ -258,7 +269,7 @@ function VehiclePanel({ rocket, mode, stage1FuelPct, stage2FuelPct }: { rocket:
|
|||
<div className="sx-spec-row"><span>二级</span><b className="sx-spec-name">{rocket.stage_2.name}</b><em>{stage2FuelPct.toFixed(0)}%</em></div>
|
||||
<div className="sx-spec-divider" />
|
||||
<div className="sx-spec-row"><span>箭体尺寸</span><b>{rocket.height_m.toFixed(1)} × Ø{rocket.diameter_m.toFixed(1)} m</b></div>
|
||||
<div className="sx-spec-row"><span>发动机</span><b>{rocket.stage_1.engine_count} + {rocket.stage_2.engine_count} 台</b></div>
|
||||
<div className="sx-spec-row"><span>发动机</span><b>{stage1Engines} + {rocket.stage_2.engine_count} 台</b></div>
|
||||
<div className="sx-spec-row"><span>一级推力</span><b>{(rocket.stage_1.max_thrust_n / 1e6).toFixed(2)} MN</b></div>
|
||||
<div className="sx-spec-row"><span>二级推力</span><b>{(rocket.stage_2.max_thrust_n / 1e6).toFixed(2)} MN</b></div>
|
||||
<div className="sx-spec-row"><span>载荷</span><b>{(rocket.payload_mass_kg / 1000).toFixed(1)} t</b></div>
|
||||
|
|
@ -382,22 +393,66 @@ function FlightData({ state, history, totalFuelPct, stage1FuelPct, stage2FuelPct
|
|||
/* Small mission-control widgets */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
function EngineGauge({ stage, total, active }: { stage: 1 | 2; total: number; active: number }) {
|
||||
// 与 3D 模型共用同一套发动机布局:2 台并排、3 台三角形、4 台方形,
|
||||
// 5 台以上才是「中心 + 外圈」,避免 2 台被画成中心一个旁边一个。
|
||||
const placements = useMemo(() => engineLayout(total, 1), [total]);
|
||||
/**
|
||||
* 发动机示意图:按真实平面构型画出芯级与每个助推器的发动机舱。
|
||||
* 分组取自 stage1EngineGroups,与 3D 模型的喷管/尾焰同源,
|
||||
* 因此带助推器的火箭不会再把 27 台画成芯级上的一个圆环。
|
||||
*/
|
||||
function EngineGauge({
|
||||
label,
|
||||
groups,
|
||||
lit,
|
||||
boostersLit = lit,
|
||||
}: {
|
||||
label: string;
|
||||
groups: EngineGroup[];
|
||||
lit: boolean;
|
||||
/** 助推器在一级飞行中段先分离,分离后其发动机不再点火 */
|
||||
boostersLit?: boolean;
|
||||
}) {
|
||||
const isLit = (group: EngineGroup) => (group.kind === 'core' ? lit : boostersLit);
|
||||
const total = groups.reduce((sum, group) => sum + group.engines, 0);
|
||||
const firing = groups.filter(isLit).reduce((sum, group) => sum + group.engines, 0);
|
||||
// 以最外侧发动机舱边缘为基准换算像素,保证三芯级并排也放得下
|
||||
const span = Math.max(...groups.map((group) => group.offset + group.radius));
|
||||
const pxPerUnit = 26 / span;
|
||||
return (
|
||||
<div className="sx-engine-gauge" aria-label={`${stage === 1 ? '一级' : '二级'}发动机 ${active}/${total} 点火`}>
|
||||
<div className="sx-engine-gauge" aria-label={`${label} ${firing}/${total} 点火`}>
|
||||
<div className="sx-engine-ring">
|
||||
{placements.map((placement, index) => (
|
||||
<i
|
||||
key={index}
|
||||
className={`sx-engine-dot ${index < active ? 'active' : ''}`}
|
||||
style={{ '--dx': placement.x, '--dy': placement.z } as CSSProperties}
|
||||
/>
|
||||
))}
|
||||
{groups.map((group, index) => {
|
||||
const cluster = group.radius * pxPerUnit;
|
||||
const ringRadius = cluster * 0.7;
|
||||
// 机数多的舱室缩小点位,避免十几个点糊成一团
|
||||
const dot = group.engines > 4
|
||||
? Math.min(8, Math.max(3, (Math.PI * 2 * ringRadius) / (group.engines * 1.7)))
|
||||
: Math.min(8, Math.max(4, cluster * 0.5));
|
||||
const placements = engineLayout(group.engines, 1);
|
||||
return (
|
||||
<div
|
||||
key={`${group.kind}-${index}`}
|
||||
className="sx-engine-group"
|
||||
style={
|
||||
{
|
||||
'--gx': `${Math.cos(group.angle) * group.offset * pxPerUnit}px`,
|
||||
'--gy': `${Math.sin(group.angle) * group.offset * pxPerUnit}px`,
|
||||
'--group-radius': `${cluster + dot / 2 + 2}px`,
|
||||
'--engine-radius': `${cluster}px`,
|
||||
'--dot': `${dot}px`,
|
||||
} as CSSProperties
|
||||
}
|
||||
>
|
||||
{placements.map((placement, dotIndex) => (
|
||||
<i
|
||||
key={dotIndex}
|
||||
className={`sx-engine-dot ${isLit(group) ? 'active' : ''}`}
|
||||
style={{ '--dx': placement.x, '--dy': placement.z } as CSSProperties}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<span>{stage === 1 ? '一级发动机' : '二级发动机'}</span>
|
||||
<span>{label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -445,13 +500,16 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {
|
|||
const progress = reachedCount / milestones.length * 100;
|
||||
const nextMilestone = milestones.find((m) => eventTime(m.id) === null);
|
||||
const stackMode = stackModeFor(state.phase);
|
||||
// 仪表盘发动机示意:一级按芯级 + 助推器分组,二级只有芯级一组
|
||||
const stage1Groups = useMemo(() => stage1EngineGroups(layoutForRocket(rocket)), [rocket]);
|
||||
const stage2Groups: EngineGroup[] = [
|
||||
{ kind: 'core', engines: Math.max(1, Math.round(rocket.stage_2.engine_count)), radius: 1, offset: 0, angle: 0 },
|
||||
];
|
||||
|
||||
const stage: 1 | 2 = ['separating', 'stage2_ignition', 'stage2_burn', 'orbit', 'payload_deploy', 'mission_complete'].includes(state.phase) ? 2 : 1;
|
||||
const stageConfig = stage === 1 ? rocket.stage_1 : rocket.stage_2;
|
||||
const stageFiring = stage === 1
|
||||
? state.phase === 'stage1_burn'
|
||||
: state.phase === 'stage2_ignition' || state.phase === 'stage2_burn';
|
||||
const activeEngines = stageFiring ? stageConfig.engine_count : 0;
|
||||
|
||||
const launchLabel = state.phase === 'mission_complete'
|
||||
? '重新模拟'
|
||||
|
|
@ -559,7 +617,12 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {
|
|||
</div>
|
||||
|
||||
<div className="sx-bottom-right">
|
||||
<EngineGauge stage={stage} total={stageConfig.engine_count} active={activeEngines} />
|
||||
<EngineGauge
|
||||
label={stage === 1 ? '一级发动机' : '二级发动机'}
|
||||
groups={stage === 1 ? stage1Groups : stage2Groups}
|
||||
lit={stageFiring}
|
||||
boostersLit={stageFiring && eventTime('booster-sep') === null}
|
||||
/>
|
||||
<AttitudeGauge pitch={state.pitch} />
|
||||
<div className="sx-controls">
|
||||
<button className="sx-icon-btn" onClick={reset} title="重置" aria-label="重置"><RotateCcw size={16} /></button>
|
||||
|
|
|
|||
|
|
@ -37,9 +37,10 @@ function AppearanceFields() {
|
|||
return (
|
||||
<Row gutter={16}>
|
||||
<Col span={24}><Alert type="info" showIcon style={{ marginBottom: 16 }} message="留空即按发动机数量自动推断构型;仅当 3D 外形与真实不符时才需要填写。" /></Col>
|
||||
<Col xs={24} md={8}><Form.Item name={['appearance', 'booster_count']} label="助推器数量" tooltip="捆绑助推器 / 侧芯级数量,0 为单芯级"><InputNumber min={0} max={8} style={{ width: '100%' }} placeholder="自动" /></Form.Item></Col>
|
||||
<Col xs={24} md={8}><Form.Item name={['appearance', 'engines_per_booster']} label="单个助推器发动机数" tooltip="用于推算助推器尾焰规模"><InputNumber min={1} max={33} style={{ width: '100%' }} placeholder="自动" /></Form.Item></Col>
|
||||
<Col xs={24} md={8}><Form.Item name={['appearance', 'booster_diameter_ratio']} label="助推器直径比" tooltip="助推器直径 / 芯级直径"><InputNumber min={0.01} max={1} step={0.01} style={{ width: '100%' }} placeholder="0.45" /></Form.Item></Col>
|
||||
<Col xs={24} md={6}><Form.Item name={['appearance', 'booster_count']} label="助推器数量" tooltip="捆绑助推器 / 侧芯级数量,0 为单芯级"><InputNumber min={0} max={8} style={{ width: '100%' }} placeholder="自动" /></Form.Item></Col>
|
||||
<Col xs={24} md={6}><Form.Item name={['appearance', 'engines_per_booster']} label="单个助推器发动机数" tooltip="每个助推器各自的喷管数量,决定助推器尾焰规模"><InputNumber min={1} max={33} style={{ width: '100%' }} placeholder="自动" /></Form.Item></Col>
|
||||
<Col xs={24} md={6}><Form.Item name={['appearance', 'core_engine_count']} label="芯级发动机数" tooltip="一级的 stage_1 发动机数量含助推器总数,这里单独登记芯级自己的台数(如猎鹰重型 27 = 芯级 9 + 2×9)"><InputNumber min={1} max={33} style={{ width: '100%' }} placeholder="自动" /></Form.Item></Col>
|
||||
<Col xs={24} md={6}><Form.Item name={['appearance', 'booster_diameter_ratio']} label="助推器直径比" tooltip="助推器直径 / 芯级直径"><InputNumber min={0.01} max={1} step={0.01} style={{ width: '100%' }} placeholder="0.45" /></Form.Item></Col>
|
||||
<Col xs={24} md={12}><Form.Item name={['appearance', 'grid_fins']} label="一级栅格翼" tooltip="回收构型一级顶部的栅格翼" valuePropName="checked"><Switch /></Form.Item></Col>
|
||||
<Col xs={24} md={12}><Form.Item name={['appearance', 'fairing']} label="载荷整流罩" tooltip="关闭表示二级自身带头锥与襟翼(如星舰飞船)" valuePropName="checked"><Switch /></Form.Item></Col>
|
||||
</Row>
|
||||
|
|
|
|||
Loading…
Reference in New Issue