[][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 UV-mapping data data of a cube into a single topology stream.

Examples

Create a topological stream of position and UV-mapping data for a cube:

use decorum::R64;
use plexus::prelude::*;
use plexus::primitive;
use plexus::primitive::cube::Cube;

fn map_uv_to_color(uv: &Duplet<R64>) -> Triplet<R64> {
    // ...
}

let cube = Cube::new();
let polygons =
    // Zip positions and texture coordinates into each vertex.
    primitive::zip_vertices((cube.polygons_with_position(), cube.polygons_with_uv_map()))
        .map_vertices(|(position, uv)| (position, uv, map_uv_to_color(&uv)))
        .triangulate()
        .collect::<Vec<_>>();