From ae74235d8d7776d4db335c460529c929b0c00eb7 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期四, 07 四月 2022 15:26:38 +0800 Subject: [PATCH] # --- static/js/object/StoreGoods.js | 151 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 122 insertions(+), 29 deletions(-) diff --git a/static/js/object/StoreGoods.js b/static/js/object/StoreGoods.js index 70b25a5..fff753f 100644 --- a/static/js/object/StoreGoods.js +++ b/static/js/object/StoreGoods.js @@ -10,24 +10,14 @@ const goodsY = 5; const goodsZ = -6; -function StoreGoods(object, data, shelf) { - let that = this; - that.data = data; - that.object = object; - that.shelf = shelf; - let palletList = []; - let goodsList = []; - - 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); - } - } - +/** + * 鍒濆鍖栨墭鐩樻ā鍨� + * @param scene 鍦烘櫙 + * @param palletList 鎵樼洏鏁版嵁鍒楄〃 + * @param ref 鍙傜収鐗� + * @param type 鍙傜収鐗╃被鍨嬶細1 - 璐ф灦锛� 2 - 杈撻�佺嚎 + */ +function InitPallet(scene, palletList, ref, type) { const manager = new THREE.LoadingManager(); new OBJLoader( manager ) .setPath( '../static/model/obj/' ) @@ -44,18 +34,59 @@ palletList.map(item => { let clone = obj.clone(); - let positionX = that.shelf.positionX || 0; - let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0; - let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0; + let positionX; + let positionY; + let positionZ; + switch (type) { + case 1: + positionX = ref.positionX || 0; + positionY = ref.bottomHight + (item.lev1-1)*ref.binHeight || 0; + positionZ = (item.bay1-1)*-ref.binHeight || 0; - clone.name = item.loc_no + "-" + "Pallet"; + clone.name = item.loc_no + "-" + "Pallet"; + clone.traverse (function (child) { + if (child instanceof THREE.Mesh) { + child.name = item.loc_no + "-" + child.name; + } + }) + break; + case 2: + positionX = ref.position.x || 0; + positionY = ref.position.y || 0; + positionZ = ref.position.z || 0; + + positionX -= 48 - 1; + positionY += 20; + positionZ -= 138 + 20; + + clone.name = item.wrkNo + "-" + "Pallet"; + clone.traverse (function (child) { + if (child instanceof THREE.Mesh) { + child.name = item.wrkNo + "-" + child.name; + } + }) + break; + default: + console.error("InitPallet param[type] error ===>> " + type); + } + clone.position.x = palletX + positionX; clone.position.y = palletY + positionY; clone.position.z = palletZ + positionZ; - that.object.addObject(clone); + scene.addObject(clone); }) }); +} +/** + * 鍒濆鍖栬揣鐗╂ā鍨� + * @param scene 鍦烘櫙 + * @param goodsList 璐х墿鏁版嵁鍒楄〃 + * @param ref 鍙傜収鐗� + * @param type 鍙傜収鐗╃被鍨嬶細1 - 璐ф灦锛� 2 - 杈撻�佺嚎 + */ +function InitGoods(scene, goodsList, ref, type) { + const manager = new THREE.LoadingManager(); const goodsWrapImg = new THREE.TextureLoader( manager ).load( '../static/img/goodsWrap.jpg' ); const goodsImg = new THREE.TextureLoader( manager ).load( '../static/img/goods.jpg' ); new OBJLoader( manager ).load( '../static/model/obj/goods.obj', function ( obj ) { @@ -73,17 +104,79 @@ goodsList.map(item => { let clone = obj.clone(); - let positionX = that.shelf.positionX || 0; - let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0; - let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0; + let positionX; + let positionY; + let positionZ; + switch (type) { + case 1: + positionX = ref.positionX || 0; + positionY = ref.bottomHight + (item.lev1-1)*ref.binHeight || 0; + positionZ = (item.bay1-1)*-ref.binHeight || 0; - clone.name = item.loc_no + "-" + "Goods"; + clone.name = item.loc_no + "-" + "Goods"; + clone.traverse (function (child) { + if (child instanceof THREE.Mesh) { + child.name = item.loc_no + "-" + child.name; + } + }) + break; + case 2: + positionX = ref.position.x || 0; + positionY = ref.position.y || 0; + positionZ = ref.position.z || 0; + + positionX -= 48 - 1; + positionY += 20; + positionZ -= 138 + 20; + + clone.name = item.wrkNo + "-" + "Goods"; + clone.traverse (function (child) { + if (child instanceof THREE.Mesh) { + child.name = item.wrkNo + "-" + child.name; + } + }) + break; + default: + console.error("InitGoods param[type] error ===>> " + type); + } + clone.position.x = goodsX + positionX; clone.position.y = goodsY + positionY; clone.position.z = goodsZ + positionZ; - that.object.addObject(clone); + scene.addObject(clone); }) }); } -export {StoreGoods} +function StoreGoods(object, data, shelf) { + let that = this; + + that.data = data; + that.object = object; + that.shelf = shelf; + + let palletList = []; + let goodsList = []; + + let init = function () { + 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); + } + } + if (palletList.length > 0) { + InitPallet(that.object, palletList, that.shelf, 1); + } + if (goodsList.length > 0) { + InitGoods(that.object, goodsList, that.shelf, 1); + } + } + init(); + +} + +export {StoreGoods, InitPallet, InitGoods} -- Gitblit v1.9.1