Crates.io | bevy_procedural_grass |
lib.rs | bevy_procedural_grass |
version | 0.2.0 |
source | src |
created_at | 2023-12-10 01:53:52.950936 |
updated_at | 2023-12-12 02:20:42.694341 |
description | A plugin for bevy to generate grass |
homepage | |
repository | https://github.com/jadedbay/bevy_procedural_grass/ |
max_upload_size | |
id | 1063981 |
size | 164,099 |
A plugin for bevy 0.12
that generates grass on top of any mesh.
Add bevy_procedural_grass
dependency to Cargo.toml
:
[dependencies]
bevy_procedural_grass = "0.2.0"
use bevy::prelude::*;
use bevy_procedural_grass::prelude::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
ProceduralGrassPlugin::default(), // add grass plugin
))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
) {
let plane = commands.spawn(
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane::default())),
..default()
},
).id();
// spawn grass
commands.spawn(GrassBundle {
mesh: meshes.add(GrassMesh::mesh(7)), // how many segments you want in the mesh (no. of verts = segments * 2 + 1)
grass: Grass {
entity: Some(plane.clone()), // set entity that grass will generate on top of.
..default()
},
lod: GrassLODMesh::new(meshes.add(GrassMesh::mesh(3))), // optional: enables LOD
..default()
});
}