|  |  | 
 |  |  |         this.firstTime = 1; | 
 |  |  |         this.stats = null; | 
 |  |  |         this.goodTypes=[];//存储所有的库位类型 | 
 |  |  |         this.wrkNo = 0; | 
 |  |  |         this.wrkTasks = [];// 任务列表 | 
 |  |  |         this.time = 0;//标记堆垛机运行的时间 | 
 |  |  |  | 
 |  |  |         this.start = function () { | 
 |  |  |             this.initMain(); | 
 |  |  | 
 |  |  |             this.stats.begin(); | 
 |  |  |             this.renderer.render(this.scene, this.camera); | 
 |  |  |             this.stats.end(); | 
 |  |  |             // this.modelMove(); | 
 |  |  |             this.modelMove(); | 
 |  |  |         } | 
 |  |  |         this.initScene = function () { | 
 |  |  |             this.scene = new THREE.Scene(); | 
 |  |  | 
 |  |  |                         }, null, null ); | 
 |  |  |                 }); | 
 |  |  |         } | 
 |  |  |         this.modelMove = function () { | 
 |  |  |         this.initModelMove = function () { | 
 |  |  |             for (var wrkMast of this.wrkTasks) { | 
 |  |  |                 console.log(wrkMast) | 
 |  |  |                 let crnBody = getArrVal(this.objects, "name", wrkMast.crnNo + "-body"); | 
 |  |  |  | 
 |  |  |                 console.log(crnBody.position); | 
 |  |  |                 // 取货点定位 | 
 |  |  |                 let sourceLocPosition = getBinPosition(wrkMast.sourceLocNo); | 
 |  |  |                 let points = [crnBody.position, 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); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     }, | 
 
 |  |  | 
 |  |  |  */ | 
 |  |  | function Route(option) { | 
 |  |  |     let curvePoints=[]; | 
 |  |  |     for(let i=0;i<option.points.length;i++) { | 
 |  |  |         let point=option.points[i]; | 
 |  |  |         curvePoints.push(new THREE.Vector3(point.x, point.y, point.z)); | 
 |  |  |     } | 
 |  |  |     return new THREE.CatmullRomCurve3(curvePoints,false/*是否闭合*/,'catmullrom',0.000000001); | 
 |  |  |     // 1.去取货 ------------------------------------------------------------------------ | 
 |  |  |     // z轴 | 
 |  |  |     curvePoints.push(option[0]); | 
 |  |  |     curvePoints.push({ | 
 |  |  |         x: option[0].x, | 
 |  |  |         y: option[0].y, | 
 |  |  |         z: option[1].z | 
 |  |  |     }); | 
 |  |  |     return new THREE.CatmullRomCurve3(curvePoints,false,'catmullrom',0.000000001); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 2. | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // let curvePoints=[]; | 
 |  |  |     // for(let i=0;i<option.points.length;i++) { | 
 |  |  |     //     let point=option.points[i]; | 
 |  |  |     //     curvePoints.push(new THREE.Vector3(point.x, point.y, point.z)); | 
 |  |  |     // } | 
 |  |  |     // return new THREE.CatmullRomCurve3(curvePoints,false/*是否闭合*/,'catmullrom',0.000000001); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | // 数组根据key取值 | 
 |  |  | function getArrVal(arrObj, key, condition) { | 
 |  |  |     if (!arrObj instanceof Array) { | 
 |  |  |         return null; | 
 |  |  | 
 |  |  |     } | 
 |  |  |     return null; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 根据库位号获取其定位 | 
 |  |  | function getBinPosition(locNo) { | 
 |  |  |     var position; | 
 |  |  |     $.ajax({ | 
 |  |  |         url: 'http://localhost:9090/jkwcs/three/query/goods/position/v1', | 
 |  |  |         type: "GET", | 
 |  |  |         data: { | 
 |  |  |             locNo: locNo | 
 |  |  |         }, | 
 |  |  |         async: false, | 
 |  |  |         success: function (res) { | 
 |  |  |             position = res.data; | 
 |  |  |         } | 
 |  |  |     }) | 
 |  |  |     return position; | 
 |  |  | } |