|
@@ -1560,6 +1560,8 @@ export default class MathUtil {
|
|
|
|
|
|
getIndexForCurvesPoints(position, points) {
|
|
|
let minDis = null;
|
|
|
+ let minDisToPoint = null;
|
|
|
+ let minPointIndex = -1;
|
|
|
let index = -1;
|
|
|
for (let i = 0; i < points.length - 1; ++i) {
|
|
|
const line = this.createLine1(points[i], points[i + 1]);
|
|
@@ -1571,8 +1573,26 @@ export default class MathUtil {
|
|
|
index = i;
|
|
|
}
|
|
|
}
|
|
|
+ if (minDisToPoint == null) {
|
|
|
+ minDisToPoint = mathUtil.getDistance(position, points[i]);
|
|
|
+ minPointIndex = i;
|
|
|
+ } else if (minDisToPoint > mathUtil.getDistance(position, points[i])) {
|
|
|
+ minDisToPoint = mathUtil.getDistance(position, points[i]);
|
|
|
+ minPointIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((index = -1)) {
|
|
|
+ if (
|
|
|
+ minDisToPoint >
|
|
|
+ mathUtil.getDistance(position, points[points.length - 1])
|
|
|
+ ) {
|
|
|
+ return points.length - 1;
|
|
|
+ } else {
|
|
|
+ return minPointIndex;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return index;
|
|
|
}
|
|
|
- return index;
|
|
|
}
|
|
|
|
|
|
// //获取一组点的偏移
|