-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(webgl): add global property support for p5.strands #8211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-2.0
Are you sure you want to change the base?
Conversation
|
hey @davepagurek, kindly review this too when you get a chance |
davepagurek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| { name: 'pmouseY', type: DataType.float1 }, | ||
| { name: 'winMouseX', type: DataType.float1 }, | ||
| { name: 'winMouseY', type: DataType.float1 }, | ||
| { name: 'frameCount', type: DataType.int1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| { name: 'displayHeight', type: DataType.float1 }, | ||
| { name: 'windowWidth', type: DataType.float1 }, | ||
| { name: 'windowHeight', type: DataType.float1 }, | ||
| { name: 'mouseButton', type: DataType.int1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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