Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattatz/bevy_curvo
Helper library for rendering curves and surfaces modeled with Curvo in Bevy.
https://github.com/mattatz/bevy_curvo
bevy nurbs
Last synced: 2 months ago
JSON representation
Helper library for rendering curves and surfaces modeled with Curvo in Bevy.
- Host: GitHub
- URL: https://github.com/mattatz/bevy_curvo
- Owner: mattatz
- License: mit
- Created: 2024-04-19T08:24:20.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-25T14:44:56.000Z (8 months ago)
- Last Synced: 2024-04-26T13:48:10.335Z (8 months ago)
- Topics: bevy, nurbs
- Language: Rust
- Homepage:
- Size: 8.03 MB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bevy_curvo
[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/mattatz/bevy_curvo#license)
[![Crates.io](https://img.shields.io/crates/v/bevy_curvo.svg)](https://crates.io/crates/bevy_curvo)
[![Docs](https://docs.rs/bevy_curvo/badge.svg)](https://docs.rs/bevy_curvo/latest/bevy_curvo/)
[![Test](https://github.com/mattatz/bevy_curvo/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mattatz/bevy_curvo/actions/workflows/test.yml)`bevy_curvo` is a helper library for rendering curves and surfaces modeled with [Curvo](https://github.com/mattatz/curvo) directly within the [Bevy](https://github.com/bevyengine/bevy) environment.
[Demo](https://github.com/mattatz/bevy_curvo/assets/1085910/5a6864c5-85fa-44ee-b194-23aaa8ff452a)
*You can try the demo on web. https://mattatz.github.io/bevy_curvo/*
## Usage
```rust
// 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::::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
```sh
cargo run --example scene --features=examples
```or with [cargo-make](https://github.com/sagiegurari/cargo-make)
```sh
cargo make example
```## Run the example in the browser
By using [cargo-make](https://github.com/sagiegurari/cargo-make), wasm files are generated using wasm-bindgen-cli, and web applications are served using an http server.
```sh
cargo make serve
```## Compatibility
| bevy | bevy_curvo |
| ---- | ---------- |
| 0.13 | 0.1 |