ted-piotrowski/mapbox-gl-shadow-simulator

Size of the shade area

Opened this issue · 5 comments

Hi,

how is the size of the shade area determined? I have a Mapbox map position absolute in Vue.

When I add the shade there's a small area on the bottom of the map where the shade is not displayed:

Screen 2022-11-30 at 17-10-10

Any ideas?

BR
Marco

The shade layer fits to the dimensions of map.getBounds(). To help me debug could you answer these questions:

Does the issue persist if you disable 3D terrain?
What version of Mapbox GL JS are you using?

I'm using this Vue wrapper library https://gitlab.com/relief-melone/vue-mapbox-ts in the most recent version.
Which itself is using Mapbox GL JS v2.9.1 (https://gitlab.com/relief-melone/vue-mapbox-ts/-/blob/master/package.json#L41)

The problem is gone when I disable 3D!!!

But the shade is not calculated correctly, even when 3D is NOT activated and the camera is pitched for more than 45°. When the camera is pitched for less than 45° the shade is calculated correctly. See here as GIF:
https://media.giphy.com/media/QpeTVbNnhuLgSwl0rc/giphy-downsized-large.gif

Ah yes. This sounds familiar. The way map.getBounds() is calculated when 3D is enabled does not actually include all the pixels on the screen. I will look into this a bit more and get back to you.

Unfortunately, the maximum pitch I currently support is 45 degrees. To get more pitch is a tricky problem because the horizon distance becomes quite far. It's something I'm researching but if this is a feature you need then know that it will take months to complete. My current workaround on shademap.app is setting maxPitch: 45 when I initialize the map. I will update the README.

Thanks for the info!

The fix for the size of the shade area will need to happen on the Mapbox side. I raised an issue here and will update when I hear back.

mapbox/mapbox-gl-js#12431