Skip to content

1.1.0

Latest
Compare
Choose a tag to compare
@ianmackenzie ianmackenzie released this 18 Oct 21:10

This release brings some new functions for conveniently creating meshes of various common forms without having to use the general TriangularMesh.indexed constructor. The simplest function is grid:

TriangularMesh.grid : Int -> Int -> (Float -> Float -> vertex) -> TriangularMesh vertex

This lets you easily create meshes in the form of rectangular grids, by passing the number of steps to take in the U (horizontal) and V (vertical) directions, and a function that will get called to create vertices at different U and V values (which each range from 0 to 1). For example, TriangularMesh.grid 3 2 f will produce a mesh like

Rectangular grid

There are also tube, ring and ball functions (with the same function signature as grid) for creating meshes that are topologically equivalent to a cylinder, torus and sphere respectively (where the mesh 'wraps around' in certain directions).

In addition, each of the above functions comes in an indexed version, for example:

TriangularMesh.indexedGrid : Int -> Int -> (Int -> Int -> vertex) -> TriangularMesh vertex

The indexed versions behave exactly the same, but instead of passing floating-point U/V values to the callback function, they pass integer U/V indices:

Rectangular grid

Finally, a TriangularMesh.radial function has been added that behaves just like TriangularMesh.fan, but joins the last vertex back to the first to form a closed shape (useful for creating cone-like shapes):

TriangularMesh.radial : vertex -> List vertex -> TriangularMesh vertex