6 releases
0.14.0 | Jul 8, 2024 |
---|---|
0.13.1 | Apr 1, 2024 |
0.1.2 | Feb 28, 2024 |
#376 in Game dev
Used in bevy_procedural_vegetatio…
105KB
2K
SLoC
Bevy Procedural: Meshes
The objective of the Bevy Procedural Project is to provide a comprehensive suite of packages for the generation of procedural graphics, unified by a consistent API.
The bevy_procedural_meshes-crate is a procedural mesh builder for bevy. It can use Lyon to generate 2D shapes and extrude them into 3D meshes. Meshes can also be optimized using Meshopt to improve their performance. Plans for future versions also include more advanced mesh operations like 3D boolean operations, parametric surfaces, and L-systems.
WARNING
This crate is still in a very early stage of development. Expect frequent API modifications, bugs, and missing features. Feel free to contribute by opening issues, pull requests or sharing your ideas in Github Discussion or the Bevy Discord.
Examples
Try the live examples!
Or run the examples on your computer like, e.g., cargo run --features="bevy/default" --example 2d
.
For package development, we recommend using the editor
-subcrate. This example has a little egui-editor. Run it using cargo watch -w editor/src -w src -x "run -p editor --profile fast-dev"
. The fast-dev
profile will enable optimizations for the dependencies, but not for the package itself. This will slow down the first build significantly, but incremental builds are slightly faster and bevy's performance improves a lot.
Usage
Install using cargo add bevy_procedural_meshes
. Create meshes for bevy like:
use bevy_procedural_meshes::*;
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let mut mesh = PMesh::<u32>::new();
mesh.fill(0.01, |builder| {
builder
.begin_here()
.quadratic_bezier_to(Vec2::new(3.0, 3.0), Vec2::new(1.5, 3.0))
.quadratic_bezier_to(Vec2::new(0.0, 3.0), Vec2::new(0.0, 0.0))
.close();
});
commands.spawn(PbrBundle {
mesh: meshes.add(mesh.to_bevy(RenderAssetUsages::all())),
material: materials.add(StandardMaterial::default()),
..default()
});
}
Features
The following features are available:
meshopt
-- Use Meshopt to optimize the performance of generated meshes.lyon
-- Use Lyon to tesselate 2D shapes like bezier curves and strokes.inspector
-- Add bevy-inspector-egui-support to different structs.dynamic
-- Compiles bevy as a dynamic library. Useful for development builds.
Supported Bevy Versions
The following table shows the compatibility of bevy_procedural_meshes
with certain versions of Bevy:
bevy | bevy_procedural_meshes |
---|---|
0.14 | 0.14.*, main |
0.13 | 0.1.* |
License
The bevy-procedural packages are free, open source and permissively licensed. Except where noted (below and/or in individual files), all code in these repositories is dual-licensed, allowing you the flexibility to choose between:
- The MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- The Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~40–78MB
~1.5M SLoC