Просмотр исходного кода

解决重复点击新建墙再拖动旋转主体不正确问题

zhibin 7 лет назад
Родитель
Сommit
df3ea15553
3 измененных файлов с 20 добавлено и 6 удалено
  1. 3 0
      libs/Build/Build.js
  2. 16 4
      libs/Controls/Pan.js
  3. 1 2
      libs/Renderer/Canvas.js

+ 3 - 0
libs/Build/Build.js

@@ -487,6 +487,9 @@ Build.prototype.adjustEndPoint2 = function (exceptid, currentwallid) {
 			}
 			else {
 				join2 = this.layer.calculateLine.isjoin(seg2, _seg1);
+
+				if (!join2) return;
+
 				if (BABYLON.Vector2.Distance(_seg1.point2, join1) < BABYLON.Vector2.Distance(_seg1.point2, join2)) {
 					this.layer.vectors[exceptid].geometry.wallInfo[0].newborder1 = join1;
 					join2 = this.layer.calculateLine.isjoin(seg1, _seg2);

+ 16 - 4
libs/Controls/Pan.js

@@ -79,7 +79,7 @@ Pan.prototype.startPan = (function() {
 				this.build.finishWall();
 			} else { //开始画墙
 				this.build.buildwallState = 2;
-				this.build.BuildingWall(point);
+				this.build.BuildingWall(args.point);
 			}
 			this.layer.control.refreshCanvas = true;
 		},
@@ -122,6 +122,7 @@ Pan.prototype.startPan = (function() {
 				// this.f_draggingBackGround = true;
 			}
 
+			console.log(this.currentState.selectWallSet)
 			//当前选择墙面
 			if (this.currentState.selectWallSet != null && this.currentState.selectWallSet.type == 1) {
 				this.f_draggingBackGround = false;
@@ -240,8 +241,9 @@ Pan.prototype.pan = function () {
 		},
 		// 拖拽墙面的角度
 		f_draggingWallCorner: function (args) {
+			// console.log()
 			this.move.moveWallcorner(
-				args.wallid, 
+				this.currentState.selectWallSet.id,
 				this.currentState.currentstartlinePointIndex, 
 				args.point
 			);
@@ -293,8 +295,10 @@ Pan.prototype.pan = function () {
 					strategy.__selectStair(args)
 
 			} else if (this.layer.data2d.wallIds.length > 0) {
+				
 				//当前点是否在墙上
 				this.currentState.selectWallSet = this.calculateElement.wallsContain(args.point);
+				this.currentState.selectWallSet && console.log(this.currentState.selectWallSet)
 
 				this.currentState.selectWallSet ?
 					strategy.__selectWallSet(args) : 
@@ -478,7 +482,6 @@ Pan.prototype.pan = function () {
 		
 		for (var i = 0, keys = Object.keys(strategy); i < keys.length; i++) {
 			if (this[keys[i]]) {
-				console.log(this[keys[i]])
 				strategy[keys[i]](args);
 				break;
 			}
@@ -604,7 +607,16 @@ Pan.prototype.active = function () {
 	this.div.addEventListener("mousedown", Pan.prototype.startPan.bind(this), true);
 	this.div.addEventListener("mousemove", Pan.prototype.pan.bind(this), true);
 	this.div.addEventListener("mouseup", Pan.prototype.endPan.bind(this), true);
-	this.div.addEventListener("dblclick", Pan.prototype.doubleclick.bind(this), true);
+
+	var doubleclick = Pan.prototype.doubleclick.bind(this)
+	var startTime = null
+	this.div.addEventListener("click", function() {
+		if (startTime && Date.now() - startTime <= 300) {
+			doubleclick.apply(this, arguments)
+		} else {
+			startTime = Date.now()
+		}
+	}, true);
 };
 
 Pan.prototype.reset = function () {

+ 1 - 2
libs/Renderer/Canvas.js

@@ -66,8 +66,7 @@ Canvas.prototype.addGrid = function () {
 	};
 	leftdown = this.layer.getPositionFromPx(leftdown);
 	rightup = this.layer.getPositionFromPx(rightup);
-
-	console.log(leftdown, rightup)
+	
 	var Maxh = height;
 	var Maxw = width;
 	var Minw = 0;