12 releases

✓ Uses Rust 2018 edition

0.0.11 Mar 1, 2019
0.0.10 Aug 30, 2018
0.0.9 Jan 21, 2018
0.0.8 Nov 25, 2017
0.0.1 Aug 20, 2017

#31 in Graphics APIs

Download history 5/week @ 2019-02-11 14/week @ 2019-02-18 21/week @ 2019-02-25 18/week @ 2019-03-04 3/week @ 2019-03-11 5/week @ 2019-03-18 68/week @ 2019-03-25 13/week @ 2019-04-01 3/week @ 2019-04-08 5/week @ 2019-04-15 13/week @ 2019-04-22 3/week @ 2019-04-29 12/week @ 2019-05-06 16/week @ 2019-05-13 38/week @ 2019-05-20

72 downloads per month
Used in 1 crate

MIT license

10K SLoC


Plexus is a Rust library for 2D and 3D mesh processing.

Build Status Documentation Crate

Primitives and Iterator Expressions

Streams of geometric data can be generated from primitives like cubes and spheres using iterator expressions. Primitives emit topological structures like Triangles or Quads, which contain arbitrary data in their vertices. These can be transformed and decomposed via tessellation and other operations.

use nalgebra::Point3;
use plexus::buffer::MeshBuffer3;
use plexus::prelude::*;
use plexus::primitive::sphere::UvSphere;

// Example module in the local crate that provides basic rendering.
use render::{self, Color, Vertex};

// Construct a linear buffer of index and vertex data from a sphere primitive.
let buffer = UvSphere::new(16, 16)
    .map_vertices(|position| -> Point3<f64> { position.into() })
    .map_vertices(|position| Vertex::new(position, Color::white()))
    .collect::<MeshBuffer3<u32, Vertex>>();
render::draw(buffer.as_index_slice(), buffer.as_vertex_slice());

For an example of rendering, see the viewer example.

Half-Edge Graph Meshes

MeshGraph, represented as a half-edge graph, supports arbitrary geometry for vertices, arcs (half-edges), edges, and faces. Graphs are persistent and can be traversed and manipulated in ways that iterator expressions and linear buffers cannot, such as circulation, extrusion, merging, and joining.

use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::sphere::{Bounds, UvSphere};

// Construct a mesh from a sphere primitive. The vertex geometry is convertible
// to `Point3` via the `FromGeometry` trait in this example.
let mut graph = UvSphere::new(8, 8)
// Extrude a face in the mesh.
let abc = graph.faces().nth(0).unwrap().key();
if let Ok(face) = graph.face_mut(abc).unwrap().extrude(1.0) {
    // ...

Plexus avoids exposing very basic topological operations like inserting individual vertices, because they can easily be done incorrectly. Instead, meshes are typically manipulated with higher-level operations like splitting and joining.

Geometric Traits

Graphs support arbitrary geometry for vertices, arcs, edges, and faces (including no geometry at all) via optional traits. Implementing these traits enables geometric features, but only one trait is required: Geometry.

use decorum::R64;
use nalgebra::{Point3, Vector3};
use plexus::geometry::convert::AsPosition;
use plexus::geometry::Geometry;

#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub struct VertexGeometry {
    pub position: Point3<R64>,
    pub normal: Vector3<R64>,

impl Geometry for VertexGeometry {
    type Vertex = Self;
    type Arc = ();
    type Edge = ();
    type Face = ();

impl AsPosition for VertexGeometry {
    type Target = Point3<R64>;

    fn as_position(&self) -> &Self::Target {

    fn as_position_mut(&mut self) -> &mut Self::Target {
        &mut self.position

Geometric operations are vertex-based. By implementing AsPosition to expose positional data from vertices and implementing geometric traits for that positional data, operations like extrusion are exposed.

Geometric traits are optionally implemented for types in the cgmath, mint, and nalgebra crates so that common types can be used out-of-the-box for vertex geometry. See the geometry-cgmath, geometry-mint, and geometry-nalgebra crate features. By default, the geometry-nalgebra feature is enabled. Both 2D and 3D geometry are supported by mesh operations.


~52K SLoC