From f9b82b114317e5d60f0537685b194da47136e478 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期五, 07 一月 2022 09:45:30 +0800
Subject: [PATCH] #
---
static/js/object/StoreShelf.js | 78 +++++++++++++++++++++++++++++----------
1 files changed, 58 insertions(+), 20 deletions(-)
diff --git a/static/js/object/StoreShelf.js b/static/js/object/StoreShelf.js
index 3591c4a..b1761e0 100644
--- a/static/js/object/StoreShelf.js
+++ b/static/js/object/StoreShelf.js
@@ -1,4 +1,6 @@
-function StoreShelf0(option) {
+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;//搴撲綅楂�
@@ -11,14 +13,19 @@
this.positionZ = option.position.z||0;//搴撲綅浣嶇疆
this.rackLengh = 3;//鏀灦鐨勯暱搴︼紝榛樿璁惧姩涓�3
this.rackWidth = 3;//鏀灦鐨勫搴︼紝榛樿璁惧畾涓�3
+ this.mesh = null;
// 鏉愯川
- let shelfMat = new THREE.MeshLambertMaterial({color:0x175EC0});//瀹氫箟鏀灦鍜屾墭鐩樼殑鏉愯川
+ let shelfMat = new THREE.MeshPhysicalMaterial({
+ color: 0x175EC0,
+ transparent: false,
+ opacity: 0.7
+ });
//瀹氫箟涓�涓粍鍚堜綋
- let group = new THREE.Group();
+ // let group = new THREE.Group();
// 璐ф灦鎬婚珮
- let shelfHeight=this.bottomHight+(this.binYNum-1)*this.binHeight;
+ let shelfHeight=this.bottomHight+(this.binYNum)*this.binHeight;
// 璐ф灦鎬诲
let shelfWidth=this.binZNum*this.binWidth;
// 鏀灦妯″瀷 + 鏉愯川
@@ -36,29 +43,60 @@
//鍙充晶鏀灦鏌辩殑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 - shelfWidth/2 + 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();
+ 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 clone = planeBoxGeometry.clone();
let positionY= this.positionY + this.bottomHight + j*this.binHeight + 1;
- 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);
+ 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);
}
}
- return group;
+
+ let mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(geometries);
+ let mesh = new THREE.Mesh(mergedGeometry, shelfMat);
+ mesh.castShadow = true;
+ this.mesh = mesh;
+ return this;
}
+
+export {StoreShelf}
--
Gitblit v1.9.1