Skip to content

Commit

Permalink
fix(Texture): don't use depreciated constants (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Mar 5, 2024
1 parent 9d0cb9d commit dce549b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/effects/Texture.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof TextureEffect>[0] & {
textureSrc: string
Expand All @@ -13,7 +13,10 @@ export const Texture = forwardRef<TextureEffect, TextureProps>(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])
Expand Down

0 comments on commit dce549b

Please sign in to comment.