Closed chrispahm closed 1 year ago
Hi @chrispahm, Thanks for your comments. This is not really a bug, the shadows still there, but in a Geometry Plane created for projecting the shadow in the Custom Layer which is below the Terrain layer rendered by Mapbox engine. As the terrain layer has its own 3D mesh created on top of the map, there's no really a way to project the shadow of an object in a Custom Layer, over the terrain mesh in a Terrain layer, or at least, I haven't found a way to make it.
Hi @jscastro76, Thanks for the explanation!
Hi @jscastro76, Thanks for the explanation!
I couldn't find a way yo make the terrain mesh to receive a shadow.
No worries, I'm just thinking about a potential way how this could be incorporated without receiving the terrain mesh from Mapbox. What do you think of the following:
It's quite hacky, but I guess there's no other way to get Mapbox's own terrain data / mesh into threebox, right?
One other thing that came to mind was to create a mesh on-the-fly by creating a point grid within the maps boundaries, and then query the elevation using map.queryTerrainElevation(point, { exaggerated: false })
for each point instead of re-fetching a raster DEM tile and interpolating it. I'm guessing that would be quite a performance hit though...
Hi @jscastro76,
I started to implement the above methodology to render shadows in a 3d terrain map: https://observablehq.com/@chrispahm/enabling-shadows-in-a-mapbox-terrain-map
There are still a few open issues though:
That’s quite impressive @chrispahm! I assume performance will be heavily affected but it could be applied as an option so each one could decide if use them or not. If you’re preparing any PR, let me know
Hey,
Describe the bug Thanks for maintaining this awesome library! I'm trying to visualise wind turbines on a 3D terrain map. Once I activate the terrain, the shadows vanish from the map though.
To Reproduce
terrain: true
-> no shadows present on the groundExpected behavior Shadows should be visible on the ground, just like they are when the 3D terrain is not active.
Relevant Code or Code Sandbox Here's an Observable notebook showcasing the bug, using a slightly altered version of the
add3dmodel
example https://observablehq.com/d/c6c236f9bb6f21f4Screenshots Shadows present without 3D terrain
Shadows not present with 3D terrain enabled