瀏覽代碼

code style

bdestombes 2 年之前
父節點
當前提交
c803646fdc
共有 1 個文件被更改,包括 33 次插入29 次删除
  1. 33 29
      backend/server.js

+ 33 - 29
backend/server.js

@@ -90,9 +90,15 @@ function getTop(dotTrio) {
 	const diff01m12 = Math.abs(dist01 - dist12);
 	const diff02m12 = Math.abs(dist02 - dist12);
 
-	if (diff01m02 < diff02m12 && diff01m02 < diff01m12) {return 0;}
-	else if (diff01m12<diff01m02 && diff01m12<diff02m12) {return 1;}
-	else if (diff02m12<diff01m02 && diff02m12<diff01m12) {return 2;}
+	if (diff01m02 < diff02m12 && diff01m02 < diff01m12) {
+		return 0;
+	}
+	else if (diff01m12 < diff01m02 && diff01m12 < diff02m12) {
+		return 1;
+	}
+	else if (diff02m12 < diff01m02 && diff02m12 < diff01m12) {
+		return 2;
+	}
 }
 
 function getAngleApex(dotTrio, topIndex) {
@@ -113,8 +119,8 @@ function getAngleApex(dotTrio, topIndex) {
 		dotC = dotTrio[1];
 	}
 
-	const AB = [dotB.x - dotA.x, dotB.y - dotA.y] ;
-	const CB = [dotB.x - dotC.x, dotB.y - dotC.y] ;
+	const AB = [dotB.x - dotA.x, dotB.y - dotA.y];
+	const CB = [dotB.x - dotC.x, dotB.y - dotC.y];
 
 	const dotProd = (AB[0] * CB[0] + AB[1] * CB[1]);
 	const crossProd = (AB[0] * CB[1] - AB[1] * CB[0]);
@@ -396,34 +402,32 @@ app.post('/emitter/json', function (req, res) {
 			// });
 			oscBundle = new Bundle ;
 			oscBundle.append([ '/tuio/2Dobj', 'alive', 1 ]);
-			if (objTriangle.dots != undefined){
+			if (objTriangle.dots != undefined) {
 				oscBundle.append([
-						'/tuio/2Dobj',
-						'set',
-						1,
-						1,
-						objTriangle.center[0],
-						objTriangle.center[1],
-						objTriangle.orientation,
-						0.0,
-						0.0,
-						0.0,
-						0.0,
-						0.0
-					]);
-				}
-				oscBundle.append([ '/tuio/2Dobj', 'fseq', fseq ]);
-				emitterOscClient.send(oscBundle, () => {
-					res.status(200).send();
-				});
-			} else {
-				res.status(400).send();
+					'/tuio/2Dobj',
+					'set',
+					1,
+					1,
+					objTriangle.center[0],
+					objTriangle.center[1],
+					objTriangle.orientation,
+					0.0,
+					0.0,
+					0.0,
+					0.0,
+					0.0
+				]);
 			}
+			oscBundle.append([ '/tuio/2Dobj', 'fseq', fseq ]);
+			emitterOscClient.send(oscBundle, () => {
+				res.status(200).send();
+			});
+		} else {
+			res.status(400).send();
+		}
 	}
 });
 
-
-
 httpServer.listen(config.app.httpPort, function () {
- console.log(`Votre app est disponible sur localhost:${config.app.httpPort} !`)
+	console.log(`Votre app est disponible sur http://localhost:${config.app.httpPort} !`)
 });