My goal is to create parallel curved lines that run alongside each other. However, when I try to adjust their positions in one axis, the outcome is not what I expected.
The code I am using is fairly simple - it involves a bezier curve as the central path and clones with different materials for the sides.
var bezier = new THREE.CubicBezierCurve3(
new THREE.Vector3(initx, inity, 0),
new THREE.Vector3(cp1x, cp1y, 0),
new THREE.Vector3( cp2x, cp2y, 0),
new THREE.Vector3(finalx, finaly, 0)
);
var curvePath = new THREE.CurvePath();
curvePath.add(bezier);
var path = curvePath.createPointsGeometry(5);
path.computeLineDistances();
var lineMat = new THREE.LineDashedMaterial({ color: 0xFFFFFF,
dashSize: 3,
gapSize: 2,
linewidth: 10});
var curveLine = new THREE.Line(path, lineMat);
curveLine.rotation.set(-Math.PI/2, 0, 0);
curveLine.position.y = 0.1;
var leftLine = curveLine.clone();
leftLine.material = matLine;
var rightLine = curveLine.clone();
rightLine.material = matLine;
leftLine.translateX(-3.5);
rightLine.position.set(3.5, 0, 0);
scene.add(curveLine);
scene.add(leftLine);
curveLine.add(rightLine);
Here is the current result: https://i.sstatic.net/r7Fi3.png
Now, examples of the desired outcome:
https://i.sstatic.net/YQq55.pnghttps://i.sstatic.net/VDv2M.pnghttps://i.sstatic.net/Otvqb.png
The last two images are from the Bezier.js library.
I believe that applying an offset to the curved line or drawing another line using the normals of the first one could solve the issue. However, I have been unable to find any relevant information on how to do this in the documentation. Drawing a line at a distance along the tangent axis might be a potential solution, but I am open to easier suggestions. Any ideas?
I looked into this resource, but it pertains to straight lines.