I want to create a CurvePath for example
var spline = new THREE.SplineCurve3([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(1, 0, 0),
new THREE.Vect
EDIT: THREE.Curve.create()
has been deprecated. See this answer for the new pattern to follow.
To create your own curve class, a sub-class of THREE.Curve
, here is the pattern to follow:
MyCurve = THREE.Curve.create(
// define the constructor (args optional)
function( points, s ) {
this.points = points;
this.myProperty = s; // add a property if you want
},
// define the getPoint() function
function( t ) {
return new THREE.Vector3( x, y, z ); // flesh this out
}
);
In your case, you can duplicate SplineCurve3
-- you just need to change the getPoint()
function. To do so, you can replace this:
v.x = THREE.Curve.Utils.interpolate(pt0.x, pt1.x, pt2.x, pt3.x, weight);
v.y = THREE.Curve.Utils.interpolate(pt0.y, pt1.y, pt2.y, pt3.y, weight);
v.z = THREE.Curve.Utils.interpolate(pt0.z, pt1.z, pt2.z, pt3.z, weight);
with simple linear interpolation:
v.copy( pt1 ).lerp( pt2, weight );
three.js r.60