TresCanvas.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { TresScene } from './TresScene'
  2. import { defineComponent, h } from 'vue'
  3. import { ShadowMapType, TextureEncoding, ToneMapping } from 'three'
  4. import { CameraType, useTresProvider } from '/@/composables'
  5. import { RendererPresetsType } from '/@/composables/useRenderer/const'
  6. export interface TresCanvasProps {
  7. shadows?: boolean
  8. shadowMapType?: ShadowMapType
  9. physicallyCorrectLights?: boolean
  10. useLegacyLights?: boolean
  11. outputColorSpace?: TextureEncoding
  12. toneMapping?: ToneMapping
  13. toneMappingExposure?: number
  14. context?: WebGLRenderingContext
  15. powerPreference?: 'high-performance' | 'low-power' | 'default'
  16. preserveDrawingBuffer?: boolean
  17. clearColor?: string
  18. windowSize?: boolean
  19. preset?: RendererPresetsType
  20. disableRender?: boolean
  21. camera?: CameraType
  22. }
  23. /**
  24. * Vue component for rendering a Tres component.
  25. */
  26. export const TresCanvas = defineComponent<TresCanvasProps>({
  27. name: 'TresCanvas',
  28. props: [
  29. 'shadows',
  30. 'shadowMapType',
  31. 'physicallyCorrectLights',
  32. 'useLegacyLights',
  33. 'outputColorSpace',
  34. 'toneMapping',
  35. 'toneMappingExposure',
  36. 'context',
  37. 'powerPreference',
  38. 'preserveDrawingBuffer',
  39. 'clearColor',
  40. 'windowSize',
  41. 'preset',
  42. 'disableRender',
  43. 'camera',
  44. ] as unknown as undefined,
  45. setup(props, { slots, expose }) {
  46. const tres = useTresProvider()
  47. expose(tres)
  48. return () => h(TresScene, props, slots)
  49. },
  50. })
  51. export default TresCanvas