From 0d0d52d7b35e41335cf2a8dcce8e1e3cef96811e Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期二, 04 一月 2022 13:20:18 +0800 Subject: [PATCH] # --- static/js/object/StoreGoods.js | 136 ++++++++++++++++++-------------------------- 1 files changed, 56 insertions(+), 80 deletions(-) diff --git a/static/js/object/StoreGoods.js b/static/js/object/StoreGoods.js index 4ff4fbf..dcd5c3a 100644 --- a/static/js/object/StoreGoods.js +++ b/static/js/object/StoreGoods.js @@ -1,85 +1,61 @@ -/** - * 鑾峰彇绫� - * @param optionGroup - * @param optionBin - * @constructor - */ -function StoreGoods(optionGroup,optionBin) { +import {MTLLoader} from "../lib/MTLLoader.js"; +import {OBJLoader} from "../lib/OBJLoader.js"; +import * as THREE from '../three.module.js'; - if(!CommonFunction.hasObj(optionGroup)||!CommonFunction.hasObj(optionBin)) - return; - let col=optionBin.Col; - let layer=optionBin.Layer; - /* - 鏀灦鐨勯珮=鏈�搴曞眰鐨勯珮搴�+(搴撲綅鏁�-1)*搴撲綅鐨勯珮搴� - */ - let shelfHeight=optionGroup.BottomHeight+(optionGroup.BinYNum)*optionGroup.BinHeight; - /* - 鏀灦鐨勫=搴撲綅鏁颁箻浠ュ簱浣嶇殑瀹藉害 - */ - let shelfWidth=optionGroup.BinZNum*optionGroup.BinWidth; +function StoreGoods(object, data, shelf) { + let that = this; + that.data = data; + that.object = object; + that.shelf = shelf; + let palletList = []; + let goodsList = []; - this.positionX=optionGroup.Position.X; - this.positionY=optionGroup.Position.Y-shelfHeight/2+optionGroup.BinHeight/2+(layer-1)*optionGroup.BinHeight+optionGroup.BottomHeight; - this.positionZ=optionGroup.Position.Z+shelfWidth/2-optionGroup.BinWidth/2-(col-1)*optionGroup.BinWidth; - - this.no=optionBin.No; - this.name=optionBin.Name; - - this.length=optionGroup.BinLength-6; - this.width=optionGroup.BinWidth-6; - this.height=optionGroup.BinHeight-6; - - - if(optionBin.State=="1") - { - this.color=0x46C191; - this.opacity=0.8; + for (let i=0;i<that.data.length;i++) { + let obj = that.data[i]; + if (obj.loc_sts === 'D') { + palletList.push(obj); + } else if (obj.loc_sts === 'F') { + palletList.push(obj); + goodsList.push(obj); + } } - else if(optionBin.State=="2") - { - this.color=0xF0CD3F; - this.opacity=0.8; - } - else if(optionBin.State=="3") - { - this.color=0xF55E35; - this.opacity=0.8; - } - else - { - this.color=0x46C191; - this.opacity=0.1; - } + + const manager = new THREE.LoadingManager(); + new MTLLoader(manager) + .setPath( '../static/model/obj/' ) + .load( 'pallet.mtl', function ( materials ) { + materials.preload(); + new OBJLoader( manager ) + .setMaterials( materials ) + .setPath( '../static/model/obj/' ) + .load( 'pallet.obj', function ( obj ) { + obj.traverse (function (child) { + child.castShadow = true; + if (child instanceof THREE.Mesh) { + child.material = new THREE.MeshLambertMaterial({ + color: 0x2F4F4F + }); + } + }); + obj.scale.set(4, 4, 3.5); + obj.position.x = -1; + obj.position.y = 22; + obj.position.z = -46; + + palletList.map(item => { + var clone = obj.clone(); + let positionX = that.shelf.positionX || 0; + let positionY = that.shelf.positionY || 0; + let positionZ = that.shelf.positionZ || 0; + + clone.position.x = -18 + positionX; + clone.position.y = 22 + positionY; + clone.position.z = -46 + positionZ; + that.object.addObject(clone); + }) + }, null, null ); + }); } -StoreGoods.prototype.create=function () { - let optionCube = { - length: this.length, - width: this.width, - height: this.height, - position: { - x: this.positionX, - y: this.positionY, - z: this.positionZ - }, - style: { - transparent:1, - opacity:this.opacity, - color: this.color, - depthTest:1 - }, - }; - let cube = new Cube(optionCube); - cube.uuid=this.no; - cube.name=this.name; - cube.type="StoreGoods"; - return cube; -} -StoreGoods.prototype.clone=function (object) { - let goods=object.clone(); - goods.position.set(this.positionX,this.positionY,this.positionZ); - goods.uuid=this.no; - goods.name=this.name; - return goods; -} \ No newline at end of file + +export {StoreGoods} -- Gitblit v1.9.1