static/js/app.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/object/StoreCrn.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/object/StoreShelf.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/object/StoreShelf0.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
static/js/utils.js | 补丁 | 查看 | 原始文档 | blame | 历史 |
static/js/app.js
@@ -29,15 +29,14 @@ this.initLight(); this.initFloor(); this.initModel(); // 取数据 this.initStoreData(); this.initModel0(); this.initStoreObjects(this); } this.animate = function () { requestAnimationFrame(this.animate.bind(this)); this.stats.begin(); this.renderer.render(this.scene, this.camera); this.stats.end(); this.initStoreObjects(this); this.modelMove(); } this.initScene = function () { @@ -58,7 +57,7 @@ // this.camera.position.z = 600; // //相机的朝向 // this.camera.lookAt(0, 0, 0); this.camera.position.set( - 550, 670, 950 ); this.camera.position.set( - 350, 1070, 1550 ); this.camera.lookAt( this.scene.position ); //将相机放到场景中 this.scene.add(this.camera); @@ -75,12 +74,29 @@ this.dom.appendChild( this.renderer.domElement ); } this.initLight = function () { //首先添加个环境光 let ambient = new THREE.AmbientLight(0xffffff, 1); //AmbientLight,影响整个场景的光源 ambient.position.set(0, 0, 0); this.addObject(ambient); //添加平行光,平行光类似于太阳光 let directionalLight = new THREE.DirectionalLight(0xffffff, 0.3);//模拟远处类似太阳的光源 directionalLight.position.set(0, 200, 0); this.addObject(directionalLight); //设置点光源 let pointLight1 = new THREE.PointLight(0xffffff, 0.3); pointLight1.position.set(-500, 200, 0); this.addObject(pointLight1); let pointLight2 = new THREE.PointLight(0xffffff, 0.3); pointLight2.position.set(500, 200, 0); this.addObject(pointLight2); // --- var bulbLight = new THREE.PointLight( 0xffee88, 1, 2000, 2 ); bulbLight.position.set( 600, 600, 500 ); bulbLight.castShadow = true; bulbLight.power = 100; this.addObject(bulbLight); // var bulbLight = new THREE.PointLight( 0xffee88, 1, 2000, 2 ); // bulbLight.position.set( 600, 600, 500 ); // bulbLight.castShadow = true; // bulbLight.power = 100; // this.addObject(bulbLight); // --- // var bulbLight1 = new THREE.PointLight( 0xffee88, 1, 2000, 2 ); // bulbLight1.position.set( -600, 600, 500 ); @@ -104,12 +120,12 @@ // hemiLight.intensity = 0.0001; // this.addObject(hemiLight); const ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 ); this.addObject( ambientLight ); const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.6 ); directionalLight.position.set( - 1, 1, 1 ); this.addObject( directionalLight ); // const ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 ); // this.addObject( ambientLight ); // // const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.6 ); // directionalLight.position.set( - 1, 1, 1 ); // this.addObject( directionalLight ); } this.initOrbitControl = function () { this.orbitControl = new OrbitControls(this.camera, this.renderer.domElement); @@ -134,7 +150,7 @@ "posy.jpg", "negy.jpg", "posz.jpg", "negz.jpg" ]); this.scene.background = new THREE.Color( 0x17c5dc ); this.scene.background = new THREE.Color( 0xf0f0f0 ); } this.removeObject = function (nameorid) { for (let i = 0; i < this.objects.length; i++) { @@ -159,7 +175,7 @@ // this.addObject(plane); // // const helper = new THREE.PolarGridHelper( 2000, 100 ); const helper = new THREE.GridHelper( 5000, 300 ); const helper = new THREE.GridHelper( 8000, 300 ); helper.position.y = - 0; helper.material.opacity = 0.25; helper.material.transparent = true; @@ -167,23 +183,38 @@ } this.initStoreObjects = function (object) { if (this.firstTime === 1) { // initStore(); initStore(); if (Store3DData !== null) { for(let i = 0;i<Store3DData.data.length;i++){ let optionArea = Store3DData.data[i]; let area = new Store3DData(optionArea); object.addObject(area); for (let j = 0; j<optionArea.store.length;j++){ let optionStore = optionArea[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 } for(var group of Store3DData.data.store.groups) { let crn = new StoreCrn(group.crn, object); for (var line of group.lines) { let shelf = new StoreShelf(line); object.addObject(shelf); //显示库位上的货物 // for (var bin of line.bins) { // let existGoods=this.getExistedGoodType(bin.State); // let storeGoods = new StoreGoods(optionGroup, bin); // if(existGoods==null) { // let goods=storeGoods.create(); // object.addObject(goods); // this.goodTypes.push({type: bin.State, object: goods}); // } else { // let goods= storeGoods.clone(existGoods); // object.addObject(goods); // } // } } } @@ -228,6 +259,9 @@ this.firstTime = 0; } } } this.initModel0 = function () { } this.getExistedGoodType=function(state){ for (let i=0;i<this.goodTypes.length;i++) { @@ -274,6 +308,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 ); @@ -311,9 +348,6 @@ }); } this.modelMove = function () { } this.initStoreData = function () { } }, static/js/object/StoreCrn.js
New file @@ -0,0 +1,44 @@ function StoreCrn(option, object) { console.log(option); this.crnBodyLength = option.crnBody.length||50;//库位长度 this.crnBodyWidth = option.crnBody.width||50;//库位宽 this.crnBodyHeight = option.crnBody.height||500;//库位高 this.crnLoadLength = option.crnLoad.length||60;//库位长度 this.crnLoadWidth = option.crnLoad.width||60;//库位宽 this.crnLoadHeight = option.crnLoad.height||40;//库位高 this.crnForkLength = option.crnFork.length||80;//库位长度 this.crnForkWidth = option.crnFork.width||20;//库位宽 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.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.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.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); } static/js/object/StoreShelf.js
@@ -1,93 +1,64 @@ function StoreShelf(option) { this.binLength = option.BinLength||50;//库位长度 this.binWidth = option.BinWidth||50;//库位宽 this.binHeight = option.BinHeight||50;//库位高 this.binXNum = option.BinXNum||1;//库位X轴方向库位数量 this.binZNum = option.BinZNum||10;//库位Z轴方向库位数量 this.binYNum = option.BinYNum||10;//库位Y轴库位数量 this.bottomHight = option.BottomHeight||20;//底层高度,底层 this.positionX = option.Position.X||0;//库位位置 this.positionY = option.Position.Y||0;//库位位置 this.positionZ = option.Position.Z||0;//库位位置 this.binLength = option.binLength||50;//库位长度 this.binWidth = option.binWidth||50;//库位宽 this.binHeight = option.binHeight||50;//库位高 this.binXNum = option.binXNum||1;//库位X轴方向库位数量 this.binZNum = option.binZNum||10;//库位Z轴方向库位数量 this.binYNum = option.binYNum||10;//库位Y轴库位数量 this.bottomHight = option.bottomHeight||20;//底层高度,底层 this.positionX = option.position.x||0;//库位位置 this.positionY = option.position.y||0;//库位位置 this.positionZ = option.position.z||0;//库位位置 this.rackLengh = 3;//支架的长度,默认设动为3 this.rackWidth = 3;//支架的宽度,默认设定为3 this.intervalRackNum=2;//间隔多少库位有一个主支架 // let binHolderPlane=new THREE.BoxGeometry(this.binLength,2,this.binWidth);//定义一个跟库位长宽相同的几何体,作为托盘 // 材质 let shelfMat = new THREE.MeshLambertMaterial({color:0x175EC0});//定义支架和托盘的材质 //定义一个组合体 let group = new THREE.Group(); //定义支架和托盘的材质 let shlefMat = new THREE.MeshPhysicalMaterial({ color:0xff0000, // 材质像金属的程度. 非金属材料,如木材或石材,使用0.0,金属使用1.0,中间没有(通常). // 默认 0.5. 0.0到1.0之间的值可用于生锈的金属外观 metalness: 1.0, // 材料的粗糙程度. 0.0表示平滑的镜面反射,1.0表示完全漫反射. 默认 0.5 roughness: 0.6, // 设置环境贴图 // 反射程度, 从 0.0 到1.0.默认0.5. // 这模拟了非金属材料的反射率。 当metalness为1.0时无效 // reflectivity: 0.5, }) let group = new THREE.Group();//定义一个组合体 //合并模型,则使用merge方法合并 let combineGeometry = new THREE.BufferGeometry(); /* 支架的高=最底层的高度+(库位数-1)*库位的高度 */ let shelfHeight=this.bottomHight+(this.binYNum-1)*this.binHeight; /* 支架的宽=库位数乘以库位的宽度 */ // 货架总高 let shelfHeight=this.bottomHight+(this.binYNum)*this.binHeight; // 货架总宽 let shelfWidth=this.binZNum*this.binWidth; let rackBoxGeometry=new THREE.BoxGeometry(this.rackLengh,shelfHeight,this.rackWidth);//定义一个支架网格 let rackObject=new THREE.Mesh( rackBoxGeometry, shlefMat, 0 ); // 支架模型 + 材质 let rackBoxGeometry=new THREE.BoxGeometry(this.rackLengh,shelfHeight,this.rackWidth); let rackObject=new THREE.Mesh(rackBoxGeometry, shelfMat, 0); // 托板模型 + 材质 let planeBoxGeometry = new THREE.BoxGeometry(this.binLength, 2, this.binWidth+this.rackWidth); // 覆盖多一根支架宽度 let planeObject=new THREE.Mesh(planeBoxGeometry, shelfMat, 0); let plane = new THREE.BoxGeometry(this.binLength, 2, this.binWidth); let holderObject = new THREE.Mesh(plane, shlefMat,0); // Y轴定位 let positionY = this.positionY + shelfHeight / 2; let leftPositionX=this.positionX-this.binLength/2+this.rackLengh/2;//左侧支架柱的X轴条码 let rightPositionX=this.positionX+this.binLength/2-this.rackLengh/2;//右侧支架柱的X轴条码 //左侧支架柱的X轴定位 let leftPositionX=this.positionX-this.binLength/2; //右侧支架柱的X轴定位 let rightPositionX=this.positionX+this.binLength/2 - this.rackLengh; // 缩进支架长度 // 初始化支架模型 for(let i=0;i<=this.binZNum;i++) { let leftRack = rackObject.clone(); let positionZ = - ( this.positionZ + i*this.binWidth ); leftRack.position.set(leftPositionX,positionY,positionZ); leftRack.updateMatrix(); group.add(leftRack); let positionY=this.positionY-this.binHeight/2;//支架柱的Y轴坐标 for(let i=0;i<this.binZNum+this.intervalRackNum;i++) { let isRack=i%this.intervalRackNum; if(isRack===0) { let PositionZ=this.positionZ-shelfWidth/2+i*this.binWidth+this.rackWidth/2; if(i>=this.binZNum) { PositionZ=PositionZ-this.rackWidth; } let leftRack=rackObject.clone(); group.add(leftRack); leftRack.position.set(leftPositionX,positionY,PositionZ); leftRack.updateMatrix(); combineGeometry.merge(leftRack.geometry, leftRack.matrix); let rightRack=rackObject.clone(); group.add(rightRack); rightRack.position.set(rightPositionX,positionY,PositionZ); rightRack.updateMatrix(); combineGeometry.merge(rightRack.geometry, rightRack.matrix); let rightRack = rackObject.clone(); rightRack.position.set(rightPositionX,positionY,positionZ); rightRack.updateMatrix(); group.add(rightRack); } // 初始化托板模型 for(let i = 0;i < this.binZNum;i++) { for (let j = 0;j <= this.binYNum;j++) { let plane = planeObject.clone(); let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1; let positionZ= - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); plane.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); plane.updateMatrix(); group.add(plane); } } //创建托板 for(let i=0;i<this.binZNum;i++) { for (let j = 0; j < this.binYNum; j++) { let positionY=this.positionY-this.binHeight/2-shelfHeight/2+this.bottomHight+j*this.binHeight; let positionZ=this.positionZ-shelfWidth/2+this.binWidth/2 + i * this.binWidth let holderObj= holderObject.clone(); group.add(holderObj); holderObj.position.set(this.positionX,positionY,positionZ); holderObj.updateMatrix(); combineGeometry.merge(holderObj.geometry, holderObj.matrix); } } let shelf= new THREE.Mesh(combineGeometry, shlefMat); shelf.uuid=option.No; shelf.name=option.Name; shelf.type="StoreShelf"; return group; } static/js/object/StoreShelf0.js
File was deleted static/js/utils.js