Following advice from this solution, I have implemented a linearly interpolated curve in the code below:
THREE.Linear3 = THREE.Curve.create(
function ( points, label /* array of Vector3 */) {
this.points = (points == undefined) ? [] : points;
this.label = label;
},
function ( t ) {
var v = new THREE.Vector3();
var c = [];
var points = this.points, point, intPoint, weight;
point = ( points.length - 1 ) * t;
intPoint = Math.floor( point );
weight = point - intPoint;
c[ 1 ] = intPoint;
c[ 2 ] = intPoint > points.length - 2 ? points.length - 1 : intPoint + 1;
var pt1 = points[ c[1] ],
pt2 = points[ c[2] ];
v.copy( pt1 ).lerp( pt2, weight );
return v;
}
);
When attempting to animate trajectories of varying lengths, I encountered unexpected behavior where the curve cuts through space instead of passing through the specified points as shown in the animated gif below:
I am struggling to understand the getPoint function and its intended output. Any assistance would be greatly appreciated.
JSFiddle
The provided JSFiddle demonstrates the issue, particularly the jerky motion in the right corner as the tube expands.