-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHybridRenderingView.vue
More file actions
68 lines (58 loc) · 1.79 KB
/
HybridRenderingView.vue
File metadata and controls
68 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script setup>
import VeaseViewToolbar from "@ogw_front/components/VeaseViewToolbar"
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer"
import { useViewerStore } from "@ogw_front/stores/viewer"
const DEFAULT_ELEMENT_HEIGHT = 100
const emit = defineEmits(["click"])
const container = useTemplateRef("viewer")
const hybridViewerStore = useHybridViewerStore()
const viewerStore = useViewerStore()
const { width: elementWidth, height: elementHeight } =
useElementSize(container)
const { width: windowWidth, height: windowHeight } = useWindowSize()
const debouncedResize = debounce(() => {
hybridViewerStore.resize(elementWidth.value, elementHeight.value)
}, DEFAULT_ELEMENT_HEIGHT)
watch([elementWidth, elementHeight, windowWidth, windowHeight], (value) => {
debouncedResize()
})
onMounted(async () => {
if (import.meta.client) {
await hybridViewerStore.initHybridViewer()
await nextTick()
hybridViewerStore.setContainer(container)
debouncedResize()
}
})
function debounce(func, wait) {
let timeout = undefined
return function executedFunction(...args) {
function later() {
clearTimeout(timeout)
func(...args)
}
clearTimeout(timeout)
timeout = setTimeout(later, wait)
}
}
</script>
<template>
<ClientOnly>
<div class="fill-height" style="position: relative; height: 100%">
<VeaseViewToolbar />
<slot name="ui"></slot>
<v-col
class="pa-0"
ref="viewer"
style="height: 100%; overflow: hidden; position: relative; z-index: 0"
@click="emit('click', $event)"
@keydown.esc="viewerStore.toggle_picking_mode(false)"
/>
</div>
</ClientOnly>
</template>
<style>
img {
pointer-events: none;
}
</style>