use bevy::{ prelude::{ shape, App, Assets, Camera3dBundle, Color, Commands, Mesh, PbrBundle, PointLight, PointLightBundle, ResMut, StandardMaterial, Transform, Vec3, }, DefaultPlugins, }; use bevy_shape_draw::{DrawShapeDebugPlugin, DrawShapeRaycastMesh, DrawShapeRaycastSource}; fn main() { let mut app = App::new(); app.add_plugins(DefaultPlugins); app.add_plugin(DrawShapeDebugPlugin::default()); app.add_startup_system(setup); app.run(); } fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { // plane commands .spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })), material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), ..Default::default() }) .insert(DrawShapeRaycastMesh::default()); // cube commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() }); // light commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, shadows_enabled: true, ..Default::default() }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }); // camera commands .spawn(Camera3dBundle { transform: Transform::from_xyz(1., 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), ..Default::default() }) .insert(DrawShapeRaycastSource::new()); }