Skip to content

Commit

Permalink
so much stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Sep 30, 2024
1 parent 8d6db58 commit f0c4c9a
Show file tree
Hide file tree
Showing 19 changed files with 1,449 additions and 152 deletions.
1,151 changes: 1,102 additions & 49 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bevy_easings = "0.14"
#bevy_panorbit_camera = { git = "https://github.com/jan-tennert/bevy_panorbit_camera", rev = "7e3c3f8" }
bevy-inspector-egui = { version = "0.26.0"}
#bevy_mod_picking = "0.15"
bevy_egui = "0.29.0"
bevy_egui = { version = "0.29.0", features = ["immutable_ctx"] }
chrono = "0.4.23"
serde_json = "1.0.107"
serde = { version = "1.0.189", features = ["derive"] }
Expand All @@ -37,3 +37,4 @@ egui-toast = "0.14.0"
tinyfiledialogs = "3.0"
egui_extras = { version = "0.28.0", features = ["chrono"] }
reqwest = { version = "0.12.7", features = ["blocking", "json"] }
anise = "0.4.3"
2 changes: 1 addition & 1 deletion scenarios/solar_system_copy.sim
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"bodies":[{"children":[{"children":[],"data":{"mass":238.0,"starting_position":{"x":0.0,"y":0.0,"z":0.0},"starting_velocity":{"x":0.0,"y":0.0,"z":0.0},"name":"Erde 2","model_path":"earth.glb","diameter":421.0,"rotation_speed":0.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":3.3011e23,"starting_position":{"x":-26582359.4034951,"y":40476075.08223532,"z":5690109.263829736},"starting_velocity":{"x":-51.19740738494808,"y":-23.82829179403439,"z":2.750476586235273},"name":"Mercury","model_path":"mercury.glb","diameter":5151.0,"rotation_speed":84480.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":4.8675e24,"starting_position":{"x":84764834.60935698,"y":65277955.33113867,"z":-4030295.749102697},"starting_velocity":{"x":-21.33838684070412,"y":27.68230884313838,"z":1.611943339470342},"name":"Venus","model_path":"venus.glb","diameter":12103.6,"rotation_speed":349946.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":7.348e22,"starting_position":{"x":147680449.19678,"y":18720522.46844263,"z":32437.75744153466},"starting_velocity":{"x":-4.694794112410923,"y":30.37390017058626,"z":0.09549595923954256},"name":"Moon","model_path":"moon.glb","diameter":1738.1,"rotation_speed":39343.68,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":5.97219e24,"starting_position":{"x":147358878.457139,"y":18543152.56927273,"z":29904.29803438578},"starting_velocity":{"x":-4.226365231723641,"y":29.41379349033467,"z":-0.002828583292782128},"name":"Earth","model_path":"earth.glb","diameter":12742.0,"rotation_speed":1436.0,"axial_tilt":23.439281,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":1.0659e16,"starting_position":{"x":-204681120.1572424,"y":-125011240.1183025,"z":2405122.029878475},"starting_velocity":{"x":13.1724712527701,"y":-16.55773129437739,"z":-0.3519634910822811},"name":"Phobos","model_path":"phobos.glb","diameter":22.16,"rotation_speed":0.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1476200000000000.0,"starting_position":{"x":-204689806.5944895,"y":-124990331.767902,"z":2411141.282914884},"starting_velocity":{"x":12.33964871357277,"y":-18.67418157402109,"z":-0.1763597828023391},"name":"Deimos","model_path":"deimos.glb","diameter":12.54,"rotation_speed":0.0,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":6.4171e23,"starting_position":{"x":-204689340.0400904,"y":-125013692.3437167,"z":2409131.185058415},"starting_velocity":{"x":13.57395490411145,"y":-18.60254221026088,"z":-0.7224152414868863},"name":"Mars","model_path":"mars.glb","diameter":6779.0,"rotation_speed":1476.0,"axial_tilt":25.19,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":9.38392e20,"starting_position":{"x":-276237122.1893816,"y":-290351815.0199021,"z":41511640.79416633},"starting_velocity":{"x":12.07056566717051,"y":-13.70357563530193,"z":-2.655445328553542},"name":"Ceres","model_path":"ceres.glb","diameter":939.4,"rotation_speed":540.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":8.931938e22,"starting_position":{"x":591042446.7821088,"y":448196368.7394117,"z":-15101850.10929203},"starting_velocity":{"x":8.957736595686779,"y":7.959026250920237,"z":0.2787009746093063},"name":"Io","model_path":"io.glb","diameter":3643.2,"rotation_speed":2547.36,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":4.799844e22,"starting_position":{"x":591779904.2824603,"y":448698328.1930672,"z":-15068236.06685701},"starting_velocity":{"x":-9.693151465294228,"y":24.69741639214316,"z":0.569429680046083},"name":"Europa","model_path":"europa.glb","diameter":1560.8,"rotation_speed":5113.70064,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.4819e23,"starting_position":{"x":592039382.9735433,"y":448074112.8331422,"z":-15093709.08536822},"starting_velocity":{"x":-2.558462326557859,"y":20.43120719962253,"z":0.5697972593813327},"name":"Ganymede","model_path":"ganymede.glb","diameter":5268.2,"rotation_speed":10303.2,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.075938e23,"starting_position":{"x":592818446.2926141,"y":447834490.0349652,"z":-15087819.74881226},"starting_velocity":{"x":-4.643871215581399,"y":18.53965996642426,"z":0.4153266498041814},"name":"Callisto","model_path":"callisto.glb","diameter":4820.6,"rotation_speed":24032.16,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":1.8981999999999999e27,"starting_position":{"x":591116405.042928,"y":448612773.658671,"z":-15086106.82481316},"starting_velocity":{"x":-8.045068878300311,"y":11.02381638213635,"z":0.1341531152888358},"name":"Jupiter","model_path":"jupiter.glb","diameter":139822.0,"rotation_speed":595.0,"axial_tilt":3.13,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":1.3452e23,"starting_position":{"x":1317062395.789841,"y":-625410954.1976979,"z":-42005663.01576936},"starting_velocity":{"x":-1.060852998165573,"y":6.402666517530363,"z":1.357634287951674},"name":"Titan","model_path":"titan.glb","diameter":5149.46,"rotation_speed":22920.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":2.3064854e21,"starting_position":{"x":1317198227.126551,"y":-626312128.6545614,"z":-41559528.59529075},"starting_velocity":{"x":2.806558904291587,"y":1.2701482567137,"z":3.694364144037066},"name":"Rhea","model_path":"rhea.glb","diameter":763.5,"rotation_speed":6480.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.8056591e21,"starting_position":{"x":1320855160.609993,"y":-627852134.0465181,"z":-41864404.17667893},"starting_velocity":{"x":4.854646792968393,"y":11.66248870085356,"z":-1.230081930411274},"name":"Iapetus","model_path":"iapetus.glb","diameter":1470.0,"rotation_speed":113760.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.0954868e21,"starting_position":{"x":1318063919.760553,"y":-626526636.509911,"z":-41528086.12631324},"starting_velocity":{"x":7.705841565764674,"y":16.66690708035977,"z":-4.861168661971909},"name":"Dione","model_path":"dione.glb","diameter":1123.0,"rotation_speed":3941.1576,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":6.174959e20,"starting_position":{"x":1317498514.533114,"y":-626196816.7390172,"z":-41643245.20863017},"starting_velocity":{"x":-3.711987600444088,"y":1.440318005837302,"z":4.443003247932851},"name":"Tethys","model_path":"tethys.glb","diameter":1062.0,"rotation_speed":2718.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":3.75094e19,"starting_position":{"x":1317862368.9731088,"y":-626273647.8866278,"z":-41636255.21668619},"starting_velocity":{"x":-5.466336813759373,"y":18.80368314533501,"z":-4.960595064530139},"name":"Mimas","model_path":"mimas.glb","diameter":396.0,"rotation_speed":1356.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.080318e20,"starting_position":{"x":1317897357.123477,"y":-626523695.3599699,"z":-41513334.7885673},"starting_velocity":{"x":12.03172552201499,"y":16.74134008425769,"z":-5.324491936368194},"name":"Enceladus","model_path":"enceladus.glb","diameter":504.0,"rotation_speed":1973.11392,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":5.6834e26,"starting_position":{"x":1317721699.784666,"y":-626376213.8853518,"z":-41573559.25955266},"starting_velocity":{"x":3.608323540191913,"y":8.705880483493228,"z":-0.2953903588682212},"name":"Saturn","model_path":"saturn.glb","diameter":116464.0,"rotation_speed":633.0,"axial_tilt":26.73,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":6.4e19,"starting_position":{"x":1876793591.976653,"y":2256780204.161452,"z":-15821844.53453541},"starting_velocity":{"x":0.5593250277603632,"y":3.223358609129066,"z":3.227082066969737},"name":"Miranda","model_path":"miranda.glb","diameter":471.6,"rotation_speed":2035.40976,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.251e21,"starting_position":{"x":1876695507.52492,"y":2256760167.205151,"z":-16046690.83471954},"starting_velocity":{"x":-8.385308784191833,"y":5.318928951790138,"z":4.453089305595049},"name":"Ariel","model_path":"ariel.glb","diameter":1157.8,"rotation_speed":3629.34576,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.275e21,"starting_position":{"x":1877032097.119599,"y":2256677176.877903,"z":-16115312.10892296},"starting_velocity":{"x":-8.506198828430891,"y":4.275436104814068,"z":-3.265378937492151},"name":"Umbriel","model_path":"umbriel.glb","diameter":1169.4,"rotation_speed":5904.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":3.4e21,"starting_position":{"x":1876446721.049093,"y":2256849468.855134,"z":-15797689.42792165},"starting_velocity":{"x":-4.077764161868127,"y":4.250690343060523,"z":3.508220529443759},"name":"Titania","model_path":"titania.glb","diameter":1576.8,"rotation_speed":12528.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":3.076e21,"starting_position":{"x":1876691132.612216,"y":2256854991.280804,"z":-15382668.94913125},"starting_velocity":{"x":-2.324170074400168,"y":3.526797505106853,"z":1.030057319525953},"name":"Oberon","model_path":"oberon.glb","diameter":1522.8,"rotation_speed":19440.0,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":8.681e25,"starting_position":{"x":1876848145.196212,"y":2256742495.428547,"z":-15933338.78791571},"starting_velocity":{"x":-5.285944969180821,"y":4.037177487005098,"z":0.0832885977451503},"name":"Uranus","model_path":"uranus.glb","diameter":50724.0,"rotation_speed":1034.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[{"children":[],"data":{"mass":2.139e22,"starting_position":{"x":4460435655.53476,"y":-311821079.6191955,"z":-96227400.08927624},"starting_velocity":{"x":0.6549830743821887,"y":8.816651890055235,"z":2.683376921837763},"name":"Triton","model_path":"triton.glb","diameter":2706.8,"rotation_speed":8496.0,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":1.024e26,"starting_position":{"x":4460737814.33013,"y":-311719495.6197202,"z":-96383087.29856476},"starting_velocity":{"x":0.3424898338191547,"y":5.454448402599064,"z":-0.1196973250551823},"name":"Neptune","model_path":"neptune.glb","diameter":49244.0,"rotation_speed":960.0,"axial_tilt":28.32,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.303e22,"starting_position":{"x":2534605027.840262,"y":-4550728311.952005,"z":-246201602.553565},"starting_velocity":{"x":4.90550581768183,"y":1.466573354685091,"z":-1.58125012378935},"name":"Pluto","model_path":"pluto.glb","diameter":2376.6,"rotation_speed":9201.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":220000000000000.0,"starting_position":{"x":-2974525169.762023,"y":4071518952.895051,"z":-1489577717.564979},"starting_velocity":{"x":0.7036787387939378,"y":0.567179895714418,"z":0.09880162683010832},"name":"Halley's Comet","model_path":"deimos.glb","diameter":11.0,"rotation_speed":0.0,"axial_tilt":0.0,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":3.1e21,"starting_position":{"x":-6899004382.898172,"y":-1090297370.986418,"z":3649000392.627125},"starting_velocity":{"x":0.2044745917565618,"y":-3.731030512801199,"z":-0.4904247640299213},"name":"Makemake","model_path":"makemake.glb","diameter":1430.0,"rotation_speed":1350.0,"axial_tilt":28.96,"simulate":true,"light_source":null}},{"children":[],"data":{"mass":1.6466e22,"starting_position":{"x":12804007409.48511,"y":5796599006.941406,"z":-2733004417.387743},"starting_velocity":{"x":-0.7745567938606255,"y":1.50385470985689,"z":1.614258646777714},"name":"Eris","model_path":"eris.glb","diameter":2326.0,"rotation_speed":1554.0,"axial_tilt":0.0,"simulate":true,"light_source":null}}],"data":{"mass":1.9885e30,"starting_position":{"x":-1253558.344523507,"y":-331931.4431501561,"z":31972.046837662},"starting_velocity":{"x":0.006931107133912123,"y":-0.01362000313964326,"z":-0.0000454388831820406},"name":"Sol","model_path":"sun.glb","diameter":1492000.0,"rotation_speed":38880.0,"axial_tilt":7.25,"simulate":true,"light_source":{"intensity":3.75,"range":4436820000000.0,"color":"#C600FF","enabled":true}}}],"starting_time_millis":1697760000000,"title":"Solar System2dd","description":"A scenario wi","scale":1e-7, "timestep": 900}
{"bodies":[{"children":[{"children":[],"data":{"mass":5.97219e24,"starting_position":{"x":132661907.41300352,"y":59622737.91959965,"z":25879893.321551036},"starting_velocity":{"x":-13.555126596660894,"y":24.447022096986885,"z":10.59802290045933},"name":"Earth","model_path":"earth.glb","diameter":12742.0,"rotation_speed":1436.0,"axial_tilt":23.439281,"simulate":true,"naif_id":399,"light_source":null}},{"children":[],"data":{"mass":6.4171e23,"starting_position":{"x":-179797351.86843538,"y":-141545418.16021723,"z":-60062982.27940703},"starting_velocity":{"x":16.704581229673664,"y":-14.67524995138464,"z":-7.181472156593413},"name":"Mars","model_path":"mars.glb","diameter":6779.0,"rotation_speed":1476.0,"axial_tilt":25.19,"simulate":true,"naif_id":4,"light_source":null}}],"data":{"mass":1.9885e30,"starting_position":{"x":-1241873.683433827,"y":-337542.17983616004,"z":-111583.58952210216},"starting_velocity":{"x":0.007299482005842327,"y":-0.012230097340821044,"z":-0.005361007667100289},"name":"Sol","model_path":"sun.glb","diameter":1492000.0,"rotation_speed":38880.0,"axial_tilt":7.25,"simulate":true,"naif_id":10,"light_source":{"intensity":3.75e28,"range":4436820000000.0,"color":"#FFFFFF","enabled":true}}}],"starting_time_millis":1697760000000,"title":"Solar System2dd","description":"A scenario wi","scale":1e-7,"timestep":900}
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::setup::SetupPlugin;
use crate::simulation::asset::SCENARIO_ASSET_SOURCE;
use crate::simulation::asset::serialization::SerializationPlugin;
use crate::simulation::components::editor::EditorPlugin;
use crate::simulation::components::horizons::{get_starting_data, HorizonsApiParameters};
use crate::simulation::SimulationPlugin;

mod constants;
Expand Down
6 changes: 4 additions & 2 deletions src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::{app::AppExit, prelude::*};
use crate::simulation::{SimState, SimStateType};
use bevy::{app::AppExit, prelude::*};
use bevy_egui::EguiContexts;

pub struct MenuPlugin;

Expand Down Expand Up @@ -42,7 +43,8 @@ struct MenuButton(pub MenuButtonType);
fn setup_background(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut state: ResMut<NextState<SimState>>
mut state: ResMut<NextState<SimState>>,
mut egui_context: EguiContexts
) {
commands
.spawn(NodeBundle {
Expand Down
16 changes: 10 additions & 6 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use bevy::text::{JustifyText, TextSection, TextStyle};
use bevy::time::TimePlugin;
use bevy_mod_billboard::{BillboardLockAxisBundle, BillboardTextBundle};
use crate::simulation::asset::from_scenario_source;
use crate::simulation::components::anise::{load_spk_files, AlmanacHolder};
use crate::simulation::components::scale::SimulationScale;
use crate::simulation::ui::toast::ToastContainer;
use crate::simulation::units::converter::scale_lumen;

pub struct SetupPlugin;
Expand All @@ -36,7 +38,7 @@ impl Plugin for SetupPlugin {
app
.init_resource::<ScenarioData>()
.add_systems(Startup, setup_camera)
.add_systems(Update, setup_planets.run_if(in_state(SimState::Loading)));
.add_systems(Update, setup_scenario.run_if(in_state(SimState::Loading)));
}
}

Expand All @@ -47,7 +49,8 @@ pub struct ScenarioData {
pub title: String,
pub description: String,
pub timestep: i32,
pub scale: f32
pub scale: f32,
pub spk_files: Vec<String>

}

Expand All @@ -59,12 +62,13 @@ impl From<SimulationData> for ScenarioData {
title: value.title,
description: value.description,
timestep: value.timestep,
scale: value.scale
scale: value.scale,
spk_files: value.data_sets
}
}
}

pub fn setup_planets(
pub fn setup_scenario(
mut commands: Commands,
assets: Res<AssetServer>,
mut selected_scenario: ResMut<SelectedScenario>,
Expand All @@ -75,7 +79,7 @@ pub fn setup_planets(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut sim_state: ResMut<NextState<SimState>>,
scale: Res<SimulationScale>
scale: Res<SimulationScale>,
) {
if selected_scenario.spawned {
return;
Expand All @@ -87,7 +91,7 @@ pub fn setup_planets(
}
let data = bodies.unwrap();
*scenario_data = ScenarioData::from(data.clone());
let stars = data.bodies.iter().count();
let stars = data.bodies.iter().count();
total_count += stars;

//iterate through the stars
Expand Down
13 changes: 12 additions & 1 deletion src/simulation/asset/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, TypePath, Asset, Clone)]
pub struct SimulationData {
pub bodies: Vec<SerializedBody>,
#[serde(default = "default_spk")]
pub data_sets: Vec<String>,
pub starting_time_millis: i64,
pub title: String,
pub description: String,
Expand Down Expand Up @@ -63,10 +65,19 @@ pub struct SerializedBodyData {
pub rotation_speed: f64,
pub axial_tilt: f32,
pub simulate: bool,
pub horizons_id: Option<i32>,
#[serde(default = "default_id")]
pub naif_id: i32,
pub light_source: Option<SerializedLightSource>
}

fn default_id() -> i32 {
-1
}

fn default_spk() -> Vec<String> {
Vec::new()
}

#[derive(Debug, Serialize, Deserialize, TypePath, Clone)]
pub struct SerializedLightSource {
pub intensity: f32,
Expand Down
Loading

0 comments on commit f0c4c9a

Please sign in to comment.