-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[p5.strands]: Allow equivalent of p5 transforms #7857
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
Comments
This would be a great enhancement, manually applying a rotation matrix to points would really be hard as I can see and I also wouldn't expect this to be something most users are comfortable with as well. Thanks for bringing this up @davepagurek :) |
Hi @davepagurek and @perminder-17! This is great to see, and @davepagurek, thanks for mentioning this use case! I've been working on a new Actually, I've been working on a proposal for several related classes:
I suppose I shouldn't hype it up too much, but I feel I've cooked up something special. For each class, I've written up motivation and use cases, a core feature set (with potential roadmap items), an API, and an implementation architecture. I'm entering the phase where I'm writing up all my ideas and finishing the details for a set of public proposals. I was originally thinking of making these sub-issues of #7754, but to keep things concise and focused, I might start a new umbrella issue since the proposals are all related. I would link to all previous discussions, including this one. How does that sound? P.S. It looks like you're using operator overloading in your demo code snippet? Is that on purpose? Don't get me wrong. I wish we had operator overloading in JavaScript, but I don't think we have that available unless we do something like paper.js has done. My operating assumption has been that this is probably off the table for p5, based on past discussions, but please let me know if that's changed! |
We actually do have that in p5.strands, as a way to bridge some of the features of GLSL to our shaders-in-js API. Like paper.js, it rewrites operators between vectors into .mult(...) and similar methods, which can also be written out explicitly. Currently it's just there though and not in general. |
Under the hood in strands, variables that look like numbers also aren't actual js numbers, they're objects that keep track of operations applied to them so that we can output matching structures in GLSL. The main benefit of operator overloading is to make those FEEL like they're just numbers so users aren't aware that anything different is happening, unlike some other GLSL builders we looked at. This happens to also allow us to do multiplications on matrices and vectors if we want in strands, but it's still up in the air whether or not we think it makes sense to actively encourage this, or just mention it's a thing you can do so people coming from GLSL don't feel like it's way more verbose in strands. |
Oh, wow. Super interesting. Thanks @davepagurek! I'm glad I asked. (And I should've known you knew what you were doing with the overloading 😅.) As I mentioned, I'm planning to propose a dedicated Regarding transforms, my sense is that it'd be best to avoid operator overloading in p5.strands (except possibly for GLSL users who really know what they're doing, although likely not even for them). I think my reasoning applies in this context, but I haven't learned a lot about p5.strands yet, so I'll explain my thinking. I'll comment briefly about overloads for general matrix operations, within p5.strands, at the end. I'd be curious to hear your thoughts about any of this.
|
Uh oh!
There was an error while loading. Please reload this page.
Increasing access
In normal p5, users have access to functions like
rotate()
,scale()
, etc. In p5.strands, if one wants to position particles, currently there is nothing that looks like that, so to do a rotation, one has to do a lot of manual trig. This is a fairly large step in the learning curve that we could possibly smooth out.Most appropriate sub-area of p5.js?
Feature enhancement details
I was working on this p5.strands sketch https://openprocessing.org/sketch/2664809 and found myself essentially manually applying a rotation matrix to points. This is fairly hard to do and I wouldn't expect this to be something most users are comfortable with. Maybe there's something we can do there?
My initial thought: we're in the process of making
p5.Matrix
public and making regular p5 functions have strands equivalents. Maybe we can make an equivalent ofp5.Matrix
that works in strands?e.g.:
The text was updated successfully, but these errors were encountered: