Add mass driver station system with Lagrange point placement
- Lagrange point computation (L1-L5) for any Sun-planet pair in Rust - Station generation: auto-place at Lagrange points by priority (inner → outer planets) - Station panel UI: count slider (5-50), launch velocity slider (5-100 km/s) with info tooltip - Blue diamond markers on 2D canvas with labels when zoomed in - Active station list in sidebar (Earth L1, Mars L2, Jupiter L4, etc.) - WASM API: generate_stations(), get_station_positions(), get_station_names() - Station positions update every frame (co-rotating with planets at Lagrange points) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use mass_driver_core::station;
|
||||
use orbital_mechanics::bodies;
|
||||
use orbital_mechanics::orbits;
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -66,3 +67,34 @@ pub fn get_orbit_points(body_id: usize, jd: f64, samples: usize) -> Vec<f64> {
|
||||
}
|
||||
orbits::orbit_points(&all, body_id, jd, samples)
|
||||
}
|
||||
|
||||
/// Generate default stations and return their configuration as JSON.
|
||||
#[wasm_bindgen]
|
||||
pub fn generate_stations(count: usize) -> String {
|
||||
let stations = station::generate_default_stations(count);
|
||||
serde_json::to_string(&stations).unwrap()
|
||||
}
|
||||
|
||||
/// Get station positions at a given Julian Date.
|
||||
/// Takes a JSON config string (from generate_stations) and returns
|
||||
/// Float64Array of [x0, y0, z0, x1, y1, z1, ...] in AU.
|
||||
#[wasm_bindgen]
|
||||
pub fn get_station_positions(stations_json: &str, jd: f64) -> Vec<f64> {
|
||||
let stations: Vec<station::Station> = match serde_json::from_str(stations_json) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return vec![],
|
||||
};
|
||||
let all_bodies = bodies::all_bodies();
|
||||
station::all_station_positions(&stations, &all_bodies, jd)
|
||||
}
|
||||
|
||||
/// Get station names from a config JSON string.
|
||||
#[wasm_bindgen]
|
||||
pub fn get_station_names(stations_json: &str) -> String {
|
||||
let stations: Vec<station::Station> = match serde_json::from_str(stations_json) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return "[]".to_string(),
|
||||
};
|
||||
let names: Vec<&str> = stations.iter().map(|s| s.name.as_str()).collect();
|
||||
serde_json::to_string(&names).unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user