From 967b1b51f17b94b9aaa6264d14266a73d48416ed Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 22 六月 2022 14:14:32 +0800
Subject: [PATCH] #

---
 static/js/object/CrnTask.js         |    1 
 static/js/object/StaTask.js         |   12 ++
 static/js/object/StoreGoods_Copy.js |  182 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 192 insertions(+), 3 deletions(-)

diff --git a/static/js/object/CrnTask.js b/static/js/object/CrnTask.js
index ea833f3..befe7e7 100644
--- a/static/js/object/CrnTask.js
+++ b/static/js/object/CrnTask.js
@@ -248,6 +248,7 @@
                                     break
                                 case 'fork':
                                     that.crnFork.position.set(point.x + xOffset1, point.y, point.z);
+                                    // console.log("loadPos:" + curves[i].loadPos + "\n" + that.pallet);
                                     if (curves[i].loadPos === 1 && that.pallet) {
                                         that.pallet.position.setX(point.x + palletX);
                                         that.goods.position.setX(point.x + goodsX);
diff --git a/static/js/object/StaTask.js b/static/js/object/StaTask.js
index 6680755..970d667 100644
--- a/static/js/object/StaTask.js
+++ b/static/js/object/StaTask.js
@@ -7,6 +7,7 @@
     that.object = object;
 
     that.no = 0;
+    that.readyIn = false;
     that.run = false;
     that.loaded = 0;
     that.wrkNo = null;
@@ -35,18 +36,23 @@
         }
 
         if (that.loaded === 0 && staData.loaded === 1) {
+            that.readyIn = true;
+        }
+        if (that.readyIn && staData.wrkNo && staData.wrkNo !== '0') {
+            console.log(staData)
             // 鏃犺揣 ===>> 鏈夎揣
 
             // 1.鍏ュ簱绗竴绔� 銆愭柊澧炪��
             if (that.inlet === 1) {
                 InitPallet(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2);
                 InitGoods(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2);
-            // 2.鏉ヨ嚜鍏朵粬绔欑偣鐨勮揣鐗� 銆愮Щ鍔ㄣ��
+                // 2.鏉ヨ嚜鍏朵粬绔欑偣鐨勮揣鐗� 銆愮Щ鍔ㄣ��
             } else {
 
             }
-
+            that.readyIn = false;
         }
+
         if (that.loaded === 1 && staData.loaded === 0) {
             // 鏈夎揣 ===>> 鏃犺揣
 
@@ -61,7 +67,7 @@
                     that.object.removeObject(that.wrkNo + "-Goods");
                 }
             }
-
+            that.readyIn = false;
         }
 
         // 瀹炴椂鏇存柊
diff --git a/static/js/object/StoreGoods_Copy.js b/static/js/object/StoreGoods_Copy.js
new file mode 100644
index 0000000..b83ff8d
--- /dev/null
+++ b/static/js/object/StoreGoods_Copy.js
@@ -0,0 +1,182 @@
+import {MTLLoader} from "../lib/MTLLoader.js";
+import {OBJLoader} from "../lib/OBJLoader.js";
+import * as THREE from '../three.module.js';
+
+const palletX = -18;
+const palletY = 2;
+const palletZ = -46;
+
+const goodsX = -17;
+const goodsY = 5;
+const goodsZ = -6;
+
+/**
+ * 鍒濆鍖栨墭鐩樻ā鍨�
+ * @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/' )
+        .load( 'pallet.obj', function ( obj ) {
+            obj.traverse (function (child) {
+                child.castShadow = true;
+                if (child instanceof THREE.Mesh) {
+                    child.material = new THREE.MeshLambertMaterial({
+                        color: 0x708090
+                    });
+                }
+            });
+            obj.scale.set(4, 4, 3.5);
+
+            palletList.map(item => {
+                let clone = obj.clone();
+                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.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;
+                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 ) {
+        obj.traverse (function (child) {
+            child.castShadow = true;
+            if (child instanceof THREE.Mesh) {
+                if (child.name === 'goods') {
+                    child.material.map = goodsImg;
+                } else if (child.name === "goods_wrap") {
+                    child.material.map = goodsWrapImg;
+                }
+            }
+        });
+        obj.scale.set(1, 1.2, 1.2);
+
+        goodsList.map(item => {
+            let clone = obj.clone();
+            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.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;
+            scene.addObject(clone);
+        })
+    });
+}
+
+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