use bevy::{pbr::PointLightBundle, prelude::*}; use bevy_polyline::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) .add_plugins(PolylinePlugin) .add_systems(Startup, setup) .add_systems(Update, rotator_system) .run(); } fn setup( mut commands: Commands, mut meshes: ResMut>, mut standard_materials: ResMut>, mut polyline_materials: ResMut>, mut polylines: ResMut>, ) { commands.spawn(PolylineBundle { polyline: polylines.add(Polyline { vertices: vec![ Vec3::new(-0.5, -0.5, -0.5), Vec3::new(0.5, -0.5, -0.5), Vec3::new(0.5, 0.5, -0.5), Vec3::new(-0.5, 0.5, -0.5), Vec3::new(-0.5, 0.5, 0.5), Vec3::new(0.5, 0.5, 0.5), Vec3::new(0.5, -0.5, 0.5), Vec3::new(-0.5, -0.5, 0.5), ], }), material: polyline_materials.add(PolylineMaterial { width: 2.0, color: Color::RED, perspective: false, // Bias the line toward the camera so the line at the cube-plane intersection is visible depth_bias: -0.0002, }), ..Default::default() }); // circular base commands.spawn(PbrBundle { mesh: meshes.add(Circle::new(4.0)), material: standard_materials.add(Color::WHITE), transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)) .with_translation(Vec3::new(0.0, -0.5, 0.0)), ..default() }); // cube commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::from_size(Vec3::ONE)), material: standard_materials.add(Color::rgb_u8(124, 144, 255)), transform: Transform::from_xyz(0.0, 0.0, 0.0), ..default() }); // light commands.spawn(PointLightBundle { transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }); // camera commands.spawn(( Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, -5.0).looking_at(Vec3::ZERO, Vec3::Y), ..Camera3dBundle::default() }, Rotates, )); } /// this component indicates what entities should rotate #[derive(Component)] struct Rotates; fn rotator_system(time: Res