From 6809123d3ed5cce20bfd8bebf150f606ddb5ed35 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期六, 25 十二月 2021 10:05:02 +0800
Subject: [PATCH] #

---
 static/js/app.js                |   26 +------------
 static/js/object/StoreConvey.js |   85 +++++++++++++++++++++---------------------
 2 files changed, 44 insertions(+), 67 deletions(-)

diff --git a/static/js/app.js b/static/js/app.js
index ff9ff31..4c26fdd 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -31,7 +31,6 @@
 		this.raycaster = null;
 		this.prevTime = performance.now();//涓婁竴娆ender鐨勬椂闂�
 		this.backgroundType = false;
-		this.conveyTypes = [];
 
 		this.start = function () {
 			this.initMain();
@@ -341,29 +340,8 @@
 			}
 		}
 		this.initConvey = function () {
-			let conveys = conveyObjects.objects;
-			for (let i = 0; i < conveys.length; i++) {
-				let conveyObj = conveys[i];
-
-				let existConvey = this.getExistedConveyType(conveyObj.objectType);
-				let storeConvey = new StoreConvey(conveyObj);
-				if(existConvey === null) {
-					storeConvey.create(this);
-				} else {
-					// let convey= storeConvey.clone(existConvey);
-					// object.addObject(convey);
-				}
-
-			}
-		}
-		this.getExistedConveyType = function (type) {
-			for (let i=0;i<this.conveyTypes.length;i++) {
-				let type=this.conveyTypes[i];
-				if(type.objectType === type) {
-					return type.object;
-				}
-			}
-			return null;
+			let storeConvey = new StoreConvey(this, conveyObjects.objects)
+			storeConvey.load();
 		}
 		this.initStoreObjects = function (object) {
 			if (this.firstTime === 1) {
diff --git a/static/js/object/StoreConvey.js b/static/js/object/StoreConvey.js
index 2548bce..4674b0c 100644
--- a/static/js/object/StoreConvey.js
+++ b/static/js/object/StoreConvey.js
@@ -2,57 +2,56 @@
 import {OBJLoader} from "../lib/OBJLoader.js";
 import * as THREE from '../three.module.js';
 
-
-function StoreConvey(object) {
+function StoreConvey(object, data) {
     let that = this;
-    that.no = 0;
-    that.objectType = null;
-    that.position = null;
+    that.data = null;
+    that.object = null;
+
+    let chainList = [];
+    let rollerList = [];
+    let transportList = [];
 
     let init = function () {
-        that.no = object.no;
-        that.objectType = object.objectType;
-        that.position = object.position;
+        that.data = data;
+        that.object = object;
+        for (let i=0;i<that.data.length;i++) {
+            let conveyObj = that.data[i];
+            switch (conveyObj.objectType) {
+                case "chain":
+                    chainList.push(conveyObj);
+                    break;
+                case "roller":
+                    rollerList.push(conveyObj);
+                    break;
+                case "transport":
+                    transportList.push(conveyObj);
+                    break;
+                default:
+                    break;
+            }
+        }
     };
     init();
 
-    that.create = function (scene) {
-        switch (that.objectType) {
-            case "chain":
-                new THREE.ObjectLoader().load( "../static/model/json/閾炬潯杈撻�佹満.json", function (obj) {
-                    obj.traverse (function (child) {
-                        if (child instanceof THREE.Mesh) {
-                            child.scale.set(1, 1, 1.8);
-                            child.material = new THREE.MeshLambertMaterial({
-                                color: 0xAAAAAA
-                            });
-                        }
+    this.load = function () {
+        new THREE.ObjectLoader().load( "../static/model/json/閾炬潯杈撻�佹満.json", function (obj) {
+            obj.traverse (function (child) {
+                if (child instanceof THREE.Mesh) {
+                    child.scale.set(1, 1, 1.8);
+                    child.material = new THREE.MeshLambertMaterial({
+                        color: 0xAAAAAA
                     });
-                    obj.position.x = 0 + that.position.x;
-                    obj.position.y = 0 + that.position.y;
-                    obj.position.z = 0 + that.position.z;
-                    scene.addObject( obj );
-                    scene.conveyTypes.push({type: that.objectType, object: obj});
-                } );
-                break;
-            case "roller":
-                break;
-            case "transport":
-                break;
-            default:
-                break;
-        }
+                }
+            });
+            for (let k=0;k<chainList.length;k++) {
+                let clone = obj.clone();
+                clone.position.x = 0 + chainList[k].position.x;
+                clone.position.y = 0 + chainList[k].position.y;
+                clone.position.z = 0 + chainList[k].position.z;
+                that.object.addObject( clone );
+            }
+        });
     }
-
-    this.clone = function (param) {
-        let goods=param.clone();
-        goods.position.set(this.positionX,this.positionY,this.positionZ);
-        goods.uuid=this.no;
-        goods.name=this.name;
-        goods.type="StoreGoods";
-        return goods;
-    }
-
 }
 
 export {StoreConvey}

--
Gitblit v1.9.1