pub struct Mesh2DFile {
pub pos_attr: Pos2DATTR,
pub layer: u8,
pub aspect: f32,
pub col_attr: ColATTR,
pub uvm_attr: UVMATTR,
pub ind_attr: IndATTR,
pub cus_attrs: Vec<CustomATTR>,
}Expand description
CPU-side 2D mesh geometry — positions, UVs, colours, indices, layer, and centre.
Mesh2DFile is the 2D counterpart of Mesh3DFile. It adds:
- A
layerfield for draw-order sorting. - An
aspectratio andCenterenumeration for positioning.
§Generated primitives
Fields§
§pos_attr: Pos2DATTR§layer: u8§aspect: f32§col_attr: ColATTR§uvm_attr: UVMATTR§ind_attr: IndATTR§cus_attrs: Vec<CustomATTR>Implementations§
Source§impl Mesh2DFile
impl Mesh2DFile
Sourcepub fn set_pos_attr(&mut self, attr: Pos2DATTR)
pub fn set_pos_attr(&mut self, attr: Pos2DATTR)
Replaces the position attribute.
Sourcepub fn set_center(&mut self, center: Center)
pub fn set_center(&mut self, center: Center)
Offsets all vertex positions by the centre vector.
Sourcepub fn set_col_attr(&mut self, attr: ColATTR)
pub fn set_col_attr(&mut self, attr: ColATTR)
Replaces the colour attribute.
Sourcepub fn set_uvm_attr(&mut self, attr: UVMATTR)
pub fn set_uvm_attr(&mut self, attr: UVMATTR)
Replaces the UV attribute.
Sourcepub fn set_ind_attr(&mut self, attr: IndATTR)
pub fn set_ind_attr(&mut self, attr: IndATTR)
Replaces the index attribute.
Sourcepub fn quad(size: &Size2D) -> Self
pub fn quad(size: &Size2D) -> Self
Creates a textured quad sized to fill the given canvas area.
The quad’s aspect ratio matches the canvas, and it is centred by default. Used for rendering sprites or UI elements where the quad should preserve the canvas’s proportions in NDC space.
§Conventions
- Position — 2D in NDC-like space (aspect-ratio aware).
- UVs — full
[0,1]²coverage. - Topology — 2 triangles, 4 vertices.
Sourcepub fn fullscreen_quad() -> Self
pub fn fullscreen_quad() -> Self
Creates a quad covering the entire NDC space (-1 to +1 on both axes).
Useful for full-screen post-processing effects.
Sourcepub fn attach_custom_attr(&mut self, attr: CustomATTR)
pub fn attach_custom_attr(&mut self, attr: CustomATTR)
Attaches a custom per-vertex attribute.
Sourcepub fn circle(radius: f32, segments: u32) -> Self
pub fn circle(radius: f32, segments: u32) -> Self
Creates a circle approximated by a regular polygon.
The first vertex is at the centre, creating a fan topology.
Sourcepub fn ring(inner_radius: f32, outer_radius: f32, segments: u32) -> Self
pub fn ring(inner_radius: f32, outer_radius: f32, segments: u32) -> Self
Creates an annular (ring) shape with inner and outer radii.
Sourcepub fn rect(width: f32, height: f32) -> Self
pub fn rect(width: f32, height: f32) -> Self
Creates a rectangle centred at the origin with the given dimensions.
This is a 2D quad in world-space units (not NDC). Use for billboards, 2D physics bodies, or UI elements that need precise world-space sizing.
§Conventions
- Position — 2D world-space, centred.
- UVs — full
[0,1]²coverage. - Topology — 2 triangles, 4 vertices.
Sourcepub fn starts_with_custom(&self) -> bool
pub fn starts_with_custom(&self) -> bool
Returns true if no built-in vertex attributes are populated.
Sourcepub fn ship(&self) -> MeshHandle
pub fn ship(&self) -> MeshHandle
Interleaves vertex attributes and uploads to the GPU.
Auto Trait Implementations§
impl Freeze for Mesh2DFile
impl RefUnwindSafe for Mesh2DFile
impl Send for Mesh2DFile
impl Sync for Mesh2DFile
impl Unpin for Mesh2DFile
impl UnsafeUnpin for Mesh2DFile
impl UnwindSafe for Mesh2DFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more