Browse Source

添加货架-半成品

master
liupeng 7 months ago
parent
commit
a7b0b0b058
  1. 123
      src/designer/model3DView/Model3DView.vue
  2. 4
      src/designer/viewWidgets/toolbox/ToolboxView.vue

123
src/designer/model3DView/Model3DView.vue

@ -16,6 +16,7 @@
<el-button>打开材质</el-button> <el-button>打开材质</el-button>
</el-upload> </el-upload>
<el-button @click="addConveyor">添加输送线</el-button> <el-button @click="addConveyor">添加输送线</el-button>
<el-button @click="createShelf">添加货架</el-button>
<div class="demo-color-block"> <div class="demo-color-block">
<span class="demonstration">材质颜色</span> <span class="demonstration">材质颜色</span>
<el-color-picker v-model="restate.targetColor" /> <el-color-picker v-model="restate.targetColor" />
@ -85,10 +86,9 @@ import Split from '@/components/split/split.vue'
import SplitArea from '@/components/split/split-area.vue' import SplitArea from '@/components/split/split-area.vue'
import { renderIcon } from '@/utils/webutils.js' import { renderIcon } from '@/utils/webutils.js'
import textureUrl from '@/assets/images/conveyor/shapes/RibSideSkirtThumbnail.jpg' import textureUrl from '@/assets/images/conveyor/shapes/RibSideSkirtThumbnail.jpg'
import textureUrl2 from '@/assets/images/conveyor/shapes/logo.png'
import moveUrl from '@/assets/images/conveyor/shapes/move.svg' import moveUrl from '@/assets/images/conveyor/shapes/move.svg'
import arrowRightUrl from '@/assets/images/conveyor/shapes/arrow-right.svg' import arrowRightUrl from '@/assets/images/conveyor/shapes/arrow-right.svg'
// import pointImg from '@/assets/images/logo.png' arrow-right.svg import rackUrl from '@/assets/images/conveyor/shapes/Rack.png'
// DOM refs // DOM refs
const canvasContainer = ref(null) const canvasContainer = ref(null)
@ -260,6 +260,125 @@ function addMarkerAt(x, y,z,textUrl, scale = 1) {
}); });
} }
function createShelf(){//
const textureLoader = new THREE.TextureLoader();
const metalTexture = textureLoader.load('path/to/your/metal/texture.jpg'); //
//
const material = new THREE.MeshStandardMaterial({
map: metalTexture,
metalness: 1.0,
roughness: 0.5
});
//
const shelfLength = 10; //
const shelfWidth = 0.8; //
const shelfThickness = 0.1; //
const rows = 3; //
const columns = 4; //
const spacingY = 1; //
const unitLength = shelfLength / columns; // 2.5m
//
const baseHeight = 2; //
// ---------------------
// 3 × 4
// ---------------------
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
const geometry = new THREE.BoxGeometry(unitLength, shelfThickness, shelfWidth);
const mesh = new THREE.Mesh(geometry, material);
const x = -shelfLength / 2 + unitLength * col + unitLength / 2;
const y = -(shelfThickness + spacingY) * row - shelfThickness / 2 + baseHeight; //
const z = 0;
mesh.position.set(x, y, z);
scene.add(mesh);
}
}
// ---------------------
//
// ---------------------
const thirdShelfCenterY = -(shelfThickness + spacingY) * 2 - shelfThickness / 2 + baseHeight;
const thirdShelfBottomY = thirdShelfCenterY - shelfThickness / 2;
// ---------------------
// +
// ---------------------
const postWidth = 0.1;
const postDepth = 0.1;
const postHeight = 3.3;
const postPositionsX = [0, 2.5, 5, 7.5, 10];
const postPositionsZ = [-shelfWidth / 2, shelfWidth / 2];
// PNG
const loader = new THREE.TextureLoader();
loader.load(rackUrl, (texture) => {
//
const stickerMaterial = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
side: THREE.DoubleSide //
});
postPositionsX.forEach(x => {
postPositionsZ.forEach(z => {
//
const postGeometry = new THREE.BoxGeometry(postWidth, postHeight, postDepth);
const post = new THREE.Mesh(postGeometry, material);
// Y 使
const postCenterY = thirdShelfBottomY + postHeight / 2;
post.position.set(
x - shelfLength / 2,
postCenterY,
z
);
scene.add(post);
// ---------------------
//
// ---------------------
const stickerWidth = 0.08; //
const stickerHeight = 0.2; //
const stickerGeometry = new THREE.PlaneGeometry(stickerWidth, stickerHeight);
const sticker = new THREE.Mesh(stickerGeometry, stickerMaterial);
//
sticker.position.set(
post.position.x + postWidth / 2, //
post.position.y, // Y
post.position.z // Z
);
//
// 使 dcm.orientation.lookAt(camera.position)
//
sticker.lookAt(new THREE.Vector3(1, 0, 0)); // X
//
sticker.position.x += 0.01;
scene.add(sticker);
});
});
})
}
function initThree() { function initThree() {
const viewerDom = canvasContainer.value const viewerDom = canvasContainer.value

4
src/designer/viewWidgets/toolbox/ToolboxView.vue

@ -102,8 +102,8 @@ export default {
{ {
name: 'other', icon: 'antd CiOutlined', label: '辅助', name: 'other', icon: 'antd CiOutlined', label: '辅助',
children: [ children: [
{ name: 'source', label: '发生器' }, { name: 'source', icon:'antd SoundOutlined',label: '发生器' },
{ name: 'sink', label: '消失器' }, { name: 'sink',icon:'fa Eraser', label: '消失器' },
{ name: 'dispatcher', label: '任务分配器' }, { name: 'dispatcher', label: '任务分配器' },
{ name: 'text', label: '文本' }, { name: 'text', label: '文本' },
{ name: 'image', label: '图片' }, { name: 'image', label: '图片' },

Loading…
Cancel
Save