FirstScene.vue 1.9 KB

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