I finally have some consistent results from my work on splines. I’ve created what can be described as a Spline Framework. With it, I can create a wide variety of polynomial-based splines. This includes
Cubic Bezier Spline
Cubic Hermite Spline
Cubic B-Spline
Cubic Tensioned B-Spline (with tension parameter)
Cubic Beta Spline (with beta1 and beta2 parameters)
Any of these splines can be created in 1, 2, or 3 dimensions (or more) from the same code. Output can be in any form desired with very little temporary memory allocated by using JavaScript generators instead of creating large temporary arrays.
I’m still working on making it easy to use, but it’s coming along well.
Here’s an update to see how fast the calculations are.
Each point moves along it’s own CatmullRom Spline (tension=1) updated each render frame.
And on every frame, all twelve spline meshes are updated using the new points.
Inside the Spline class, I split up the point calculation and the matrix setup. The setup matrices only need to be recalculated when the “t” parameter exceeds 1. When that happens, a new random point is added to the spline’s input points and the first point is shifted off.