-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Adding strokeMode() to access SIMPLE lines. #7390
Conversation
The test which are currently failing are
I have observed that these tests are also failing in the current Dev 2.0 branch. Therefore, I believe that this pull request is not related to the issues affecting these tests. |
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.
Thanks @perminder-17, this is looking good, great explanation of the use of both modes!
src/core/constants.js
Outdated
* @property {String} FULLY | ||
* @final | ||
*/ | ||
export const FULLY = 'fully'; |
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.
A minor note, could we call this FULL instead of FULLY to use the same adjective form as SIMPLE?
src/webgl/3d_primitives.js
Outdated
*/ | ||
|
||
fn.strokeMode = function(mode){ | ||
if(mode === constants.SIMPLE){ |
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.
Could we make this return the current mode if we call it with no arguments?
src/webgl/p5.Geometry.js
Outdated
@@ -1398,7 +1399,7 @@ class Geometry { | |||
if (dirOK) { | |||
this._addSegment(begin, end, fromColor, toColor, dir); | |||
} | |||
|
|||
if(!this.renderer._simpleLines){ |
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.
Since p5.Geometry
created manually won't have a renderer passed in, I think we need to handle the case where there is no renderer, and mayube default to the full line behaviour:
if(!this.renderer._simpleLines){ | |
if(!this.renderer?._simpleLines){ |
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.
Also, do you think we could intent the block inside this to keep the indentation consistent everywhere?
src/webgl/p5.Geometry.js
Outdated
@@ -1520,6 +1522,7 @@ class Geometry { | |||
} | |||
} | |||
this.lineVertices.push(...a, ...b, ...a, ...b, ...b, ...a); | |||
if(!this.renderer._simpleLines){ |
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.
Similarly here, we might need to check for the existence of the renderer first:
if(!this.renderer._simpleLines){ | |
if(!this.renderer?._simpleLines){ |
src/webgl/shaders/line.vert
Outdated
@@ -67,6 +68,8 @@ vec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) { | |||
|
|||
void main() { | |||
HOOK_beforeVertex(); | |||
|
|||
if(!uSimpleLines){ |
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.
Could we indent the block below?
src/webgl/3d_primitives.js
Outdated
* let lineLength = 50; | ||
* | ||
* beginShape(LINES); | ||
* vertex(centerX - lineLength / 2, centerY, 0); |
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.
How do you feel about having a 3D shape like a default sphere()
, and maybe a single Bezier curve in each of these examples? I feel like those are two cases where the difference is clear: the sphere probably looks the same regardless, and the curve (especially with a higher stroke weight) will look very disjoint without full curve decorations.
We can also make the examples more than 100x100 if that makes it easier to see since I think the new site's layout accommodates that decently.
Adjusting the indentation caused unexpected spacing issues in the code, making it difficult to review. I apologize for any inconvenience this may have caused. Also, the checks were failing because we need to check the existence of the renderer first. Thanks for the suggestions:) |
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.
Thanks for the updates, looks great!
fixes : #7278
Created a method
strokeMode()
to access SIMPLE lines for faster fps.