(simplex, pixelCoord, model, view, projection, resolution)
| 16858 | } |
| 16859 | |
| 16860 | function closestPointToPickLocation(simplex, pixelCoord, model, view, projection, resolution) { |
| 16861 | if(simplex.length === 1) { |
| 16862 | return [0, simplex[0].slice()] |
| 16863 | } |
| 16864 | var simplex2D = new Array(simplex.length) |
| 16865 | for(var i=0; i<simplex.length; ++i) { |
| 16866 | simplex2D[i] = projectVertex(simplex[i], model, view, projection, resolution); |
| 16867 | } |
| 16868 | |
| 16869 | var closestIndex = 0 |
| 16870 | var closestDist = Infinity |
| 16871 | for(var i=0; i<simplex2D.length; ++i) { |
| 16872 | var d2 = 0.0 |
| 16873 | for(var j=0; j<2; ++j) { |
| 16874 | d2 += Math.pow(simplex2D[i][j] - pixelCoord[j], 2) |
| 16875 | } |
| 16876 | if(d2 < closestDist) { |
| 16877 | closestDist = d2 |
| 16878 | closestIndex = i |
| 16879 | } |
| 16880 | } |
| 16881 | |
| 16882 | var weights = barycentricCoord(simplex2D, pixelCoord) |
| 16883 | var s = 0.0 |
| 16884 | for(var i=0; i<3; ++i) { |
| 16885 | if(weights[i] < -0.001 || |
| 16886 | weights[i] > 1.0001) { |
| 16887 | return null |
| 16888 | } |
| 16889 | s += weights[i] |
| 16890 | } |
| 16891 | if(Math.abs(s - 1.0) > 0.001) { |
| 16892 | return null |
| 16893 | } |
| 16894 | return [closestIndex, interpolate(simplex, weights), weights] |
| 16895 | } |
| 16896 | |
| 16897 | /***/ }), |
| 16898 |
nothing calls this directly
no test coverage detected
searching dependent graphs…