-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move wireframe mesh transform into separate file
- Loading branch information
Showing
3 changed files
with
37 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Rearranges element array for triangles into a new element array that draws a wireframe | ||
// Used for debugging | ||
export default function makeWireframeForTriangleElementData (element_data) { | ||
const wireframe_data = new Uint16Array(element_data.length * 2); | ||
|
||
// Draw triangles as lines: | ||
// Make a copy of element_data, and for every group of three vertices, duplicate | ||
// each vertex according to the following pattern: | ||
// [1, 2, 3] => [1, 2, 2, 3, 3, 1] | ||
// This takes three vertices which would have been interpreted as a triangle, | ||
// and converts them into three 2-vertex line segments. | ||
for (let i = 0; i < element_data.length; i += 3) { | ||
wireframe_data.set( | ||
[ | ||
element_data[i], | ||
element_data[i+1], | ||
element_data[i+1], | ||
element_data[i+2], | ||
element_data[i+2], | ||
element_data[i] | ||
], | ||
i * 2 | ||
); | ||
} | ||
return wireframe_data; | ||
} |
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
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