index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script setup lang="ts">
  2. import { TresCanvas } from '@tresjs/core'
  3. import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
  4. import { Perf, TresLeches, useControls } from '@tresjs/leches'
  5. import '@tresjs/leches/styles'
  6. import { OrbitControls } from '@tresjs/cientos'
  7. import AkuAku from './AkuAku.vue'
  8. const gl = {
  9. clearColor: '#82DBC5',
  10. shadows: true,
  11. alpha: false,
  12. shadowMapType: BasicShadowMap,
  13. outputColorSpace: SRGBColorSpace,
  14. toneMapping: NoToneMapping,
  15. }
  16. const { sphere } = useControls({
  17. sphere: true,
  18. })
  19. const ctx = ref(null)
  20. watchEffect(() => {
  21. if (!ctx.value) { return }
  22. // eslint-disable-next-line no-console
  23. console.log('ctx', ctx.value)
  24. })
  25. useControls({
  26. button: {
  27. label: 'Render dispose',
  28. type: 'button',
  29. onClick() {
  30. ctx?.value?.dispose()
  31. },
  32. },
  33. })
  34. </script>
  35. <template>
  36. <TresLeches />
  37. <TresCanvas
  38. v-bind="gl"
  39. ref="ctx"
  40. >
  41. <Perf />
  42. <TresPerspectiveCamera :position="[3, 3, 3]" />
  43. <OrbitControls />
  44. <Suspense>
  45. <AkuAku v-if="sphere" />
  46. </Suspense>
  47. <!-- <TresMesh
  48. v-if="sphere.value"
  49. :position="[0, 0, 0]"
  50. >
  51. <TresSphereGeometry />
  52. <TresMeshStandardMaterial color="teal" />
  53. </TresMesh> -->
  54. <TresAmbientLight :intensity="1" />
  55. </TresCanvas>
  56. </template>