update
This commit is contained in:
parent
ca2b06efb8
commit
ebf470f312
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -880,6 +880,15 @@ dependencies = [
|
|||||||
"glam",
|
"glam",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_panorbit_camera"
|
||||||
|
version = "0.26.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca6e15e297754d0bcb7665620c390c4f05665d4ac4ac91b4b5d3c66b9fe1f0e6"
|
||||||
|
dependencies = [
|
||||||
|
"bevy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_pbr"
|
name = "bevy_pbr"
|
||||||
version = "0.16.1"
|
version = "0.16.1"
|
||||||
@ -3818,6 +3827,7 @@ name = "solar-sim"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
|
"bevy_panorbit_camera",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@ -5,6 +5,7 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16"
|
bevy = "0.16"
|
||||||
|
bevy_panorbit_camera = "0.26"
|
||||||
|
|
||||||
# Enable a small amount of optimization in the dev profile.
|
# Enable a small amount of optimization in the dev profile.
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
14
src/main.rs
14
src/main.rs
@ -1,4 +1,5 @@
|
|||||||
use bevy::{math::DVec3, prelude::*};
|
use bevy::{math::DVec3, prelude::*};
|
||||||
|
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
|
||||||
|
|
||||||
// Unit wrapper types - all distances in AU
|
// Unit wrapper types - all distances in AU
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
@ -90,11 +91,17 @@ fn sync_position_to_transform(mut query: Query<(&Position, &mut Transform), Chan
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup_rendering(mut commands: Commands) {
|
fn setup_rendering(mut commands: Commands) {
|
||||||
// Spawn camera positioned to view the solar system
|
// Spawn camera with pan/orbit/zoom controls
|
||||||
// Place it above and to the side for a good perspective view
|
// Place it at a good distance to view the solar system
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3d::default(),
|
Camera3d::default(),
|
||||||
Transform::from_xyz(2.0, 1.5, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_translation(Vec3::new(2.0, 1.5, 2.0)),
|
||||||
|
PanOrbitCamera {
|
||||||
|
focus: Vec3::ZERO,
|
||||||
|
radius: Some(3.0),
|
||||||
|
is_upside_down: false,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
// Spawn directional light from the sun's position
|
// Spawn directional light from the sun's position
|
||||||
@ -163,6 +170,7 @@ fn setup_solar_system(mut commands: Commands) {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(PanOrbitCameraPlugin)
|
||||||
.add_plugins(SolarRenderingPlugin)
|
.add_plugins(SolarRenderingPlugin)
|
||||||
.add_systems(Startup, setup_solar_system)
|
.add_systems(Startup, setup_solar_system)
|
||||||
.run();
|
.run();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user