UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

46 lines (32 loc) 1.22 kB
/** * resolve ordering and edge number * @param {number[]} out * @param {number} out_offset * @param {number[]} indices * @param {number} indices_offset * @param {number} i0_in * @param {number} i1_in * @returns {void} */ export function GetEdge(out, out_offset, indices, indices_offset, i0_in, i1_in) { // test if first index is on the edge const index_0 = indices[indices_offset]; const index_1 = indices[indices_offset + 1]; if (index_0 === i0_in || index_0 === i1_in) { // test if second index is on the edge if (index_1 === i0_in || index_1 === i1_in) { out[out_offset + 2] = 0; // first edge out[out_offset] = index_0; //i0 out[out_offset + 1] = index_1; //i1 } else { out[out_offset + 2] = 2; // third edge out[out_offset] = indices[indices_offset + 2]; //i0 out[out_offset + 1] = index_0; //i1 } } else { // only second and third index is on the edge out[out_offset + 2] = 1; // second edge out[out_offset] = index_1; //i0 out[out_offset + 1] = indices[indices_offset + 2]; //i1 } }