maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.61k stars 713 forks source link

Implement ray/triange intersection in combination of coordsframebuffer #1596

Open prozessor13 opened 2 years ago

prozessor13 commented 2 years ago

currently screen-pixel to geo-coordinate transormation is done via a hidden framebuffer, which contains RGB-encoded geo-coordinates. But aspecially in heavy terrain this has rounding-errors, so i propose an improvement:

https://www.npmjs.com/package/ray-triangle-intersection

HarelM commented 2 years ago

Sounds interesting! This package is fairly old and might not be up to date with security and other issues. Since this is basically a single method of around 20 lines I would consider simply writing the method in here at maplibre: https://github.com/substack/ray-triangle-intersection/blob/master/index.js I hope we have the relevant math function that are referenced there in our code already.

HarelM commented 2 years ago

Can this problem be the source of the fact that the marker and the point on the terrain looks slightly moved aside: image This is how it look in 2D: image

prozessor13 commented 2 years ago

what is the difference of the 2 markers? symbol-layer & maplibregl.Marker?

HarelM commented 2 years ago

Yes, one is an html object and the other is part of the canvas.

HarelM commented 1 year ago

Assigned L bounty. Link to parent Bounty: https://github.com/maplibre/maplibre/issues/189

rotu commented 1 year ago

Can you check whether some of the supposed rounding errors are actually fixed by #2772? There was a minor mistake in the elevation logic.

I suspect it's responsible for https://github.com/maplibre/maplibre-gl-js/issues/1596#issuecomment-1252864823