diff --git a/Cargo.lock b/Cargo.lock index f2392d5..fd36472 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1014,6 +1014,16 @@ dependencies = [ "glam", ] +[[package]] +name = "bevy_panorbit_camera" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6e15e297754d0bcb7665620c390c4f05665d4ac4ac91b4b5d3c66b9fe1f0e6" +dependencies = [ + "bevy", + "bevy_egui", +] + [[package]] name = "bevy_pbr" version = "0.16.0" @@ -1472,6 +1482,7 @@ version = "0.1.0" dependencies = [ "bevy", "bevy_egui", + "bevy_panorbit_camera", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ed730ea..6798d2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2024" [dependencies] bevy = { version = "0.16.0", features = ["shader_format_wesl"] } bevy_egui = "0.34.1" +bevy_panorbit_camera = { version = "0.26.0", features = ["bevy_egui"] } # Enable a small amount of optimization in the dev profile. [profile.dev] diff --git a/src/camera.rs b/src/camera.rs index 55c6655..76b9a27 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,12 +1,14 @@ use bevy::prelude::*; +use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin}; pub fn plugin(app: &mut App) { - app.add_systems(Startup, setup); + app.add_plugins(PanOrbitCameraPlugin) + .add_systems(Startup, setup); } fn setup(mut commands: Commands) { commands.spawn(( - Camera3d::default(), Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + PanOrbitCamera::default(), )); } diff --git a/src/main.rs b/src/main.rs index e3a47ef..9515d69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use bevy::{color::palettes::css::RED, prelude::*, render::storage::ShaderStorageBuffer}; +use bevy_egui::EguiPlugin; use mandelbulb::{MandelbulbExtension, MandelbulbMaterial, MandelbulbStorage}; mod camera; @@ -6,7 +7,12 @@ mod mandelbulb; fn main() { App::new() - .add_plugins(DefaultPlugins) + .add_plugins(( + DefaultPlugins, + EguiPlugin { + enable_multipass_for_primary_context: false, + }, + )) .add_plugins((camera::plugin, mandelbulb::plugin)) .add_systems(Startup, setup) .add_systems(Update, (rotate_things,))