Conditional.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script setup lang="ts">
  2. import { BasicShadowMap, MeshPhongMaterial, NoToneMapping, SRGBColorSpace } from 'three'
  3. import { reactive } from 'vue'
  4. import { OrbitControls } from '@tresjs/cientos'
  5. import { TresCanvas } from '@tresjs/core'
  6. import { TresLeches, useControls } from '@tresjs/leches'
  7. import '@tresjs/leches/styles'
  8. const state = reactive({
  9. clearColor: '#201919',
  10. shadows: true,
  11. alpha: false,
  12. shadowMapType: BasicShadowMap,
  13. outputColorSpace: SRGBColorSpace,
  14. toneMapping: NoToneMapping,
  15. })
  16. const paneElements = reactive({
  17. boxVisible: true,
  18. groupVisible: true,
  19. boxPropMaterialVisible: true,
  20. })
  21. useControls('fpsgraph')
  22. useControls(paneElements)
  23. const material = new MeshPhongMaterial({ color: '#ff0000' })
  24. </script>
  25. <template>
  26. <TresLeches />
  27. <TresCanvas v-bind="state">
  28. <TresPerspectiveCamera
  29. :position="[11, 11, 11]"
  30. :fov="45"
  31. :near="0.1"
  32. :far="1000"
  33. :look-at="[-8, 3, -3]"
  34. />
  35. <TresDirectionalLight
  36. :position="[0, 8, 4]"
  37. :intensity="0.2"
  38. cast-shadow
  39. />
  40. <TresMesh
  41. v-if="paneElements.boxPropMaterialVisible"
  42. :position="[0, 0, 0]"
  43. :material="material"
  44. >
  45. <TresBoxGeometry :args="[1, 1, 1]" />
  46. </TresMesh>
  47. <TresMesh
  48. v-if="paneElements.boxVisible"
  49. :position="[4, 0, 0]"
  50. >
  51. <TresBoxGeometry :args="[1, 1, 1]" />
  52. <TresMeshToonMaterial color="#efefef" />
  53. </TresMesh>
  54. <TresGroup
  55. v-if="paneElements.groupVisible"
  56. :position="[0, -4, -5]"
  57. >
  58. <TresGroup>
  59. <TresMesh :position="[0, 0, 0]">
  60. <TresBoxGeometry :args="[1, 1, 1]" />
  61. <TresMeshBasicMaterial color="#efef11" />
  62. </TresMesh>
  63. </TresGroup>
  64. </TresGroup>
  65. <OrbitControls />
  66. <TresAmbientLight :intensity="0.5" />
  67. </TresCanvas>
  68. </template>