content/hifi-content/dave/walk-tools/walkTools/libraries/three.js/extras/curves/LineCurve.js
2022-02-13 22:49:05 +01:00

38 lines
792 B
JavaScript

/**************************************************************
* Line
**************************************************************/
THREE.LineCurve = function ( v1, v2 ) {
this.v1 = v1;
this.v2 = v2;
};
THREE.LineCurve.prototype = Object.create( THREE.Curve.prototype );
THREE.LineCurve.prototype.constructor = THREE.LineCurve;
THREE.LineCurve.prototype.getPoint = function ( t ) {
var point = this.v2.clone().sub(this.v1);
point.multiplyScalar( t ).add( this.v1 );
return point;
};
// Line curve is linear, so we can overwrite default getPointAt
THREE.LineCurve.prototype.getPointAt = function ( u ) {
return this.getPoint( u );
};
THREE.LineCurve.prototype.getTangent = function( t ) {
var tangent = this.v2.clone().sub(this.v1);
return tangent.normalize();
};