Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing a better example for Mesh-building in docs. #8885

Merged
merged 7 commits into from
Jun 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/bevy_render/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,20 @@ pub struct Mesh {
/// # use bevy_render::render_resource::PrimitiveTopology;
/// fn create_triangle() -> Mesh {
Adamkob12 marked this conversation as resolved.
Show resolved Hide resolved
/// let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
/// mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, vec![[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]]);
/// mesh.set_indices(Some(Indices::U32(vec![0,1,2])));
/// mesh.insert_attribute(
/// Mesh::ATTRIBUTE_POSITION,
/// vec![[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0], [0.0, 0.0, 0.0]]
/// );
/// // We have created 4 vertices, each with it's own position attribute.
Adamkob12 marked this conversation as resolved.
Show resolved Hide resolved
/// mesh.insert_attribute(
/// Mesh::ATTRIBUTE_UV_0,
/// vec![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]
/// );
Adamkob12 marked this conversation as resolved.
Show resolved Hide resolved
/// // We have assigned a UV coordinate for each of the 4 vertices we created.
/// // NOTE: Multiple vertices can have the same attribute, but multiple attributes cannot be
/// // of the same vertex.
Adamkob12 marked this conversation as resolved.
Show resolved Hide resolved
/// // We define the triangles using the defined vertices' indices.
/// mesh.set_indices(Some(Indices::U32(vec![0,1,2 , 0,1,3])));
Adamkob12 marked this conversation as resolved.
Show resolved Hide resolved
/// mesh
/// }
/// ```
Expand Down