index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!-- eslint-disable max-len -->
  2. <script setup lang="ts">
  3. import { useDevtoolsClient } from '@nuxt/devtools-kit/iframe-client'
  4. const client = useDevtoolsClient()
  5. // Scene Graph
  6. const { scene, memory, fps } = useDevtoolsHook()
  7. </script>
  8. <template>
  9. <div class="relative n-bg-base flex flex-col h-screen">
  10. <header
  11. class="p4 flex items-center justify-between hover:bg-active"
  12. border="b base"
  13. >
  14. <div class="flex items-center gap-4">
  15. <img
  16. src="/logo.svg"
  17. alt="tres logo"
  18. >
  19. <h2 class="text-xl opacity-60 font-bold">
  20. TresJS DevTools
  21. </h2>
  22. </div>
  23. <div class="flex items-center gap-2">
  24. <UButton
  25. variant="ghost"
  26. color="white"
  27. size="sm"
  28. icon="i-carbon-document"
  29. target="_blank"
  30. to="https://docs.tresjs.org/"
  31. />
  32. <UButton
  33. variant="ghost"
  34. color="white"
  35. size="sm"
  36. icon="i-iconoir-github"
  37. target="_blank"
  38. to="https://github.com/Tresjs/nuxt"
  39. />
  40. <UButton
  41. variant="solid"
  42. color="white"
  43. size="sm"
  44. target="_blank"
  45. class="ml2"
  46. to="https://github.com/Tresjs/nuxt/issues/new?labels=enhancement&template=feature_request.yml"
  47. >
  48. Request feature
  49. </UButton>
  50. </div>
  51. </header>
  52. <div
  53. v-if="client && scene.objects > 0"
  54. class="flex flex-col gap-2"
  55. >
  56. <NSectionBlock
  57. icon="i-iconoir-movie"
  58. text="Scene Graph"
  59. :description="`Total Objects ${scene.objects}`"
  60. >
  61. <SceneGraphItem :item="scene.graph" />
  62. </NSectionBlock>
  63. <NSectionBlock
  64. icon="i-iconoir-dashboard-speed"
  65. text="Performance"
  66. >
  67. <template #actions>
  68. <NBadge n="green">
  69. FPS: {{ fps.value }}
  70. </NBadge>
  71. <NBadge
  72. n="yellow"
  73. >
  74. Memory: {{ Math.round(memory?.currentMem) }}MB
  75. </NBadge>
  76. </template>
  77. <template #default>
  78. <PerformanceMonitor />
  79. </template>
  80. </NSectionBlock>
  81. </div>
  82. <div v-else-if="scene.objects === 0">
  83. <div class="p4 h-full">
  84. <NLoading />
  85. </div>
  86. </div>
  87. <div v-else>
  88. <NTip n="yellow">
  89. Failed to connect to the client. Did you open this page inside Nuxt DevTools?
  90. </NTip>
  91. </div>
  92. </div>
  93. </template>