Hello. I need to learn how to connect two elements with a Bezier line on a 2D plane.
I tried to do it this way:
const curve = new CubicBezierCurve(
// Vector2 of the first element
// Here I have problems
// Here I have problems
// Vector2 of the second element
);
const geometry = new BufferGeometry().setFromPoints(curve.getPoints(50));
const material = new LineBasicMaterial({ color: 0xff0000 });
const line = new Line(geometry, material);
scene.add(line);
Also I have some code that updates the positions when moving my elements.
My problem is to calculate an acceptable formula for Bezier. I need something like here:
ThreeJS playground
Or like:
NodeToy
Also, no matter what parameters I passed with the second and third arguments when creating CubicBezierCurve, when moving my elements, the middle of the line somehow sticks to the center of the scene:
I’ll be glad if someone tells me how I can achieve the solution of my task. How do I get a similar formula on ThreeJS playground or NodeToy? Thank you!