From 173a8c329ac743625ba958ff8e5462e67308110b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期五, 18 三月 2022 13:11:29 +0800
Subject: [PATCH] #
---
static/js/object/StoreGoods.js | 86 ++++++++++++++++++++++++++++--------------
1 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/static/js/object/StoreGoods.js b/static/js/object/StoreGoods.js
index dcd5c3a..70b25a5 100644
--- a/static/js/object/StoreGoods.js
+++ b/static/js/object/StoreGoods.js
@@ -2,6 +2,14 @@
import {OBJLoader} from "../lib/OBJLoader.js";
import * as THREE from '../three.module.js';
+const palletX = -18;
+const palletY = 2;
+const palletZ = -46;
+
+const goodsX = -17;
+const goodsY = 5;
+const goodsZ = -6;
+
function StoreGoods(object, data, shelf) {
let that = this;
that.data = data;
@@ -21,41 +29,61 @@
}
const manager = new THREE.LoadingManager();
- new MTLLoader(manager)
+ new OBJLoader( manager )
.setPath( '../static/model/obj/' )
- .load( 'pallet.mtl', function ( materials ) {
- materials.preload();
- new OBJLoader( manager )
- .setMaterials( materials )
- .setPath( '../static/model/obj/' )
- .load( 'pallet.obj', function ( obj ) {
- obj.traverse (function (child) {
- child.castShadow = true;
- if (child instanceof THREE.Mesh) {
- child.material = new THREE.MeshLambertMaterial({
- color: 0x2F4F4F
- });
- }
+ .load( 'pallet.obj', function ( obj ) {
+ obj.traverse (function (child) {
+ child.castShadow = true;
+ if (child instanceof THREE.Mesh) {
+ child.material = new THREE.MeshLambertMaterial({
+ color: 0x708090
});
- obj.scale.set(4, 4, 3.5);
- obj.position.x = -1;
- obj.position.y = 22;
- obj.position.z = -46;
+ }
+ });
+ obj.scale.set(4, 4, 3.5);
- palletList.map(item => {
- var clone = obj.clone();
- let positionX = that.shelf.positionX || 0;
- let positionY = that.shelf.positionY || 0;
- let positionZ = that.shelf.positionZ || 0;
+ palletList.map(item => {
+ let clone = obj.clone();
+ let positionX = that.shelf.positionX || 0;
+ let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0;
+ let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0;
- clone.position.x = -18 + positionX;
- clone.position.y = 22 + positionY;
- clone.position.z = -46 + positionZ;
- that.object.addObject(clone);
- })
- }, null, null );
+ clone.name = item.loc_no + "-" + "Pallet";
+ clone.position.x = palletX + positionX;
+ clone.position.y = palletY + positionY;
+ clone.position.z = palletZ + positionZ;
+ that.object.addObject(clone);
+ })
});
+ const goodsWrapImg = new THREE.TextureLoader( manager ).load( '../static/img/goodsWrap.jpg' );
+ const goodsImg = new THREE.TextureLoader( manager ).load( '../static/img/goods.jpg' );
+ new OBJLoader( manager ).load( '../static/model/obj/goods.obj', function ( obj ) {
+ obj.traverse (function (child) {
+ child.castShadow = true;
+ if (child instanceof THREE.Mesh) {
+ if (child.name === 'goods') {
+ child.material.map = goodsImg;
+ } else if (child.name === "goods_wrap") {
+ child.material.map = goodsWrapImg;
+ }
+ }
+ });
+ obj.scale.set(1, 1.2, 1.2);
+
+ goodsList.map(item => {
+ let clone = obj.clone();
+ let positionX = that.shelf.positionX || 0;
+ let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0;
+ let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0;
+
+ clone.name = item.loc_no + "-" + "Goods";
+ clone.position.x = goodsX + positionX;
+ clone.position.y = goodsY + positionY;
+ clone.position.z = goodsZ + positionZ;
+ that.object.addObject(clone);
+ })
+ });
}
export {StoreGoods}
--
Gitblit v1.9.1