feat: Add ShaderMaterial uniforms typing and autocompletion (+ ShaderPass)#151
Open
Lutymane wants to merge 2 commits intothree-types:masterfrom
Open
feat: Add ShaderMaterial uniforms typing and autocompletion (+ ShaderPass)#151Lutymane wants to merge 2 commits intothree-types:masterfrom
Lutymane wants to merge 2 commits intothree-types:masterfrom
Conversation
Member
|
This PR has become a bit convoluted, I think if you want to fix some types these should be different PRs |
Author
|
Oh, I'm sorry it just took so long I started to forget about this PR so it became indeed convoluted, sorry again. Tell me, please, if the part about shader materials is ok, so I'll isolate it. While I'll create a separate PR for postprocessing changes on a different branch |
4f06fe4 to
ccfe9eb
Compare
Contributor
|
I just have reached to the same |
|
What is the status of this pr? I would love to use it on my project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
To increase quality and speed of development. With autocompletion you won't misspell uniform names and mistype their values.
What
Added uniforms typings for ShaderMaterial, RawShaderMaterial and ShaderPass and also overall type improvements.
The uniform types are automatically inferred when creating an instance from parameters.
Or they can be supplied in generic (useful when just declaring variables) in multiple ways:
The uniform types will be asserted while creating an instance.
In
ShaderMaterial.d.tsyou can also find a more strict variant for uniforms (which is commented out) for the case when you don't supply types during declaration, meaning uniforms themselves can be undefined (as there's no assertion during instance creation) or when you cast Material to ShaderMaterial which produces a correct type error but due to the fact this practice is used everywhere in legacy code I decided not to keep it and leave it more loosely making it fully backwards compatible.Also as
nulla separate type it's recommended to type uniforms the following way:Because if it's simply a
nullit will be replaced byanyto allow value modification.Checklist