mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 05:03:47 +00:00
aefe1f0739
Co-authored-by: Mike <mike.hsu@gmail.com>
24 lines
732 B
Rust
24 lines
732 B
Rust
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
|
|
|
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Startup, setup)
|
|
.run();
|
|
}
|
|
|
|
fn setup(
|
|
mut commands: Commands,
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
|
) {
|
|
commands.spawn(Camera2dBundle::default());
|
|
commands.spawn(MaterialMesh2dBundle {
|
|
mesh: meshes.add(Mesh::from(shape::Quad::default())).into(),
|
|
transform: Transform::default().with_scale(Vec3::splat(128.)),
|
|
material: materials.add(ColorMaterial::from(Color::PURPLE)),
|
|
..default()
|
|
});
|
|
}
|