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

---
 static/js/data/ConveyData.js    |   62 +++++++++++++++++--------------
 static/js/object/StoreConvey.js |   56 ++++++++++++++++++++++++---
 2 files changed, 83 insertions(+), 35 deletions(-)

diff --git a/static/js/data/ConveyData.js b/static/js/data/ConveyData.js
index 51d6b51..262d497 100644
--- a/static/js/data/ConveyData.js
+++ b/static/js/data/ConveyData.js
@@ -2,56 +2,62 @@
     objects: [
         {
             no: '1',
-            objectName: 'chain-1',
             objectType: 'chain',
-            length: 2750,
-            width: 800,
-            height: 1,
             position: {
                 x: 110,
                 y: 0,
                 z: 220
             },
-            style:{
-                color: 0x5F7480,
+            rotateY: 0,
+            traverse: {
+                color: 0xAAAAAA,
+                scale: {
+                    x: 1,
+                    y: 1,
+                    z: 1
+                }
             }
         },
         {
             no: '2',
-            objectName: 'chain-2',
             objectType: 'chain',
-            length: 2750,
-            width: 800,
-            height: 1,
             position: {
                 x: 0,
                 y: 0,
                 z: 0
             },
-            style:{
-                color: 0x5F7480,
-            }
-        },
-        {
-            no: '2',
-            objectName: 'roller-1',
-            objectType: 'roller',
-            length: 2750,
-            width: 800,
-            height: 1,
-            position: {
-                x: 0,
-                y: 0,
-                z: 0
-            },
-            style:{
+            rotateY: Math.PI/2,
+            traverse: {
+                scale: {
+                    x: 2,
+                    y: 2,
+                    z: 2
+                },
                 color: 0x5F7480,
             }
         },
         {
             no: '3',
+            objectType: 'roller',
+            position: {
+                x: 210,
+                y: 10,
+                z: 120
+            },
+            rotateY: Math.PI/2,
+            traverse: {
+                scale: {
+                    x: 2,
+                    y: 2,
+                    z: 2
+                },
+                color: 0x000000,
+            }
+        },
+        {
+            no: '3',
             objectName: 'transport-1',
-            objectType: 'transport',
+            objectType: 'transport1',
             length: 2750,
             width: 800,
             height: 1,
diff --git a/static/js/object/StoreConvey.js b/static/js/object/StoreConvey.js
index 4674b0c..908cd44 100644
--- a/static/js/object/StoreConvey.js
+++ b/static/js/object/StoreConvey.js
@@ -43,15 +43,57 @@
                     });
                 }
             });
-            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 );
-            }
+            chainList.map(item => {
+                that.object.addObject(customize(obj.clone(), item));
+            })
+        });
+        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
+                    });
+                }
+            });
+            rollerList.map(item => {
+                that.object.addObject(customize(obj.clone(), item));
+            })
+        });
+        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
+                    });
+                }
+            });
+            transportList.map(item => {
+                that.object.addObject(customize(obj.clone(), item));
+            })
         });
     }
+
+    function customize(clone, info) {
+        clone.position.x = 0 + info.position.x;
+        clone.position.y = 0 + info.position.y;
+        clone.position.z = 0 + info.position.z;
+        clone.rotateY(info.rotateY);
+        if (info.traverse !== undefined) {
+            let traverse = info.traverse;
+            clone.traverse (function (child) {
+                if (child instanceof THREE.Mesh) {
+                    child.scale.set(traverse.scale.x, traverse.scale.y, traverse.scale.z);
+                    child.material = new THREE.MeshLambertMaterial({
+                        color: traverse.color
+                    });
+                }
+            });
+        }
+        return clone;
+    }
+
 }
 
 export {StoreConvey}

--
Gitblit v1.9.1