PolylineMaterial
PolylineMaterial represents a material for polyline geometry rendering.
Properties
Section titled “Properties”Type: number | undefined
Description: Softens the edge of the line: its opacity fades out toward the edge over blur pixels. A wide blurred line under a thin one makes the line look like it glows. 0 draws a hard edge.
Default: 0
Example:
{ polyline: { width: 12, blur: 4 }}Type: "butt" | "round" | "square" | undefined
Description: Shape of the ends of the line and of the dashes of its dashArray pattern. "round" adds a half circle, half a line width in radius, beyond both ends of the line and of every dash. Each dash is therefore one line width longer than its dashArray entry, and a dash of length 0 is drawn as a dot. "square" extends both ends of the line by half a line width and leaves the ends of the dashes square. A closed ring has no ends.
Default: "butt"
Example:
{ polyline: { // A dotted line dashArray: [0, 2], cap: "round" }}castShadow
Section titled “castShadow”Type: boolean | undefined
Description: Specifies whether the polyline casts shadows.
Default: undefined
Example:
{ polyline: { castShadow: true }}clampToGround
Section titled “clampToGround”Type: boolean
Description: Specifies whether to clamp the polyline to the ground.
Default: Required
Example:
{ polyline: { clampToGround: true }}Type: Color
Description: Specifies the polyline color as a Color instance.
Default: Required
Example:
import { Color } from "@navaramap/three";
{ polyline: { color: new Color().setHex(0x0066cc) }}dashArray
Section titled “dashArray”Type: number[] | undefined
Description: Lengths of the alternating dashes and gaps of the line, in multiples of the line width. The pattern repeats along the line with a period equal to the sum of the entries, following the line-dasharray property of the MapLibre Style Spec. An array with an odd number of entries therefore ends in a dash that joins the first one: [1, 2, 1] draws dashes two line widths long. An empty array draws a solid line.
The pattern keeps its place on the line while the camera moves, and a dash is drawn up to twice as long as specified, depending on the camera distance. A line that is not clamped to the ground starts the pattern in the middle of its longest gap, and a line clamped with clampToGround starts it with the first dash. A clamped line of a GeoJSON source continues one pattern across the tiles it is drawn in, while a line of a vector-tile source, or a tiled line that is not clamped, restarts the pattern at every tile boundary. Picking treats the gaps as part of the line.
Default: undefined
Example:
{ polyline: { width: 4, // 12px dashes separated by 8px gaps dashArray: [3, 2] }}depthWrite
Section titled “depthWrite”Type: boolean | undefined
Description: Enables writing to the depth buffer. Set to false for transparent materials to prevent depth sorting issues.
Default: true
Example:
{ polyline: { depthWrite: false }}effectIds
Section titled “effectIds”Type: string[] | undefined
Description: Specifies the IDs of selective effects to apply (e.g., “bloom”, “outline”). Used in conjunction with SelectiveBloomEffectDesc or SelectiveOutlineEffectDesc.
Default: undefined
Example:
{ polyline: { effectIds: ["bloom", "outline"] }}emissiveColor
Section titled “emissiveColor”Type: Color | undefined
Description: Specifies the emissive color as a Color instance.
Default: undefined
Example:
import { Color } from "@navaramap/three";
{ polyline: { emissiveColor: new Color().setHex(0xff0000) }}emissiveIntensity
Section titled “emissiveIntensity”Type: number | undefined
Description: Specifies the emissive intensity.
Default: undefined
Example:
{ polyline: { emissiveIntensity: 0.5 }}geodesic
Section titled “geodesic”Type: boolean | undefined
Description: Specifies whether edges drawn through the tiled path (clampToGround or tiled) of a GeoJSON source follow the geodesic. When true, two consecutive vertices more than 180° apart in longitude are also joined the short way, across the antimeridian; a closed ring that would then no longer close, such as one around a pole, is kept as given. When false, edges are straight lines in Web Mercator and longitudes are used as given, so a longitude of 190° lies east of 180°, as in MapLibre. Edges outside the tiled path and edges from vector tile sources are not affected.
The option applies to the whole layer: its tiled polygon and polyline share one geometry, which follows the geodesic unless both set geodesic: false. It is read when the layer’s tiles are first built, so changing it on an existing layer has no effect.
Default: true
Example:
{ polyline: { clampToGround: true, geodesic: false }}geometryTypes
Section titled “geometryTypes”Type: ("line" | "polygon")[] | undefined
Description: Source geometry categories this material consumes. When set to include "polygon", polygon boundary rings (the outer ring and any holes) render as closed polylines at the ring’s base height. Extruded side edges are not included, so use the polygon material’s outline for extruded polygons. Setting the array replaces the default, so include "line" when line geometry should keep rendering. This option applies when the layer’s geometry is built: set it at layer creation. layer.update() applies a new value only to tiles loaded afterwards, so already-loaded tiles keep their previous geometry until the layer is re-created.
Default: ["line"]
Example:
{ polyline: { geometryTypes: ["line", "polygon"] }}gradient
Section titled “gradient”Type: { progress: number; color: Color; opacity?: number }[] | undefined
Description: Colors each line along its length instead of with color, following the line-gradient property of the MapLibre Style Spec. Each stop gives a color and an opacity at a progress along the line, from 0 at its first position to 1 at its last. Between two stops the color and opacity change linearly. Before the first stop and after the last they keep that stop’s values. Two stops at the same progress make a hard change. A stop’s opacity multiplies the line’s opacity. The gradient is the same for every line of the layer and replaces a feature’s own color too.
The progress is measured as MapLibre measures line-progress: by length in Web Mercator over the whole line of the source, so the pieces a line is cut into for tiles continue one gradient. Only a geojson source with lineMetrics: true measures it. Lines of a geojson source without it, or of a vector-tile source, draw with color, and a warning is logged. On a source with lineMetrics, polygon outlines drawn through geometryTypes have no progress and take the gradient’s color at progress 0, as in MapLibre; on any other source they draw with color like its lines. The gradient of PolylineMeshDesc measures the progress in meters instead.
As in MapLibre, the gradient is drawn from a ramp of 256 colors over the part of the line a tile holds. Stops close together take up to 4096 colors, so that they keep their places on a long line. The stops must be in ascending progress, with progress and opacity between 0 and 1; addLayer() and update() throw otherwise. [] removes the gradient.
Default: undefined
Example:
import { Color } from "@navaramap/three";
view.addLayer({ type: "vector", source: view.addSource({ type: "geojson", url: "https://example.com/route.geojson", // The gradient reads where each point lies along its line. lineMetrics: true, }), polyline: { width: 6, // Blue at the start of each line, red at its end gradient: [ { progress: 0, color: new Color().setStyle("#2979ff") }, { progress: 1, color: new Color().setStyle("#d50000") } ] }});height
Section titled “height”Type: number | undefined
Description: Specifies the height of the polyline. The unit is meters.
Default: undefined
Example:
{ polyline: { height: 1 }}Type: boolean | undefined
Description: Applies the lighting equation to the color output. When false, the polyline renders as plain albedo. The rest of the lit pipeline still runs, so normals and the shadow G-buffer keep being written. Leaving it unset follows the scene default, view.lit. Setting it explicitly overrides that default in either direction.
Default: undefined (follows view.lit)
Example:
{ polyline: { lit: false // Plain albedo output, e.g. for a deferred lighting pass }}maxWidth
Section titled “maxWidth”Type: number | undefined
Description: Maximum line width in pixels, clamping the rendered width regardless of zoom level. Smaller values are cheaper to render as they reduce fragment shader overdraw.
Default: undefined
Example:
{ polyline: { maxWidth: 10 }}receiveShadow
Section titled “receiveShadow”Type: boolean | undefined
Description: Specifies whether the polyline receives shadows.
Default: undefined
Example:
{ polyline: { receiveShadow: true }}Type: boolean | undefined
Description: Specifies whether to show the polyline.
Default: undefined
Example:
{ polyline: { show: true }}transparent
Section titled “transparent”Type: boolean | undefined
Description: Enables transparency and alpha blending. This allows the polyline to be rendered with opacity.
Default: false
Example:
{ polyline: { transparent: true }}Type: boolean | undefined
Description: Splits the polyline into XYZ vector tiles for rendering, even when the data source is not an MVT layer. This can improve performance for large polylines. Enabling clampToGround implicitly forces tiled to true.
Default: false
Example:
{ polyline: { tiled: true }}Type: number
Description: Specifies the width of the polyline. The unit is pixels.
A line clamped with clampToGround is drawn on the ground at its width, and its blur, in pixels at the zoom level at the center of the view, as MapLibre’s line-width. In a tilted view its farther parts are therefore drawn thinner. The width follows the zoom level in steps of half a level, so a clamped line is drawn up to about 23% wider or narrower than its width until the zoom level reaches the next step. Where a clamped line is narrower than one texel of the texture the terrain is drawn with, it is drawn one texel wide and faded in proportion to its width.
Default: Required
Example:
{ polyline: { width: 3 }}