MultipleCanvas.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <script setup lang="ts">
  2. import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
  3. import { TresCanvas } from '@tresjs/core'
  4. // import { GLTFModel, OrbitControls } from '@tresjs/cientos'
  5. const state = reactive({
  6. clearColor: '#201919',
  7. shadows: true,
  8. alpha: false,
  9. shadowMapType: BasicShadowMap,
  10. outputColorSpace: SRGBColorSpace,
  11. toneMapping: NoToneMapping,
  12. disableRender: false,
  13. stencil: false,
  14. })
  15. const state2 = reactive({
  16. clearColor: '#4f4f4f',
  17. shadows: true,
  18. alpha: false,
  19. /* shadowMapType: BasicShadowMap,
  20. outputColorSpace: SRGBColorSpace,
  21. toneMapping: NoToneMapping, */
  22. })
  23. const log = () => {
  24. console.log(3)
  25. }
  26. </script>
  27. <template>
  28. <div class="flex">
  29. <input
  30. id=""
  31. v-model="state.clearColor"
  32. type="text"
  33. name=""
  34. >
  35. <input
  36. v-model="state.stencil"
  37. type="checkbox"
  38. name=""
  39. >
  40. <div class="w-1/2 aspect-video">
  41. <TresCanvas v-bind="state">
  42. <TresPerspectiveCamera
  43. :position="[5, 5, 5]"
  44. :fov="45"
  45. :near="0.1"
  46. :far="1000"
  47. :look-at="[0, 4, 0]"
  48. />
  49. <TresAmbientLight :intensity="0.5" />
  50. <TresMesh
  51. :position="[0, 4, 0]"
  52. @click="log"
  53. >
  54. <TresBoxGeometry :args="[1, 1, 1]" />
  55. <TresMeshToonMaterial color="cyan" />
  56. </TresMesh>
  57. <Suspense>
  58. <TestSphere />
  59. </Suspense>
  60. <TresDirectionalLight
  61. :position="[0, 2, 4]"
  62. :intensity="1"
  63. />
  64. </TresCanvas>
  65. </div>
  66. <div class="w-1/2 aspect-video">
  67. <TresCanvas v-bind="state2">
  68. <TresPerspectiveCamera
  69. :position="[5, 5, 5]"
  70. :fov="45"
  71. :near="0.1"
  72. :far="1000"
  73. :look-at="[0, 4, 0]"
  74. />
  75. <TresAmbientLight :intensity="0.5" />
  76. <TresMesh
  77. :position="[0, 4, 0]"
  78. cast-shadow
  79. >
  80. <TresSphereGeometry :args="[2, 32, 32]" />
  81. <TresMeshToonMaterial color="yellow" />
  82. </TresMesh>
  83. <TresDirectionalLight
  84. :position="[0, 2, 4]"
  85. :intensity="1"
  86. cast-shadow
  87. />
  88. </TresCanvas>
  89. </div>
  90. </div>
  91. </template>