-
-
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
ShapeUtils: Use earcut for polygon triangulation (2nd attempt) #12661
Conversation
Just curious, was there a particular concern with using an npm dependency in the previous PR? |
Maybe just me being old fashioned and cautious 😇 |
Thanks! |
|
||
bx = contour[ verts[ v ] ].x; | ||
by = contour[ verts[ v ] ].y; | ||
function earcut( data, holeIndices, dim ) { |
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.
Probably better to move this function to the top of the file? Otherwise we're going to be instantiating it every time we call to triangulate
.
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.
Okay, but i think we have to move all functions (not only earcut
) inside triangulate
because they are on the same hierarchy. How about moving the code to a new file Earcut.js
in src/extras
instead? In this way, the code is a little bit better separated and organized.
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've made a PR to see the result of this suggestion.
@Mugen87 Also, broken links to earcut examples still remain. |
@WestLangley I'm afraid i don't understand your feedback 😅 . To what kind of broken links do you refer? |
Ah, you mean the docs? That's right, i'll fix this! |
Successor of #12286 😊
This time i have re-written
ShapeUtils.triangulate()
based on earcut. So it's just a simple port, no usage of a npm module and no further modifications. Nevertheless, many problems in context of triangulation should be solved with this implementation.