#
luxiaotao1123
2021-12-15 4d317e08d281b9e5e2cf742788c3d4b5b6bb9b38
static/js/app.js
@@ -14,8 +14,10 @@
      this.firstTime = 1;
      this.stats = null;
      this.goodTypes=[];//存储所有的库位类型
      this.wrkNo = 0;
      this.wrkTasks = [];// 任务列表
      this.crnTasks = [];// 堆垛机列表
      this.time = 0;//标记堆垛机运行的时间
      this.progress = 0;
      this.start = function () {
         this.initMain();
@@ -31,7 +33,6 @@
         this.initLight();
         this.initFloor();
         this.initModel();
         this.queryTask();
         this.initStoreObjects(this);
      }
      this.animate = function () {
@@ -39,7 +40,9 @@
         this.stats.begin();
         this.renderer.render(this.scene, this.camera);
         this.stats.end();
         // this.modelMove();
         // this.queryTask();
         this.queryCrn();
         this.modelMove();
      }
      this.initScene = function () {
         this.scene = new THREE.Scene();
@@ -263,9 +266,27 @@
         }
      }
      this.queryTask = function () {
         if (this.firstTime === 1) {
            queryTaskCurrent();
            this.wrkTasks = TaskData;
         if (TaskDatas !== null) {
            for (let TaskData of TaskDatas) {
               let wrkTask = getArrVal(this.wrkTasks, "wrkNo", TaskData.wrkNo);
               if (null == wrkTask) {
                  this.wrkTasks.push(TaskData);
               }
            }
         }
      }
      this.queryCrn = function () {
         if (CrnDatas !== null) {
            for (let crnData of CrnDatas) {
               let crnTask = getArrVal(this.crnTasks, "crnNo", crnData.crnNo);
               if (null == crnTask) {
                  this.crnTasks.push(new CrnTask(crnData));
               } else {
                  if(!crnTask.run) {
                     crnTask.modify(crnData);
                  }
               }
            }
         }
      }
      this.getExistedGoodType=function(state){
@@ -346,22 +367,40 @@
                  .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 );
                  }, null, null );
            });
      }
      this.modelMove = function () {
         for (var wrkMast of this.wrkTasks) {
            console.log(wrkMast)
            let crnBody = getArrVal(this.objects, "name", wrkMast.crnNo + "-body");
      this.initModelMove = function () {
         console.log(this.crnTasks)
         // for (var wrkMast of this.wrkTasks) {
         //    this.crnBody = getArrVal(this.objects, "name", wrkMast.crnNo + "-body");
         //    // 取货点定位
         //    let sourceLocPosition = getBinPosition(wrkMast.sourceLocNo);
         //    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(crnBody.position);
      }
      this.modelMove = function () {
         if (this.curve) {
            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);
               }
            }
         }
      }
   },
};