Skip to content
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

fill-extrusion-flat-ceilings style spec property #10355

Open
andrewharvey opened this issue Feb 5, 2021 · 18 comments
Open

fill-extrusion-flat-ceilings style spec property #10355

andrewharvey opened this issue Feb 5, 2021 · 18 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏

Comments

@andrewharvey
Copy link
Collaborator

Motivation

When using fill-extrusions on a map with terrain enabled, since #10347 the extrusion ceiling will be flat. This is good for buildings, but per #10170 (comment) sometimes you might want these extrusions to follow the terrain.

One example is for vegetation extrusions to show forest areas of a fixed height above the terrain.

Design Alternatives

The user could split the polygons but they still would be flat, just stepped. A smoother extrusion which follows the terrain could only be achieved my unlocking it with a style spec property.

Design

Using a style spec property which defaults to flat allows backwards compatibility, but still supporting curved extrusion ceilings.

It's fine if this is not something you're keen on implementing, but thought I'd raise this ticket for further discussion since the existing ones were closed out.

@mourner mourner added cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 labels Feb 9, 2021
@astojilj
Copy link
Contributor

@karimnaaji started work on scoping the mechanism.

@andrewharvey ,

One example is for vegetation extrusions to show forest areas of a fixed height above the terrain.

Do you see that it would be beneficial to style it differently?
E.g.

  • round top (chamfer at top),
  • extrude in direction of slope normal (not vertically),
  • or something else?

cc @karimnaaji @asheemmamoowala

@andrewharvey
Copy link
Collaborator Author

Do you see that it would be beneficial to style it differently?

For the vegetation use case, I don't think that's too important.

@karimnaaji
Copy link
Contributor

Some other interesting use cases for such a property: https://cameronwkruse.com/home/projects/glacslide/.

Some considerations to properly support the non-flat case:

  • Adjust the normals to follow slope, so that shading used on the fill-extrusions is accurate. Currently, normals are always pointing up on the top geometry.
  • Subdivide the polygon to fit the terrain geometry, some artifacts may be seen when the polygon does not have enough subdivision to properly follow the terrain slopes.

@andrewharvey
Copy link
Collaborator Author

Another use case for non-flat ceilings of extrusions which follow the terrain is visualising land zoning restrictions of maximum building height. Source data might have large polygons covering several blocks together, so using a fixed height of extrusion would result in a wrong visualisation.

@Confusedfish
Copy link

Thanks for looking into this. My use case is to mark areas of turbulence behind hills in different wind directions. The turbulence isn't flat, nor exactly follows the ground elevation but having the ability to follow the ground elevation would be preferable.

Adding some form of tilt setting would also help immensely as the turbulence tapers off by distance from the top of the hill but I appreciate that is just adding further complexity. My planned approach was to use a series of stepped polygons which would be visually inferior.

@searoutefinder
Copy link

searoutefinder commented Jun 7, 2021

Hello all! I am writing in this issue thread to report a behavior in GL JS v2.2 that I think is a bug unless I am missing something.
I am working on a project where we deploy flight regulations based on height above mean sea level. I am using grid cells from our system and display them on a GL JS map using a fill-extrusion layer. The problem I am reporting happens only when 3D terrain view is enabled. Eventually I'd like to display the grid on a fixed vertical position relative to the earth and NOT the terrain. After doing some research I found that for the time being I can not do such a thing which is a petty, because without the 3D terrain it's completely possible to do. Do you have any ideas? Is there something I am missing? Thanks a million for all your answers!

2

This is basically what I want to achieve but with 3D terrain enabled. I don't have any issues if some of the tiles intersect or get hidden by the terrain on lower elevations.

3

@astojilj
Copy link
Contributor

astojilj commented Jun 7, 2021

@searoutefinder
I understand that what I'm about to propose is not convenient, but it might be a viable workaround until we design the property. So, flat roofs are enabled only if the feature has properties:

const flatRoof = this.enableTerrain && feature.properties &&
vectorTileFeatureTypes[feature.type] === 'Polygon';

If the feature has no properties tag, e.g. render test opacity-terrain includes geojson source where features define polygons but have no properties tag, fill extrusion roof would follow terrain slope.

image

In opposite case, e.g. opacity-terrain-flat, features have properties:

{
            "type": "Feature",
            "properties": {
              "type": "building",
              "height": 20
            },
            "geometry": {

and roof is flat:

image

@searoutefinder
Copy link

@searoutefinder
I understand that what I'm about to propose is not convenient, but it might be a viable workaround until we design the property. So, flat roofs are enabled only if the feature has properties:

const flatRoof = this.enableTerrain && feature.properties &&
vectorTileFeatureTypes[feature.type] === 'Polygon';

If the feature has no properties tag, e.g. render test opacity-terrain includes geojson source where features define polygons but have no properties tag, fill extrusion roof would follow terrain slope.

image

In opposite case, e.g. opacity-terrain-flat, features have properties:

{
            "type": "Feature",
            "properties": {
              "type": "building",
              "height": 20
            },
            "geometry": {

and roof is flat:

image

Hey astojilj,

First of all, let me thank you for your quick response!
I fear that I was expressing myself in a wrong way, and therefore my problem didn't come through.
So if you take a look at the first screenshot of my original post, you can see that the "roofs" are level. I have no issues with that, and my grid cell polygons do have a properties object literal, which contains a number of attributes on each cell.
However, I'd like to have these grid cells to constitute a 3D pane, that I can move up and down by setting the fill-extrusion-base and fill-extrusion-height properties.
So imagine a place where only 300m something high hills there are. I'd like to ble able to visualize a grid that can lift up and down based on the elevation I tell it. Let's say 700m. In that case, I expect the grid cells to be flat rectangles placed 700m away from mean sea level vertically. Do you get my point?

Thanks again!

Tamas

@runshotgun
Copy link

runshotgun commented Jun 23, 2021

Can we get this for -floor as well? I'm trying to set the -base of an object and bring it up in the air but the base follows the geometry of the terrain while in the air instead of being flat... That seems to correlate with the issue described above.

2021-06-23_17-21-35

@astojilj
Copy link
Contributor

@searoutefinder @TheMapleSyrupCan

Thank you for clarifying this.

This is the same issue as with custom roof approach, when additional fill extrusion layer is used only for roof (base == height), enabling different paint for roofs, e.g.:

Screen Shot 2021-06-24 at 8 25 33

@astojilj
Copy link
Contributor

astojilj commented Jun 24, 2021

I'm happy with the output we got from the thread here. Thanks.

One way to address this would be by adding properties: "fill-extrusion-height-terrain-alignment" and "fill-extrusion-base-terrain-alignment", e.g.:

    "fill-extrusion-base-terrain-alignment": {
      "type": "enum",
      "values": {
        "terrain": {
          "doc": "The fill extrusion base follows terrain slope."
        },
        "flat": {
          "doc": "The fill extrusion base is flat over terrain."
        }
      },
      "doc": "Controls the behavior of fill extrusion base over terrain",
      "default": "terrain",
      "property-type": "data-constant"
    }

@karimnaaji, this would extend previous approach by supporting base, too. WDYT?

@markcarroll
Copy link

did this every get resolved? We are hitting this issue too and would like to be able to decide whether the extrusions should be relative to the 3D terrain or flat (i.e. mean sea level).

@thibaultclem
Copy link

Hi @astojilj,
I think your idea of having "fill-extrusion-height-terrain-alignment" and "fill-extrusion-base-terrain-alignment" would be a good idea. We are stuck on our side when trying to render different floor of a building on terrain:

Screenshot 2023-10-03 at 11 13 22 AM

With a fill-extrusion-base-terrain-alignment equal to flat, this would solve our problem for upper floor.

Do you know if there is any update about it ?

Thanks a lot

@Adraesh
Copy link

Adraesh commented Dec 28, 2023

Hello,

Interesting topic here.

We also would like to be able to decide whether the base and/or ceiling should be relative to the 3D terrain or flat (AMSL or ASFC)

Thanks.

@Adraesh
Copy link

Adraesh commented Jan 17, 2024

Hello!

Any news on this feature?

Thank you!

@astojilj
Copy link
Contributor

Thanks for your patience on this - we were busy with other 3D features! We'll take a look.

@speps
Copy link
Contributor

speps commented Nov 13, 2024

Thanks for your patience, we have introduced new style spec properties to help with this issue. They landed in v3.8.0.

Both properties work with the 'fill-extrusion' layer type, they can be either 'terrain' or 'flat' and control respectively the ceiling (aka 'height') and the floor (aka 'base'):

  • fill-extrusion-height-alignment (defaults to 'flat')
  • fill-extrusion-base-alignment (defaults to 'terrain')

Let us know if there's any issues on these as they are experimental for now.

@Adraesh
Copy link

Adraesh commented Nov 13, 2024

Excellent news @speps !

Gonna try it out asap!

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏
Projects
None yet
Development

No branches or pull requests