bevy/crates/bevy_gizmos/src
Robert Walter 9e78433427
Curve gizmos integration (#14971)
# Objective

- Add gizmos integration for the new `Curve` things in the math lib

## Solution

- Add the following methods
  - `curve_2d(curve, sample_times, color)`
  - `curve_3d(curve, sample_times, color)`
  - `curve_gradient_2d(curve, sample_times_with_colors)`
  - `curve_gradient_3d(curve, sample_times_with_colors)`

## Testing

- I added examples of the 2D and 3D variants of the gradient curve
gizmos to the gizmos examples.

## Showcase

### 2D


![image](https://github.com/user-attachments/assets/01a75706-a7b4-4fc5-98d5-18018185c877)

```rust
    let domain = Interval::EVERYWHERE;
    let curve = function_curve(domain, |t| Vec2::new(t, (t / 25.0).sin() * 100.0));
    let resolution = ((time.elapsed_seconds().sin() + 1.0) * 50.0) as usize;
    let times_and_colors = (0..=resolution)
        .map(|n| n as f32 / resolution as f32)
        .map(|t| (t - 0.5) * 600.0)
        .map(|t| (t, TEAL.mix(&HOT_PINK, (t + 300.0) / 600.0)));
    gizmos.curve_gradient_2d(curve, times_and_colors);
```

### 3D


![image](https://github.com/user-attachments/assets/3fd23983-1ec9-46cd-baed-5b5e2dc935d0)

```rust
    let domain = Interval::EVERYWHERE;
    let curve = function_curve(domain, |t| {
        (Vec2::from((t * 10.0).sin_cos())).extend(t - 6.0)
    });
    let resolution = ((time.elapsed_seconds().sin() + 1.0) * 100.0) as usize;
    let times_and_colors = (0..=resolution)
        .map(|n| n as f32 / resolution as f32)
        .map(|t| t * 5.0)
        .map(|t| (t, TEAL.mix(&HOT_PINK, t / 5.0)));
    gizmos.curve_gradient_3d(curve, times_and_colors);
```
2024-08-29 16:48:22 +00:00
..
primitives Improve the gizmo for Plane3d, reusing grid (#14650) 2024-08-29 15:51:36 +00:00
aabb.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
arcs.rs Gizmos: arc_2d utility helpers (#14932) 2024-08-28 11:33:11 +00:00
arrows.rs Fix Gizmos warnings and doc errors when a subset of features are selected (#14887) 2024-08-23 16:19:06 +00:00
circles.rs Use Isometry in bevy_gizmos wherever we can (#14676) 2024-08-28 01:37:19 +00:00
config.rs Fix Gizmos warnings and doc errors when a subset of features are selected (#14887) 2024-08-23 16:19:06 +00:00
cross.rs Use Isometry in bevy_gizmos wherever we can (#14676) 2024-08-28 01:37:19 +00:00
curves.rs Curve gizmos integration (#14971) 2024-08-29 16:48:22 +00:00
gizmos.rs Use Isometry in bevy_gizmos wherever we can (#14676) 2024-08-28 01:37:19 +00:00
grid.rs Improve the gizmo for Plane3d, reusing grid (#14650) 2024-08-29 15:51:36 +00:00
lib.rs Curve gizmos integration (#14971) 2024-08-29 16:48:22 +00:00
light.rs Use Isometry in bevy_gizmos wherever we can (#14676) 2024-08-28 01:37:19 +00:00
line_joints.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
lines.wgsl view.inverse_clip_from_world should be world_from_clip (#13756) 2024-06-09 14:40:14 +00:00
pipeline_2d.rs Make TrackedRenderPass::set_vertex_buffer aware of slice size (#14916) 2024-08-28 11:41:42 +00:00
pipeline_3d.rs Make TrackedRenderPass::set_vertex_buffer aware of slice size (#14916) 2024-08-28 11:41:42 +00:00
rounded_box.rs Use Isometry in bevy_gizmos wherever we can (#14676) 2024-08-28 01:37:19 +00:00