asr@asr.fr 2 سال پیش
والد
کامیت
0a45ca684c
3فایلهای تغییر یافته به همراه19 افزوده شده و 45 حذف شده
  1. 8 1
      backend/server.js
  2. 4 4
      frontend/assets/config.json
  3. 7 40
      frontend/index.html

+ 8 - 1
backend/server.js

@@ -163,11 +163,17 @@ function getOrientation(dotTrio, topIndex) {
 }
 
 function objectGarbageCollector(){
+	//si un point dans last dots est detecté dans un des triangle alors on ne réduit pas sa duration
 	for(const triangle of objectsAlive){
-		triangle.remainingDuration -= 1;
+		if(triangle.dots.some(dot => lastDots.some(lastDot => lastDot.x == lastDot.x))){
+			console.log("---- filter");
+		} else {
+			triangle.remainingDuration -= 1;
+		}
 	};
 	objectsAlive = objectsAlive.filter(triangle => triangle.remainingDuration > 0);
 	createBundle();
+	console.dir(lastDots);
 	console.dir(objectsAlive);
 }
 
@@ -424,6 +430,7 @@ app.post('/emitter/json', function (req, res) {
 
 		res.status(200).send();
 	} else {
+		lastDots = [];
 		res.status(200).send();
 	}
 });

+ 4 - 4
frontend/assets/config.json

@@ -14,7 +14,7 @@
 					"dots": false,
 					"segments": false,
 					"triangles": false,
-					"apex": false,
+					"apex": true,
 					"matchingObject": false,
 					"aliveTriangles": false
 				},
@@ -28,13 +28,13 @@
 					"events": false
 				},
 				"receiver": {
-					"onAddTuioCursor": true,
-					"onUpdateTuioCursor": true,
+					"onAddTuioCursor": false,
+					"onUpdateTuioCursor": false,
 					"onRemoveTuioCursor": false,
 					"onAddTuioObject": true,
 					"onUpdateTuioObject": true,
 					"onRemoveTuioObject": true,
-					"onRefresh": true
+					"onRefresh": false
 				}
 			}
 		},

+ 7 - 40
frontend/index.html

@@ -156,23 +156,12 @@
 				function draw(){
 					context.clearRect(0, 0, canvas.width, canvas.height);
 					for(obj of Object.values(objects)){
-						const apexAngle = 35;
-						const mediatrice = 300;
-
 						if (config.app.debugDisplay) {
 							const apex = {
-								x: Math.cos(obj.angle * Math.PI / 180) * (mediatrice / 2) + obj.xPos,
-								y: Math.sin(obj.angle * Math.PI / 180) * (mediatrice / 2) + obj.yPos
-							};
-							const b = {
-								x: Math.cos((apexAngle / 2) * Math.PI / 180) * (mediatrice / 2) + apex.x,
-								y: Math.sin((apexAngle / 2) * Math.PI / 180) * (mediatrice / 2) + apex.y
+								x: Math.cos(obj.angle * Math.PI /180) * 150 + obj.xPos,
+								y: Math.sin(obj.angle * Math.PI /180) * 150 + obj.yPos
 							};
-							const c = {
-								x: Math.cos((-1 * apexAngle / 2) * Math.PI / 180) * (mediatrice / 2) + apex.x,
-								y: Math.sin((-1 * apexAngle / 2) * Math.PI / 180) * (mediatrice / 2) + apex.y
-							};
-							drawTriangle(apex, b, c, {
+							drawIndicationLine(apex, {
 								x: obj.xPos,
 								y: obj.yPos
 							}, obj.symbolId);
@@ -180,19 +169,14 @@
 					}
 				}
 
-				const drawTriangle = (a, b, c, center, id) => {
-					//
+				const drawIndicationLine = (apex, center, id) => {
 					const path = new Path2D();
-					/*
-					path.moveTo(Math.round(a.x), Math.round(a.y));
-					path.lineTo(Math.round(b.x), Math.round(b.y));
-					path.lineTo(Math.round(c.x), Math.round(c.y));
-					*/
 					path.moveTo(Math.round(center.x), Math.round(center.y));
-					path.lineTo(Math.round(a.x), Math.round(a.y));
+					path.lineTo(Math.round(apex.x), Math.round(apex.y));
 					context.stroke(path);
-					context.fillText(id, Math.round(a.x), Math.round(a.y));
+					context.fillText(id, Math.round(apex.x), Math.round(apex.y));
 				};
+				
 				const client = new Tuio.Client({
 					host: `http://localhost:${config.app.httpPort}`
 				});
@@ -204,11 +188,6 @@
 				},
 
 				onAddTuioCursor = function(addCursor) {
-					/*
-					var $addCursor = $('<div class="tuioCursor"></div>');
-					$('body').append($addCursor);
-					cursors[addCursor.getCursorId()] = $addCursor;
-					*/
 					onUpdateTuioCursor(addCursor);
 					if (config.app.debug && config.app.debugLog.frontend.receiver.onAddTuioCursor) {
 						console.log('addTuioCursor', addCursor);
@@ -216,24 +195,12 @@
 				},
 
 				onUpdateTuioCursor = function(updateCursor) {
-					/*
-					var $updateCursor = cursors[updateCursor.getCursorId()];
-					$updateCursor.css({
-						left: updateCursor.getScreenX(screenW),
-						top: updateCursor.getScreenY(screenH)
-					});
-					*/
 					if (config.app.debug && config.app.debugLog.frontend.receiver.onUpdateTuioCursor) {
 						console.log('updateTuioCursor', updateCursor);
 					}
 				},
 
 				onRemoveTuioCursor = function(removeCursor) {
-					/*
-					var $removeCursor = cursors[removeCursor.getCursorId()];
-					$removeCursor.remove();
-					delete[removeCursor.getCursorId()];
-					*/
 					if (config.app.debug && config.app.debugLog.frontend.receiver.onRemoveTuioCursor) {
 						console.log('removeTuioCursor', removeCursor);
 					}