MultipleCanvas.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script setup lang="ts">
  2. import { BasicShadowMap, NoToneMapping, sRGBEncoding } from 'three'
  3. import { TresCanvas } from '/@/components/TresCanvas'
  4. import { GLTFModel, OrbitControls } from '@tresjs/cientos'
  5. const state = reactive({
  6. clearColor: '#201919',
  7. shadows: true,
  8. alpha: false,
  9. shadowMapType: BasicShadowMap,
  10. outputEncoding: sRGBEncoding,
  11. toneMapping: NoToneMapping,
  12. })
  13. const state2 = reactive({
  14. clearColor: '#4f4f4f',
  15. shadows: true,
  16. alpha: false,
  17. /* shadowMapType: BasicShadowMap,
  18. outputEncoding: sRGBEncoding,
  19. toneMapping: NoToneMapping, */
  20. })
  21. </script>
  22. <template>
  23. <div class="flex">
  24. <div class="w-1/2 aspect-video">
  25. <TresCanvas v-bind="state">
  26. <TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[0, 4, 0]" />
  27. <OrbitControls />
  28. <TresAmbientLight :intensity="0.5" />
  29. <TresMesh :position="[0, 4, 0]">
  30. <TresBoxGeometry :args="[1, 1, 1]" />
  31. <TresMeshToonMaterial color="cyan" />
  32. </TresMesh>
  33. <Suspense>
  34. <TestSphere />
  35. </Suspense>
  36. <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" />
  37. </TresCanvas>
  38. </div>
  39. <div class="w-1/2 aspect-video">
  40. <TresCanvas v-bind="state2">
  41. <TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[0, 4, 0]" />
  42. <TresAmbientLight :intensity="0.5" />
  43. <TresMesh :position="[0, 4, 0]" cast-shadow>
  44. <TresSphereGeometry :args="[2, 32, 32]" />
  45. <TresMeshToonMaterial color="yellow" />
  46. </TresMesh>
  47. <OrbitControls />
  48. <Suspense>
  49. <GLTFModel
  50. path="https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/aku-aku/AkuAku.gltf"
  51. draco
  52. />
  53. </Suspense>
  54. <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
  55. </TresCanvas>
  56. </div>
  57. </div>
  58. </template>