[][src]Function plexus::primitive::zip_vertices

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

Zips the vertices and topologies from multiple iterators into a single iterator.

This is useful for zipping different attributes of a primitive generator. For example, it can be used to combine position, plane, and normal data data of a cube into a single topology stream.

Examples

Zip position, normal, and plane data for 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<_>>();