Skip to content

Extrudable not implemented for Polygons #15255

@AnjanaYEAH

Description

@AnjanaYEAH

Hi,

Beginner Rust and Bevy developer here!

I don't see why RegularPolygons are extrudable and Polygons are not extrudable https://docs.rs/bevy/latest/bevy/render/mesh/trait.Extrudable.html

The code below does not work with the following error message:

the trait From<bevy::prelude::Extrusion<bevy::prelude::Polygon<_>>> is not implemented for bevy::prelude::Mesh, which is required by bevy::prelude::Extrusion<bevy::prelude::Polygon<_>>: Into<bevy::prelude::Mesh>
fn spawn_polygon(
    mut commands: Commands,
    mut materials: ResMut<Assets<StandardMaterial>>,
    mut meshes: ResMut<Assets<Mesh>>,
) {
    let points2d = vec!
        [
            vec2(-6., 2.),
            vec2(-2., 4.),
            vec2(-3., 5.)
        ];
    let p = Polygon::new(points2d);
    let e = Extrusion::new(p, 2.0);
    let mesh_handle: Handle<Mesh> = meshes.add(e);

    commands.spawn((
        PbrBundle {
            mesh: mesh_handle,
            material: materials.add(StandardMaterial {
               base_color: Srgba::hex("#ffd891").unwrap().into(), 
                ..default()
            }),
            ..default()
        },
        Cube,
    ));
}

I want to be able to create custom polygons and extrude them, not sure why this is not possible at the moment?
Happy to help implement this with some guidance :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MathFundamental domain-agnostic mathematical operationsC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions