Skip to content
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

Merged
merged 1 commit into from
Nov 22, 2017

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Nov 15, 2017

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.

@donmccurdy
Copy link
Collaborator

Just curious, was there a particular concern with using an npm dependency in the previous PR?

@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2017

Just curious, was there a particular concern with using an npm dependency in the previous PR?

Maybe just me being old fashioned and cautious 😇

@mrdoob mrdoob merged commit e523785 into mrdoob:dev Nov 22, 2017
@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2017

Thanks!


bx = contour[ verts[ v ] ].x;
by = contour[ verts[ v ] ].y;
function earcut( data, holeIndices, dim ) {
Copy link
Owner

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.

Copy link
Collaborator Author

@Mugen87 Mugen87 Nov 22, 2017

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.

Copy link
Collaborator Author

@Mugen87 Mugen87 Nov 22, 2017

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.

@WestLangley
Copy link
Collaborator

@Mugen87 Also, broken links to earcut examples still remain.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Nov 22, 2017

@WestLangley I'm afraid i don't understand your feedback 😅 . To what kind of broken links do you refer?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Nov 22, 2017

Ah, you mean the docs? That's right, i'll fix this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants