CubicBezierCurve.js 671 B

1234567891011121314151617181920212223242526272829303132
  1. import { Curve } from '../core/Curve.js';
  2. import { CubicBezier } from '../core/Interpolations.js';
  3. import { Vector2 } from '../../math/Vector2.js';
  4. function CubicBezierCurve( v0, v1, v2, v3 ) {
  5. Curve.call( this );
  6. this.v0 = v0;
  7. this.v1 = v1;
  8. this.v2 = v2;
  9. this.v3 = v3;
  10. }
  11. CubicBezierCurve.prototype = Object.create( Curve.prototype );
  12. CubicBezierCurve.prototype.constructor = CubicBezierCurve;
  13. CubicBezierCurve.prototype.getPoint = function ( t ) {
  14. var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
  15. return new Vector2(
  16. CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
  17. CubicBezier( t, v0.y, v1.y, v2.y, v3.y )
  18. );
  19. };
  20. export { CubicBezierCurve };