Created
July 5, 2021 16:36
-
-
Save mattdesl/3f81b85dd46e170b3a58906136cf4a03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Project 3D points to 2D | |
const vertices2D = vertices.map(p => project(p)); | |
// Draw each cell | |
for (let cell of cells) { | |
// Get the 2D points that define this triangle or quad | |
const points2D = cell.map(idx => vertices2D[idx]); | |
// Draw this polygon | |
context.beginPath(); | |
for (let [x, y] of points2D) { | |
context.lineTo(x, y); | |
} | |
context.closePath(); | |
context.stroke(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment