|  |  |  | 
|---|
|  |  |  | init(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.load = function () { | 
|---|
|  |  |  | new THREE.ObjectLoader().load( "../static/model/json/链条输送机.json", function (obj) { | 
|---|
|  |  |  | new THREE.ObjectLoader().load( "../static/model/json/chainConvey.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 | 
|---|
|  |  |  | child.scale.set(1, 1, 1.6); | 
|---|
|  |  |  | child.material = new THREE.MeshPhysicalMaterial({ | 
|---|
|  |  |  | color: 0x444444 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (child.name === "Box034" || child.name === "Box035") { | 
|---|
|  |  |  | child.material = new THREE.MeshPhysicalMaterial({ | 
|---|
|  |  |  | color: 0x1C1C1C | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | child.castShadow = true; | 
|---|
|  |  |  | // child.receiveShadow = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | chainList.map(item => { | 
|---|
|  |  |  | that.object.addObject(customize(obj.clone(), item)); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | new THREE.ObjectLoader().load( "../static/model/json/rollerConvey.json", function (obj) { | 
|---|
|  |  |  | obj.traverse (function (child) { | 
|---|
|  |  |  | if (child instanceof THREE.Mesh) { | 
|---|
|  |  |  | child.scale.set(0.5, 1, 1); | 
|---|
|  |  |  | child.material = new THREE.MeshPhysicalMaterial({ | 
|---|
|  |  |  | color: 0x444444 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | child.castShadow = true; | 
|---|
|  |  |  | // child.receiveShadow = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | rollerList.map(item => { | 
|---|
|  |  |  | that.object.addObject(customize(obj.clone(), item)); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | new THREE.ObjectLoader().load( "../static/model/json/transportConvey.json", function (obj) { | 
|---|
|  |  |  | obj.traverse (function (child) { | 
|---|
|  |  |  | if (child instanceof THREE.Mesh) { | 
|---|
|  |  |  | child.scale.set(1, 1, 1); | 
|---|
|  |  |  | child.material = new THREE.MeshPhysicalMaterial({ | 
|---|
|  |  |  | color: 0x444444 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 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 ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | transportList.map(item => { | 
|---|
|  |  |  | that.object.addObject(customize(obj.clone(), item)); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function customize(clone, info) { | 
|---|
|  |  |  | let positionX = info.position.x || 0; | 
|---|
|  |  |  | let positionY = info.position.y || 0; | 
|---|
|  |  |  | let positionZ = info.position.z || 0; | 
|---|
|  |  |  | let rotateY = info.rotateY || 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | clone.name = info.no + "-sta"; | 
|---|
|  |  |  | clone.position.x = 0 + positionX; | 
|---|
|  |  |  | clone.position.y = 0 + positionY; | 
|---|
|  |  |  | clone.position.z = 0 + positionZ; | 
|---|
|  |  |  | clone.rotateY(rotateY); | 
|---|
|  |  |  | if (info.traverse !== undefined) { | 
|---|
|  |  |  | let traverse = info.traverse; | 
|---|
|  |  |  | clone.traverse (function (child) { | 
|---|
|  |  |  | if (child instanceof THREE.Mesh) { | 
|---|
|  |  |  | // 拉伸 | 
|---|
|  |  |  | if (traverse.scale !== undefined) { | 
|---|
|  |  |  | let scaleX = traverse.scale.x || 1; | 
|---|
|  |  |  | let scaleY = traverse.scale.y || 1; | 
|---|
|  |  |  | let scaleZ = traverse.scale.z || 1; | 
|---|
|  |  |  | child.scale.set(scaleX, scaleY, scaleZ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 颜色 | 
|---|
|  |  |  | if (traverse.color !== undefined) { | 
|---|
|  |  |  | child.material = new THREE.MeshLambertMaterial({ | 
|---|
|  |  |  | color: traverse.color | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return clone; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export {StoreConvey} | 
|---|