瀏覽代碼

Merge pull request #250 from Tresjs/bugfix/colorspaces-types

fix: colorspace types
Alvaro Saburido 2 年之前
父節點
當前提交
da28abc1bb
共有 2 個文件被更改,包括 7 次插入7 次删除
  1. 3 4
      src/components/TresScene.ts
  2. 4 3
      src/composables/useRenderer/index.ts

+ 3 - 4
src/components/TresScene.ts

@@ -1,6 +1,6 @@
 import { App, defineComponent, h, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue'
 import * as THREE from 'three'
-import { ShadowMapType, TextureEncoding, ToneMapping } from 'three'
+import { ColorSpace, ShadowMapType, ToneMapping } from 'three'
 import { createTres } from '/@/core/renderer'
 import { CameraType, TRES_CONTEXT_KEY, useLogger } from '/@/composables'
 import { useCamera, useRenderer, useRenderLoop, useRaycaster, useTres } from '/@/composables'
@@ -15,7 +15,7 @@ export interface TresSceneProps {
   shadowMapType?: ShadowMapType
   physicallyCorrectLights?: boolean
   useLegacyLights?: boolean
-  outputColorSpace?: TextureEncoding
+  outputColorSpace?: ColorSpace
   toneMapping?: ToneMapping
   toneMappingExposure?: number
   context?: WebGLRenderingContext
@@ -107,8 +107,7 @@ export const TresScene = defineComponent<TresSceneProps>({
       })
 
       onLoop(() => {
-        if (activeCamera.value && props.disableRender !== true && props.disableRender !== '')
-          renderer.value?.render(scene, activeCamera.value)
+        if (activeCamera.value && props.disableRender !== true) renderer.value?.render(scene, activeCamera.value)
 
         if (raycaster.value) {
           const intersects = raycaster.value.intersectObjects(scene.children)

+ 4 - 3
src/composables/useRenderer/index.ts

@@ -16,8 +16,9 @@ import {
   ShadowMapType,
   PCFShadowMap,
   Clock,
+  ColorSpace,
 } from 'three'
-import type { TextureEncoding, ToneMapping } from 'three'
+import type { ToneMapping } from 'three'
 import { useRenderLoop, useTres } from '/@/composables/'
 import { normalizeColor } from '/@/utils/normalize'
 import { TresColor } from '/@/types'
@@ -63,7 +64,7 @@ export interface UseRendererOptions extends WebGLRendererParameters {
    *
    * @default LinearSRGBColorSpace
    */
-  outputColorSpace?: MaybeRefOrGetter<TextureEncoding>
+  outputColorSpace?: MaybeRefOrGetter<ColorSpace>
 
   /**
    * Defines the tone mapping used by the renderer.
@@ -190,7 +191,7 @@ You could set windowSize=true to force the canvas to be the size of the window.`
     renderer.value.toneMapping = (toValue(toneMapping) as ToneMapping) || NoToneMapping
     renderer.value.toneMappingExposure = toValue(toneMappingExposure) as number
     // Wating for https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65356/files to be merged
-    renderer.value.outputColorSpace = (toValue(outputColorSpace) as TextureEncoding) || LinearSRGBColorSpace
+    renderer.value.outputColorSpace = toValue(outputColorSpace as ColorSpace) || LinearSRGBColorSpace
     if (clearColor?.value) renderer.value.setClearColor(normalizeColor(toValue(clearColor) as TresColor))
 
     /*    renderer.value.physicallyCorrectLights = toValue(physicallyCorrectLights) as boolean */