Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1x 1x | // ---------------------------------------------------------------------------- // Marching squares case functions (using lines to generate the 2D tessellation). // For each case, a list of edge ids that form the triangles. A -1 marks the // end of the list of edges. Edges are taken three at a time to generate // triangle points. // ---------------------------------------------------------------------------- const MARCHING_SQUARES_CASES = [ [-1, -1, -1, -1, -1] /* 0 */, [0, 3, -1, -1, -1] /* 1 */, [1, 0, -1, -1, -1] /* 2 */, [1, 3, -1, -1, -1] /* 3 */, [2, 1, -1, -1, -1] /* 4 */, [0, 3, 2, 1, -1] /* 5 */, [2, 0, -1, -1, -1] /* 6 */, [2, 3, -1, -1, -1] /* 7 */, [3, 2, -1, -1, -1] /* 8 */, [0, 2, -1, -1, -1] /* 9 */, [1, 0, 3, 2, -1] /* 10 */, [1, 2, -1, -1, -1] /* 11 */, [3, 1, -1, -1, -1] /* 12 */, [0, 1, -1, -1, -1] /* 13 */, [3, 0, -1, -1, -1] /* 14 */, [-1, -1, -1, -1, -1] /* 15 */, ]; const EDGES = [ [0, 1], [1, 3], [2, 3], [0, 2], ]; function getCase(index) { return MARCHING_SQUARES_CASES[index]; } // Define the four edges of the pixel by the following pairs of vertices function getEdge(eid) { return EDGES[eid]; } // ---------------------------------------------------------------------------- // Static API // ---------------------------------------------------------------------------- export default { getCase, getEdge, }; |