From 270599836144b4f423df6b2c827af9ecca730bd1 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 12 Mar 2025 19:13:31 +0100 Subject: [PATCH] Add bevy_flycam pluing and some basic objects --- Cargo.toml | 1 + src/main.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 82e98c1..57d34be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2024" [dependencies] avian3d = "0.2.1" bevy = "0.15.3" +bevy_flycam = "0.15.0" diff --git a/src/main.rs b/src/main.rs index d216c17..3236775 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,38 @@ use bevy::prelude::*; +use bevy_flycam::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) + .add_plugins(PlayerPlugin) + .add_systems(Startup, setup) .run(); } + +/// set up a simple 3D scene +fn setup( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + // circular base + commands.spawn(( + Mesh3d(meshes.add(Circle::new(4.0))), + MeshMaterial3d(materials.add(Color::WHITE)), + Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), + )); + // cube + commands.spawn(( + Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))), + MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))), + Transform::from_xyz(0.0, 0.5, 0.0), + )); + // light + commands.spawn(( + PointLight { + shadows_enabled: true, + ..default() + }, + Transform::from_xyz(4.0, 8.0, 4.0), + )); +}