Skip to content

Commit 1c4f72f

Browse files
authored
feat(Texture): support opacity (#271)
1 parent b18b3ff commit 1c4f72f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/effects/Texture.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { TextureLoader, RepeatWrapping } from 'three'
55

66
type TextureProps = ConstructorParameters<typeof TextureEffect>[0] & {
77
textureSrc: string
8+
/** opacity of provided texture */
9+
opacity?: number
810
}
911

1012
export const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(
11-
{ textureSrc, texture, ...props }: TextureProps,
13+
{ textureSrc, texture, opacity = 1, ...props }: TextureProps,
1214
ref: Ref<TextureEffect>
1315
) {
1416
const t = useLoader(TextureLoader, textureSrc)
@@ -20,5 +22,5 @@ export const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(
2022
t.wrapS = t.wrapT = RepeatWrapping
2123
}, [t])
2224
const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture])
23-
return <primitive ref={ref} object={effect} dispose={null} />
25+
return <primitive ref={ref} object={effect} blendMode-opacity-value={opacity} dispose={null} />
2426
})

0 commit comments

Comments
 (0)