bevy_curvo

Crates.iobevy_curvo
lib.rsbevy_curvo
version0.1.4
sourcesrc
created_at2024-04-19 08:58:33.826473
updated_at2024-04-25 14:45:59.827724
descriptionNURBS modeling plugin for Bevy
homepagehttps://github.com/mattatz/bevy_curvo
repositoryhttps://github.com/mattatz/bevy_curvo
max_upload_size
id1213413
size148,761
mattatz (mattatz)

documentation

README

bevy_curvo

License Crates.io Docs Test

bevy_curvo is a helper library for rendering curves and surfaces modeled with Curvo directly within the Bevy environment.

Demo

You can try the demo on web. https://mattatz.github.io/bevy_curvo/

Usage

// Create a set of points to interpolate
let points = vec![
    Point3::new(-1.0, -1.0, 0.),
    Point3::new(1.0, -1.0, 0.),
    Point3::new(1.0, 1.0, 0.),
    Point3::new(-1.0, 1.0, 0.),
];

// Create a NURBS curve that interpolates the given points with degree 3
let interpolated = NurbsCurve3D::<f64>::try_interpolate(&points, 3, None, None).unwrap();

// Create a NURBS surface by extruding the curve along the z-axis
let extrusion = NurbsSurface::extrude(&interpolated, Vector3::z() * 3.0);

// Create a SurfaceTessellation from the NURBS surface
let tess = extrusion.tessellate(Some(AdaptiveTessellationOptions {
    norm_tolerance: 1e-2 * 2.5,
    ..Default::default()
}));

// Create a bevy friendly data from the tessellation
let surface_mesh = NurbsSurfaceMesh::from(tess);

commands.spawn(PbrBundle {
  // Here you can use the mesh to render the surface
  mesh: surface_mesh,
  material: materials.add(StandardMaterial {
    ..default()
  }),
  ..default()
});

// or you can build a mesh for the surface
let tri: Mesh = surface_mesh.build_surface_triangle_list(Some(RenderAssetUsages::default()));

Run the example

cargo run --example scene --features=examples

or with cargo-make

cargo make example

Run the example in the browser

By using cargo-make, wasm files are generated using wasm-bindgen-cli, and web applications are served using an http server.

cargo make serve

Compatibility

bevy bevy_curvo
0.13 0.1
Commit count: 30

cargo fmt