Skip to content

Conversation

@kfc35
Copy link
Contributor

@kfc35 kfc35 commented Dec 30, 2025

Objective

Solution

Testing

  • Ran cargo run --example 3d_gizmos --features=free_camera and saw that the green 3d square gizmo now closes
Screenshot 2025-12-30 at 4 06 41 PM
Modified Demo for Triangle 3d
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, draw_shapes)
        .run();
}

fn setup(
    mut config_store: ResMut<GizmoConfigStore>,
    mut commands: Commands
)
{
    let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
    config.line.width = 10.0;
    config.line.joints = GizmoLineJoint::Miter;

    commands.spawn((Camera3d::default(), 
        Transform::from_xyz(0.0, 0.0, -5.0).looking_at(Vec3::ZERO, Vec3::Z)));
}

fn draw_shapes(mut gizmos: Gizmos) {
    gizmos.primitive_3d(
        &Triangle3d { vertices: [Vec3::ZERO, Vec3::new(1.0, 0., 0.), Vec3::new(0.0, 1.0, 0.) ] },
        Vec3::new(0.0, 0.0, 0.),
        Color::srgb_u8(0xFF, 0, 0)
    );
}

Before (notice notch in bottom left hand corner):
Screenshot 2025-12-30 at 2 46 36 PM

After (notch in bottom left hand corner is gone):
Screenshot 2025-12-30 at 2 47 28 PM

@kfc35 kfc35 marked this pull request as draft December 30, 2025 20:09
@kfc35 kfc35 force-pushed the 22204_3d_gizmos_closed_shapes branch from 24e9b0a to 892caff Compare December 30, 2025 20:10
@kfc35 kfc35 marked this pull request as ready for review December 30, 2025 20:19
@JMS55 JMS55 requested a review from atlv24 December 31, 2025 03:18
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it A-Gizmos Visual editor and debug gizmos labels Dec 31, 2025
@alice-i-cecile alice-i-cecile added the C-Code-Quality A section of code that is hard to understand or change label Dec 31, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 31, 2025
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Dec 31, 2025
Merged via the queue into bevyengine:main with commit 1537f8c Dec 31, 2025
46 checks passed
cart pushed a commit that referenced this pull request Jan 8, 2026
# Objective

- Fixes #22204 

## Solution

- Refactored the solution from #22085 and made it use 3 dimensions; have
2d `lineloop` delegate to the 3d one.
- Updated any relevant usages of `linestrip` to use `lineloop` (rect and
`GizmoPrimitive3d<Triangle3d>`). `GizmoPrimitive3d<Polyline3d>`, cube(),
and aabb3d() still use `linestrip`. As far as I could tell, the cube
looked ok for all corners in the `3d_gizmos` example (the black cube in
the center of the scene) but another pair of eyes could be helpful
there.
- This does not do anything for #22095 !

## Testing

- Ran `cargo run --example 3d_gizmos --features=free_camera` and saw
that the green 3d square gizmo now closes
<img width="1063" height="182" alt="Screenshot 2025-12-30 at 4 06 41 PM"
src="https://github.com/user-attachments/assets/5f9f4337-d1fe-4c2e-98c0-2d83fe4b0ea6"
/>

- Ran the demo in #22085 and ensured no regressions for 2d_gizmos
- Ran a modified demo for `Triangle3d` and verified that `Triangle3d`
now closes
<details>
  <summary>Modified Demo for Triangle 3d</summary>

```rust
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, draw_shapes)
        .run();
}

fn setup(
    mut config_store: ResMut<GizmoConfigStore>,
    mut commands: Commands
)
{
    let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
    config.line.width = 10.0;
    config.line.joints = GizmoLineJoint::Miter;

    commands.spawn((Camera3d::default(), 
        Transform::from_xyz(0.0, 0.0, -5.0).looking_at(Vec3::ZERO, Vec3::Z)));
}

fn draw_shapes(mut gizmos: Gizmos) {
    gizmos.primitive_3d(
        &Triangle3d { vertices: [Vec3::ZERO, Vec3::new(1.0, 0., 0.), Vec3::new(0.0, 1.0, 0.) ] },
        Vec3::new(0.0, 0.0, 0.),
        Color::srgb_u8(0xFF, 0, 0)
    );
}
```

Before (notice notch in bottom left hand corner):
<img width="369" height="308" alt="Screenshot 2025-12-30 at 2 46 36 PM"
src="https://github.com/user-attachments/assets/3b073b9e-7145-4eef-b070-13a56376b17f"
/>


After (notch in bottom left hand corner is gone):
<img width="361" height="339" alt="Screenshot 2025-12-30 at 2 47 28 PM"
src="https://github.com/user-attachments/assets/47494176-b212-42ac-82b0-f042c94941f3"
/>

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bevy 3d_gizmos doesn't have closed shapes

3 participants