Function plexus::primitive::zip_vertices
source · [−]pub fn zip_vertices<T, U>(
tuple: U
) -> impl Iterator<Item = <<OuterZip<T> as Iterator>::Item as Zip>::Output> where
OuterZip<T>: From<U> + Iterator,
<OuterZip<T> as Iterator>::Item: Zip,
Expand description
Zips the vertices of Topological
types from multiple iterators into a
single iterator.
This is useful for zipping different geometric attributes of a
generator. For example, it can be used to combine position,
plane, and normal data data of a Cube
into a single topology iterator.
Examples
Zip position, normal, and plane attributes of a cube:
use decorum::N64;
use nalgebra::Point3;
use plexus::prelude::*;
use plexus::primitive;
use plexus::primitive::cube::{Cube, Plane};
use plexus::primitive::generate::{Normal, Position};
type E3 = Point3<N64>;
let cube = Cube::new();
// Zip positions and texture coordinates into each vertex.
let polygons = primitive::zip_vertices((
cube.polygons::<Position<E3>>(),
cube.polygons::<Normal<E3>>(),
cube.polygons::<Plane>(),
))
.triangulate()
.collect::<Vec<_>>();