From e55be2985c9b8cd3d4f4a13c4c33de26d2299c48 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Tue, 5 Mar 2024 06:56:12 +0100 Subject: [PATCH] fix(Texture): don't use depreciated constants --- src/effects/Texture.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/effects/Texture.tsx b/src/effects/Texture.tsx index 576d2dfb..e9e06668 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])