feat(webgl): add global property support for p5.strands#8211
feat(webgl): add global property support for p5.strands#8211davepagurek merged 15 commits intoprocessing:dev-2.0from
Conversation
|
hey @davepagurek, kindly review this too when you get a chance |
davepagurek
left a comment
There was a problem hiding this comment.
Hi, sorry for the delay, we were busy getting the 2.1 release out. Now that that's done, I can give an actual review! Your general approach looks good.
- Do you think you can add some unit tests that make use of these globals so we can both verify that it works, and also help ensure that it doesn't break in the future after other changes?
- It would also be great to put up a test sketch in the p5 web editor to play around with and help find bugs. To do that, you can run
npm run build, uploadlib/p5.jsto a web editor sketch, and edit its p5 script tag in index.html to point to your uploaded file.
src/strands/strands_api.js
Outdated
There was a problem hiding this comment.
While this is an integer value, it's fairly unintuitive for users of strands for it to actually be a glsl int instead of a float, since in JS all numbers are floats, and you'd expect frameCount / 2 to have decimals sometimes. So maybe let's turn all the ints into floats here?
src/strands/strands_api.js
Outdated
There was a problem hiding this comment.
In p5 2.x this isn't an int, it's an object: https://beta.p5js.org/reference/p5/mousebutton/ We might need to special case this one by either making each property a uniform, or by just omitting it for now.
- Changed frameCount from int1 to float1 for JS compatibility - Removed mouseButton (object type in p5 2.x) - Added unit tests for all 14 global properties Addresses feedback from @davepagurek in processing#8211
|
Hey @davepagurek, made the necessary changes. Please review whenever you get a chance. |
|
Hi! Sorry for the delay on this, we've been busy getting some other changes out. I'm back now to dedicate full attention to this if you're still interested in continuing! You should try running the tests on your PR, as it will surface issues faster than my reviews will. Running the tests on this, there are a number of test failures currently. In existing tests, the code breaks because the width property is being redefined. We may need to remove the old property before adding a new property descriptor. Additionally, the new tests added are failing because |
test/unit/webgl/p5.Shader.js
Outdated
There was a problem hiding this comment.
Is this test enough? do you suggest adding unit tests as well? @davepagurek
There was a problem hiding this comment.
maybe we could add a visual test that makes use of e.g. width and height?
There was a problem hiding this comment.
maybe we could add a visual test that makes use of e.g. width and height?
Aah yes, I mean visual tests.
Removed redundant assertions for mxInHook and wInHook.
davepagurek
left a comment
There was a problem hiding this comment.
one other thought: could we add support for millis() too?�im trying to think if there are other things like it which are functions, not properties, that should also be added. maybe thats it though
Yes, I really like the idea of adding |
Add visual test for getFinalColor using width/height
test/unit/webgl/p5.Shader.js
Outdated
There was a problem hiding this comment.
One last thing for this before merging, these variables don't get assigned to -- the callback in modify has no access to these due to our transpilation process. Currently it'd effectively be assigning to a global variable. We should probably remove these lets and then declare them locally in the shader to avoid confusion.
|
@perminder-17 a separate PR is ok! |
|
Sorry for the delay, I was away for exams .....really thanks @perminder-17 @davepagurek for the help, pls let me know if there's anything left for me to fix to get this merged asap |
Thanks for your work on this @avinxshKD! I pushed a few additional commits directly to your PR to help move things along, but your original commits are unchanged and still credited to you. |
|
@all-contributors please add @avinxshKD for code |
|
I've put up a pull request to add @avinxshKD! 🎉 |
- Changed frameCount from int1 to float1 for JS compatibility - Removed mouseButton (object type in p5 2.x) - Added unit tests for all 14 global properties Addresses feedback from @davepagurek in processing#8211
Resolves #8171
Changes:
What was changed:
src/strands/strands_api.jsto automatically intercept 16 p5 global properties when strands is activeScreenshots of the change:
N/A - This is an API enhancement without visual changes.
PR Checklist
npm run lintpasses