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

customize line thickness #21

Open
pkra opened this issue Jan 27, 2020 · 4 comments
Open

customize line thickness #21

pkra opened this issue Jan 27, 2020 · 4 comments

Comments

@pkra
Copy link

pkra commented Jan 27, 2020

It would be great to allow users to customize line-thickness (alongside colors) to improve contrast and to enable more variation.

@pkra
Copy link
Author

pkra commented Jan 27, 2020

Also: this is a wonderful tool -- thank you!

@anvaka
Copy link
Owner

anvaka commented Jan 30, 2020

Thank you! I'd totally love to do this, but I don't know how to do it efficiently.

Right now it is not uncommon to have a road graph with 100,000+ segments, each encoded as a pair of coordinates (x, y).

To render segments I'm using gl.LINES draw type, which is very fast, and needs just two points per segment.

The only way that I know how to add thickness to the line is via triangulation. We turn each line segment into a rectangle, and then split it into two triangles. This method would require much more memory and a little bit more pre-processing.

Even if we don't consider memory consumption a problem, there is another thing that I haven't solved yet. My current implementation of thick lines doesn't have smooth transition between connected segments, which gives very jagged experience on high zoom levels:

image

I'm learning webgl myself, and if there are some good tricks that could help us get thick lines in the most efficient manner - please share!

@pkra
Copy link
Author

pkra commented Jan 30, 2020

Thanks for taking the time to respond, @anvaka ! I don't know much about webgl, I'm afraid. But I did notice that the SVG export is relatively easy to customize afterwards (by increasing the stroke-width of the <g> wrapping around the paths).

@anvaka
Copy link
Owner

anvaka commented Feb 29, 2020

Found a solution that doesn't consume as much CPU power as my original version. You can try it now, by loading a city, and then in the browser's developer tools, enter this command:

scene.queryLayer().lineWidth = 2; // Sets new width to lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants