From 75ce35a2d6cd026a091805a34c6b7ce8a38f943a Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期日, 07 四月 2024 14:20:49 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | 37 ++----------------
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx | 56 ++++++++++++++++++---------
2 files changed, 41 insertions(+), 52 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
index 9f6818d..010d3ed 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -10,7 +10,7 @@
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader'
import * as Utils from '../../utils'
-const help = false;
+const help = true;
export default class ShelfThree {
@@ -121,14 +121,14 @@
initControls = () => {
const controls = new OrbitControls(this.camera, this.renderer.domElement);
// controls.enableRotate = false; // 绂佺敤鏁翠綋鏃嬭浆鍔熻兘
- controls.enablePan = false; // 鍏佽骞崇Щ
+ controls.enablePan = true; // 鍏佽骞崇Щ
controls.enableDamping = true; // 寮�鍚樆灏�
controls.dampingFactor = 0.08; // 闃诲凹鍥犲瓙
controls.enableZoom = true; // 鍏佽缂╂斁
// controls.minDistance = 1; // 鏈�灏忕缉鏀捐窛绂�
// controls.maxDistance = 30; // 鏈�澶х缉鏀捐窛绂�
controls.minPolarAngle = 0; // 鏈�灏忎刊浠拌搴︼紙鍚戜笅鐪嬶級
- controls.minPolarAngle = Math.PI / 2.1;
+ // controls.minPolarAngle = Math.PI / 2.1;
controls.maxPolarAngle = Math.PI / 2.1; // 鏈�澶т刊浠拌搴︼紙鍚戜笂鐪嬶級
controls.rotateSpeed = 0.6; // 瑙嗚绉诲姩閫熷害鍑忔參
controls.autoRotate = true; // 鑷姩鏃嬭浆
@@ -190,37 +190,8 @@
}
generateMesh = (fn) => {
- // fn(this.addObject);
const loader = new FBXLoader();
- const promise = new Promise((resolve) => {
- loader.load('model/04.fbx', (mesh) => {
- mesh.position.set(0, 10, 0);
- mesh.scale.set(5, 5, 5);
- mesh.name = '1-1-1';
- mesh.traverse(function (child) {
- if (child.isMesh) {
- if (child.name === '涓嶈鍒�') {
- // child.visible = false;
- child.material.color.set(0xE8B67E);
- }
- if (child.name === '璐ф灦') {
- // child.visible = false;
- child.material.color.set(0x4680BF);
- }
- if (child.name === '鎵樼洏') {
- // child.visible = false;
- child.material.color.set(0xBEBEBE);
- }
- child.name = '1-1-1'
- child.castShadow = true;
- child.receiveShadow = true;
- }
- });
- this.addObject(mesh);
- resolve();
- })
- })
- return promise;
+ fn(loader, this.addObject);
}
setNewSelectedMesh = (objName) => {
diff --git a/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx b/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
index 3a313fc..f1cfead 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
@@ -59,28 +59,46 @@
const fetchShelfInfo = async (locNo) => {
const res = await Http.doGet('/api/map/shelf/info', { locNo: locNo });
if (res?.data && shelfThree) {
- shelfThree.generateMesh((addObject) => {
+ shelfThree.generateMesh((loader, addObject) => {
+ const promises = [];
for (const item of res.data) {
- const { row, bay, lev } = Utils.parseLocNo(item.locNo);
- // shelf
- const shelfMesh = new THREE.Mesh(new THREE.BoxGeometry(100, 40, 100), new THREE.MeshStandardMaterial({
- color: '#006266',
+ const { lev } = Utils.parseLocNo(item.locNo);
+ promises.push(new Promise((resolve) => {
+ loader.load('model/04.fbx', (mesh) => {
+ mesh.position.set(0, 20 + 100 * (lev - 1), 0);
+ mesh.scale.set(5, 5, 5);
+ mesh.name = item.locNo;
+ mesh.traverse(function (child) {
+ if (child.isMesh) {
+ if (child.name === '涓嶈鍒�') {
+ // child.visible = false;
+ child.material.color.set(0xE8B67E);
+ }
+ if (child.name === '璐ф灦') {
+ // child.visible = false;
+ child.material.color.set(0x4680BF);
+ }
+ if (child.name === '鎵樼洏') {
+ // child.visible = false;
+ child.material.color.set(0xBEBEBE);
+ }
+ child.name = item.locNo
+ child.castShadow = true;
+ child.receiveShadow = true;
+ }
+ });
+ addObject(mesh);
+ resolve();
+ })
}));
- shelfMesh.name = item.locNo;
- shelfMesh.position.set(0, 20 + 100 * (lev - 1), 0);
- addObject(shelfMesh)
-
- // pallet
- const palletMesh = new THREE.Mesh(new THREE.BoxGeometry(100, 60, 100), new THREE.MeshStandardMaterial({
- color: '#2c2c54',
- }));
- palletMesh.name = item.locNo;
- palletMesh.position.set(0, 70 + 100 * (lev - 1), 0);
- addObject(palletMesh)
}
- }).then(() => {
- shelfThree.setNewSelectedMesh(locNo);
- });
+
+ Promise.all(promises).then(() => {
+ shelfThree.setNewSelectedMesh(locNo);
+ }).catch(error => {
+ console.error(error);
+ });
+ })
}
}
--
Gitblit v1.9.1