浏览代码

Merge remote-tracking branch 'origin/master'

bill 2 年之前
父节点
当前提交
84a7201529
共有 1 个文件被更改,包括 14 次插入10 次删除
  1. 14 10
      src/graphic/Service/CurveRoadService.js

+ 14 - 10
src/graphic/Service/CurveRoadService.js

@@ -9,6 +9,8 @@ import RoadService from "./RoadService";
 import { lineService } from "./LineService";
 import { uiService } from "./UIService";
 
+const offsetDis = 50;
+
 export default class CurveRoadService extends RoadService {
   constructor() {
     super();
@@ -72,14 +74,16 @@ export default class CurveRoadService extends RoadService {
     rightEdge.points.push(edgePoints.rightEdgeStart);
     rightEdge.points.push(edgePoints.rightEdgeEnd);
 
-    this.addCPoint(
-      curveRoad,
-      {
-        x: (startPoint.x + endPoint.x) / 2,
-        y: (startPoint.y + endPoint.y) / 2,
-      },
-      0
-    );
+    //得有点曲率
+    const midPoint = {
+      x: (startPoint.x + endPoint.x) / 2,
+      y: (startPoint.y + endPoint.y) / 2,
+    };
+    const line = mathUtil.createLine1(startPoint, endPoint);
+    let parallelLines = mathUtil.getParallelLineForDistance(line, offsetDis);
+    const join = mathUtil.getJoinLinePoint(midPoint, parallelLines.line1);
+
+    this.addCPoint(curveRoad, join, 0);
     this.setLanes(curveRoad.vectorId);
     return curveRoad;
   }
@@ -171,11 +175,11 @@ export default class CurveRoadService extends RoadService {
     rightEdge.points.push(edgePoints.rightEdgeStart);
     rightEdge.points.push(edgePoints.rightEdgeEnd);
 
-    for (let i = 1; i < newCurveRoad.points.length - 1; ++i) {
+    for (let i = 1; i < curveRoad.points.length - 1; ++i) {
       this.addCPoint(
         newCurveRoad,
         uiService.getNewPositionForPop(curveRoad.points[i]),
-        curveRoad.points[i].getIndex()
+        curveRoad.points[i].getIndex() - 1
       );
     }