|  |  | 
 |  |  | import * as BufferGeometryUtils from '../utils/BufferGeometryUtils.js'; | 
 |  |  |  | 
 |  |  | function StoreShelf(option) { | 
 |  |  |     this.binLength = option.binLength||50;//库位长度 | 
 |  |  |     this.binWidth = option.binWidth||50;//库位宽 | 
 |  |  | 
 |  |  |     this.rackWidth = 3;//支架的宽度,默认设定为3 | 
 |  |  |  | 
 |  |  |     // 材质 | 
 |  |  |     let shelfMat = new THREE.MeshLambertMaterial({ | 
 |  |  |     let shelfMat = new THREE.MeshPhysicalMaterial({ | 
 |  |  |         color: 0x175EC0, | 
 |  |  |         transparent: true, | 
 |  |  |         opacity: .2 | 
 |  |  |     });//定义支架和托盘的材质 | 
 |  |  |         opacity: 0.7 | 
 |  |  |     }); | 
 |  |  |     //定义一个组合体 | 
 |  |  |     let group = new THREE.Group(); | 
 |  |  |  | 
 |  |  | 
 |  |  |     //右侧支架柱的X轴定位 | 
 |  |  |     let rightPositionX=this.positionX+this.binLength/2 - this.rackLengh;    // 缩进支架长度 | 
 |  |  |  | 
 |  |  |     let geometries = []; | 
 |  |  |     let transform = new THREE.Object3D(); | 
 |  |  |     // 初始化支架模型 | 
 |  |  |     for(let i=0;i<=this.binZNum;i++) { | 
 |  |  |         let leftRack = rackObject.clone(); | 
 |  |  |         let positionZ = - ( this.positionZ + i*this.binWidth ); | 
 |  |  |         leftRack.position.set(leftPositionX,positionY,positionZ); | 
 |  |  |         leftRack.updateMatrix(); | 
 |  |  |         group.add(leftRack); | 
 |  |  |         // let leftRack = rackObject.clone(); | 
 |  |  |         // let positionZ = - ( this.positionZ + i*this.binWidth ); | 
 |  |  |         // leftRack.position.set(leftPositionX,positionY,positionZ); | 
 |  |  |         // leftRack.updateMatrix(); | 
 |  |  |         // group.add(leftRack); | 
 |  |  |         // | 
 |  |  |         // let rightRack = rackObject.clone(); | 
 |  |  |         // rightRack.position.set(rightPositionX,positionY,positionZ); | 
 |  |  |         // rightRack.updateMatrix(); | 
 |  |  |         // group.add(rightRack); | 
 |  |  |  | 
 |  |  |         let rightRack = rackObject.clone(); | 
 |  |  |         rightRack.position.set(rightPositionX,positionY,positionZ); | 
 |  |  |         rightRack.updateMatrix(); | 
 |  |  |         group.add(rightRack); | 
 |  |  |         let positionZ = - ( this.positionZ + i*this.binWidth ); | 
 |  |  |         // ----- | 
 |  |  |         let leftClone = rackBoxGeometry.clone(); | 
 |  |  |         transform.position.set(leftPositionX,positionY,positionZ); | 
 |  |  |         transform.updateMatrix(); | 
 |  |  |         leftClone.applyMatrix4(transform.matrix); | 
 |  |  |         geometries.push(leftClone); | 
 |  |  |  | 
 |  |  |         let rightClone = rackBoxGeometry.clone(); | 
 |  |  |         transform.position.set(rightPositionX,positionY,positionZ); | 
 |  |  |         transform.updateMatrix(); | 
 |  |  |         rightClone.applyMatrix4(transform.matrix); | 
 |  |  |         geometries.push(rightClone); | 
 |  |  |     } | 
 |  |  |     // 初始化托板模型 | 
 |  |  |     for(let i = 0;i < this.binZNum;i++) { | 
 |  |  |         for (let j = 0;j <= this.binYNum;j++) { | 
 |  |  |             let plane = planeObject.clone(); | 
 |  |  |             // let plane = planeObject.clone(); | 
 |  |  |             // let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1; | 
 |  |  |             // let positionZ= - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); | 
 |  |  |             // plane.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); | 
 |  |  |             // plane.updateMatrix(); | 
 |  |  |             // group.add(plane); | 
 |  |  |  | 
 |  |  |             let clone = planeBoxGeometry.clone(); | 
 |  |  |             let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1; | 
 |  |  |             let positionZ= - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); | 
 |  |  |             plane.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); | 
 |  |  |             plane.updateMatrix(); | 
 |  |  |             group.add(plane); | 
 |  |  |             transform.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); | 
 |  |  |             transform.updateMatrix(); | 
 |  |  |             clone.applyMatrix4(transform.matrix); | 
 |  |  |             geometries.push(clone); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     return group; | 
 |  |  |  | 
 |  |  |     let mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(geometries); | 
 |  |  |     return  new THREE.Mesh(mergedGeometry, shelfMat); | 
 |  |  | } | 
 |  |  |  | 
 |  |  | export {StoreShelf} |