mapbox / mapbox/mapbox-gl-js

Rendering curved lines

Open
#6,973 5 comments 38 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

Both the GeoJSON and vector tile specifications encode line geometry as discrete points, with straight line segments connecting them. This is a great, lightweight format to store and render geometry, but makes it difficult to render curves, either when

1) we want actual curves, or
2) when we want to draw complex, organic shapes with minimal number of vertices. Curves would allow us to approximate the original line by applying smoothening on the render side.

https://github.com/mapbox/mapbox-gl-js/issues/981 and https://github.com/mapbox/mapbox-gl-js/issues/4180 are related, except they're for camera movements

## Design Alternatives

My current workaround is simply to manipulate the source geometry (via [turf.bezierSpline](http://turfjs.org/docs/#bezierSpline) and the like), adding more vertices to improve perceived smoothness.

## Design

The current workflow is not ideal, because it

1) can greatly bloat the size of the line geometry, and
2) is never actually infinitely smooth (as far as the current screen resolution allows)

[Preliminary](https://webglfundamentals.org/webgl/lessons/webgl-3d-geometry-lathe.html) [reading](https://threejs.org/docs/#api/extras/curves/CubicBezierCurve3) suggests that this is possible on the rendering side, possibly more efficiently than by data manipulation.

### Mock-Up

Some kind of `line-bezier` property, with [dimensionless values](http://cubic-bezier.com/#.17,.67,.83,.67) like in CSS, or [resolution and sharpness](http://turfjs.org/docs/#bezierSpline), or something else.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file, entry point, or test is named. Start by reviewing the related camera-movement issues and the linked WebGL and Three.js curve references, then identify the rendering path and define the proposed curve API and acceptance criteria. Done should be a concrete, testable scope for rendering smooth lines without source-geometry expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.