Releases: tangrams/tangram
v0.5.1
New Features
- Support data sources with either clock-wise (CW) or counter-clock-wise (CCW) winding order. See #241.
- Winding requirements are inconsistent across formats: GeoJSON has no formal requirement, while recent MVT spec versions mandate CW winding. For the greatest flexibility, we now detect the winding order and adapt to the data source (including allowing mixing data sources with different winding orders).
- As part of this change, the
enforce_winding
parameter for data sources is deprecated; it is a no-op with the new behavior, so will cause no compatibility issues if present (it will simply be ignored).
Bug Fixes
- Fix rendering issues for polygon outlines when using MVT data sources with buffered tiles. See #242.
- When drawing polygon outlines, any line segments wholly outside the tile bounds are now discarded. Fixes issues on polygons extending into the buffer area.
- Improves rendering of buffered tile sources such as Mapbox's. (Mapzen's MVT tiles are not buffered, but Mapbox's are.)
- Query GL API for shader float precision
- Fixes issue with devices not supporting
highp
float in fragment shader (reported as issue on Samsung S3 Mini).
- Fixes issue with devices not supporting
- Build line outline before the line fill
- Ensures the outline geometry is placed in the VBO before the fill, which partially fixes an issue where outlines were not drawing properly with
blend: overlay
(the "outline" would render on top of the fill, making the entire line appear in the outline color). - Note: there is still an issue with order conflicts between outlines/fill when lines segments intersect/overlap each other. To address, all outlines should be consolidated underneath all fills, but this necessitates larger structural changes.
- Ensures the outline geometry is placed in the VBO before the fill, which partially fixes an issue where outlines were not drawing properly with
Internal
- Peg all node module versions for more reliable build process and avoid unexpected regressions from automatic version upgrades.
v0.5.0
New Features
- Sprite/point collision (so sprites and text labels don't overlap)
- Extends the collision detection previously applied only to text labels so that it is also applied to features drawn with the point style (often sprites).
priority
is respected between these features to control which will be most likely to draw. (NB: Also fixes an issue where labels drawn with multiple styles derived from the text style would not collide with each other.) No new syntax is required, the behavior is automatically applied to points, though thecollide: false
parameter can be used to disable collision for points or text labels where desired. See #229.
- Extends the collision detection previously applied only to text labels so that it is also applied to features drawn with the point style (often sprites).
- Label text can be defined as a series of fallbacks
- Enables support for a preferred label language, by adding the ability for
text_source
to be an array of possible sources of label text, in priority order. For example:text_source: [name:en, name]
will display an English label (name:en
) when available, and will fall back to the default localname
when not available. See #235.
- Enables support for a preferred label language, by adding the ability for
- Dynamic (run-time) data sources
- Adds a JS API,
Scene.setDataSource (name, config)
for creating or updating a data source at run-time. The data source can be provided either as aurl
, or with direct data, such as by passing a GeoJSON object in thedata
field. See #227.
- Adds a JS API,
- Dynamic (run-time) textures
-
Adds support for additional texture sources that can be created or updated at run-time.
-
img
,canvas
, andvideo
DOM objects can be set directly on a texture with theelement
, or can be specified as CSS selectors, for example- HTML:
<canvas class='awesome-texture'>
- Scene YAML:
textures: awesome-texture: element: .awesome-texture
-
Alternatively, raw RGBA byte data can be provided with
data
,width
, andheight
parameters. -
See #226.
-
- Screenshot support and
view_complete
event- Adds a
Scene.screenshot()
method to assist in capturing the current map view.screenshot()
returns a Promise that fulfills withurl
(a URL suitable for loading into an<img>
or opening in a new tab/window) andblob
(aBlob
of typeimage/png
, suitable for saving to a file). Note that actually saving the blob to disk is left to the user or 3rd party library such as FileSaver.js. - Example usage:
scene.screenshot().then(function(result) { window.open(result.url); });
- In addition, a scene event
view_complete
has been added. It fires when the view is in a "resting state", meaning new geometry is rendered, and no further tiles are loading/building. This is useful for detecting significant view changes, and can be paired withScene.screenshot()
to automate screenshots. - See #230.
- Adds a
- Miter limit
- Adds a
miter_limit
parameter to thelines
style. Miter limits convert sharp miter joins to bevels when the miter join length is longer than the ratio of themiter_limit
to the width of the line. See SVG miter limit for reference, and #231 for more info.
- Adds a
- Filter line segments on any tile edge
- Avoid artifacts in rare cases where very large features are clipped beyond the local tile area (The Highline in NYC is an example). See #237.
Bug Fixes
- Fix
modelPosition()
y coordinate value range to be[0, 1]
(rather than[0, -1]
). - Fix handling of 2d values for point
size
.
v0.4.6
Bug Fixes
- Apply basic packing of label texture atlas to keep texture within max GL size for the device. If atlas could not fit (should not happen or be very rare), an error is thrown and those labels will not be drawn. Fixes issue observed with Refill style at z20 on iPhone, where max texture size is 2048x2048.
v0.4.5
Maintenance release focused on optimization.
New Features
- Add warnings for invalid layers & data sources.
- Allow data sources to set a
max_zoom
higher than the overall Tangram default (currently 18).
Bug Fixes
- Fix incorrect alpha for CSS-style colors.
- Fix issue where visible layers weren't drawing if a non-visible layer also matched.
- Guard against empty draw group definitions
Internal
- Optimize style parsing and geometry build processes (~40% decrease in build time for complex scene of NYC z9).
v0.4.4
New Features + Style Syntax/API Changes
-
Adds minimum distance between similar labels, to reduce repeats.
- Specify the minimum distance (in pixels) required between labels with
repeat_distance
. The default is256px
(the CSS pixel size of one tile). e.g. to make labels repeat more frequently than the default:
draw: text: repeat_distance: 100px # label can repeat every 100 pixels ...
- Specify the grouping mechanism by which labels are considered the "same" with the
repeat_group
parameter. By default, labels are grouped by the the set oflayers
(styling rules) that they match. For example, multiple road segments with different classifications (e.g. one matching amajor_roads
layer, one matchingminor_roads
layer) will be allowed to repeat even if they have the same label text, because they are placed into different repeat groups. If one wanted to place all roads into the same repeat group, that could be accomplished withrepeat_group: roads-fewer-labels
. - See #222.
- Specify the minimum distance (in pixels) required between labels with
-
Add
blend_order
to control render order of styles with non-opaque blending.blend_order
is an optional parameter used when defining a render style, which controls the order in which styles with non-opaque blending (add
,multiply
,inlay
,overlay
) are rendered.- For example, to create
marker
andicons
styles that are drawn on top of the built-in styles:
styles: marker: base: points blend: overlay blend_order: 1 # marker goes on top of icons and text ... icons: base: points blend: overlay blend_order: 0 # icons go on top of text, underneath marker ...
- See #223.
-
Add support for zoom interpolation (e.g. stops syntax) for the
offset
parameter applied topoints
(sprites) andtext
styles.- For example:
offset: [[13, [0, 6px]], [15, [0, 9px]]]
. This can be used in conjunction withanchor
to position text and sprites adjacent to each other, even when the sprite's size is interpolating across zooms. (The preferred future solution to this is to offer a unified label style for sprite and text.)
- For example:
-
Deterministically resolve conflicts between
layers
at the same depth that modify the same style properties. To resolve, layers are lexically sorted by name. As with deeper layers overwriting the properties of shallower layers, the last layer sorted by name will overwrite any earlier layers. e.g.layerB
wins overlayerA
. See #225.layers: layerA: color: red layerB: color: blue # feature will be blue because `layerB` sorts after `layerA`
-
Add text
collide: false
option to turn off collision (e.g. allow overlap) for text labels. -
Fallback to Helvetica when all other fonts specified in
family
are unavailable. -
When loading a scene with
scene.load()
, allow a full scene file URL to be passed as scene base path (previously only paths without the file itself were accepted; if a file URL is provided, the path will now be derived from it).
Bug Fixes
- Remove Leaflet scroll wheel zoom modification that was interfering with zoom animations for Leaflet vector (SVG) layers.
- Fix rare cases where Tangram canvas would not reposition relative to Leaflet container.
Internal
- Track the
layers
that contributed to each final draw group (to aid future debugging and authoring tools). - Return to using round-robin assignment of workers, since random distribution didn't always seem very random :)
v0.4.3
Bug Fixes
- Fix line label fitting logic, can result in significantly more line labels being placed
- Fix sprite/label anchors on retina displays
- Fix first frame render with un-initialized normal matrix (could result in brief render with incorrect lighting)
- Handle features that have no geometry (a
geometry: null
is valid GeoJSON) - Additional error detail when layer fails to parse
Internal
- Text style refactor
v0.4.2
v0.4.1
New Features + Style Syntax/API Changes
- Zoom-based interpolation ("stops") for the following font properties:
- Font
size
(specified inpx
,pt
, orem
) fill
color (partially worked previously, fixes bugs with using string colors)- Stroke
width
(specified inpx
) - Stroke
color
- Example (see #214 for more info):
- Font
draw:
text:
font:
family: Helvetica
fill: [[14, white], [18, gray]]
size: [[14, 12px], [16, 16px], [20, 24px]]
stroke:
color: [[16, white], [18, red], [20, blue]]
width: [[14, 3px], [20, 8px]]
- Add anchor positioning to points/sprites.
- Uses the same
anchor
syntax as for point labels (left
,bottom-right
, etc.). - Unlike with labels, the align keyword is not needed.
- See #213 for more info.
- Uses the same
- Add
vec3 worldNormal()
accessor in shaders, to complementmodelPosition()
andworldPosition()
functions. Provides compatibility with Tangram ES. See #209. - Transparency (alpha) values are now supported in text rendering (e.g. font
fill
and strokecolor
will now parse alpha values). - If an explicit
size
is not specified for asprite
, it defaults to the sprite's pixel size. - Draw lines that have zero width at the current zoom but will scale up to have a positive width at the next zoom; causes lines to ease/scale in rather than popping in when the tile zoom changes.
- When device pixel ratio changes, for example when switching from an external to built-in display, the map resolution is updated to match. See #211.
Bug Fixes
- When an array is used as a layer filter, it is implicitly treated as an
any
filter.- To illustrate, the following are equivalent:
filter: [ kind: minor_road, railway: true ]
filter: { any: [ kind: minor_road, railway: true ] }
- Fixes discrepancy with docs and Tangram ES.
- To illustrate, the following are equivalent:
- Fix comparison of data sources updated at run-time. See #215.
- GLSL global initializers must be constant. Not enforced on most devices, but fixes shader compilation errors on some (observed on Samsung Galaxy Note Edge). See #212.
- Support multipolygon decoding for MTV tiles. See #217.
- Don't render lines with negative or NaN width.
- Don't load tiles outside expected coordinates for current zoom (e.g. negative tile coords).
Internal
- Convert all JS properties/filters
NaN
return values tonull
(NaN
is unpredictable when used as a binary value for typed arrays / GL VBOs).
v0.4.0
New Features + Style Syntax/API Changes
- Multi-line labels: line wrapping of labels, controlled by
text_wrap
andalign
properties intext
-based styles. By default, wrapping is enabled for point labels, and disabled for line labels. See #205 for more info.- Wrapping
text_wrap: true
uses default wrapping (15 characters).text_wrap: 10
sets a maximum line length of 10 characters.text_wrap: false
disables wrapping.- Explicit line breaks (
\n
chars) will cause a line break (even iftext_wrap
is disabled).
- Alignment of text for multi-line labels can be controlled with
align
, with one of:center
(default)left
justifiedright
justified- Alignment has no effect for single-line labels.
- Wrapping
- Label anchors: point labels can be anchored relative to their point location. See #182 for more info.
anchor
can be set to:center
(default),top
,bottom
,left
,right
,top-left
,top-right
,bottom-left
,bottom-right
- Text alignment is also defaulted (if not explicitly set with
align
) to match the anchor type:anchor: center | top | bottom
=> defaultsalign: center
anchor: left | top-left | bottom-left
=> defaultsalign: right
anchor: right | top-right | bottom-right
=> defaultsalign: left
- JS-only option to move the label into the tile is now exposed as style property
move_into_tile
(defaultstrue
to match previous behavior, but should be set tofalse
if using anchor/align functionality for text + icon combinations, otherwise, text can get out of sync with expected position).
- Transparent backgrounds: adds alpha to the Tangram GL canvas, which allows for Leaflet layers (or other HTML content) to be placed beneath the map, in addition to on top of it. See #202 for more info. Examples:
- Default is transparent background, equivalent to:
scene: { background: { color: transparent } }
- To allow background to show through with 50% opacity:
scene: { background: { color: [0, 0, 0, .5] } }
- Default is transparent background, equivalent to:
- Shader position accessors:
vec4 modelPosition()
andvec4 worldPosition()
accessors should be used in lieu of directly accessing attributea_position
and varyingv_world_position
.modelPosition()
provides vertex position within its tile (model) space, where [0, 1] is the scale of the tile on x & y axes. Unclipped geometries can contain values outside [0, 1] range, as can z coordinates which have the same scale, e.g. a height of 1 corresponds to the length of the tile in x and y.worldPosition()
provides vertex position in world space (web mercator meters), with wrapping (configurable viaTANGRAM_WORLD_POSITION_WRAP
) applied to avoid float precision issues at higher zooms.- This change avoids styles that depend on implementation details (such as position packed as a short integer) which are subject to change and which diverge between JS and ES. The new accessors provided a common interface to these properties. See #197.
- Browserify/bundle compatibility: Tangram can be loaded outside of a bundled JS file. Due to lingering issues around web worker instantiation, Tangram still cannot (yet) be used as a a browserify module itself (except through
browserify-shim
), however dependencies such as Leaflet can now be bundled separately. See #208 for more info.
Breaking Changes
- Due to new GL canvas position in DOM (to support transparency), event listeners that were previously attached to
scene.container
should now be attached tomap.getContainer()
(wheremap
is the Leaflet map object). See the included demo here and here for an example. JS used for hover/click feature interactivity (for features markedinteractive
) are affected by this change and should be updated.
Bug Fixes
- Style mixing: support "diamond" mixin patterns for more complex style composition, e.g.:
- B mixes A
- C mixes A
- D mixes [B, C]
- D should end up with only one copy of A's shader blocks
- Shader uniform "inheritance": at run-time, style-specific uniforms will use the value explicitly defined for that style if present, otherwise will forward to the appropriate ancestor style from which it was mixed in. Allows uniform values to be changed at run-time and properly cascade one or more levels to descendant styles.
- Polygon extrusion: don't extrude polygon edges along tile boundaries by default. These were usually invisible due to being "interior walls" in buildings, but are not desirable and produce artifacts when alpha blending is used.
- Leaflet: fix ability for Leaflet scroll wheel zoom to be enabled/disabled at run-time.
- Style materials: fix support for texture objects embedded in material properties, e.g.
material: diffuse: texture: { url: ..., filtering: mipmap }
- Style mixing: fix mixing of
blend
,null
values would causeopaque
default to be used, instead of falling back on base style via prototype. - Textures: add URL cache buster for textures.
- Tile data: clear worker tile cache when data source config changes (sources with custom data transforms were not refreshing properly when config was updated).
- Leaflet: when tile build finishes, only update tile list via tile manager internally; calling scene update was interfering with Leaflet animations such as
flyTo()
. - Style layer rules: expose
$layer
property for JS filters/properties. - Feature selection: fix feature selection change flag (did not always register a change).
- Resolves all remaining known issues with "dirty" text halos.
Internal
- To support transparent backgrounds, the GL canvas is now inserted in the correct location in the Leaflet DOM (previously it was pulled out of the DOM to make positioning simpler, and because without alpha it often got covered by other layers).
- Clean up shaders by moving attribute unpacking into macros.
- Worker broker: remove neutered transferables from parent objects (these should not be accessed after transfer).
- Move Canvas text layout and rasterization to own file.
- Upgrade Babel (4.7.8 -> 5.8.29), and use runtime option (rather than polyfill) for both library and test builds.
v0.3.3
- Modifications to scroll-wheel zoom behavior to fix issues with animated styles in Chrome
- Make
u_device_pixel_ratio
uniform available in thepoints
vertex shader - Fix alpha for
points
drawn withblend: inlay
- Fix issue where
px
units caused parsing error with text stroke width - Fix issues with hyphens in style names
- Fix issues with style trying to mix into itself