Line data Source code
1 13 : <template>
2 11 : <dl
3 : class="pointer-events-none absolute top-2 right-2 z-10 m-0 grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5 rounded-md bg-background/80 px-2 py-1 text-xs text-foreground tabular-nums"
4 : >
5 33 : <template v-for="row in rows" :key="row.key">
6 : <dt class="opacity-70">{{ row.label }}</dt>
7 : <dd class="m-0 text-right">{{ row.value }}</dd>
8 : </template>
9 : </dl>
10 : </template>
11 :
12 : <script setup lang="ts">
13 : import { computed } from 'vue'
14 : import { useI18n } from 'vue-i18n'
15 :
16 : import type { ModelStats } from '@comfyorg/viewport3d/load3d/modelStats'
17 :
18 : const { stats } = defineProps<{ stats: ModelStats }>()
19 :
20 11 : const { t, locale } = useI18n()
21 :
22 11 : const rows = computed(() => {
23 11 : const formatter = new Intl.NumberFormat(locale.value)
24 11 : return [
25 : {
26 : key: 'vertices',
27 : label: t('load3d.stats.vertices'),
28 : count: stats.vertices
29 : },
30 : { key: 'edges', label: t('load3d.stats.edges'), count: stats.edges },
31 : {
32 : key: 'triangles',
33 : label: t('load3d.stats.triangles'),
34 : count: stats.triangles
35 : }
36 : ].map(({ count, ...row }) => ({ ...row, value: formatter.format(count) }))
37 : })
38 : </script>
|