static/js/app.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/data/Asrs.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/object/CrnTask.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/object/StoreCrn.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
views/index.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
static/js/app.js
@@ -3,6 +3,7 @@ import {MTLLoader} from './lib/MTLLoader.js'; import {OBJLoader} from './lib/OBJLoader.js'; import {StoreShelf} from './object/StoreShelf.js'; import {StoreCrn} from './object/StoreCrn.js'; var APP = { @@ -41,9 +42,7 @@ this.stats.begin(); this.renderer.render(this.scene, this.camera); this.stats.end(); // this.queryTask(); this.queryCrn(); // this.modelMove(); this.crnMove(); } this.initScene = function () { @@ -214,66 +213,6 @@ } } //显示仓库区域 // for (let i = 0; i < Store3DData.Areas.length; i++) { // let optionArea = Store3DData.Areas[i]; // let area = new StoreArea(optionArea); // object.addObject(area); // //显示仓库 // for (let j = 0; j < optionArea.Stores.length; j++) { // let optionStore = optionArea.Stores[j]; // optionStore.Position = CommonFunction.transPosition(optionStore.Position, optionArea.Position); // let store = new Store(optionStore); // // object.addObject(store); // //显示每行信息 // for (let k = 0; k < optionStore.Groups.length; k++) { // let optionGroup = optionStore.Groups[k]; // optionGroup.Position = CommonFunction.transPosition(optionGroup.Position, optionStore.Position); // let shelf = new StoreShelf(optionGroup); // let group=new StoreGroup(optionGroup,1); // object.addObject(shelf); // // object.addObject(group); // //显示库位上的货物 // for (let m = 0; m < optionGroup.Bins.length; m++) { // let optionBin = optionGroup.Bins[m]; // let existGoods=this.getExistedGoodType(optionBin.State); // let storeGoods = new StoreGoods(optionGroup, optionBin); // if(existGoods==null) { // let goods=storeGoods.create(); // object.addObject(goods); // this.goodTypes.push({type: optionBin.State, object: goods}); // } else { // let goods= storeGoods.clone(existGoods); // object.addObject(goods); // } // } // } // // } // } // this.firstTime = 0; } } } this.queryTask = function () { if (TaskDatas !== null) { for (let TaskData of TaskDatas) { let wrkTask = getArrVal(this.wrkTasks, "wrkNo", TaskData.wrkNo); if (null == wrkTask) { this.wrkTasks.push(TaskData); } } } } @@ -303,81 +242,56 @@ } this.initModel = function () { let that = this; // let object; // const onProgress = function ( xhr ) { // if ( xhr.lengthComputable ) { // const percentComplete = xhr.loaded / xhr.total * 100; // console.log( Math.round( percentComplete, 2 ) + '% downloaded' ); // } // }; // const onError = function () { }; // function loadModel() { // object.traverse( function ( child ) { // if ( child.isMesh ) child.material.map = texture; // } ); // object.position.y = 195; // that.addObject( object ); // } // const manager = new THREE.LoadingManager(loadModel); // const textureLoader = new THREE.TextureLoader( manager ); // const texture = textureLoader.load( '../static/model/obj/uv_grid_opengl.jpg' ); // const loader = new OBJLoader( manager ); // loader.load( '../static/model/obj/AGV.obj', function ( obj ) { // object = obj; // }, onProgress, onError ); const manager = new THREE.LoadingManager(); // manager.addHandler( /\.dds$/i, new DDSLoader() ); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '货叉.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .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 ); }); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '载货台.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .load( '载货台.obj', function ( object ) { object.position.z = -500; object.position.x = -2060; object.scale.set(0.025, 0.025, 0.025); object.rotateY(- Math.PI / 2) that.addObject( object ); }, null, null ); }); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '堆垛机本体.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .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 ); }); // new MTLLoader(manager) // .setPath( '../static/model/obj/' ) // .load( '货叉.mtl', function ( materials ) { // materials.preload(); // new OBJLoader( manager ) // .setMaterials( materials ) // .setPath( '../static/model/obj/' ) // .load( '货叉.obj', function ( object ) { // object.position.z = -480; // object.position.x = -1735; // object.scale.set(0.03, 0.03, 0.03); // object.rotateY(- Math.PI / 2) // that.addObject( object ); // }, null, null ); // }); // new MTLLoader(manager) // .setPath( '../static/model/obj/' ) // .load( '载货台.mtl', function ( materials ) { // materials.preload(); // new OBJLoader( manager ) // .setMaterials( materials ) // .setPath( '../static/model/obj/' ) // .load( '载货台.obj', function ( object ) { // object.position.z = -480; // object.position.x = -1735; // object.scale.set(0.03, 0.03, 0.03); // object.rotateY(- Math.PI / 2) // that.addObject( object ); // }, null, null ); // }); // new MTLLoader(manager) // .setPath( '../static/model/obj/' ) // .load( '堆垛机本体.mtl', function ( materials ) { // materials.preload(); // new OBJLoader( manager ) // .setMaterials( materials ) // .setPath( '../static/model/obj/' ) // .load( '堆垛机本体.obj', function ( object ) { // object.position.z = -480; // object.position.x = -1735; // // object.position.z = 0; // // object.position.x = 0; // // object.position.y = 0; // object.scale.set(0.03, 0.03, 0.03); // object.rotateY(- Math.PI / 2) // that.addObject( object ); // }, null, null ); // }); } this.initModelMove = function () { console.log(this.crnTasks) @@ -389,19 +303,6 @@ // this.curve = new Route(points); // } } 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); } } } } this.crnMove = function (object) { for (let crnTask of this.crnTasks) { static/js/data/Asrs.js
@@ -1,22 +1,8 @@ setInterval(function () { queryTaskCurrent(); queryCrnCurrent(); },1000); var TaskDatas = null; function queryTaskCurrent() { $.ajax({ // url: 'http://47.97.1.152:58080/jkwcs/three/init/store/v1', url: 'http://localhost:9090/jkwcs/three/query/task/current/v1', type: "GET", data: {}, async: false, success: function (res) { TaskDatas = res.data; } }) } var CrnDatas = null; function queryCrnCurrent() { static/js/object/CrnTask.js
@@ -1,3 +1,16 @@ const xOffset = -1735; const yOffset = -289; const zOffset = -480; const xOffset0 = -1735; const yOffset0 = -108; const zOffset0 = -480; const xOffset1 = -1735; const yOffset1 = -107; const zOffset1 = -475; // 堆垛机当前运行状态对象 function CrnTask(crnData, object) { let that = this; @@ -44,8 +57,8 @@ init(); that.modify = function (crnData) { if (that.run || that.crnNo === 0) { console.error(that.crnNo + "号堆垛机更新失败"); if (that.run || that.crnNo === 0 || that.crnBody===null || that.crnLoad===null || that.crnFork==null) { // console.log(that.crnNo + "号堆垛机更新失败"); } else { if (JSON.stringify(crnData.position) === JSON.stringify(that.position)) { return; @@ -163,12 +176,12 @@ that.crnBody.position.set(point.x, point.y, point.z); break case 'load': that.crnBody.position.z = point.z; that.crnLoad.position.set(point.x, point.y, point.z); that.crnFork.position.set(point.x, point.y, point.z); that.crnBody.position.z = point.z + zOffset; that.crnLoad.position.set(point.x, point.y + yOffset0, point.z + zOffset0); that.crnFork.position.set(point.x, point.y + yOffset1, point.z + zOffset1); break case 'fork': that.crnFork.position.set(point.x, point.y, point.z); that.crnFork.position.set(point.x + xOffset1, point.y, point.z); break default: break static/js/object/StoreCrn.js
@@ -1,4 +1,20 @@ import {MTLLoader} from "../lib/MTLLoader.js"; import {OBJLoader} from "../lib/OBJLoader.js"; const xOffset = -1735; const yOffset = -289; const zOffset = -480; const xOffset0 = -1735; const yOffset0 = -108; const zOffset0 = -480; const xOffset1 = -1735; const yOffset1 = -107; const zOffset1 = -475; function StoreCrn(option, object) { let that = this; this.crnBodyLength = option.crnBody.length||50;//库位长度 this.crnBodyWidth = option.crnBody.width||50;//库位宽 this.crnBodyHeight = option.crnBody.height||500;//库位高 @@ -10,37 +26,93 @@ this.crnForkHeight = option.crnFork.height||30;//库位高 // 立柱 var a = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnBodyLength, this.crnBodyHeight, this.crnBodyWidth), new THREE.MeshBasicMaterial({ color: 0xff0000, transparent: true, opacity: .3 })) a.name = option.crnNo + "-body"; a.position.x = option.crnBody.position.x; a.position.y = option.crnBody.position.y + this.crnBodyHeight/2; a.position.z = option.crnBody.position.z - this.crnBodyWidth/2; object.addObject(a); // var a = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnBodyLength, this.crnBodyHeight, this.crnBodyWidth), new THREE.MeshBasicMaterial({ // color: 0xff0000, // transparent: true, // opacity: .3 // })) // a.name = option.crnNo + "-body"; // a.position.x = option.crnBody.position.x; // a.position.y = option.crnBody.position.y + this.crnBodyHeight/2; // a.position.z = option.crnBody.position.z - this.crnBodyWidth/2; // object.addObject(a); // 载货台 var b = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnLoadLength, this.crnLoadHeight, this.crnLoadWidth), new THREE.MeshBasicMaterial({ color: 0x00ff00, transparent: true, opacity: .5 })) b.name = option.crnNo + "-load"; b.position.x = option.crnLoad.position.x; b.position.y = option.crnLoad.position.y + this.crnLoadHeight/2; b.position.z = option.crnLoad.position.z - this.crnLoadWidth/2 + 5; object.addObject(b); // var b = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnLoadLength, this.crnLoadHeight, this.crnLoadWidth), new THREE.MeshBasicMaterial({ // color: 0x00ff00, // transparent: true, // opacity: .5 // })) // b.name = option.crnNo + "-load"; // b.position.x = option.crnLoad.position.x; // b.position.y = option.crnLoad.position.y + this.crnLoadHeight/2; // b.position.z = option.crnLoad.position.z - this.crnLoadWidth/2 + 5; // object.addObject(b); // 叉牙 var c = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnForkLength, this.crnForkWidth, this.crnForkHeight), new THREE.MeshBasicMaterial({ color: 0xff00ff, transparent: true, opacity: 1 })) c.name = option.crnNo + "-fork"; c.position.x = option.crnFork.position.x; c.position.y = option.crnFork.position.y + this.crnLoadHeight/2; c.position.z = option.crnFork.position.z - this.crnLoadWidth/2; object.addObject(c); // var c = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnForkLength, this.crnForkWidth, this.crnForkHeight), new THREE.MeshBasicMaterial({ // color: 0xff00ff, // transparent: true, // opacity: 1 // })) // c.name = option.crnNo + "-fork"; // c.position.x = option.crnFork.position.x; // c.position.y = option.crnFork.position.y + this.crnLoadHeight/2; // c.position.z = option.crnFork.position.z - this.crnLoadWidth/2; // object.addObject(c); const manager = new THREE.LoadingManager(); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '堆垛机本体.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .load( '堆垛机本体.obj', function ( obj ) { obj.scale.set(0.03, 0.03, 0.03); obj.rotateY(- Math.PI / 2); obj.name = option.crnNo + "-body"; obj.position.x = option.crnBody.position.x + xOffset; obj.position.y = option.crnBody.position.y + that.crnBodyHeight/2 + yOffset; obj.position.z = option.crnBody.position.z - that.crnBodyWidth/2 + zOffset; object.addObject( obj ); }, null, null ); }); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '载货台.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .load( '载货台.obj', function ( obj ) { obj.scale.set(0.03, 0.03, 0.03); obj.rotateY(- Math.PI / 2); obj.name = option.crnNo + "-load"; obj.position.x = option.crnLoad.position.x + xOffset0; obj.position.y = option.crnLoad.position.y + that.crnLoadHeight/2 + yOffset0; obj.position.z = option.crnLoad.position.z - that.crnLoadWidth/2 + 5 + zOffset0; object.addObject( obj ); }, null, null ); }); new MTLLoader(manager) .setPath( '../static/model/obj/' ) .load( '货叉.mtl', function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( '../static/model/obj/' ) .load( '货叉.obj', function ( obj ) { obj.scale.set(0.03, 0.03, 0.03); obj.rotateY(- Math.PI / 2); obj.name = option.crnNo + "-fork"; obj.position.x = option.crnFork.position.x + xOffset1; obj.position.y = option.crnFork.position.y + that.crnLoadHeight/2 + yOffset1; obj.position.z = option.crnFork.position.z - that.crnLoadWidth/2 + zOffset1; object.addObject( obj ); }, null, null ); }); } export {StoreCrn} views/index.html
@@ -16,7 +16,7 @@ <script type="text/javascript" src="../static/js/object/StoreArea.js"></script> <script type="text/javascript" src="../static/js/object/Store.js"></script> <script type="text/javascript" src="../static/js/object/StoreGroup.js"></script> <script type="text/javascript" src="../static/js/object/StoreCrn.js"></script> <!-- <script type="text/javascript" src="../static/js/object/StoreCrn.js"></script>--> <!-- <script type="text/javascript" src="../static/js/object/StoreShelf.js"></script>--> <script type="text/javascript" src="../static/js/object/StoreGoods.js"></script> <script type="text/javascript" src="../static/js/object/Route.js"></script>