Jelajahi Sumber

继续绘图

xushiting 2 tahun lalu
induk
melakukan
ef17374213
1 mengubah file dengan 17 tambahan dan 0 penghapusan
  1. 17 0
      src/graphic/Service/CurveRoadService.js

+ 17 - 0
src/graphic/Service/CurveRoadService.js

@@ -122,6 +122,11 @@ export default class CurveRoadService extends RoadService {
       rightCurveEdge.points[startIndex + 1]
     );
 
+    const line = mathUtil.createLine1(
+      curveRoad.points[startIndex],
+      curveRoad.points[startIndex + 2]
+    );
+
     if (
       mathUtil.Angle(
         curveRoad.points[startIndex + 1],
@@ -129,11 +134,19 @@ export default class CurveRoadService extends RoadService {
         curveRoad.points[startIndex + 2]
       ) > Constant.maxAngle
     ) {
+      const join = mathUtil.getJoinLinePoint(position, line);
+      let dx = position.x - join.x;
+      let dy = position.y - join.y;
+
       leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
+      leftJoin.x += dx;
+      leftJoin.y += dy;
       leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
       curveEdgeService.setCurves(leftCurveEdge);
 
       rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
+      rightJoin.x += dx;
+      rightJoin.y += dy;
       rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
       curveEdgeService.setCurves(rightCurveEdge);
 
@@ -143,6 +156,8 @@ export default class CurveRoadService extends RoadService {
           curveRoad.leftLanes[i][startIndex + 1]
         );
         leftJoin = mathUtil.getJoinLinePoint(position, leftLaneLine);
+        leftJoin.x += dx;
+        leftJoin.y += dy;
         curveRoad.leftLanes[i].splice(startIndex + 1, 0, leftJoin);
         curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
           curveRoad.leftLanes[i]
@@ -155,6 +170,8 @@ export default class CurveRoadService extends RoadService {
           curveRoad.rightLanes[i][startIndex + 1]
         );
         rightJoin = mathUtil.getJoinLinePoint(position, rightLaneLine);
+        rightJoin.x += dx;
+        rightJoin.y += dy;
         curveRoad.rightLanes[i].splice(startIndex + 1, 0, rightJoin);
         curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
           curveRoad.rightLanes[i]