-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
SVGLoader: Implement custom createShapes() method. #21380
SVGLoader: Implement custom createShapes() method. #21380
Conversation
for svg fillrule
I see that i still have to do some linting. |
I don't think this PR can be accepted then. A lot of user level code will going to break. Would it be possible to move this implementation to |
package.json
Outdated
@@ -89,7 +89,7 @@ | |||
"@rollup/plugin-babel": "^5.3.0", | |||
"@rollup/plugin-node-resolve": "^11.2.0", | |||
"concurrently": "^5.3.0", | |||
"eslint": "^7.20.0", | |||
"eslint": "^7.21.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.
Please remove all changes to package.json
and package-lock.json
.
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.
Done! I however have no idea why he flags a change in the last rule of package-lock.json
.
…Ttommeke/three.js into issue/ShapePath-toShapes-scanlineMethod
Thanks for the feedback. |
That sounds like a plan 👍 . |
Yep, sounds much more safe 👍 |
Hi, I've done some tests. I hate to bring bad news, here are some results. I will look with more insight in some days or when you make more commits. For the tests I've made the following:
Results:
(BTW, you forgot to modify the js and not the jsm) |
With the following changes the tiger shows up. I've not managed to make the text holes look correct. Added this
And added this check in this
|
@yomboprime That is a good fix. I'll sort out the text holes. Shouldn't be that difficult. |
I feel a bit stupid for asking, but i'm not sure what i have to do now. Do i have to edit both? Or only one? |
You always edit files in |
BTW, I think all the polarAngle calculations can be removed, since the theta angle is not used anywhere? |
|
Sorry for the wait. @yomboprime That looks great. I've added to the code. I've a question out of curiosity. Why did you choose to not return the classification of an intersection and instead use a variable( I believe to have fixed all of the issues @Mugen87 found in my pull request. |
Yes, should be faster as the JS engine doesn't have to create an additional object to return it and then just forget it after use. The V8 probably does a good job with such return-and-forget objects but it still should be faster. Since the intersection call is deeply nested in paths and segments loops, the optimization is multiplied potentially thousands of times. |
@yomboprime Do you know why the test files |
@Ttommeke Do you mind changing this line in the editor, too? Line 495 in 5635d4b
Besides, please update the code examples in the documentation and also add the new method: https://threejs.org/docs/index.html#examples/en/loaders/SVGLoader |
I noticed it some time ago and was going to look at it when I have some spare time. |
Okay. Just wanted to make sure this is unrelated to the PR 👍 |
@yomboprime Found the issue, see 330b186#r48264467. |
I was writing the documentation when i realized that most other loaders do not define static methods. They also all implement a parse method. For the sake of keeping things organized and the same, would it be a good idea to refactor the function createShapes(as a static method) to a parse(non static) method? |
I don't understand... SVGLoader already has a Also, the utility functions like |
You are right. I was wrong. I shouldn't be thinking about refactoring code at 1 am. |
Is this ready to merge then? |
It seems #21380 (comment) is still a todo. |
I think yes. But Tom was doing documentation, I understood. |
Yes. I'm finishing up now. |
Believe it's ready. |
Alright! |
Thanks! 🙏 |
It was a pleasure! Thanks for the great experience! @yomboprime @Mugen87 @mrdoob First public PR ever. |
Related issue: Fixed #16950.
Description
The current implementation of
ShapePath
only allowed thetoShapes()
function to generate shapes with holes correctly if the path orientation(CW
orCCW
) was known before hand. This made it difficult to import and convert a user generated SVG via theSVGLoader
into aShape
object.This implementation adds a scanline that will automatically determine the outside of a shape and its orientation. By passing the
fillRule
argument (same as the SVG stylefill-rule
), it can proceed to generate a correct shape.Some issues that need to be addressed:
isCCW
andnoHoles
parameter and replaced them withfillRule
.