Generate a flat path that follows the terrain with a spline

I think I succeeded. Is it good like that?

lbi[p] = BABYLON.MeshBuilder.CreateLines('lbi', {
    points: [
             cpath[p], 
             cpath[p].add(levelbis[p].scale(2)), 
             cpath[p].add(levelbis[p].scale(2).negate())
    ], 
    updatable: true
}, scene);

Multiply the level binormal by -1 and add it to the control point. Now you have two points on either side of the control point

Craig

2 Likes

I think I didn’t understand what I should multiply by -1 (normal bi levels, are a vector3 array, what should I multiply?.
And I didn’t understand what you call the checkpoint.

I feel stupid sometimes. Your sentence seems simple, but once you look at the code, it’s not as simple as doing a 2x2=4 multiplication;

I understood that this was not good. The ribbon created is not complete.

cpath[p].add(levelbis[p].scale(2)), 
cpath[p].add(levelbis[p].scale(2).negate())

I used your PG to add what I have managed to do so far with the multiplier

cpath[p].add(levelbis[p].scale(2)),
cpath[p].add(levelbis[p].multiply(new BABYLON.Vector3(-1, 0, -1)).scale(2)),

My apologies for the inconvenience.

Wow, that was what I was searching for. After finding a solution for the centering issue, can you modify the previous pg?

I don’t yet have a solution to create the ribbon on each side of the central line.

I was thinking of making a second ribbon (one on each side of the line) Then merging the two ribbons to make one. But maybe there is an easier way.

@mathus1

I did this which works. I did as I said by creating two ribbons (one on each side of the line) Then merging them to make one.
The main line is found in the middle.

I don’t know if this is the right way to do it, but it works.

1 Like

First, please carefully read or re-read the Babylon js docs and examples on creating ribbons. You need to build an array of shapes (i.e. point arrays), which the CreateRibbon function will triangulate for you. In this case, each shape is three points:

[ cpath[p].add(levelbis[p].scale(4)), cpath[p], cpath[p].add(levelbis[p].scale(4).negate())]

along the control points generated by the Path3D , i.e. cpath.

1 Like

Cool! You can do this with just a single CreateRibbon call if you use the shapes as I outlined in the last reply, here

Thanks @lowclouds. I understood my mistake. I wasn’t far from the result. Now everything is perfect. I have other challenges awaiting me now, kike texturing this path at the same time as it is generated.

1 Like