diff --git a/src/views/bim/bimHome/components/DeviceDetial.vue b/src/views/bim/bimHome/components/DeviceDetial.vue index 586fa8d..a5778e6 100644 --- a/src/views/bim/bimHome/components/DeviceDetial.vue +++ b/src/views/bim/bimHome/components/DeviceDetial.vue @@ -17,7 +17,7 @@ import RealInfo from './RealInfo.vue'; import HistoryInfo from './HistoryInfo.vue'; import { ElMessage } from 'element-plus'; const deviceData = { - 'EQ0001': { + 'set1': { name: '立仓', imgUrl: 'licang', detail: [ @@ -75,7 +75,7 @@ const deviceData = { }, ] }, - 'EQ0002': { + 'set6': { name: '过滤槽', imgUrl: 'guolvcao', detail: [ diff --git a/src/views/bim/bimHome/components/DeviceInfoDialog.vue b/src/views/bim/bimHome/components/DeviceInfoDialog.vue index 25a0a73..962cb6d 100644 --- a/src/views/bim/bimHome/components/DeviceInfoDialog.vue +++ b/src/views/bim/bimHome/components/DeviceInfoDialog.vue @@ -59,28 +59,28 @@ const data = reactive({ { type: '生产设备', name: '立仓', - num: 'EQ0001', + num: 'set1', value: 45, id: "echartDiv0" }, { type: '生产设备', name: '过滤槽', - num: 'EQ0002', + num: 'set6', value: 130, id: "echartDiv1" }, { type: '安防设备', name: '摄像头', - num: 'EQ0001', + num: 'set1', value: 180, id: "echartDiv2" }, { type: '消防设备', name: '烟感', - num: 'EQ0001', + num: 'set1', value: 100, id: "echartDiv3" } @@ -101,28 +101,28 @@ const data = reactive({ { type: '生产设备', name: '立仓', - num: 'EQ0001', + num: 'set1', value: 15, id: "echartDiv0" }, { type: '生产设备', name: '过滤槽', - num: 'EQ0002', + num: 'set6', value: 50, id: "echartDiv1" }, { type: '安防设备', name: '摄像头', - num: 'EQ0001', + num: 'set1', value: 80, id: "echartDiv2" }, { type: '消防设备', name: '烟感', - num: 'EQ0001', + num: 'set1', value: 50, id: "echartDiv3" } @@ -144,28 +144,28 @@ const data = reactive({ { type: '生产设备', name: '立仓', - num: 'EQ0001', + num: 'set1', value: 30, id: "echartDiv0" }, { type: '生产设备', name: '过滤槽', - num: 'EQ0002', + num: 'set6', value: 80, id: "echartDiv1" }, { type: '安防设备', name: '摄像头', - num: 'EQ00011', + num: 'set1', value: 100, id: "echartDiv2" }, { type: '消防设备', name: '烟感', - num: 'EQ0002', + num: 'set1', value: 50, id: "echartDiv3" } diff --git a/src/views/bim/bimHome/components/ThreeView2.vue b/src/views/bim/bimHome/components/ThreeView2.vue index 9a586be..b02a9da 100644 --- a/src/views/bim/bimHome/components/ThreeView2.vue +++ b/src/views/bim/bimHome/components/ThreeView2.vue @@ -42,7 +42,7 @@ onMounted(() => { // 右击事件 window.addEventListener('contextmenu', function (e) { if (e.button === 2) { - console.log("点击了鼠标右键"); + onMouseDownRight(e); } }); // document.addEventListener("mousemove", onMouseMove); @@ -197,6 +197,23 @@ const onMouseMove = (event) => { } } } +const emit = defineEmits(['handleRightClick']) +// 鼠标右击事件 +const onMouseDownRight = (event) => { + var raycaster = new THREE.Raycaster() + mouse.x = ((event.clientX - marginLeft) / window.innerWidth) * 2 - 1; + mouse.y = -((event.clientY - marginTop) / window.innerHeight) * 2 + 1; + raycaster.setFromCamera(mouse, camera); + const intersects = raycaster.intersectObjects(scene.children, true); + console.log(123, event); + + if (intersects.length > 0) { + const clickedObject = intersects[0].object; + console.log('这是我选中的模型', clickedObject); + var selectedObject = isSelent(clickedObject); + emit('handleRightClick',selectedObject); + } +} // 鼠标点击效果 const onMouseDown = (event) => { var raycaster = new THREE.Raycaster() diff --git a/src/views/bim/bimHome/index.vue b/src/views/bim/bimHome/index.vue index 4a9c792..181424f 100644 --- a/src/views/bim/bimHome/index.vue +++ b/src/views/bim/bimHome/index.vue @@ -1,7 +1,7 @@