1
0

FirstScene.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 clear-color="#82DBC5" shadows alpha physically-correct-lights :output-encoding="sRGBEncoding">
  18. <OrbitControls />
  19. <TresPerspectiveCamera :position="[11, 11, 11]" :fov="45" :aspect="1" :near="0.1" :far="1000" />
  20. <TresScene>
  21. <TresMesh :position="[-2, 6, 0]" :rotation="[0, Math.PI, 0]" cast-shadow>
  22. <TresConeGeometry :args="[1, 1.5, 3]" />
  23. <TresMeshToonMaterial color="#82DBC5" />
  24. </TresMesh>
  25. <TresMesh :position="[0, 4, 0]" cast-shadow>
  26. <TresBoxGeometry :args="[1.5, 1.5, 1.5]" />
  27. <TresMeshToonMaterial color="#4F4F4F" />
  28. </TresMesh>
  29. <TresMesh :position="[2, 2, 0]" cast-shadow>
  30. <TresSphereGeometry />
  31. <TresMeshToonMaterial color="#FBB03B" />
  32. </TresMesh>
  33. <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
  34. <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
  35. <TresPlaneGeometry :args="[10, 10, 10, 10]" />
  36. <TresMeshToonMaterial color="greenyellow" />
  37. </TresMesh>
  38. <TresAmbientLight :intensity="0.75" />
  39. <TresDirectionalLight ref="LightRef" :position="[-4, 8, 4]" :intensity="0.5" cast-shadow />
  40. </TresScene>
  41. </TresCanvas>
  42. </template>