#
luxiaotao1123
2021-12-17 c1a770f7d71370878bc3d28f5248881b698d7718
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,10 @@
         this.stats.begin();
         this.renderer.render(this.scene, this.camera);
         this.stats.end();
         this.queryTask();
         // this.queryTask();
         this.queryCrn();
         // this.modelMove();
         this.crnMove();
      }
      this.initScene = function () {
         this.scene = new THREE.Scene();
@@ -188,7 +192,7 @@
            initStore();
            if (Store3DData !== null) {
               for(var group of Store3DData.data.store.groups) {
                  let crn = new StoreCrn(group.crn, object);
                  new StoreCrn(group.crn, object);
                  for (var line of group.lines) {
                     let shelf = new StoreShelf(line);
                     object.addObject(shelf);
@@ -272,6 +276,21 @@
            }
         }
      }
      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, this));
               } else {
                  if(!crnTask.run) {
                     // console.log(2)
                     crnTask.modify(crnData);
                  }
               }
            }
         }
      }
      this.getExistedGoodType=function(state){
         for (let i=0;i<this.goodTypes.length;i++) {
            let type=this.goodTypes[i];
@@ -350,6 +369,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 );
@@ -357,30 +379,32 @@
            });
      }
      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)
            // 取货点定位
            let sourceLocPosition = getBinPosition(wrkMast.sourceLocNo);
            let points = [crnBody.position, sourceLocPosition];
            this.curve = new Route(points);
            console.log(this.curve);
         }
         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);
         // }
      }
      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;
            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);
               }
            }
            if(point&&point.x){
               this.AgvCar.position.set(point.x,40,point.z);
               this.AgvCar.lookAt(point1.x,40,point1.z);
            }
         }
      }
      this.crnMove = function (object) {
         for (let crnTask of this.crnTasks) {
            crnTask.move();
         }
      }
   },