-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Fixes SVGLoader arc parsing with zero radius path commands. #20644
Conversation
It's also necessary to update |
examples/jsm/loaders/SVGLoader.js
Outdated
for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) { | ||
// skip command if start point == end point | ||
if( numbers[ j + 5 ] == 0 && numbers[ j + 6 ] == 0 ) continue |
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.
Shouldn't this line be if( numbers[ j + 5 ] == point.x && numbers[ j + 6 ] == point.y ) continue;
?
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.
Νο, the 'a' indicates that the arguments are relative to the current point, so a 0 means no displacement
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.
Ok, missed that
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.
I found three things to be improved.
Oops, I messed a little bit the review, but the three things are there. |
examples/js/loaders/SVGLoader.js
Outdated
if( rx == 0 || ry == 0 ) { | ||
// draw a line if either of the radii == 0 | ||
path.lineTo( end.x, end.y ); | ||
return; | ||
} | ||
|
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.
As per yomboprime's suggestion
examples/js/loaders/SVGLoader.js
Outdated
|
||
// skip command if start point == end point | ||
if( numbers[ j + 5 ] == point.x && numbers[ j + 6 ] == point.y ) continue; |
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.
as per yomboprime's suggestion
Minor thing: Can change the |
Just committed the changes! |
Thanks! |
Related issue: #20641
Description
If an SVG path has an arc command (A/a) with zero radius the path data gets thrown off. Adding a check in the path parser for zero radius fixes this:
Also, to avoid unnecessary computation, a check for useless arc command was added: