车间模型有了,但是还是显得空旷,这节给车间添加线边仓,线边仓的作用是为了节省时间,保持产线持续生产的,比如生成手机的时候,会更多的原料放在线边仓,如果产线上的物料用完了,可以从线边仓得到补给,而不用去仓库领料,这样可以保持产线的不间断,所以一般的仓库都有线边仓的存在,有的也叫暂存仓等。

        之前的章节中有绘制过仓库,我们可以参考那个章节的功能,先分析功能,假设我们需要绘制一个两排,五层,三列的货架,。那么首先应该需要循环三次,第一层循环是循环两次,产生两排货架,并保证每次循环,x或者y轴存在偏移来保持货架不重叠,偏移的距离要大于货架的长度或者宽度,第二层循环用来循环是循环五次,产生货架的层数,货架的层数要考虑到层板厚度的影响,层数的偏移要大于今后放置物品的高度,第三层循环是循环每层的列数,循环列数要注意的是考虑到立柱的宽度,也就是货架腿的宽度,最终产生完整的货架。

首先我们需要整合下数据,下面是代码:

initShelf(){
      for (let i = 0; i < this.rackRowCount; i++) { //循环两次产生两排
        this.indistanceY = this.indistanceY + 55;//并排货架的偏移量,正式开发中可以根据货架的层板动态算出来
        for (let j = 0; j < this.rackColCount; j++) { //循环三次产生三列
          let shelfName = '货架' + (j + 1) + "上"
          this.shelfList.push({
            shelfName: (i + 1) + "排_" + shelfName,
            planeWidth: this.plane.planeWidth,
            planeHeight: this.plane.planeHeight,
            planeLength: this.plane.planeLength,
            holderLength: this.holder.holderLength,
            holderHeight: this.holder.holderHeight,
            holderWidth: this.holder.holderWidth,
            positionX: this.indistanceX,
            positionY: this.indistanceY + (j * this.plane.planeLength),//每个货架层平移产生多列货架
            positionZ: this.holder.holderHeight ,//距离地面的高度
            layerNum: this.layerNum,
            columnNum: this.columnNum
          });
        }
      }
      for(let i = 0;i < this.shelfList.length; i++){//再次循环货架列,调用生成货架的方法,传参要包含xyz,以及长宽高等
        for(let j = 0; j < this.shelfList[i].layerNum; j++){//循环每列货架的的层数
          this.addShelf(
              this.shelfList[i].positionX,
              this.shelfList[i].positionY,
              this.shelfList[i].positionZ*(j+1)-10,//因为整个场景的地板并非0,所以要往下偏移让货架腿放在地板上,+1是为了层板厚度
              this.shelfList[i].planeWidth,
              this.shelfList[i].planeLength,
              this.shelfList[i].planeHeight,
              this.shelfList[i].holderLengt