Skip to content

Commit

Permalink
fix: colorspace types
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed May 8, 2023
1 parent e744672 commit 27e10e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/components/TresScene.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -15,7 +15,7 @@ export interface TresSceneProps {
shadowMapType?: ShadowMapType
physicallyCorrectLights?: boolean
useLegacyLights?: boolean
outputColorSpace?: TextureEncoding
outputColorSpace?: ColorSpace
toneMapping?: ToneMapping
toneMappingExposure?: number
context?: WebGLRenderingContext
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/composables/useRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 27e10e9

Please sign in to comment.