Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active July 5, 2021 17:11
Embed
What would you like to do?
// Number of horizontal and vertical slices
const subdivisions = 20;
// Calculate vertices at each grid point and gather the triangle indices of the mesh
// We pass our 'parametricTerrain' function in as an input to the generator
const [ vertices, cells ] = generateGeometry(parametricTerrain, subdivisions);
// vertices are 3D positions on the surface
// [ [ x0, y0, z0 ], [ x1, y1, z1 ], ... ]
// cells are indices into the above array, defining triangles
// [ [ 0, 1, 3 ], [ 1, 4, 3 ], [ 1, 2, 4 ], ... ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment