mapbox / delaunator

An incredibly fast JavaScript library for Delaunay triangulation of 2D points
https://mapbox.github.io/delaunator/
ISC License
2.33k stars 142 forks source link

fix wrong mouse pointer coordinates in example #1

Closed MaxGraey closed 7 years ago

MaxGraey commented 7 years ago

Happy to see Ukraine with Crimea=)

mourner commented 7 years ago

Thanks! I think the coordinates got fixed in Firefox after I added position: relative to the canvas, so there seems to be no need for sophisticated functions (I prefer to keep things as simple as possible). Do you know any browsers the current page will fail in?

BTW didn't expect a PR so soon, I didn't even release this yet :) Thank you!

MaxGraey commented 7 years ago

Ok, It seems adding relative resolved issue. Are you planning to do a full triangulation routine like do in earcut with holes and point filtering?

mourner commented 7 years ago

@MaxGraey not planning Constrained Delaunay Triangulation at the moment — implementing this is complex and very hard to do in a robust way. The library will most likely remain for points only.

MaxGraey commented 7 years ago

hmm, maybe this will help a little: https://github.com/mikolalysenko/cdt2d

And for good quality we need some refinements like Chew’s Second Delaunay Refinement or Ruppert.

tyrasd commented 7 years ago

got fixed in Firefox

…but it still doesn't work properly on a Chromium 58 here.

MaxGraey commented 7 years ago

@tyrasd how about this PR, is it resolve Chromium 58 issue?

tyrasd commented 7 years ago

I have to correct myself slightly: It happens in Chromium only when page zoom isn't 100% (the more zoomed in/out you are, the more the mouse pointer coordinates are off).

how about this PR

Yes, cherry-picking your commit 1586473 onto current master fixes the issue.

MaxGraey commented 7 years ago

@tyrasd I confirm this. And I pushed new commit that resolve this issue completely.