FirstScene.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <script setup lang="ts">
  2. import { ref, onMounted } from 'vue'
  3. import { Color, sRGBEncoding, ACESFilmicToneMapping } from 'three'
  4. import { OrbitControls } from '@tresjs/cientos'
  5. const LightRef = ref()
  6. onMounted(() => {
  7. LightRef.value.shadow.mapSize.set(1024, 1024)
  8. LightRef.value.shadow.camera.near = 0.5
  9. LightRef.value.shadow.camera.far = 2000
  10. LightRef.value.shadow.camera.left = -10
  11. LightRef.value.shadow.camera.right = 10
  12. LightRef.value.shadow.camera.top = 10
  13. LightRef.value.shadow.camera.bottom = -10
  14. })
  15. </script>
  16. <template>
  17. <TresCanvas
  18. clear-color="#82DBC5"
  19. shadows
  20. alpha
  21. physically-correct-lights
  22. :output-encoding="sRGBEncoding"
  23. :tone-mapping="ACESFilmicToneMapping"
  24. >
  25. <OrbitControls />
  26. <TresPerspectiveCamera :position="[11, 11, 11]" :fov="45" :aspect="1" :near="0.1" :far="1000" />
  27. <TresScene>
  28. <TresMesh :position="[-2, 6, 0]" :rotation="[0, Math.PI, 0]" cast-shadow>
  29. <TresConeGeometry :args="[1, 1.5, 3]" />
  30. <TresMeshToonMaterial color="#82DBC5" />
  31. </TresMesh>
  32. <TresMesh :position="[0, 4, 0]" cast-shadow>
  33. <TresBoxGeometry :args="[1.5, 1.5, 1.5]" />
  34. <TresMeshToonMaterial color="#4F4F4F" />
  35. </TresMesh>
  36. <TresMesh :position="[2, 2, 0]" cast-shadow>
  37. <TresSphereGeometry />
  38. <TresMeshToonMaterial color="#FBB03B" />
  39. </TresMesh>
  40. <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
  41. <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
  42. <TresPlaneGeometry :args="[10, 10, 10, 10]" />
  43. <TresMeshToonMaterial color="greenyellow" />
  44. </TresMesh>
  45. <TresAmbientLight :intensity="0.75" />
  46. <TresDirectionalLight ref="LightRef" :position="[-4, 8, 4]" :intensity="0.5" cast-shadow />
  47. </TresScene>
  48. </TresCanvas>
  49. </template>