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
PIXI.Polygon#isClockwise
Add the possibility to clear the cached result
#8855
Comments
As a general rule, I don't think it is a good idea to treat polygons or other shapes as mutable. It would be preferable to return a new polygon instead of mutating it in many (maybe not all) cases. In my opinion, it complicates the code to have to assume the polygon will just mutate at will. Testing for orientation is non-trivial, so checking repeatedly will have a performance impact. Orientation is particularly important for using polygons with holes, so as Foundry starts to rely on more complex geometric manipulations, this will become more of a concern. As Foundry already adds an As for what to return when the polygon has 0, 1, or 2 points, I do not agree with returning false. If I ask if a polygon is oriented "clockwise," I would expect that if the answer is false, the polygon is "counterclockwise." This is necessary, again, to determine if a polygon represents a hole. Returning false whenever the polygon has less than 3 points makes all such polygons holes. Returning |
I agree, caching the result would be preferable if possible, but The user can call |
PIXI.Polygon#isClockwise
must not cache its resultPIXI.Polygon#isClockwise
Add the possibility to clear the cached result
I have to say it disagree with the choice to cache the orientation polygon for the reasons I explained in my previous comment. There wasn't even documentation added to Also this part of the issue was not addressed:
The documented return type still |
I think a ternary return is not meaningless. The polygon is either clockwise, counterclockwise, or degenerate (the |
What happened?
The points of the polygon are mutable. So caching the orientation can lead to problems:
Also I don't think it makes sense to return
undefined
if there are less than 3 points. This is just one of many cases of degenerate polygons that do not have a well-defined orientation.A polygon without well-defined orientation certainly doesn't have a clockwise orientation, so it makes sense to return
false
.What ways of accessing Foundry can you encounter this issue in?
Reproduction Steps
.
What core version are you reporting this for?
Version 11 Prototype 1 (build 292)
Relevant log output
No response
Bug Checklist
The text was updated successfully, but these errors were encountered: