Created
December 18, 2023 08:41
-
-
Save DGriffin91/7883c262bc6baa8b1597186aec72fef4 to your computer and use it in GitHub Desktop.
Somewhat to scale solar eclipse with point light except the sun is way too close.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
fn main() { | |
App::new() | |
.add_plugins(DefaultPlugins) | |
.add_systems(Startup, setup) | |
.run(); | |
} | |
fn setup( | |
mut commands: Commands, | |
mut meshes: ResMut<Assets<Mesh>>, | |
mut materials: ResMut<Assets<StandardMaterial>>, | |
) { | |
let km = 1000.0; | |
commands.spawn(PbrBundle { | |
mesh: meshes.add(Mesh::from(shape::UVSphere { | |
radius: 12_756.0 * km, | |
stacks: 64, | |
sectors: 64, | |
})), | |
transform: Transform::from_xyz(0.0, 0.0, 0.0), | |
material: materials.add(Color::BLUE.into()), | |
..default() | |
}); | |
commands.spawn(PbrBundle { | |
mesh: meshes.add(Mesh::from(shape::UVSphere { | |
radius: 1_737.0 * km, | |
stacks: 64, | |
sectors: 64, | |
})), | |
transform: Transform::from_xyz(-384_400.0 * km, 0.0, 0.0), | |
material: materials.add(Color::GRAY.into()), | |
..default() | |
}); | |
commands.spawn(PointLightBundle { | |
point_light: PointLight { | |
intensity: 100000000000000.0 * km.powf(2.0), | |
shadows_enabled: true, | |
range: 2_000_000.0 * km, | |
..default() | |
}, | |
transform: Transform::from_xyz(-1_000_000.0 * km, 0.0, 0.0), | |
..default() | |
}); | |
commands.spawn(Camera3dBundle { | |
transform: Transform::from_xyz(-300_000.0 * km, 0.0, 450_000.0 * km) | |
.looking_at(Vec3::new(-150_000.0 * km, 0.0, 0.0), Vec3::Y), | |
..default() | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment