From c087c4b39244d8da62aa4119258500b411b79ffc Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期五, 17 十二月 2021 14:58:38 +0800
Subject: [PATCH] #
---
static/js/object/StoreShelf.js | 159 +++++++++++++++++++++++++++-------------------------
1 files changed, 82 insertions(+), 77 deletions(-)
diff --git a/static/js/object/StoreShelf.js b/static/js/object/StoreShelf.js
index d5d039a..63262ba 100644
--- a/static/js/object/StoreShelf.js
+++ b/static/js/object/StoreShelf.js
@@ -1,93 +1,98 @@
+import * as BufferGeometryUtils from '../utils/BufferGeometryUtils.js';
+
function StoreShelf(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
- this.intervalRackNum=2;//闂撮殧澶氬皯搴撲綅鏈変竴涓富鏀灦
- // let binHolderPlane=new THREE.BoxGeometry(this.binLength,2,this.binWidth);//瀹氫箟涓�涓窡搴撲綅闀垮鐩稿悓鐨勫嚑浣曚綋锛屼綔涓烘墭鐩�
+ // 鏉愯川
+ let shelfMat = new THREE.MeshLambertMaterial({
+ color: 0x175EC0,
+ transparent: true,
+ opacity: .6
+ });//瀹氫箟鏀灦鍜屾墭鐩樼殑鏉愯川
+ //瀹氫箟涓�涓粍鍚堜綋
+ let group = new THREE.Group();
- //瀹氫箟鏀灦鍜屾墭鐩樼殑鏉愯川
- let shlefMat = new THREE.MeshPhysicalMaterial({
- color:0xff0000,
- // 鏉愯川鍍忛噾灞炵殑绋嬪害. 闈為噾灞炴潗鏂欙紝濡傛湪鏉愭垨鐭虫潗锛屼娇鐢�0.0锛岄噾灞炰娇鐢�1.0锛屼腑闂存病鏈夛紙閫氬父锛�.
- // 榛樿 0.5. 0.0鍒�1.0涔嬮棿鐨勫�煎彲鐢ㄤ簬鐢熼攬鐨勯噾灞炲瑙�
- metalness: 1.0,
- // 鏉愭枡鐨勭矖绯欑▼搴�. 0.0琛ㄧず骞虫粦鐨勯暅闈㈠弽灏勶紝1.0琛ㄧず瀹屽叏婕弽灏�. 榛樿 0.5
- roughness: 0.6,
- // 璁剧疆鐜璐村浘
- // 鍙嶅皠绋嬪害, 浠� 0.0 鍒�1.0.榛樿0.5.
- // 杩欐ā鎷熶簡闈為噾灞炴潗鏂欑殑鍙嶅皠鐜囥�� 褰搈etalness涓�1.0鏃舵棤鏁�
- // reflectivity: 0.5,
- })
-
- let group = new THREE.Group();//瀹氫箟涓�涓粍鍚堜綋
- //鍚堝苟妯″瀷锛屽垯浣跨敤merge鏂规硶鍚堝苟
- let combineGeometry = new THREE.BufferGeometry();
- /*
- 鏀灦鐨勯珮=鏈�搴曞眰鐨勯珮搴�+(搴撲綅鏁�-1)*搴撲綅鐨勯珮搴�
- */
- let shelfHeight=this.bottomHight+(this.binYNum-1)*this.binHeight;
- /*
- 鏀灦鐨勫=搴撲綅鏁颁箻浠ュ簱浣嶇殑瀹藉害
- */
+ // 璐ф灦鎬婚珮
+ 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, shlefMat, 0 );
+ // 鏀灦妯″瀷 + 鏉愯川
+ 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 plane = new THREE.BoxGeometry(this.binLength, 2, this.binWidth);
- let holderObject = new THREE.Mesh(plane, shlefMat,0);
+ // Y杞村畾浣�
+ let positionY = this.positionY + shelfHeight / 2;
- let leftPositionX=this.positionX-this.binLength/2+this.rackLengh/2;//宸︿晶鏀灦鏌辩殑X杞存潯鐮�
- let rightPositionX=this.positionX+this.binLength/2-this.rackLengh/2;//鍙充晶鏀灦鏌辩殑X杞存潯鐮�
+ //宸︿晶鏀灦鏌辩殑X杞村畾浣�
+ let leftPositionX=this.positionX-this.binLength/2;
+ //鍙充晶鏀灦鏌辩殑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 rightRack = rackObject.clone();
+ // rightRack.position.set(rightPositionX,positionY,positionZ);
+ // rightRack.updateMatrix();
+ // group.add(rightRack);
- let positionY=this.positionY-this.binHeight/2;//鏀灦鏌辩殑Y杞村潗鏍�
+ 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);
- for(let i=0;i<this.binZNum+this.intervalRackNum;i++) {
- let isRack=i%this.intervalRackNum;
- if(isRack===0) {
- let PositionZ=this.positionZ-shelfWidth/2+i*this.binWidth+this.rackWidth/2;
- if(i>=this.binZNum) {
- PositionZ=PositionZ-this.rackWidth;
- }
+ 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 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 leftRack=rackObject.clone();
- group.add(leftRack);
- leftRack.position.set(leftPositionX,positionY,PositionZ);
- leftRack.updateMatrix();
- combineGeometry.merge(leftRack.geometry, leftRack.matrix);
- let rightRack=rackObject.clone();
- group.add(rightRack);
- rightRack.position.set(rightPositionX,positionY,PositionZ);
- rightRack.updateMatrix();
- combineGeometry.merge(rightRack.geometry, rightRack.matrix);
+ 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);
}
}
- //鍒涘缓鎵樻澘
- for(let i=0;i<this.binZNum;i++) {
- for (let j = 0; j < this.binYNum; j++) {
- let positionY=this.positionY-this.binHeight/2-shelfHeight/2+this.bottomHight+j*this.binHeight;
- let positionZ=this.positionZ-shelfWidth/2+this.binWidth/2 + i * this.binWidth
- let holderObj= holderObject.clone();
- group.add(holderObj);
- holderObj.position.set(this.positionX,positionY,positionZ);
- holderObj.updateMatrix();
- combineGeometry.merge(holderObj.geometry, holderObj.matrix);
- }
- }
- let shelf= new THREE.Mesh(combineGeometry, shlefMat);
- shelf.uuid=option.No;
- shelf.name=option.Name;
- shelf.type="StoreShelf";
- return group;
+ let mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(geometries);
+ return new THREE.Mesh(mergedGeometry, shelfMat);
}
+
+export {StoreShelf}
--
Gitblit v1.9.1