LCOV - code coverage report
Current view: top level - src/extensions/core/load3d/components/menubar - SceneMenuGroup.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 93.3 % 30 28
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           13 : <template>
       2              :   <Button
       3              :     variant="textonly"
       4              :     size="unset"
       5              :     :tooltip="t('load3d.menuBar.showGrid')"
       6              :     tooltip-side="bottom"
       7              :     :class="actionClass(showGrid)"
       8              :     :aria-pressed="showGrid"
       9              :     type="button"
      10              :     :aria-label="compact ? t('load3d.menuBar.showGrid') : undefined"
      11              :     @click="toggleGrid"
      12              :   >
      13              :     <i class="icon-[lucide--grid-3x3]" />
      14              :     <span v-if="!compact">{{ t('load3d.menuBar.showGrid') }}</span>
      15              :   </Button>
      16              : 
      17              :   <template v-if="!hasImage && !hdriActive">
      18              :     <Button
      19              :       variant="textonly"
      20              :       size="unset"
      21              :       :tooltip="t('load3d.menuBar.bgColor')"
      22              :       tooltip-side="bottom"
      23              :       :class="actionClass(false)"
      24              :       type="button"
      25              :       :aria-label="compact ? t('load3d.menuBar.bgColor') : undefined"
      26              :       @click="colorRef?.click()"
      27              :     >
      28              :       <i class="icon-[lucide--palette]" />
      29              :       <span v-if="!compact">{{ t('load3d.menuBar.bgColor') }}</span>
      30              :     </Button>
      31              :     <input
      32              :       ref="colorRef"
      33              :       type="color"
      34              :       class="pointer-events-none absolute size-0 opacity-0"
      35              :       :value="bgColor"
      36              :       @input="setBackgroundColor"
      37              :     />
      38              :     <template v-if="canUseBackgroundImage">
      39              :       <Button
      40              :         variant="textonly"
      41              :         size="unset"
      42              :         :tooltip="t('load3d.menuBar.bgImage')"
      43              :         tooltip-side="bottom"
      44              :         :class="actionClass(false)"
      45              :         type="button"
      46              :         :aria-label="compact ? t('load3d.menuBar.bgImage') : undefined"
      47              :         @click="bgImageRef?.click()"
      48              :       >
      49              :         <i class="icon-[lucide--image]" />
      50              :         <span v-if="!compact">{{ t('load3d.menuBar.bgImage') }}</span>
      51              :       </Button>
      52              :       <input
      53              :         ref="bgImageRef"
      54              :         type="file"
      55              :         accept="image/*"
      56              :         class="pointer-events-none absolute size-0 opacity-0"
      57              :         data-testid="scene-bg-image-input"
      58              :         @change="onBackgroundImagePicked"
      59              :       />
      60              :     </template>
      61              :   </template>
      62              : 
      63              :   <template v-if="hasImage">
      64              :     <Button
      65              :       variant="textonly"
      66              :       size="unset"
      67              :       :tooltip="t('load3d.menuBar.panorama')"
      68              :       tooltip-side="bottom"
      69              :       :class="actionClass(isPanorama)"
      70              :       :aria-pressed="isPanorama"
      71              :       type="button"
      72              :       :aria-label="compact ? t('load3d.menuBar.panorama') : undefined"
      73              :       @click="togglePanorama"
      74              :     >
      75              :       <i class="icon-[lucide--globe]" />
      76              :       <span v-if="!compact">{{ t('load3d.menuBar.panorama') }}</span>
      77              :     </Button>
      78              :     <PopoverRoot v-if="isPanorama" v-model:open="fovOpen">
      79              :       <PopoverTrigger as-child>
      80              :         <Button
      81              :           variant="textonly"
      82              :           size="unset"
      83              :           :tooltip="t('load3d.menuBar.fov')"
      84              :           tooltip-side="bottom"
      85              :           :class="actionClass(false)"
      86              :           type="button"
      87              :           :aria-label="compact ? t('load3d.menuBar.fov') : undefined"
      88              :         >
      89              :           <i class="icon-[lucide--focus]" />
      90              :           <span v-if="!compact">{{ t('load3d.menuBar.fov') }}</span>
      91              :         </Button>
      92              :       </PopoverTrigger>
      93              :       <PopoverContent
      94              :         align="start"
      95              :         :side-offset="8"
      96              :         :class="cn(formPanelClass, 'w-56')"
      97              :       >
      98              :         <div class="flex flex-col gap-2 p-1">
      99              :           <span class="text-sm text-foreground">{{ t('load3d.fov') }}</span>
     100              :           <Slider
     101              :             :model-value="[fovValue]"
     102              :             :min="10"
     103              :             :max="150"
     104              :             :step="1"
     105              :             @update:model-value="setFov"
     106              :           />
     107              :         </div>
     108              :       </PopoverContent>
     109              :     </PopoverRoot>
     110              :     <Button
     111              :       variant="textonly"
     112              :       size="unset"
     113              :       :tooltip="t('load3d.menuBar.removeBackground')"
     114              :       tooltip-side="bottom"
     115              :       :class="actionClass(false)"
     116              :       type="button"
     117              :       :aria-label="compact ? t('load3d.menuBar.removeBackground') : undefined"
     118              :       @click="removeBackgroundImage"
     119              :     >
     120              :       <i class="icon-[lucide--x]" />
     121              :       <span v-if="!compact">{{ t('load3d.menuBar.removeBackground') }}</span>
     122              :     </Button>
     123              :   </template>
     124              : </template>
     125              : 
     126              : <script setup lang="ts">
     127              : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
     128              : import { computed, ref } from 'vue'
     129              : import { useI18n } from 'vue-i18n'
     130              : 
     131              : import { cn } from '@comfyorg/tailwind-utils'
     132              : 
     133              : import {
     134              :   actionClass,
     135              :   formPanelClass
     136              : } from '@/extensions/core/load3d/components/menubar/menuBarStyles'
     137              : import { usePopoverExclusivity } from '@/extensions/core/load3d/components/menubar/usePopoverExclusivity'
     138              : import Button from '@comfyorg/design-system/button/Button'
     139              : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
     140              : import Slider from '@comfyorg/design-system/slider/Slider'
     141              : import type { SceneConfig } from '@comfyorg/viewport3d/load3d/interfaces'
     142              : 
     143              : const {
     144              :   compact = false,
     145              :   canUseBackgroundImage = true,
     146              :   hdriActive = false
     147              : } = defineProps<{
     148              :   compact?: boolean
     149              :   canUseBackgroundImage?: boolean
     150              :   hdriActive?: boolean
     151              : }>()
     152              : 
     153           26 : const config = defineModel<SceneConfig>('config')
     154           26 : const fov = defineModel<number>('fov')
     155              : 
     156           26 : const emit = defineEmits<{
     157              :   (e: 'updateBackgroundImage', file: File | null): void
     158              : }>()
     159              : 
     160           26 : const { t } = useI18n()
     161              : 
     162           26 : const showGrid = computed(() => config.value?.showGrid ?? false)
     163           26 : const bgColor = computed(() => config.value?.backgroundColor ?? '#000000')
     164           26 : const hasImage = computed(
     165              :   () => !!config.value?.backgroundImage && config.value.backgroundImage !== ''
     166              : )
     167           26 : const isPanorama = computed(
     168              :   () => config.value?.backgroundRenderMode === 'panorama'
     169              : )
     170           26 : const fovValue = computed(() => fov.value ?? 10)
     171              : 
     172           26 : const colorRef = ref<HTMLInputElement | null>(null)
     173           26 : const bgImageRef = ref<HTMLInputElement | null>(null)
     174              : 
     175           26 : const fovOpen = usePopoverExclusivity()('scene-fov')
     176              : 
     177            2 : function toggleGrid() {
     178            2 :   if (config.value) config.value.showGrid = !config.value.showGrid
     179              : }
     180              : 
     181            1 : function setBackgroundColor(event: Event) {
     182            1 :   if (config.value) {
     183            1 :     config.value.backgroundColor = (event.target as HTMLInputElement).value
     184              :   }
     185              : }
     186              : 
     187            1 : function onBackgroundImagePicked(event: Event) {
     188            1 :   const input = event.target as HTMLInputElement
     189            1 :   const file = input.files?.[0]
     190            1 :   input.value = ''
     191            1 :   if (file) emit('updateBackgroundImage', file)
     192              : }
     193              : 
     194            1 : function removeBackgroundImage() {
     195            1 :   emit('updateBackgroundImage', null)
     196              : }
     197              : 
     198            1 : function togglePanorama() {
     199            1 :   if (!config.value) return
     200            1 :   config.value.backgroundRenderMode =
     201              :     config.value.backgroundRenderMode === 'panorama' ? 'tiled' : 'panorama'
     202              : }
     203              : 
     204            0 : function setFov(value?: number[]) {
     205            0 :   if (value?.length) fov.value = value[0]
     206              : }
     207              : </script>
        

Generated by: LCOV version 2.0-1