#graphics

bevy-single-variable-function-mesh

A 2D or 3D mesh (bevy::render::mesh::Mesh) generated from a single-variable function f(f32) -> f32

2 releases

new 0.2.4 Mar 19, 2023
0.2.3 Feb 11, 2023
0.2.2 Jan 1, 2023
0.2.1 Dec 27, 2022

#44 in Rendering

31 downloads per month

MIT/Apache

345KB
209 lines

bevy-single-variable-function-mesh

A 2D or 3D mesh (bevy::render::mesh::Mesh) generated from a single-variable function f(f32) -> f32.

Usage

Add this to your Cargo.toml:

[dependencies]
bevy-single-variable-function-mesh = "0.2.3"

Examples

We have one math function that generates a half squircle and one that generates a half circle.

fn squircle(x: f32) -> f32 {
    (1.0 - (x).abs().powf(4.0)).powf(0.25)
}

fn circle(x: f32) -> f32 {
    (1.0 - x.powf(2.0)).powf(0.5)
}
bevy_single_variable_function_mesh::SingleVariableFunctionMesh {
    f: squircle, // Or circle.
    relative_height: 0.0,
	..default()
}
bevy_single_variable_function_mesh::SingleVariableFunctionMesh {
    f: squircle, // Or circle.
    relative_height: 0.2,
	..default()
}
bevy_single_variable_function_mesh::SingleVariableFunctionMesh {
    f: squircle, // Or circle.
    relative_height: 1.0,
	..default()
}

Details

  • Feel free to add ideas to the bug tracker.
  • This crate will automatically search for good vertices by comparing the slopes of the input function called f.

License

Licensed under either of these:

Dependencies

~13–49MB
~874K SLoC