From ce233f75205501532c91fb2fdf0ca1a3f1dbb442 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期一, 13 十二月 2021 14:19:43 +0800 Subject: [PATCH] # --- static/js/object/Route.js | 28 +++++++++++-- static/js/app.js | 29 +++++++++++--- static/js/utils.js | 18 +++++++++ 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index 5fb69a3..a7723c5 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -14,8 +14,8 @@ this.firstTime = 1; this.stats = null; this.goodTypes=[];//瀛樺偍鎵�鏈夌殑搴撲綅绫诲瀷 - this.wrkNo = 0; this.wrkTasks = [];// 浠诲姟鍒楄〃 + this.time = 0;//鏍囪鍫嗗灈鏈鸿繍琛岀殑鏃堕棿 this.start = function () { this.initMain(); @@ -39,7 +39,7 @@ 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(); @@ -352,12 +352,29 @@ }, 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); + } } } }, diff --git a/static/js/object/Route.js b/static/js/object/Route.js index b27209b..92a4274 100644 --- a/static/js/object/Route.js +++ b/static/js/object/Route.js @@ -12,9 +12,27 @@ */ 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); } diff --git a/static/js/utils.js b/static/js/utils.js index 2999835..6f3299e 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1,4 +1,5 @@ +// 鏁扮粍鏍规嵁key鍙栧�� function getArrVal(arrObj, key, condition) { if (!arrObj instanceof Array) { return null; @@ -11,3 +12,20 @@ } 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; +} -- Gitblit v1.9.1