Skip to content

v0.20.0

Compare
Choose a tag to compare
@bcamper bcamper released this 04 Jan 21:05
· 74 commits to master since this release

New Functionality

  • Custom attributes for styles #739
    • Styles can now define custom vertex attributes/varyings for use in GLSL shader code. This simplifies existing uses of per-feature property data in shaders (which have usually been "smuggled" into the shader by encoding non-color values in the color parameter), moving these values to semantic-appropriate attributes, and enabling more advanced forms of custom shader visualizations by allowing for multiple attributes to be defined.
    • In a style declaration, the shaders block can now contain a new entry called attributes -- a mapping of names to properties of custom vertex attributes. Those new attributes are given values in draw groups by assigning a value to the attribute's name in a new attributes block, and are then available inside shader blocks. All together, the new syntax looks like this:
      buildings:
        base: polygons
        shaders:
          attributes:
            height:
              type: float
          blocks:
            color: |
              // Use the custom attribute's varying to shade by height
              color.rgb = vec3(min(height / 100., 1.), 0., 0.);
        draw:
          # use default draw parameters to set the height attribute value from the height feature property
          attributes:
            height: function() { return feature.height; }
      
    • The above example uses default draw parameters (inside the style definition) to assign the attribute values, which is convenient if the attribute is always tied a specific feature property. However, these attributes can also be set in any draw group within layers, as with all other draw parameters.
    • Attribute values can be set as a JS function (e.g. to tie a numeric feature property to an attribute of the same name, likely the most common case for this functionality: custom: function(){ return feature.custom; }), a single value (custom: 5), or zoom-interpolated values (custom: [[14, 50], [15, 150], [16, 300]]).
    • Only 32-bit floating point values (defined as type: float in the attribute definition) are supported at this time (other attribute types may be supported in the future).
    • See #739 for full syntax.
  • Alpha parameter for draw groups #740
    • A new alpha parameter inside draw groups allows the scene author to set only the alpha channel of a color, independently of the RGB channels. This is useful for cases such as:
      • Modifying the alpha for named CSS colors
      • Modifying the alpha channel in a sub-layer
      • Using a feature property to set the color, but then modifying only the alpha
    • In draw groups where an alpha parameter is present, its value will override the alpha channel set by the corresponding color parameter. For example:
      translucent_polygons:
        color: red
        alpha: 0.5 # red polygon with 50% opacity
      
    • The alpha parameter is available for polygons (fill color), lines (inline and outline color), points (fill and outline color), text (font fill and stroke color), and raster (color).
    • alpha values can be set as a single value (alpha: 0.5), zoom-interpolated values (alpha: [[14, 0.5], [16, 1]]), or JS function (alpha: function(){ return feature.height/200; })
    • See #740 for full syntax.
  • Add raster-based styles to blend/base default styles 4609a89
    • An oversight when these new built-in style combinations were added in v0.19.0

Bug Fixes

  • Fix mesh variant cache for line outlines 4fc6b91
  • Fix event subscription notifications for style compilation errors e76e4fd
    • Fixes Tangram Play inline shader compile errors

Internal

  • Avoid polluting user-defined styles (scene.config.styles) with blend/base default styles 824ec12