Skip to content

shaderMaterial in Typescript + React #2288

Answered by SrPumpkin
SrPumpkin asked this question in Q&A
Discussion options

You must be logged in to vote

This problem can be resolved as follows.

Our component:

const DreiShaderMaterial = shaderMaterial(
    {
        u_time: 0.0,
        u_tex: new THREE.Texture()
    },
    vertex,
    fragment
)

extend({ DreiShaderMaterial })

You just need to add this code to any "***.d.ts" file:

import {DreiShaderMaterial} from "./components/Item.tsx";

declare global {
    namespace JSX {
        interface IntrinsicElements {
            dreiShaderMaterial: ReactThreeFiber.Node<typeof DreiShaderMaterial & JSX.IntrinsicElements['dreiShaderMaterial'], typeof DreiShaderMaterial>
        }
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SrPumpkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant