added pan/orbit camera and eguiplugin

This commit is contained in:
TÁNCZOS Vilmos Zsombor 2025-05-31 23:13:16 +02:00
parent 405d187a29
commit a9829b700e
4 changed files with 23 additions and 3 deletions

11
Cargo.lock generated
View file

@ -1014,6 +1014,16 @@ 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",
"bevy_egui",
]
[[package]] [[package]]
name = "bevy_pbr" name = "bevy_pbr"
version = "0.16.0" version = "0.16.0"
@ -1472,6 +1482,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy_egui", "bevy_egui",
"bevy_panorbit_camera",
] ]
[[package]] [[package]]

View file

@ -6,6 +6,7 @@ edition = "2024"
[dependencies] [dependencies]
bevy = { version = "0.16.0", features = ["shader_format_wesl"] } bevy = { version = "0.16.0", features = ["shader_format_wesl"] }
bevy_egui = "0.34.1" 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. # Enable a small amount of optimization in the dev profile.
[profile.dev] [profile.dev]

View file

@ -1,12 +1,14 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
pub fn plugin(app: &mut App) { pub fn plugin(app: &mut App) {
app.add_systems(Startup, setup); app.add_plugins(PanOrbitCameraPlugin)
.add_systems(Startup, setup);
} }
fn setup(mut commands: Commands) { fn setup(mut commands: Commands) {
commands.spawn(( commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
PanOrbitCamera::default(),
)); ));
} }

View file

@ -1,4 +1,5 @@
use bevy::{color::palettes::css::RED, prelude::*, render::storage::ShaderStorageBuffer}; use bevy::{color::palettes::css::RED, prelude::*, render::storage::ShaderStorageBuffer};
use bevy_egui::EguiPlugin;
use mandelbulb::{MandelbulbExtension, MandelbulbMaterial, MandelbulbStorage}; use mandelbulb::{MandelbulbExtension, MandelbulbMaterial, MandelbulbStorage};
mod camera; mod camera;
@ -6,7 +7,12 @@ mod mandelbulb;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins((
DefaultPlugins,
EguiPlugin {
enable_multipass_for_primary_context: false,
},
))
.add_plugins((camera::plugin, mandelbulb::plugin)) .add_plugins((camera::plugin, mandelbulb::plugin))
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (rotate_things,)) .add_systems(Update, (rotate_things,))