LCOV - code coverage report
Current view: top level - src/extensions/core/load3d/components/menubar - CameraMenuGroup.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 4.8 % 21 1
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.switchProjection')"
       6              :     tooltip-side="bottom"
       7              :     :class="actionClass(false)"
       8              :     type="button"
       9              :     :aria-label="compact ? t('load3d.menuBar.switchProjection') : undefined"
      10              :     @click="switchCamera"
      11              :   >
      12              :     <i class="icon-[lucide--camera]" />
      13              :     <span v-if="!compact">{{ cameraTypeLabel }}</span>
      14              :   </Button>
      15              : 
      16              :   <Button
      17              :     v-if="hasCustomUp"
      18              :     variant="textonly"
      19              :     size="unset"
      20              :     :tooltip="upActionLabel"
      21              :     tooltip-side="bottom"
      22              :     :class="actionClass(false)"
      23              :     type="button"
      24              :     :aria-label="compact ? upActionLabel : undefined"
      25              :     @click="toggleUp"
      26              :   >
      27              :     <i
      28              :       :class="
      29              :         useCustomUp ? 'icon-[lucide--compass]' : 'icon-[lucide--rotate-ccw]'
      30              :       "
      31              :     />
      32              :     <span v-if="!compact">{{ upLabel }}</span>
      33              :   </Button>
      34              : 
      35              :   <PopoverRoot v-if="isPerspective" v-model:open="fovOpen">
      36              :     <PopoverTrigger as-child>
      37              :       <Button
      38              :         variant="textonly"
      39              :         size="unset"
      40              :         :tooltip="t('load3d.menuBar.fov')"
      41              :         tooltip-side="bottom"
      42              :         :class="actionClass(false)"
      43              :         type="button"
      44              :         :aria-label="compact ? t('load3d.menuBar.fov') : undefined"
      45              :       >
      46              :         <i class="icon-[lucide--focus]" />
      47              :         <span v-if="!compact">{{ t('load3d.menuBar.fov') }}</span>
      48              :       </Button>
      49              :     </PopoverTrigger>
      50              :     <PopoverContent
      51              :       align="start"
      52              :       :side-offset="8"
      53              :       :class="cn(formPanelClass, 'w-56')"
      54              :     >
      55              :       <div class="flex flex-col gap-2 p-1">
      56              :         <span class="text-sm text-foreground">{{ t('load3d.fov') }}</span>
      57              :         <Slider
      58              :           :model-value="[fov]"
      59              :           :min="10"
      60              :           :max="150"
      61              :           :step="1"
      62              :           @update:model-value="setFov"
      63              :         />
      64              :       </div>
      65              :     </PopoverContent>
      66              :   </PopoverRoot>
      67              : </template>
      68              : 
      69              : <script setup lang="ts">
      70              : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
      71              : import { computed } from 'vue'
      72              : import { useI18n } from 'vue-i18n'
      73              : 
      74              : import { cn } from '@comfyorg/tailwind-utils'
      75              : 
      76              : import {
      77              :   actionClass,
      78              :   formPanelClass
      79              : } from '@/extensions/core/load3d/components/menubar/menuBarStyles'
      80              : import { usePopoverExclusivity } from '@/extensions/core/load3d/components/menubar/usePopoverExclusivity'
      81              : import Button from '@comfyorg/design-system/button/Button'
      82              : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
      83              : import Slider from '@comfyorg/design-system/slider/Slider'
      84              : import type { CameraConfig } from '@comfyorg/viewport3d/load3d/interfaces'
      85              : 
      86              : const { compact = false } = defineProps<{
      87              :   compact?: boolean
      88              : }>()
      89              : 
      90            0 : const config = defineModel<CameraConfig>('config')
      91              : 
      92            0 : const { t } = useI18n()
      93              : 
      94            0 : const fovOpen = usePopoverExclusivity()('camera-fov')
      95              : 
      96            0 : const cameraType = computed(() => config.value?.cameraType)
      97            0 : const isPerspective = computed(() => cameraType.value === 'perspective')
      98            0 : const cameraTypeLabel = computed(() =>
      99              :   cameraType.value ? t(`load3d.cameraType.${cameraType.value}`) : ''
     100              : )
     101            0 : const fov = computed(() => config.value?.fov ?? 0)
     102            0 : const hasCustomUp = computed(() => config.value?.hasCustomUp === true)
     103            0 : const useCustomUp = computed(
     104              :   () => config.value?.hasCustomUp === true && config.value.useCustomUp
     105              : )
     106            0 : const upActionLabel = computed(() =>
     107              :   useCustomUp.value ? t('load3d.useNaturalUp') : t('load3d.useCustomUp')
     108              : )
     109            0 : const upLabel = computed(() =>
     110              :   useCustomUp.value
     111              :     ? t('load3d.menuBar.customUp')
     112              :     : t('load3d.menuBar.naturalUp')
     113              : )
     114              : 
     115            0 : function toggleUp() {
     116            0 :   const current = config.value
     117            0 :   if (!current?.hasCustomUp) return
     118            0 :   current.useCustomUp = !current.useCustomUp
     119              : }
     120              : 
     121            0 : function switchCamera() {
     122            0 :   if (!config.value) return
     123            0 :   config.value.cameraType =
     124              :     config.value.cameraType === 'perspective' ? 'orthographic' : 'perspective'
     125              : }
     126              : 
     127            0 : function setFov(value?: number[]) {
     128            0 :   if (config.value && value?.length) config.value.fov = value[0]
     129              : }
     130              : </script>
        

Generated by: LCOV version 2.0-1