#mesh #bevy #procedural #graphics #gamedev #2d-3d

bevy_procedural_meshes

Procedural Meshes for the Bevy game engine

5 releases

0.13.1 Apr 1, 2024
0.13.0 Apr 1, 2024
0.1.2 Feb 28, 2024
0.1.1 Feb 26, 2024
0.1.0 Feb 26, 2024

#533 in Game dev

Download history 357/week @ 2024-02-24 38/week @ 2024-03-02 2/week @ 2024-03-09 226/week @ 2024-03-30 30/week @ 2024-04-06 1/week @ 2024-04-13

257 downloads per month
Used in bevy_procedural_vegetatio…

MIT/Apache

105KB
2K SLoC

Bevy Procedural: Meshes

Documentation Bevy crates.io License

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

Build Status Discord Downloads GitHub Repo stars Lines of Code

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.13 0.1.*, main

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:

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

~42–82MB
~1.5M SLoC