forge sprite 配置
This commit is contained in:
parent
334d0d5212
commit
520810b1ce
@ -33,7 +33,7 @@ const updateHeatBarIsShow = (isShow) => {
|
||||
heat_bar_isShow.value = isShow;
|
||||
};
|
||||
|
||||
const { updateDataVisualization, createSprites, hideAllObjects } = useForgeSprite()
|
||||
const { updateDataVisualization, createSprites, hideAllObjects, forgeClickListener } = useForgeSprite()
|
||||
|
||||
const forgeDom = ref(null);
|
||||
|
||||
@ -162,9 +162,13 @@ const initForge = async () => {
|
||||
"Autodesk.Viewing.GEOMETRY_LOADED_EVENT",
|
||||
viewer.isLoadDone()
|
||||
);
|
||||
|
||||
if (viewer.isLoadDone()) {
|
||||
// updateForgeViewer(viewer);
|
||||
// createSprites()
|
||||
hideAllObjects();
|
||||
createSprites();
|
||||
forgeClickListener();
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
|
@ -71,85 +71,38 @@ onMounted(() => {
|
||||
<template>
|
||||
<ul class="px-1 menu-box my-2">
|
||||
<li class="flex flex-col items-center justify-center">
|
||||
<router-link
|
||||
:to="{ name: 'dashboard' }"
|
||||
class="flex flex-col justify-center items-center btn-group text-white"
|
||||
>
|
||||
<font-awesome-icon
|
||||
:icon="['fas', 'home']"
|
||||
size="2x"
|
||||
class="w-10 m-auto"
|
||||
/>
|
||||
<router-link :to="{ name: 'dashboard' }" class="flex flex-col justify-center items-center btn-group text-white">
|
||||
<font-awesome-icon :icon="['fas', 'home']" size="2x" class="w-10 m-auto" />
|
||||
{{ $t("home") }}
|
||||
</router-link>
|
||||
</li>
|
||||
<li
|
||||
v-for="page in authPages"
|
||||
class="flex flex-col items-center justify-center"
|
||||
>
|
||||
<a
|
||||
v-if="page.authCode === 'PF1'"
|
||||
@click="showDrawer"
|
||||
class="flex flex-col justify-center items-center btn-group text-white cursor-pointer"
|
||||
>
|
||||
<font-awesome-icon
|
||||
:icon="['fas', page.icon]"
|
||||
size="2x"
|
||||
class="w-10 m-auto"
|
||||
/>
|
||||
<li v-for="page in authPages" class="flex flex-col items-center justify-center">
|
||||
<a v-if="page.authCode === 'PF1'" @click="showDrawer"
|
||||
class="flex flex-col justify-center items-center btn-group text-white cursor-pointer">
|
||||
<font-awesome-icon :icon="['fas', page.icon]" size="2x" class="w-10 m-auto" />
|
||||
{{ page.subName }}
|
||||
</a>
|
||||
<router-link
|
||||
v-else
|
||||
:to="page.navigate"
|
||||
type="link"
|
||||
class="flex flex-col justify-center items-center btn-group text-white"
|
||||
>
|
||||
<font-awesome-icon
|
||||
:icon="['fas', page.icon]"
|
||||
size="2x"
|
||||
class="w-10 m-auto"
|
||||
/>
|
||||
<router-link v-else :to="page.navigate" type="link"
|
||||
class="flex flex-col justify-center items-center btn-group text-white">
|
||||
<font-awesome-icon :icon="['fas', page.icon]" size="2x" class="w-10 m-auto" />
|
||||
{{ page.subName }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<a-drawer
|
||||
:width="250"
|
||||
placement="left"
|
||||
:open="open"
|
||||
:closable="false"
|
||||
@close="onClose"
|
||||
class="sub-drawer"
|
||||
:maskStyle="{ opacity: 0 }"
|
||||
:bodyStyle="{ paddingLeft: 0, paddingRight: 0 }"
|
||||
>
|
||||
<a-menu
|
||||
mode="inline"
|
||||
theme="dark"
|
||||
class="text-lg bg-transparent"
|
||||
:openKeys="openKeys"
|
||||
@openChange="handleOpenChange"
|
||||
>
|
||||
<a-sub-menu
|
||||
v-for="main in buildingStore.mainSubSys"
|
||||
:key="main.main_system_tag"
|
||||
:title="main.full_name"
|
||||
>
|
||||
<a-menu-item
|
||||
v-for="sub in main.history_Sub_systems"
|
||||
:key="sub.sub_system_tag"
|
||||
@click="() => onClose()"
|
||||
>
|
||||
<router-link
|
||||
:to="{
|
||||
<a-drawer :width="250" placement="left" :open="open" :closable="false" @close="onClose" class="sub-drawer"
|
||||
:maskStyle="{ opacity: 0 }" :bodyStyle="{ paddingLeft: 0, paddingRight: 0 }">
|
||||
<a-menu mode="inline" theme="dark" class="text-lg bg-transparent" :openKeys="openKeys"
|
||||
@openChange="handleOpenChange">
|
||||
<a-sub-menu v-for="main in buildingStore.mainSubSys" :key="main.main_system_tag" :title="main.full_name">
|
||||
<a-menu-item v-for="sub in main.history_Sub_systems" :key="sub.sub_system_tag" @click="() => onClose()">
|
||||
<router-link :to="{
|
||||
name: 'sub_system',
|
||||
params: {
|
||||
main_system_id: main.main_system_tag,
|
||||
sub_system_id: sub.sub_system_tag,
|
||||
floor_id: 'main'
|
||||
},
|
||||
}"
|
||||
>
|
||||
}">
|
||||
{{ sub.full_name }}
|
||||
</router-link>
|
||||
</a-menu-item>
|
||||
@ -166,16 +119,19 @@ onMounted(() => {
|
||||
color: #35759d !important;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
::v-deep .ant-menu-item:not(.ant-menu-item-selected) {
|
||||
&::before {
|
||||
@apply absolute w-[15px] h-[15px] bottom-3.5 left-7 bg-no-repeat z-10 grayscale;
|
||||
content: "";
|
||||
background: url(@ASSET/img/chart-data-background03.svg) center center;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .ant-menu-item-selected {
|
||||
@apply bg-transparent relative;
|
||||
|
||||
@ -184,9 +140,11 @@ onMounted(() => {
|
||||
content: "";
|
||||
background: url(@ASSET/img/chart-data-background03.svg) center center;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #89d2ff !important;
|
||||
text-shadow: 0px 0px 1px #fff;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { watch, inject, markRaw, ref } from "vue";
|
||||
import { watch, inject, markRaw, ref, computed } from "vue";
|
||||
import useAlarmStore from "@/stores/useAlarmStore";
|
||||
import hexToRgb from "@/util/hexToRgb";
|
||||
import { useRoute } from "vue-router";
|
||||
import useSelectedFloor from "@/hooks/useSelectedFloor";
|
||||
|
||||
export default function useForgeSprite() {
|
||||
const store = useAlarmStore();
|
||||
@ -12,7 +14,7 @@ export default function useForgeSprite() {
|
||||
forgeViewer.value = markRaw(viewer);
|
||||
}
|
||||
|
||||
const dataVisualization = await NOP_VIEWER.loadExtension(
|
||||
const dataVisualization = await viewer.loadExtension(
|
||||
"Autodesk.DataVisualization"
|
||||
);
|
||||
dataVizExtn.value = markRaw(dataVisualization);
|
||||
@ -20,13 +22,24 @@ export default function useForgeSprite() {
|
||||
|
||||
const onSpriteClicked = (event) => {
|
||||
event.hasStopped = true;
|
||||
const data = deviceList.value.find((d) => d.spriteDbId === event.dbId);
|
||||
modalContent.value = data;
|
||||
store.getDbIdStore(data.forge_dbid);
|
||||
toggleModal(event.originalEvent);
|
||||
console.log("onSpriteClicked", event);
|
||||
// const data = deviceList.value.find((d) => d.spriteDbId === event.dbId);
|
||||
// modalContent.value = data;
|
||||
};
|
||||
|
||||
const { selectedFloor } = useSelectedFloor();
|
||||
const showData = computed(() =>
|
||||
selectedFloor.value?.key === "main"
|
||||
? subscribeData.value
|
||||
: subscribeData.value.filter(
|
||||
({ floor_guid }) => floor_guid === selectedFloor.value?.key
|
||||
) || []
|
||||
);
|
||||
|
||||
// 創建 sprites
|
||||
const createSprites = async () => {
|
||||
if (dataVizExtn.value) {
|
||||
dataVizExtn.value.removeAllViewables();
|
||||
const DataVizCore = Autodesk.DataVisualization.Core;
|
||||
const viewableType = DataVizCore.ViewableType.SPRITE;
|
||||
let spriteColor = new THREE.Color(0xffffff);
|
||||
@ -39,8 +52,9 @@ export default function useForgeSprite() {
|
||||
);
|
||||
const viewableData = new DataVizCore.ViewableData();
|
||||
viewableData.spriteSize = 24; // Sprites as points of size 24 x 24 pixels
|
||||
subscribeData.value?.forEach((d, index) => {
|
||||
showData.value?.forEach((d, index) => {
|
||||
if (d.device_coordinate_3d) {
|
||||
console.log(d.device_coordinate_3d);
|
||||
const position = d.device_coordinate_3d;
|
||||
style.color = new THREE.Color(hexToRgb(d.device_normal_color));
|
||||
const viewable = new DataVizCore.SpriteViewable(
|
||||
@ -51,10 +65,35 @@ export default function useForgeSprite() {
|
||||
viewableData.addViewable(viewable);
|
||||
}
|
||||
});
|
||||
await viewableData.finish();
|
||||
// await viewableData.finish();
|
||||
// dataVizExtn.value.addViewables(viewableData);
|
||||
// console.log(dataVizExtn.value);
|
||||
viewableData.then(
|
||||
() => {
|
||||
dataVizExtn.value.addViewables(viewableData);
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
forgeViewer.value.addEventListener(DataVizCore.MOUSE_CLICK, onSpriteClicked);
|
||||
watch(
|
||||
() => showData,
|
||||
() => {
|
||||
forgeViewer.value?.isLoadDone() && createSprites();
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
}
|
||||
);
|
||||
|
||||
const forgeClickListener = () => {
|
||||
forgeViewer.value.addEventListener(
|
||||
Autodesk.DataVisualization.Core.MOUSE_CLICK,
|
||||
onSpriteClicked
|
||||
);
|
||||
forgeViewer.value.addEventListener(
|
||||
Autodesk.Viewing.SELECTION_CHANGED_EVENT,
|
||||
onSpriteClicked
|
||||
@ -99,5 +138,6 @@ export default function useForgeSprite() {
|
||||
createSprites,
|
||||
updateDataVisualization,
|
||||
hideAllObjects,
|
||||
forgeClickListener,
|
||||
};
|
||||
}
|
||||
|
17
src/hooks/useSelectedFloor.js
Normal file
17
src/hooks/useSelectedFloor.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { useRoute } from "vue-router";
|
||||
import { computed, inject, ref, watch } from "vue";
|
||||
|
||||
function useSelectedFloor() {
|
||||
const { currentFloor } = inject("system_deviceList");
|
||||
const route = useRoute();
|
||||
const selectedFloor = computed(() =>
|
||||
currentFloor.value?.find(({ key }) => key == route.params.floor_id)
|
||||
);
|
||||
|
||||
return {
|
||||
selectedFloor,
|
||||
currentFloor,
|
||||
};
|
||||
}
|
||||
|
||||
export default useSelectedFloor;
|
@ -38,15 +38,10 @@ const router = createRouter({
|
||||
component: System,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
path: ":floor_id",
|
||||
name: "sub_system",
|
||||
component: SystemMain,
|
||||
},
|
||||
{
|
||||
path: "floor/:floor_id",
|
||||
name: "floor",
|
||||
component: SystemFloor,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import ForgeForSystem from "@/components/forge/ForgeForSystem.vue";
|
||||
import { getSystemDevices, getSystemRealTime } from "@/apis/system";
|
||||
import SystemSubBar from './components/SystemSubBar.vue';
|
||||
import SystemInfoModal from './components/SystemInfoModal.vue';
|
||||
import SystemMain from "./SystemMain.vue"
|
||||
|
||||
const buildingStore = useBuildingStore()
|
||||
|
||||
@ -41,7 +42,7 @@ const getData = async () => {
|
||||
forge_dbid: parseInt(dev.forge_dbid),
|
||||
device_coordinate_3d: dev.device_coordinate_3d
|
||||
? JSON.parse(dev.device_coordinate_3d)
|
||||
: { x: 0, y: 0 },
|
||||
: null,
|
||||
alarmMsg: "",
|
||||
is_show: true,
|
||||
currentColor: dev.device_normal_point_color,
|
||||
@ -79,7 +80,7 @@ watch(raw_data, (newValue) => {
|
||||
});
|
||||
|
||||
const updateDataByGas = (gas) => {
|
||||
console.log(`updateDataByGas`, gas)
|
||||
|
||||
const update_values = raw_data.value.map((d) => (
|
||||
{
|
||||
...d,
|
||||
@ -98,8 +99,8 @@ watch(() => buildingStore.selectedBuilding, (newBuilding) => {
|
||||
deep: true,
|
||||
})
|
||||
|
||||
watch(route, (newRoute, oldRoute) => {
|
||||
if (buildingStore.selectedBuilding && newRoute.params.sub_system_id !== oldRoute?.params.sub_system_id) {
|
||||
watch(() => route.params.sub_system_id, (newRoute, oldRoute) => {
|
||||
if (buildingStore.selectedBuilding && newRoute !== oldRoute) {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
@ -195,6 +196,7 @@ provide("system_selectedDevice", { selectedDeviceRealtime, selectedDevice, getCu
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-1 h-full">
|
||||
|
||||
<ForgeForSystem :initialData="{}" />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,6 +3,8 @@ import { useRoute } from 'vue-router';
|
||||
import EffectScatter from "@/components/chart/EffectScatter.vue";
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import useSelectedFloor from "@/hooks/useSelectedFloor"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const { currentFloor, subscribeData } = inject("system_deviceList")
|
||||
@ -34,7 +36,7 @@ const defaultOption = (map, data = []) => ({
|
||||
},
|
||||
});
|
||||
|
||||
const selectedFloor = computed(() => currentFloor.value?.find(({ key }) => key == route.params.floor_id))
|
||||
const { selectedFloor } = useSelectedFloor()
|
||||
|
||||
watch([selectedFloor, () => asset_floor_chart, subscribeData], ([newValue, newChart, newData]) => {
|
||||
if (newValue && newChart.value) {
|
||||
|
@ -1,17 +1,26 @@
|
||||
<script setup>
|
||||
import { inject } from "vue"
|
||||
import { computed, inject, watch } from "vue"
|
||||
import useSelectedFloor from "@/hooks/useSelectedFloor"
|
||||
|
||||
const { data } = inject("system_deviceList")
|
||||
|
||||
const { getCurrentInfoModalData } = inject("system_selectedDevice")
|
||||
|
||||
const { selectedFloor } = useSelectedFloor()
|
||||
|
||||
const showData = computed(() => selectedFloor.value?.key === 'main' ? data.value : data.value.filter(({ floor_guid }) => floor_guid === selectedFloor.value?.key) || [])
|
||||
|
||||
watch(selectedFloor, (newValue) => {
|
||||
console.log(newValue)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- <InfoModal :data="currentInfoModalData" /> -->
|
||||
|
||||
<template v-if="data.length > 0">
|
||||
<div class="equipment-show" v-for="d in data" :key="d.full_name">
|
||||
<template v-if="showData.length > 0">
|
||||
<div class="equipment-show" v-for="d in showData" :key="d.full_name">
|
||||
<template v-if="d.device_list.length > 0">
|
||||
<p class="title">{{ d.full_name }}</p>
|
||||
<div class="grid grid-cols-3 gap-5">
|
||||
|
@ -19,7 +19,7 @@ const getFloors = async () => {
|
||||
{
|
||||
title: "總覽",
|
||||
key: "main",
|
||||
active: route.params.floor_id ? false : true,
|
||||
active: route.params.floor_id === "main",
|
||||
},
|
||||
...data.floors.map((d, idx) => ({
|
||||
title: d.full_name,
|
||||
@ -36,20 +36,11 @@ const getFloors = async () => {
|
||||
const onClick = (item) => {
|
||||
changeActiveBtn(item)
|
||||
|
||||
if (item.key == "main") {
|
||||
router.push({
|
||||
name: 'sub_system', params: {
|
||||
...route.params
|
||||
}, query: { gas: route.query.gas }
|
||||
})
|
||||
} else {
|
||||
router.push({
|
||||
name: 'floor', params: {
|
||||
...route.params, floor_id: item.key
|
||||
}, query: { gas: route.query.gas }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ watch(() => buildingStore, (newValue) => {
|
||||
newValue.selectedSystem?.points?.length > 0 && setItems(newValue.selectedSystem.points.map(d => ({
|
||||
title: d.full_name,
|
||||
key: d.points,
|
||||
active: route.query.gas ? route.query.gas === d.points : d.points === "Temp",
|
||||
active: route.query.gas ? route.query.gas === d.points : d.points === "temp",
|
||||
})))
|
||||
}, {
|
||||
deep: true,
|
||||
|
Loading…
Reference in New Issue
Block a user