Line data Source code
1 13 : <template>
2 4 : <div class="space-y-4">
3 : <div v-if="!hasBackgroundImage" class="flex flex-col gap-2">
4 : <label>
5 : {{ $t('load3d.backgroundColor') }}
6 : </label>
7 : <input v-model="backgroundColor" type="color" class="h-8 w-full" />
8 : </div>
9 :
10 : <div class="flex items-center gap-2">
11 : <input
12 : id="showGrid"
13 : v-model="showGrid"
14 : type="checkbox"
15 : name="showGrid"
16 : class="size-4 cursor-pointer accent-muted-foreground"
17 : />
18 : <label for="showGrid" class="cursor-pointer">
19 : {{ $t('load3d.showGrid') }}
20 : </label>
21 : </div>
22 :
23 : <div v-if="!hasBackgroundImage && !disableBackgroundUpload">
24 : <Button variant="secondary" class="w-full" @click="openImagePicker">
25 : <i class="icon-[lucide--image]" />
26 : {{ $t('load3d.uploadBackgroundImage') }}
27 : </Button>
28 : <input
29 : ref="imagePickerRef"
30 : type="file"
31 : accept="image/*"
32 : class="hidden"
33 : @change="handleImageUpload"
34 : />
35 : </div>
36 :
37 : <div v-if="hasBackgroundImage" class="space-y-2">
38 : <div class="flex gap-2">
39 : <Button
40 : :variant="backgroundRenderMode === 'tiled' ? 'primary' : 'secondary'"
41 : class="flex-1"
42 : @click="setBackgroundRenderMode('tiled')"
43 : >
44 : <i class="icon-[lucide--layout-grid]" />
45 : {{ $t('load3d.tiledMode') }}
46 : </Button>
47 : <Button
48 : :variant="
49 : backgroundRenderMode === 'panorama' ? 'primary' : 'secondary'
50 : "
51 : class="flex-1"
52 : @click="setBackgroundRenderMode('panorama')"
53 : >
54 : <i class="icon-[lucide--globe]" />
55 : {{ $t('load3d.panoramaMode') }}
56 : </Button>
57 : </div>
58 : <Button variant="secondary" class="w-full" @click="removeBackgroundImage">
59 : <i class="icon-[lucide--x]" />
60 : {{ $t('load3d.removeBackgroundImage') }}
61 : </Button>
62 : </div>
63 : </div>
64 : </template>
65 :
66 : <script setup lang="ts">
67 : import { ref } from 'vue'
68 :
69 : import Button from '@comfyorg/design-system/button/Button'
70 :
71 2 : const backgroundColor = defineModel<string>('backgroundColor')
72 2 : const showGrid = defineModel<boolean>('showGrid')
73 2 : const backgroundRenderMode = defineModel<'tiled' | 'panorama'>(
74 : 'backgroundRenderMode'
75 : )
76 :
77 : defineProps<{
78 : hasBackgroundImage?: boolean
79 : disableBackgroundUpload?: boolean
80 : }>()
81 :
82 2 : const emit = defineEmits<{
83 : (e: 'updateBackgroundImage', file: File | null): void
84 : }>()
85 :
86 2 : const imagePickerRef = ref<HTMLInputElement | null>(null)
87 :
88 2 : const openImagePicker = () => {
89 0 : imagePickerRef.value?.click()
90 : }
91 :
92 2 : const handleImageUpload = (event: Event) => {
93 0 : const input = event.target as HTMLInputElement
94 0 : if (input.files && input.files[0]) {
95 0 : emit('updateBackgroundImage', input.files[0])
96 : }
97 :
98 0 : input.value = ''
99 : }
100 :
101 2 : const removeBackgroundImage = () => {
102 0 : emit('updateBackgroundImage', null)
103 : }
104 :
105 2 : const setBackgroundRenderMode = (mode: 'tiled' | 'panorama') => {
106 0 : backgroundRenderMode.value = mode
107 : }
108 : </script>
|