diff --git a/Cargo.toml b/Cargo.toml index 338beef..aeafe52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ bevy = { version = "0.9", default_features = false, features = [ "bevy_winit", "x11", ] } +bevy_framepace = "0.11" [features] default = ["debug"] diff --git a/assets/fonts/FiraMono-Medium.ttf b/assets/fonts/FiraMono-Medium.ttf deleted file mode 100644 index 1e95ced..0000000 Binary files a/assets/fonts/FiraMono-Medium.ttf and /dev/null differ diff --git a/assets/fonts/FiraMono-Regular.ttf b/assets/fonts/FiraMono-Regular.ttf new file mode 100644 index 0000000..67bbd42 Binary files /dev/null and b/assets/fonts/FiraMono-Regular.ttf differ diff --git a/examples/demo.rs b/examples/demo.rs index 75e08d6..7dbb49e 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -3,17 +3,23 @@ use bevy::{ prelude::*, render::primitives::{Aabb, Sphere}, }; -use big_space::{camera::CameraController, FloatingOrigin, GridCell}; +use big_space::{ + camera::{CameraController, CameraInput, CameraVelocity}, + FloatingOrigin, GridCell, +}; fn main() { App::new() .add_plugins(DefaultPlugins.build().disable::()) .add_plugin(big_space::FloatingOriginPlugin::::default()) .add_plugin(big_space::debug::FloatingOriginDebugPlugin::::default()) - .add_plugin(big_space::camera::CameraControllerPlugin) + .add_plugin(big_space::camera::CameraControllerPlugin::::default()) + .add_plugin(bevy_framepace::FramepacePlugin) .insert_resource(ClearColor(Color::BLACK)) .add_startup_system(setup) .add_system(cursor_grab_system) + .add_system(ui_text_system) + .add_startup_system(ui_setup) .run() } @@ -32,8 +38,8 @@ fn setup( GridCell::::default(), // All spatial entities need this component FloatingOrigin, // Important: marks this as the entity to use as the floating origin CameraController { - max_speed: 10e12, - smoothness: 0.9, + max_speed: 10e35, + smoothness: 0.8, ..default() }, // Built-in camera controller )); @@ -41,20 +47,21 @@ fn setup( let mesh_handle = meshes.add( shape::Icosphere { radius: 0.5, - subdivisions: 16, + subdivisions: 32, } .try_into() .unwrap(), ); let matl_handle = materials.add(StandardMaterial { - base_color: Color::YELLOW, - unlit: false, + base_color: Color::MIDNIGHT_BLUE, + perceptual_roughness: 0.8, + reflectance: 1.0, ..default() }); let mut translation = Vec3::ZERO; - for i in 1..100i128 { - let j = i.pow(10) as f32 + 1.0; + for i in 1..=100i128 { + let j = i.pow(14) as f32; translation.x += j; commands.spawn(( PbrBundle { @@ -81,21 +88,79 @@ fn setup( },)); } +#[derive(Component, Reflect)] +pub struct BigSpaceDebugText; + +fn ui_setup(mut commands: Commands, asset_server: Res) { + commands.spawn(( + TextBundle::from_section( + "", + TextStyle { + font: asset_server.load("fonts/FiraMono-Regular.ttf"), + font_size: 18.0, + color: Color::WHITE, + }, + ) + .with_text_alignment(TextAlignment::TOP_LEFT) + .with_style(Style { + position_type: PositionType::Absolute, + position: UiRect { + top: Val::Px(10.0), + left: Val::Px(10.0), + ..default() + }, + ..default() + }), + BigSpaceDebugText, + )); +} + +fn ui_text_system( + mut text: Query<&mut Text, With>, + time: Res