From 18bd54d17c3d09e48b14fcb0cc0fc74758a920b2 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期四, 30 六月 2022 16:51:43 +0800 Subject: [PATCH] # --- static/js/object/StoreShelf.js | 63 +++++++++++++++---------------- 1 files changed, 31 insertions(+), 32 deletions(-) diff --git a/static/js/object/StoreShelf.js b/static/js/object/StoreShelf.js index c583ea0..cf49404 100644 --- a/static/js/object/StoreShelf.js +++ b/static/js/object/StoreShelf.js @@ -13,26 +13,22 @@ this.positionZ = option.position.z||0;//搴撲綅浣嶇疆 this.rackLengh = 3;//鏀灦鐨勯暱搴︼紝榛樿璁惧姩涓�3 this.rackWidth = 3;//鏀灦鐨勫搴︼紝榛樿璁惧畾涓�3 + this.mesh = null; // 鏉愯川 let shelfMat = new THREE.MeshPhysicalMaterial({ color: 0x175EC0, - transparent: true, + transparent: false, opacity: 0.7 }); - //瀹氫箟涓�涓粍鍚堜綋 - let group = new THREE.Group(); // 璐ф灦鎬婚珮 let shelfHeight=this.bottomHight+(this.binYNum)*this.binHeight; - // 璐ф灦鎬诲 - let shelfWidth=this.binZNum*this.binWidth; // 鏀灦妯″瀷 + 鏉愯川 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, 2, this.binWidth+this.rackWidth); // 瑕嗙洊澶氫竴鏍规敮鏋跺搴� - let planeObject=new THREE.Mesh(planeBoxGeometry, shelfMat, 0); + let planeRackBoxGeometry = new THREE.BoxGeometry(3, 2, this.binWidth+this.rackWidth); // Y杞村畾浣� let positionY = this.positionY + shelfHeight / 2; @@ -46,17 +42,6 @@ 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 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(); @@ -74,25 +59,39 @@ // 鍒濆鍖栨墭鏉挎ā鍨� for(let i = 0;i < this.binZNum;i++) { 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 + i * this.binWidth + this.binWidth/2 ); - // plane.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); - // plane.updateMatrix(); - // group.add(plane); + if (j !== this.binYNum) { + let leftClone = planeRackBoxGeometry.clone(); + let positionY = this.positionY + this.bottomHight + j*this.binHeight + 1; + let positionZ = - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); + transform.position.set(this.positionX - 16, positionY, positionZ); + transform.updateMatrix(); + leftClone.applyMatrix4(transform.matrix); + geometries.push(leftClone); - let clone = planeBoxGeometry.clone(); - let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1; - let positionZ= - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); - transform.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); - transform.updateMatrix(); - clone.applyMatrix4(transform.matrix); - geometries.push(clone); + let rightClone = planeRackBoxGeometry.clone(); + positionY = this.positionY + this.bottomHight + j*this.binHeight + 1; + positionZ = - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); + transform.position.set(this.positionX + 13, positionY, positionZ); + transform.updateMatrix(); + rightClone.applyMatrix4(transform.matrix); + geometries.push(rightClone); + } else { + let clone = planeBoxGeometry.clone(); + let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1; + let positionZ= - ( this.positionZ + i * this.binWidth + this.binWidth/2 ); + transform.position.set(this.positionX-this.rackLengh/2,positionY,positionZ); + transform.updateMatrix(); + clone.applyMatrix4(transform.matrix); + geometries.push(clone); + } } } let mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(geometries); - return new THREE.Mesh(mergedGeometry, shelfMat); + let mesh = new THREE.Mesh(mergedGeometry, shelfMat); + mesh.castShadow = true; + this.mesh = mesh; + return this; } export {StoreShelf} -- Gitblit v1.9.1