TheBasic.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script setup lang="ts">
  2. import { sRGBEncoding, BasicShadowMap, NoToneMapping } from 'three'
  3. import { reactive, ref } from 'vue'
  4. import { OrbitControls, TransformControls } from '@tresjs/cientos'
  5. import { useRenderLoop } from '..'
  6. /* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
  7. const state = reactive({
  8. clearColor: '#201919',
  9. shadows: true,
  10. alpha: false,
  11. physicallyCorrectLights: true,
  12. shadowMapType: BasicShadowMap,
  13. outputEncoding: sRGBEncoding,
  14. toneMapping: NoToneMapping,
  15. })
  16. const sphereRef = ref()
  17. const { onLoop } = useRenderLoop()
  18. onLoop(({ elapsed }) => {
  19. sphereRef.value.position.y += Math.sin(elapsed * 0.01) * 0.1
  20. })
  21. </script>
  22. <template>
  23. <TresCanvas v-bind="state">
  24. <TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[-8, 3, -3]" />
  25. <OrbitControls make-default />
  26. <TresScene>
  27. <TresAmbientLight :intensity="0.5" />
  28. <TransformControls mode="scale" :object="sphereRef" />
  29. <TresMesh ref="sphereRef" :position="[0, 4, 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 />
  37. </TresMesh>
  38. <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
  39. </TresScene>
  40. </TresCanvas>
  41. </template>