use bevy::{ pbr::wireframe::{Wireframe, WireframePlugin}, prelude::*, }; use bevy_mops::{GIMesh, MergeSettings}; use bevy_panorbit_camera::*; fn main() { let mut app = App::new(); app.add_plugins((DefaultPlugins, PanOrbitCameraPlugin, WireframePlugin)); app.add_systems(Startup, setup) .add_systems(Update, (show_slice_gizmos, rotate_mesh_b).chain()); app.run(); } #[derive(Component)] pub struct SliceA; #[derive(Component)] pub struct SliceB; #[derive(Component)] pub struct Output { pub index: usize, } fn setup( mut meshes: ResMut>, mut materials: ResMut>, mut commands: Commands, ) { commands.spawn(( Camera3dBundle { transform: Transform::from_xyz(0.0, 0.0, 5.0), ..default() }, PanOrbitCamera::default(), )); commands.spawn(( // meshes.add(Sphere::new(0.75)), //Cuboid::new(1.0, 1.0, 1.0)), meshes.add(Cuboid::new(0.5, 0.5, 0.5)), materials.add(StandardMaterial { base_color: Color::rgba(1.0, 0.0, 0.0, 1.0), // alpha_mode: AlphaMode::Blend, cull_mode: None, ..default() }), SpatialBundle { transform: Transform::from_xyz(0.5, 0.0, 0.0), ..default() }, SliceA, )); commands.spawn(( meshes.add(Cuboid::new(1.0, 1.0, 1.0)), //Plane3d::new(Vec3::Y)), materials.add(StandardMaterial { base_color: Color::rgba(1.0, 1.0, 1.0, 0.5), alpha_mode: AlphaMode::Blend, cull_mode: None, ..default() }), SpatialBundle { transform: Transform::from_xyz(0.0, 0.0, 0.0), ..default() }, SliceB, )); commands.spawn(( meshes.add(Cuboid::new(1.0, 1.0, 1.0)), materials.add(StandardMaterial { base_color: Color::rgb(0.0, 0.0, 1.0), // cull_mode: None, ..default() }), SpatialBundle { transform: Transform::from_xyz(0.75, 2.0, 0.0), ..default() }, Wireframe, Output { index: 0 }, )); commands.spawn(( meshes.add(Cuboid::new(1.0, 1.0, 1.0)), materials.add(StandardMaterial { base_color: Color::rgb(1.0, 0.0, 0.0), // cull_mode: None, ..default() }), SpatialBundle { transform: Transform::from_xyz(-0.75, 2.0, 0.0), ..default() }, Wireframe, Output { index: 1 }, )); } fn rotate_mesh_b(time: Res