(bounds, resolution)
| 98862 | 1 |
| 98863 | ]); |
| 98864 | function createMesh(bounds, resolution) { |
| 98865 | if (!resolution) return createQuad(bounds); |
| 98866 | var maxXSpan = Math.max(Math.abs(bounds[0][0] - bounds[3][0]), Math.abs(bounds[1][0] - bounds[2][0])); |
| 98867 | var maxYSpan = Math.max(Math.abs(bounds[1][1] - bounds[0][1]), Math.abs(bounds[2][1] - bounds[3][1])); |
| 98868 | var uCount = Math.ceil(maxXSpan / resolution) + 1; |
| 98869 | var vCount = Math.ceil(maxYSpan / resolution) + 1; |
| 98870 | var vertexCount = (uCount - 1) * (vCount - 1) * 6; |
| 98871 | var indices = new Uint32Array(vertexCount); |
| 98872 | var texCoords = new Float32Array(uCount * vCount * 2); |
| 98873 | var positions = new Float64Array(uCount * vCount * 3); |
| 98874 | var vertex = 0; |
| 98875 | var index = 0; |
| 98876 | for(var u = 0; u < uCount; u++){ |
| 98877 | var ut = u / (uCount - 1); |
| 98878 | for(var v = 0; v < vCount; v++){ |
| 98879 | var vt = v / (vCount - 1); |
| 98880 | var p = interpolateQuad(bounds, ut, vt); |
| 98881 | positions[vertex * 3 + 0] = p[0]; |
| 98882 | positions[vertex * 3 + 1] = p[1]; |
| 98883 | positions[vertex * 3 + 2] = p[2] || 0; |
| 98884 | texCoords[vertex * 2 + 0] = ut; |
| 98885 | texCoords[vertex * 2 + 1] = 1 - vt; |
| 98886 | if (u > 0 && v > 0) { |
| 98887 | indices[index++] = vertex - vCount; |
| 98888 | indices[index++] = vertex - vCount - 1; |
| 98889 | indices[index++] = vertex - 1; |
| 98890 | indices[index++] = vertex - vCount; |
| 98891 | indices[index++] = vertex - 1; |
| 98892 | indices[index++] = vertex; |
| 98893 | } |
| 98894 | vertex++; |
| 98895 | } |
| 98896 | } |
| 98897 | return { |
| 98898 | vertexCount: vertexCount, |
| 98899 | positions: positions, |
| 98900 | indices: indices, |
| 98901 | texCoords: texCoords |
| 98902 | }; |
| 98903 | } |
| 98904 | exports.default = createMesh; |
| 98905 | function createQuad(bounds) { |
| 98906 | var positions = new Float64Array(12); |
nothing calls this directly
no test coverage detected