SceneGraphItem.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <script setup lang="ts">
  2. import type { SceneGraphObject } from '../types'
  3. withDefaults(defineProps<{
  4. item: SceneGraphObject
  5. depth?: number
  6. }>(), {
  7. depth: 0,
  8. })
  9. const isExpanded = ref(false)
  10. function roundNumber(num: number) {
  11. return Math.round((num + Number.EPSILON) * 100) / 100
  12. }
  13. </script>
  14. <template>
  15. <div
  16. :class="{ 'text-sm text-gray-400 font-mono': depth > 0 }"
  17. >
  18. <div
  19. class="flex gap-2 items-end cursor-pointer pt2 mb2"
  20. @click="isExpanded = !isExpanded"
  21. >
  22. <span
  23. v-if="depth > 0"
  24. class="h-1 border-b border-gray-300 w-4"
  25. />
  26. <div class="flex gap-2 items-center -mb2.5">
  27. <Icon :name="item.icon" />
  28. <!-- <i :class="item.icon" /> -->{{ item.type }} <UBadge
  29. v-if="item.name "
  30. variant="soft"
  31. >
  32. {{ item.name }}
  33. </UBadge>
  34. <template v-if="item.type.includes('Light') && !isExpanded">
  35. <UBadge
  36. color="gray"
  37. variant="soft"
  38. >
  39. <span
  40. class="w4 h4 rounded-full mr-2 border border-gray-200"
  41. :style="{ backgroundColor: `#${item.color}` }"
  42. />
  43. #{{ item.color }}
  44. </UBadge>
  45. <UBadge
  46. color="green"
  47. variant="soft"
  48. >
  49. {{ item.intensity }}
  50. </UBadge>
  51. </template>
  52. <template v-if="item.type.includes('Camera') && !isExpanded">
  53. <UTooltip
  54. text="X"
  55. >
  56. <UBadge
  57. color="gray"
  58. variant="soft"
  59. >
  60. {{ roundNumber(item.position.x) }}
  61. </UBadge>
  62. </UTooltip>
  63. <UTooltip
  64. text="Y"
  65. >
  66. <UBadge
  67. color="gray"
  68. variant="soft"
  69. >
  70. {{ roundNumber(item.position.y) }}
  71. </UBadge>
  72. </UTooltip>
  73. <UTooltip
  74. text="Z"
  75. >
  76. <UBadge
  77. color="gray"
  78. variant="soft"
  79. >
  80. {{ roundNumber(item.position.z) }}
  81. </UBadge>
  82. </UTooltip>
  83. </template>
  84. </div>
  85. </div>
  86. <div
  87. v-if="isExpanded || depth === 0"
  88. :class="{ 'border-l border-gray-300': item.children.length > 0, 'ml2.5': depth === 0, 'ml6.5': depth > 0 }"
  89. >
  90. <template v-if="item.children.length > 0">
  91. <SceneGraphItem
  92. v-for="(child, index) in item.children"
  93. :key="index"
  94. :depth="depth + 1"
  95. :item="child"
  96. />
  97. </template>
  98. <template v-else>
  99. <div class="p4 text-gray-400 text-xs font-mono">
  100. <div
  101. v-if="item.geometry"
  102. class="mb-2 flex items-center gap-2"
  103. >
  104. <strong>Geometry</strong>
  105. <UBadge
  106. color="gray"
  107. variant="soft"
  108. >
  109. <i class="i-iconoir-box-3d-three-points mr2" />
  110. <a
  111. :href="`https://threejs.org/docs/#api/en/geometries/${item.geometry.type}`"
  112. target="_blank"
  113. >
  114. {{ item.geometry.type.replace('Geometry', '') }}
  115. </a>
  116. </UBadge>
  117. </div>
  118. <div
  119. v-if="item.material"
  120. class="mb-2 flex items-center gap-2"
  121. >
  122. <strong>Material</strong>
  123. <UBadge
  124. color="gray"
  125. variant="soft"
  126. >
  127. <i class="i-iconoir-select-face-3d mr2" />
  128. <a
  129. :href="`https://threejs.org/docs/#api/en/materials/${item.material.type}`"
  130. target="_blank"
  131. >
  132. {{ item.material?.type.replace('Material', '') }}
  133. </a>
  134. </UBadge>
  135. <UBadge
  136. color="gray"
  137. variant="soft"
  138. >
  139. <span
  140. class="w4 h4 rounded-full mr-2 border border-gray-200"
  141. :style="{ backgroundColor: `#${item.material.color.getHexString()}` }"
  142. />
  143. #{{ item.material.color.getHexString() }}
  144. </UBadge>
  145. </div>
  146. <div
  147. v-if="item.color"
  148. class="mb-2 flex items-center gap-2"
  149. >
  150. <strong>Color</strong>
  151. <UTooltip
  152. text="Color"
  153. >
  154. <UBadge
  155. color="gray"
  156. variant="soft"
  157. >
  158. <span
  159. class="w4 h4 rounded-full mr-2 border border-gray-200"
  160. :style="{ backgroundColor: `#${item.color}` }"
  161. />
  162. #{{ item.color }}
  163. </UBadge>
  164. </UTooltip>
  165. </div>
  166. <div
  167. v-if="item.color"
  168. class="mb-2 flex items-center gap-2"
  169. >
  170. <strong>Intensity</strong>
  171. <UTooltip
  172. text="Intensity"
  173. >
  174. <UBadge
  175. color="gray"
  176. variant="soft"
  177. >
  178. {{ item.intensity }}
  179. </UBadge>
  180. </UTooltip>
  181. </div>
  182. <div class="flex items-center mb2 gap-2">
  183. <UTooltip
  184. text="Position"
  185. >
  186. <i
  187. class="i-iconoir-axes mr1"
  188. />
  189. </UTooltip>
  190. <UTooltip
  191. text="X"
  192. >
  193. <UBadge
  194. color="gray"
  195. variant="soft"
  196. >
  197. {{ roundNumber(item.position.x) }}
  198. </UBadge>
  199. </UTooltip>
  200. <UTooltip
  201. text="Y"
  202. >
  203. <UBadge
  204. color="gray"
  205. variant="soft"
  206. >
  207. {{ roundNumber(item.position.y) }}
  208. </UBadge>
  209. </UTooltip>
  210. <UTooltip
  211. text="Z"
  212. >
  213. <UBadge
  214. color="gray"
  215. variant="soft"
  216. >
  217. {{ roundNumber(item.position.z) }}
  218. </UBadge>
  219. </UTooltip>
  220. </div>
  221. <div class="flex items-center mb2 gap-2">
  222. <UTooltip
  223. text="Rotation"
  224. >
  225. <i class="i-carbon-rotate-clockwise mr-1" />
  226. </UTooltip>
  227. <UTooltip
  228. text="X"
  229. >
  230. <UBadge
  231. color="gray"
  232. variant="soft"
  233. >
  234. {{ roundNumber(item.rotation.x) }}
  235. </UBadge>
  236. </UTooltip>
  237. <UTooltip
  238. text="Y"
  239. >
  240. <UBadge
  241. color="gray"
  242. variant="soft"
  243. >
  244. {{ roundNumber(item.rotation.y) }}
  245. </UBadge>
  246. </UTooltip>
  247. <UTooltip
  248. text="Z"
  249. >
  250. <UBadge
  251. color="gray"
  252. variant="soft"
  253. >
  254. {{ roundNumber(item.rotation.z) }}
  255. </UBadge>
  256. </UTooltip>
  257. </div>
  258. <div
  259. v-if="item.scale"
  260. class="flex items-center mb2 gap-2"
  261. >
  262. <UTooltip
  263. text="Scale"
  264. >
  265. <i class="i-iconoir-ellipse-3d-three-points mr-1" />
  266. </UTooltip>
  267. <UTooltip
  268. text="X"
  269. >
  270. <UBadge
  271. color="gray"
  272. variant="soft"
  273. >
  274. {{ roundNumber(item.scale?.x) }}
  275. </UBadge>
  276. </UTooltip>
  277. <UTooltip
  278. text="Y"
  279. >
  280. <UBadge
  281. color="gray"
  282. variant="soft"
  283. >
  284. {{ roundNumber(item.scale?.y) }}
  285. </UBadge>
  286. </UTooltip>
  287. <UTooltip
  288. text="Z"
  289. >
  290. <UBadge
  291. color="gray"
  292. variant="soft"
  293. >
  294. {{ roundNumber(item.scale?.z) }}
  295. </UBadge>
  296. </UTooltip>
  297. </div>
  298. </div>
  299. </template>
  300. </div>
  301. </div>
  302. </template>