Fix some bugs in p5.strands type aliasing #8251
Merged
+250
−51
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.
Fixes a few bugs:
uniformTexture()no longer worked in the intro to strands tutorial. The issue was that the base type in GLSL is "sampler2D". We previously added a human-readable "texture" alias for this, similar to how we can calluniformVector3()instead of the more GLSL-yuniformVec3()to be more in line with p5 naming. I think this got lost in the refactor because typecasting methods likeint(something)would cause issues withtexture(...)already being an existing p5 method. Typecasting isn't really necessary for texture types so I've omitted that, and just added the alias foruniformTexture.shared*orvarying*methods for p5.strands types. Because these are generated in code and are not documented and are not based on JSON data anywhere, for now it means there's similar logic in the TS type generation script to in p5.strands. I don't love that, but I avoided refactoring that for now to just get things working.Added some tests:
uniformTexture()works@ts-ignorefor some of the vector operations since TS doesn't like those on arrays. Maybe in the future we can figure out a better way to do our JS-bending in TS.