QuaternionLinearInterpolant.js 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Spherical linear unit quaternion interpolant.
  3. *
  4. * @author tschw
  5. */
  6. THREE.QuaternionLinearInterpolant = function(
  7. parameterPositions, sampleValues, sampleSize, resultBuffer ) {
  8. THREE.Interpolant.call(
  9. this, parameterPositions, sampleValues, sampleSize, resultBuffer );
  10. };
  11. THREE.QuaternionLinearInterpolant.prototype =
  12. Object.assign( Object.create( THREE.Interpolant.prototype ), {
  13. constructor: THREE.QuaternionLinearInterpolant,
  14. interpolate_: function( i1, t0, t, t1 ) {
  15. var result = this.resultBuffer,
  16. values = this.sampleValues,
  17. stride = this.valueSize,
  18. offset = i1 * stride,
  19. alpha = ( t - t0 ) / ( t1 - t0 );
  20. for ( var end = offset + stride; offset !== end; offset += 4 ) {
  21. THREE.Quaternion.slerpFlat( result, 0,
  22. values, offset - stride, values, offset, alpha );
  23. }
  24. return result;
  25. }
  26. } );