# How to create a road from vector points?

Hello,

I’m able to create a very basic straight “road” using PlaneGeometry or BoxGeometry, but have no idea how to add turns, hills, etc.

Let’s assume I have a bunch of vectors:

[0, 0, 0], // start
[0, 0, -10], // straight ahead
[10, 0, -10], // right turn
[10, 0, -20], // left turn
[10, 0, -30], // straight ahead
[10, 10, -40], // uphill
[10, 10, -50], // top of hill
[10, 0, -60] // downhill

What’s a good way to create a road based on those points?

The closest thing I could find is to use the TubeGeometry (which handles 3d curves) but maybe there’s a better way?

Thanks

Look at the examples from the collection:

1 Like

I did check out that example, but honestly it left more questions than answers.

It looks like it’s passing the raw coords into CatmullRomCurve3, then grabbing the modified points. That part makes sense.

Then it’s using BufferGeometry, BufferAttribute, 5 road materials, 4 loops, and a whole bunch of vaguely-named variables to generate the mesh. That part is what doesn’t make sense to me (i.e. because I’m a newbie).

It’ll take a while, but I’ll try to make sense of all this. I really wish that creating a basic (1 solid color) road didn’t require creating a custom geometry though.

Thanks

In its simplest form, one can extrude a path. ExtrudePath

Similar to cylinder and box, a plane can also be deformed.
2021 discourse.threejs.hofk.de

2 Likes

@hofk Thanks, I’ll try it out. Also, do you freelance?

See the PM.