Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active July 5, 2021 17:11
Show Gist options
  • Save mattdesl/6c421c2d678b000fe9c208a254c7d504 to your computer and use it in GitHub Desktop.
Save mattdesl/6c421c2d678b000fe9c208a254c7d504 to your computer and use it in GitHub Desktop.
// 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