#
whycq
2021-12-11 79f43426a1a14980683f67ea5182b79af87e1178
static/js/object/StoreShelf0.js
@@ -1,24 +1,19 @@
function StoreShelf0(option) {
    this.binLength = option.BinLength||50;//库位长度
    this.binWidth = option.BinWidth||50;//库位宽
    this.binHeight = option.BinHeight||50;//库位高
    this.binXNum = option.BinXNum||1;//库位X轴方向库位数量
    this.binZNum = option.BinZNum||10;//库位Z轴方向库位数量
    this.binYNum = option.BinYNum||10;//库位Y轴库位数量
    this.bottomHight = option.BottomHeight||20;//底层高度,底层
    this.positionX = option.Position.X||0;//库位位置
    this.positionY = option.Position.Y||0;//库位位置
    this.positionZ = option.Position.Z||0;//库位位置
    this.binLength = option.binLength||50;//库位长度
    this.binWidth = option.binWidth||50;//库位宽
    this.binHeight = option.binHeight||50;//库位高
    this.binXNum = option.binXNum||1;//库位X轴方向库位数量
    this.binZNum = option.binZNum||10;//库位Z轴方向库位数量
    this.binYNum = option.binYNum||10;//库位Y轴库位数量
    this.bottomHight = option.bottomHeight||20;//底层高度,底层
    this.positionX = option.position.x||0;//库位位置
    this.positionY = option.position.y||0;//库位位置
    this.positionZ = option.position.z||0;//库位位置
    this.rackLengh = 3;//支架的长度,默认设动为3
    this.rackWidth = 3;//支架的宽度,默认设定为3
    // 材质
    let shelfMat = new THREE.MeshPhysicalMaterial({
        color:0xfc8c00,
        metalness: 1.0,
        roughness: 0.6,
    })
    let shelfMat = new THREE.MeshLambertMaterial({color:0x175EC0});//定义支架和托盘的材质
    //定义一个组合体
    let group = new THREE.Group();
@@ -30,21 +25,21 @@
    let rackBoxGeometry=new THREE.BoxGeometry(this.rackLengh,shelfHeight,this.rackWidth);
    let rackObject=new THREE.Mesh(rackBoxGeometry, shelfMat, 0);
    // 托板模型 + 材质
    let planeBoxGeometry = new THREE.BoxGeometry(this.binLength+this.rackLengh, 2, this.binWidth+this.rackWidth);
    let planeBoxGeometry = new THREE.BoxGeometry(this.binLength, 2, this.binWidth+this.rackWidth);  // 覆盖多一根支架宽度
    let planeObject=new THREE.Mesh(planeBoxGeometry, shelfMat, 0);
    // Y轴定位
    let positionY = this.positionY + shelfHeight / 2;
    //左侧支架柱的X轴定位
    let leftPositionX=this.positionX-this.binLength/2-this.rackLengh/2;
    let leftPositionX=this.positionX-this.binLength/2;
    //右侧支架柱的X轴定位
    let rightPositionX=this.positionX+this.binLength/2-this.rackLengh/2;
    let rightPositionX=this.positionX+this.binLength/2 - this.rackLengh;    // 缩进支架长度
    // 初始化支架模型
    for(let i=0;i<=this.binZNum;i++) {
        let leftRack = rackObject.clone();
        let positionZ = this.positionZ - shelfWidth/2 + i*this.binWidth + this.rackWidth/2;
        let positionZ = this.positionZ - shelfWidth/2 + i*this.binWidth;
        leftRack.position.set(leftPositionX,positionY,positionZ);
        leftRack.updateMatrix();
        group.add(leftRack);
@@ -59,7 +54,7 @@
        for (let j = 0;j < this.binYNum;j++) {
            let plane = planeObject.clone();
            let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1;
            let positionZ= this.positionZ - shelfWidth/2 + i * this.binWidth + this.binWidth / 2+this.rackWidth/2;
            let positionZ= this.positionZ - shelfWidth/2 + i * this.binWidth + this.binWidth/2;
            plane.position.set(this.positionX-this.rackLengh/2,positionY,positionZ);
            plane.updateMatrix();
            group.add(plane);