From 1f7585d8c4cc86f0a1e6d3d62188e88698b57089 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 15 十二月 2021 16:14:36 +0800
Subject: [PATCH] #

---
 static/js/app.js            |   10 ++++++++--
 static/js/object/CrnTask.js |   31 ++++++++++++++++++++++++++-----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/static/js/app.js b/static/js/app.js
index 7004db9..938a1dc 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -42,7 +42,8 @@
 			this.stats.end();
 			// this.queryTask();
 			this.queryCrn();
-			this.modelMove();
+			// this.modelMove();
+			this.crnMove();
 		}
 		this.initScene = function () {
 			this.scene = new THREE.Scene();
@@ -280,7 +281,7 @@
 				for (let crnData of CrnDatas) {
 					let crnTask = getArrVal(this.crnTasks, "crnNo", crnData.crnNo);
 					if (null == crnTask) {
-						this.crnTasks.push(new CrnTask(crnData));
+						this.crnTasks.push(new CrnTask(crnData, this));
 					} else {
 						if(!crnTask.run) {
 							crnTask.modify(crnData);
@@ -400,6 +401,11 @@
 				}
 			}
 		}
+		this.crnMove = function (object) {
+			for (let crnTask of this.crnTasks) {
+				crnTask.move(this);
+			}
+		}
 	},
 
 };
diff --git a/static/js/object/CrnTask.js b/static/js/object/CrnTask.js
index ce2ed87..ed48490 100644
--- a/static/js/object/CrnTask.js
+++ b/static/js/object/CrnTask.js
@@ -1,5 +1,5 @@
 // 鍫嗗灈鏈哄綋鍓嶈繍琛岀姸鎬佸璞�
-function CrnTask(crnData) {
+function CrnTask(crnData, object) {
     let that = this;
 
     that.crnNo = 0;
@@ -21,6 +21,10 @@
     that.position = null;
     that.forkPos = -1;
 
+    that.crnBody = null;
+    that.curve = null;
+    that.progress = 0;
+
     let init = function () {
         that.crnNo = crnData.crnNo;
         that.bay = crnData.bay;
@@ -30,6 +34,8 @@
         that.z = crnData.position.z;
         that.position = crnData.position;
         that.forkPos = crnData.forkPos;
+
+        that.crnBody = getArrVal(object.objects, "name", that.crnNo + "-body")
     };
     init();
 
@@ -57,12 +63,27 @@
             that.position = crnData.position;
             that.forkPos = crnData.forkPos;
             // create Route ------------------------------------------------
-            let bodyRoute = new Route([that.prePosition, that.position]);    // body
+            that.curve = new Route([that.prePosition, that.position]);    // body
+
             // new Route();    // load
             // console.log(bodyRoute);
-            // console.log("pre" + JSON.stringify(that.prePosition));
-            // console.log(JSON.stringify(that.position));
-            // that.run = true;
+            console.log("pre" + JSON.stringify(that.prePosition));
+            console.log(JSON.stringify(that.position));
+            that.run = true;
+        }
+    }
+
+    that.move = function (object) {
+        if (that.curve) {
+            that.progress += 0.001;
+            if (that.progress>1.0) {
+                that.curve = null;
+            } else {
+                let point = that.curve.getPoint(that.progress);
+                if(point && point.x){
+                    that.crnBody.position.set(point.x,point.y,point.z);
+                }
+            }
         }
     }
 

--
Gitblit v1.9.1