Closed mattrossman closed 1 year ago
Updated implementation with uniform types for .setValues()
Oh yes ! , many effects use shaderMaterial
and they all have this problem , would be great to have a proper solution
if you can, do make the PR ❤
:tada: This issue has been resolved in version 1.7.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Describe the feature you'd like:
shaderMaterial()
has trouble with TypeScript. The storybook example has several type errors because custom uniforms don't exist on the resulting class type.In the main drei project, they work around this by specifying the types when extending the JSX namespace.
https://github.com/pmndrs/drei/blob/f5354c4cc5349e048c00d5ad2b8c839cde5bd132/.storybook/stories/shaderMaterial.stories.tsx#L58-L69
This adds friction and duplication in userland though. I would like
shaderMaterial
to automaticallly wire up these uniform types to its resulting class type. Uniform types can be inferred from the function arguments or provided by the user through generics.Suggested implementation:
See implementation with generics here: TypeScript Playground
This resolves the type errors in the storybook example.
I can make a PR for this.