LineCurve.js 792 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**************************************************************
  2. * Line
  3. **************************************************************/
  4. THREE.LineCurve = function ( v1, v2 ) {
  5. this.v1 = v1;
  6. this.v2 = v2;
  7. };
  8. THREE.LineCurve.prototype = Object.create( THREE.Curve.prototype );
  9. THREE.LineCurve.prototype.constructor = THREE.LineCurve;
  10. THREE.LineCurve.prototype.getPoint = function ( t ) {
  11. var point = this.v2.clone().sub(this.v1);
  12. point.multiplyScalar( t ).add( this.v1 );
  13. return point;
  14. };
  15. // Line curve is linear, so we can overwrite default getPointAt
  16. THREE.LineCurve.prototype.getPointAt = function ( u ) {
  17. return this.getPoint( u );
  18. };
  19. THREE.LineCurve.prototype.getTangent = function( t ) {
  20. var tangent = this.v2.clone().sub(this.v1);
  21. return tangent.normalize();
  22. };