Good morning everyone … first apologize for my English … I am Spanish and I do not control the language very much.
I have been trying for months to get something that is surely simple but I do not dominate much ThreeJS and I am being impossible to get it.
I want to make it go by drawing my route that I do with my car on the map, that is in the form of a trail but I do not succeed … I am trying to make a GPS for tractors … and the function of drawing the route does not achievement…
To see if someone can help me … I leave a link where I have a test of the graphic part that does not work …
You can do this in a couple of ways you could use a canvas as texture and paint the path in that canvas (this would be really efficient but you would have to manage tiles for big surfaces), another simplier way is to generate geometry along the path (a simple zig-zag pattern should work just fine).
To create the geometry you can start by calculation a direction vector for each of your path points (the direction vector should point in the direction of the next vector).
After that you can go point by point two vertices equidistant (distance should be the tickness of the road) in the rect that makes 90 degress with your direction vector for your current point and for the next one, after that create two faces containing the vertices organized to compose two triangles and add them to your geometry object.
You want you can also add UV’s easly (look at the square implementation in threejs, uv can be done the same way.
In the technique i explained above you can also calculade intermediate points (average of two consecutive points) with the average direction vector to “”"“tesselate”""" the mesh further!