| | |
| | | import {MTLLoader} from "../lib/MTLLoader.js"; |
| | | import {OBJLoader} from "../lib/OBJLoader.js"; |
| | | import {Color} from "../three.module.js"; |
| | | import * as THREE from '../three.module.js'; |
| | | |
| | | const xOffset = 35; |
| | | const yOffset = 44; |
| | | const zOffset = 28; |
| | | |
| | | const xOffset0 = -1407; |
| | | const yOffset0 = 0; |
| | | const zOffset0 = 490; |
| | | |
| | | function StoreConvey(object) { |
| | | let that = this; |
| | | that.no = 0; |
| | | that.objectType = null; |
| | | that.position = null; |
| | | |
| | | const manager = new THREE.LoadingManager(); |
| | | let init = function () { |
| | | that.no = object.no; |
| | | that.objectType = object.objectType; |
| | | that.position = object.position; |
| | | }; |
| | | init(); |
| | | |
| | | let chain = null; |
| | | new MTLLoader(manager) |
| | | .setPath( '../static/model/obj/' ) |
| | | .load( '链条输送机.mtl', function ( materials ) { |
| | | materials.preload(); |
| | | new OBJLoader( manager ) |
| | | .setMaterials( materials ) |
| | | .setPath( '../static/model/obj/' ) |
| | | .load( '链条输送机.obj', function ( obj ) { |
| | | chain = obj; |
| | | chain.scale.set(0.03, 0.03, 0.025); |
| | | chain.rotateY( -Math.PI / 2); |
| | | chain.traverse (function (child) { |
| | | 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 |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | for (let i = 0; i<24; i++) { |
| | | let clone = chain.clone(); |
| | | // roller.name = option.crnNo + "-body"; |
| | | let offset = 0; |
| | | if (i % 2 === 0) { |
| | | offset = 90; |
| | | } |
| | | clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230; |
| | | clone.position.y = yOffset0; |
| | | clone.position.z = zOffset0 + 39; |
| | | object.addObject( clone ); |
| | | } |
| | | |
| | | for (let i = 0; i<24; i++) { |
| | | let clone = chain.clone(); |
| | | // roller.name = option.crnNo + "-body"; |
| | | let offset = 0; |
| | | if (i % 2 === 0) { |
| | | offset = 90; |
| | | } |
| | | clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230; |
| | | clone.position.y = yOffset0; |
| | | clone.position.z = zOffset0 + 39 + 82; |
| | | object.addObject( clone ); |
| | | } |
| | | |
| | | for (let i = 0; i<24; i++) { |
| | | var clone = chain.clone(); |
| | | // roller.name = option.crnNo + "-body"; |
| | | let offset = 0; |
| | | if (i % 2 === 0) { |
| | | offset = 90; |
| | | } |
| | | clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230; |
| | | clone.position.y = yOffset0 + 310; |
| | | clone.position.z = zOffset0 + 39; |
| | | object.addObject( clone ); |
| | | } |
| | | |
| | | }, null, null ); |
| | | 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}); |
| | | }); |
| | | |
| | | let roller = null; |
| | | new MTLLoader(manager) |
| | | .setPath( '../static/model/obj/' ) |
| | | .load( '123.mtl', function ( materials ) { |
| | | materials.preload(); |
| | | new OBJLoader( manager ) |
| | | .setMaterials( materials ) |
| | | .setPath( '../static/model/obj/' ) |
| | | .load( '123.obj', function ( obj ) { |
| | | roller = obj; |
| | | roller.traverse (function (child) { |
| | | if (child instanceof THREE.Mesh) { |
| | | child.material = new THREE.MeshLambertMaterial({ |
| | | color: 0xAAAAAA |
| | | }); |
| | | break; |
| | | case "roller": |
| | | break; |
| | | case "transport": |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | roller.scale.set(55, 45, 55); |
| | | // roller.rotateY(- Math.PI / 2); |
| | | // roller.name = option.crnNo + "-body"; |
| | | roller.position.x = xOffset + 60; |
| | | roller.position.y = yOffset; |
| | | roller.position.z = zOffset + 140; |
| | | // object.addObject( roller ); |
| | | |
| | | }, null, null ); |
| | | }); |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | |