diff --git a/src/effects/Texture.tsx b/src/effects/Texture.tsx index 576d2df..e9e0666 100644 --- a/src/effects/Texture.tsx +++ b/src/effects/Texture.tsx @@ -1,7 +1,7 @@ import { TextureEffect } from 'postprocessing' import { Ref, forwardRef, useMemo, useLayoutEffect } from 'react' import { useLoader } from '@react-three/fiber' -import { TextureLoader, sRGBEncoding, RepeatWrapping } from 'three' +import { TextureLoader, RepeatWrapping } from 'three' type TextureProps = ConstructorParameters[0] & { textureSrc: string @@ -13,7 +13,10 @@ export const Texture = forwardRef(function Texture( ) { const t = useLoader(TextureLoader, textureSrc) useLayoutEffect(() => { - t.encoding = sRGBEncoding + // @ts-ignore + if ('encoding' in t) t.encoding = 3001 // sRGBEncoding + // @ts-ignore + else t.colorSpace = 'srgb' t.wrapS = t.wrapT = RepeatWrapping }, [t]) const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture])