InspectorControl.vue 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <script setup lang="ts">
  2. import { useDevtoolsHook } from '../../composables/useDevtoolsHook'
  3. import InspectorBoolean from './InspectorBoolean.vue'
  4. import InspectorNumber from './InspectorNumber.vue'
  5. const props = defineProps<{
  6. label: string
  7. value: any
  8. type?: string
  9. path?: string
  10. }>()
  11. const { editSceneObjectByPath } = useDevtoolsHook()
  12. function changeValue(value) {
  13. editSceneObjectByPath(props?.path || '', value)
  14. }
  15. </script>
  16. <template>
  17. <div class="flex items-center">
  18. <InspectorBoolean
  19. v-if="type === 'boolean'"
  20. :label="label"
  21. :value="value"
  22. :type="type"
  23. :path="path"
  24. @change="changeValue"
  25. />
  26. <InspectorNumber
  27. v-else-if="type === 'number'"
  28. :label="label"
  29. :value="value"
  30. :type="type"
  31. :path="path"
  32. @change="changeValue"
  33. />
  34. <!-- <input
  35. class="ml-2 bg-gray-200"
  36. :value="value"
  37. :type="type"
  38. @input="changeValue"
  39. > -->
  40. </div>
  41. </template>