Skip to content

Commit dce549b

Browse files
fix(Texture): don't use depreciated constants (#268)
1 parent 9d0cb9d commit dce549b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/effects/Texture.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TextureEffect } from 'postprocessing'
22
import { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'
33
import { useLoader } from '@react-three/fiber'
4-
import { TextureLoader, sRGBEncoding, RepeatWrapping } from 'three'
4+
import { TextureLoader, RepeatWrapping } from 'three'
55

66
type TextureProps = ConstructorParameters<typeof TextureEffect>[0] & {
77
textureSrc: string
@@ -13,7 +13,10 @@ export const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(
1313
) {
1414
const t = useLoader(TextureLoader, textureSrc)
1515
useLayoutEffect(() => {
16-
t.encoding = sRGBEncoding
16+
// @ts-ignore
17+
if ('encoding' in t) t.encoding = 3001 // sRGBEncoding
18+
// @ts-ignore
19+
else t.colorSpace = 'srgb'
1720
t.wrapS = t.wrapT = RepeatWrapping
1821
}, [t])
1922
const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture])

0 commit comments

Comments
 (0)