zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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) => { 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', })); 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) 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); } }).then(() => { shelfThree.setNewSelectedMesh(locNo); 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(); }) })); } Promise.all(promises).then(() => { shelfThree.setNewSelectedMesh(locNo); }).catch(error => { console.error(error); }); }) } }