struct
Mesh
pub struct Mesh {
pub positions: Vec<f32>,
pub normals: Vec<f32>,
pub uvs: Vec<f32>,
pub colors: Option<Vec<f32>>,
pub joints: Option<Vec<f32>>,
pub weights: Option<Vec<f32>>,
pub attributes: Vec<(String, u8, Vec<f32>)>,
pub indices: Vec<u32>,
}Triangle geometry: positions, normals, texture coordinates, optional colours and skinning, and the indices of its triangles.
Fields
joints
pub joints: Option<Vec<f32>>Skinning: up to four joints per vertex (indices into the skin's joints, as floats) and their weights, four of each per vertex.
attributes
pub attributes: Vec<(String, u8, Vec<f32>)>Extra per-vertex data for custom shaders: (name, components 1–4, values).
Methods
plane
pub fn plane(width: f32, height: f32) -> MeshRectangle in the XY plane facing +Z, as three.js's PlaneGeometry: width along x, height along y. Turn it with rotate-x: -90 to lay it flat as a floor.
sphere
pub fn sphere(radius: f32, segments: u32, rings: u32) -> MeshUV sphere with segments around and rings top-to-bottom.
push_vertex
pub fn push_vertex(&mut self, p: Vec3, n: Vec3, uv: (f32, f32))Add a vertex at p, with normal n and texture coordinate uv.
torus
pub fn torus(radius: f32, tube: f32, segments: u32, rings: u32) -> MeshRing torus in the XZ plane.
torus_knot
pub fn torus_knot(radius: f32, tube: f32, p: u16, q: u16, segments: u32, tube_segments: u32) -> MeshA (p, q) torus knot tube.
icosphere
pub fn icosphere(radius: f32, detail: u8) -> MeshGeodesic sphere: an icosahedron subdivided detail times.
cylinder
pub fn cylinder(radius: f32, height: f32, segments: u32) -> MeshCapped cylinder along Y, centred on the origin.
cone
pub fn cone(radius: f32, height: f32, segments: u32) -> MeshCapped cone along Y (apex at the top), centred on the origin.
append
pub fn append(&mut self, other: &Mesh, m: &Mat4)Append other, its positions and normals through m.
compute_normals
pub fn compute_normals(&mut self)Smooth normals from the triangles (area-weighted), for meshes that came without any.