experience.vue 765 B

123456789101112131415161718192021222324252627282930313233343536
  1. <script setup lang="ts">
  2. import { OrbitControls } from '@tresjs/cientos'
  3. import { useTres } from '@tresjs/core'
  4. import { ref, watch } from 'vue'
  5. import BlenderCube from '../../../components/BlenderCube.vue'
  6. const { invalidate } = useTres()
  7. const blenderCubeRef = ref()
  8. watch(blenderCubeRef, (prev, next) => {
  9. if (!next) { return }
  10. invalidate()
  11. })
  12. function onControlChange() {
  13. invalidate()
  14. }
  15. </script>
  16. <template>
  17. <TresPerspectiveCamera
  18. :position="[5, 5, 5]"
  19. :look-at="[0, 0, 0]"
  20. />
  21. <Suspense>
  22. <BlenderCube ref="blenderCubeRef" />
  23. </Suspense>
  24. <TresGridHelper />
  25. <OrbitControls @change="onControlChange" />
  26. <TresAmbientLight :intensity="1" />
  27. <TresDirectionalLight
  28. :position="[0, 8, 4]"
  29. :intensity="0.7"
  30. />
  31. </template>