1
0

ExtendExample.vue 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script setup lang="ts">
  2. import { useTresContext } from '@tresjs/core'
  3. const styles = {
  4. width: '100%',
  5. height: '550px',
  6. border: '1px solid #e2e2e2',
  7. borderRadius: '8px',
  8. overflow: 'hidden',
  9. }
  10. const { camera, renderer } = useTresContext()
  11. </script>
  12. <template>
  13. <ClientOnly>
  14. <TresCanvas
  15. shadows
  16. clear-color="#fff"
  17. :style="styles"
  18. >
  19. <TresPerspectiveCamera :position="[0, 2, 4]" />
  20. <TresScene>
  21. <TresOrbitControls
  22. v-if="renderer"
  23. :args="[camera, renderer?.domElement]"
  24. />
  25. <TresDirectionalLight
  26. :position="[0, 2, 4]"
  27. :intensity="2"
  28. cast-shadow
  29. />
  30. <TresMesh :rotation="[-Math.PI / 4, -Math.PI / 4, Math.PI / 4]">
  31. <TresTorusGeometry :args="[1, 0.5, 16, 32]" />
  32. <TresMeshToonMaterial color="#FBB03B" />
  33. </TresMesh>
  34. </TresScene>
  35. </TresCanvas>
  36. </ClientOnly>
  37. </template>