diff --git a/Cargo.toml b/Cargo.toml index 2ca115340..7a6e5d539 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ c11-orbit = ["trackball/cc"] [dependencies] bevy = { version = "0.13.0", default-features = false, features = ["bevy_render"] } -bevy_egui = { version = "0.24.0", default-features = false, optional = true } +bevy_egui = { version = "0.25.0", default-features = false, features = ["render"], optional = true } trackball = { git = "https://github.com/qu1x/trackball", features = ["glam"] } [dev-dependencies.bevy] diff --git a/examples/egui.rs b/examples/egui.rs index 8edba685d..59b53b4dd 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -3,7 +3,6 @@ use std::f32::consts::PI; use bevy::{ - core_pipeline::clear_color::ClearColorConfig, prelude::*, render::{ camera::RenderTarget, @@ -91,7 +90,7 @@ fn setup( ..default() }; - let cube_handle = meshes.add(Mesh::from(shape::Cube { size: 4.0 })); + let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0)); let default_material = StandardMaterial { base_color: Color::rgb(0.8, 0.7, 0.6), reflectance: 0.02, @@ -117,7 +116,7 @@ fn setup( // Cube parameters. let cube_size = 4.0; - let cube_handle = meshes.add(Mesh::from(shape::Box::new(cube_size, cube_size, cube_size))); + let cube_handle = meshes.add(Cuboid::new(cube_size, cube_size, cube_size)); // Main pass cube. let main_material_handle = materials.add(default_material); @@ -142,7 +141,7 @@ fn setup( commands.spawn(SpotLightBundle { transform: Transform::from_xyz(eye.x, eye.y, eye.z).looking_at(target, up), spot_light: SpotLight { - intensity: 4400.0, // lumens + intensity: 10_000_000., range: 100.0, color: Color::WHITE, shadows_enabled: true, @@ -166,14 +165,11 @@ fn setup( commands .spawn(( Camera3dBundle { - camera_3d: Camera3d { - clear_color: ClearColorConfig::Custom(Color::rgba(1.0, 1.0, 1.0, 0.0)), - ..default() - }, camera: Camera { // render before the "main pass" camera order: -1, target: RenderTarget::Image(image_handle), + clear_color: ClearColorConfig::Custom(Color::rgba(1.0, 1.0, 1.0, 0.0)), ..default() }, ..default() @@ -248,13 +244,12 @@ fn color_picker_widget(ui: &mut egui::Ui, color: &mut Color) -> egui::Response { egui::color_picker::Alpha::Opaque, ); let [r, g, b, a] = egui_color.to_srgba_unmultiplied(); - *color = [ + *color = Color::rgba( r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, a as f32 / 255.0, - ] - .into(); + ); res } diff --git a/src/camera.rs b/src/camera.rs index 902f21449..3a4a93325 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use bevy::{prelude::*, render::camera::ScalingMode, transform::components::Transform}; +use bevy::{prelude::*, render::camera::ScalingMode}; use trackball::{approx::AbsDiffEq, nalgebra::Point2, Clamp, Delta, Fixed, Frame, Scope}; /// Trackball camera component mainly defined by [`Frame`] and [`Scope`]. diff --git a/src/controller.rs b/src/controller.rs index 141e55082..24a5d666d 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -1,11 +1,7 @@ use bevy::{ - input::{ - keyboard::KeyCode, - mouse::{MouseMotion, MouseWheel}, - }, + input::mouse::{MouseMotion, MouseWheel}, prelude::*, - time::Time, - window::{CursorGrabMode, CursorIcon, PrimaryWindow}, + window::{CursorGrabMode, PrimaryWindow}, }; pub use input::{TrackballInput, TrackballVelocity, TrackballWheelUnit}; use key::key; diff --git a/src/controller/input.rs b/src/controller/input.rs index 10b332b7f..bffdcf126 100644 --- a/src/controller/input.rs +++ b/src/controller/input.rs @@ -1,4 +1,4 @@ -use bevy::{input::keyboard::KeyCode, prelude::*}; +use bevy::prelude::*; use trackball::Fixed; /// Trackball controller input mappings and settings. diff --git a/src/controller/key.rs b/src/controller/key.rs index 4cf110cd0..fa22e5ace 100644 --- a/src/controller/key.rs +++ b/src/controller/key.rs @@ -1,4 +1,4 @@ -use bevy::{input::keyboard::KeyCode, prelude::*, window::CursorGrabMode}; +use bevy::{prelude::*, window::CursorGrabMode}; use trackball::nalgebra::{Point3, Unit, UnitQuaternion}; use crate::{TrackballCamera, TrackballController, TrackballEvent}; diff --git a/src/controller/mouse.rs b/src/controller/mouse.rs index 6eea10310..add474bed 100644 --- a/src/controller/mouse.rs +++ b/src/controller/mouse.rs @@ -1,7 +1,7 @@ use bevy::{ input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel}, prelude::*, - window::{CursorGrabMode, CursorIcon}, + window::CursorGrabMode, }; use trackball::{ nalgebra::{Point2, Point3}, diff --git a/src/controller/viewport.rs b/src/controller/viewport.rs index ed062f122..ea05044ef 100644 --- a/src/controller/viewport.rs +++ b/src/controller/viewport.rs @@ -1,8 +1,8 @@ -use bevy::prelude::*; use bevy::{ - input::{keyboard::KeyCode, mouse::MouseWheel, touch::TouchPhase}, + input::{mouse::MouseWheel, touch::TouchPhase}, + prelude::*, render::camera::RenderTarget, - window::{PrimaryWindow, Window, WindowRef}, + window::{PrimaryWindow, WindowRef}, }; use super::{TrackballCamera, TrackballController}; diff --git a/src/lib.rs b/src/lib.rs index c1e723378..c4ad6a8d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -333,14 +333,10 @@ impl Plugin for TrackballPlugin { mut viewport: ResMut, mut contexts: Query<&mut EguiContext>, ) { - let stolen = contexts - .iter_mut() - .next() - .map(|mut context| { - let context = context.get_mut(); - context.wants_pointer_input() || context.wants_keyboard_input() - }) - .unwrap_or_default(); + let stolen = contexts.iter_mut().next().is_some_and(|mut context| { + let context = context.get_mut(); + context.wants_pointer_input() || context.wants_keyboard_input() + }); viewport.set_stolen(stolen.then_some(2)); }