As you can see in the code, the round corner is created with a QuadraticBezierCurve. Users can easily adjust the shape of the corner via the respective control point (first two parameters of Path.quadraticCurveTo().
You can only use the Path API for creating 2D structures which are normally used to create 2D Shapes (see ShapeGeometry).
But there are 3D variants of curves like LineCurve3 or QuadraticBezierCurve3 you could use for creating 3D curves. So create an instance of CurvePath, add your curve objects and then sample points via getPoints( subdivisions ).
I’ve compared two approaches.
The same array of points. The red line is based on my old approach. The yellow line (you can see its parts) is based on the approach with THREE.QuadraticBezierCurve3(). As you can see, the sharper an angle, the greater the difference. Using curves, I can’t control the radius. And based on this thread, I can’t do it at all.
But possibly I’m missing something. I’ll appreciate any help
The second argument of QuadraticBezierCurve3 is the control point that influences the form of the curve. If you displace this point in certain directions, you get different shapes.
Unfortunately, i can’t tell you ad hoc how to change your code so you can adjust the menioned displacement based on a parameter. I guess you have to try this out
Obviously
Thanks anyway
I’ve already thought about it, while going to lunch )) But it would be great, if we were able to put weight for the second point, thus we could get points from that curve like it’s a rational one.
@prisoner849 once upon a time I built a curve visualization tool for GSAP.
If you change the curve type to Cubic or Quadratic and play with the floating control points it may help you to visualize how they work.
Interesting tool
It was enough to read about THREE.QuadraticBezierCurve3() and some articles on the internet to realize what the second point does and how it works in general.
My goal is to build a line with rounded angles of controllable radius and smoothness, using abilities of our fellow framework
The approach with quadratic bezier curves promised to be simplier than mine, but inability to set and use weights for control points of curves ruins that good start
@prisoner849 Out of curiosity: How would an implementation from your point of view look like that supports weights for control points? I guess we have to change the actual curve class and the respective interpolation function…
Yes, I’ve already looked at the source code of both curve and interpolation before I’ve made my previous post, with a small hope that I can override some methods in prototypes Found it complicated, but I can’t say that it’s impossible I’ll post it here, when I come up with something.
Totally agree. It should be an optional parameter with the default value of 1.
I’m that lazy ass, who doesn’t want to work much
Somehow I remembered, that once upon a time I went through the source code of examples and somewhere there I met a mention about weight for points. Quick search gave me what I was looking for. NURBS
So, I’ve just adapted that piece of code.