bevy_prototype_lyon
bevy_prototype_lyon copied to clipboard
can't show 2D and 3D models at the same time
Here is a simple example which demonstrate the problem:
use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;
const SHOW_2D: bool = true;
const SHOW_3D: bool = true;
fn main() {
App::new()
.insert_resource(Msaa { samples: 4 })
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_startup_system(setup_system)
.run();
}
fn setup_system(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
if SHOW_2D {
let shape = shapes::RegularPolygon {
sides: 6,
feature: shapes::RegularPolygonFeature::Radius(200.0),
..shapes::RegularPolygon::default()
};
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(GeometryBuilder::build_as(
&shape,
DrawMode::Outlined {
fill_mode: FillMode::color(Color::CYAN),
outline_mode: StrokeMode::new(Color::BLACK, 10.0),
},
Transform::default(),
));
}
if SHOW_3D {
// cube
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 2.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
..Default::default()
});
// light
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
});
// camera
commands.spawn_bundle(PerspectiveCameraBundle {
transform: Transform::from_xyz(-3.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
}
}
and the Cargo.toml file:
[package]
name = "bevytest"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = {version="0.6", default-features=true}
bevy_prototype_lyon = "0.4.0"
When I start it, it shows only the cube. But when I set SHOW_3D to false, it shows the 2D triangle. How can I show both? The triangle in the foreground.