From a56777639efc65d506b85d2bcff68ce0e3748490 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 15 十二月 2021 11:02:43 +0800
Subject: [PATCH] #

---
 static/js/app.js |   50 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/static/js/app.js b/static/js/app.js
index 796ffe3..8545e93 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -15,7 +15,9 @@
 		this.stats = null;
 		this.goodTypes=[];//瀛樺偍鎵�鏈夌殑搴撲綅绫诲瀷
 		this.wrkTasks = [];// 浠诲姟鍒楄〃
+		this.crnTasks = [];// 鍫嗗灈鏈哄垪琛�
 		this.time = 0;//鏍囪鍫嗗灈鏈鸿繍琛岀殑鏃堕棿
+		this.progress = 0;
 
 		this.start = function () {
 			this.initMain();
@@ -38,8 +40,9 @@
 			this.stats.begin();
 			this.renderer.render(this.scene, this.camera);
 			this.stats.end();
-			this.queryTask();
-			// this.modelMove();
+			// this.queryTask();
+			this.queryCrn();
+			this.modelMove();
 		}
 		this.initScene = function () {
 			this.scene = new THREE.Scene();
@@ -272,6 +275,21 @@
 				}
 			}
 		}
+		this.queryCrn = function () {
+			if (CrnDatas !== null) {
+				for (let crnData of CrnDatas) {
+					let crnTask = getArrVal(this.crnTasks, "crnNo", crnData.crnNo);
+					if (null == crnTask) {
+						// let crnFork = getArrVal(this.objects, "name", wrkMast.crnNo + "-fork");
+						this.crnTasks.push(new CrnTask(crnData));
+					} else {
+						if(!crnTask.run) {
+							crnTask.modify(crnData);
+						}
+					}
+				}
+			}
+		}
 		this.getExistedGoodType=function(state){
 			for (let i=0;i<this.goodTypes.length;i++) {
 				let type=this.goodTypes[i];
@@ -350,6 +368,9 @@
 						.load( '鍫嗗灈鏈烘湰浣�.obj', function ( object ) {
 							object.position.z = -500;
 							object.position.x = -2060;
+							// object.position.z = 0;
+							// object.position.x = 0;
+							// object.position.y = 0;
 							object.scale.set(0.025, 0.025, 0.025);
 							object.rotateY(- Math.PI / 2)
 							that.addObject( object );
@@ -359,27 +380,24 @@
 		this.initModelMove = function () {
 			console.log(this.wrkTasks)
 			for (var wrkMast of this.wrkTasks) {
-				let crnBody = getArrVal(this.objects, "name", wrkMast.crnNo + "-body");
-				console.log(crnBody)
+				this.crnBody = getArrVal(this.objects, "name", wrkMast.crnNo + "-body");
 				// 鍙栬揣鐐瑰畾浣�
 				let sourceLocPosition = getBinPosition(wrkMast.sourceLocNo);
-				let points = [crnBody.position, sourceLocPosition];
+				let points = [new THREE.Vector3(this.crnBody.position.x, this.crnBody.position.y, this.crnBody.position.z), sourceLocPosition];
 				this.curve = new Route(points);
-				console.log(this.curve);
 			}
+
 		}
 		this.modelMove = function () {
 			if (this.curve) {
-				this.time = this.time + 1;
-				let points = this.curve.getPoints(2000);
-				let point = points[this.time];
-				let point1 = points[this.time+1];
-				if(this.time >= 2000) {
-					this.time = 0;
-				}
-				if(point&&point.x){
-					this.AgvCar.position.set(point.x,40,point.z);
-					this.AgvCar.lookAt(point1.x,40,point1.z);
+				this.progress += 0.001;
+				if (this.progress>1.0) {
+					this.curve = null;
+				} else {
+					let point = this.curve.getPoint(this.progress);
+					if(point&&point.x){
+						this.crnBody.position.set(point.x,point.y,point.z);
+					}
 				}
 			}
 		}

--
Gitblit v1.9.1