|
@@ -19,21 +19,24 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-function Interpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
|
|
|
+class Interpolant {
|
|
|
|
|
|
- this.parameterPositions = parameterPositions;
|
|
|
- this._cachedIndex = 0;
|
|
|
+ constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
|
|
|
|
|
|
- this.resultBuffer = resultBuffer !== undefined ?
|
|
|
- resultBuffer : new sampleValues.constructor( sampleSize );
|
|
|
- this.sampleValues = sampleValues;
|
|
|
- this.valueSize = sampleSize;
|
|
|
+ this.parameterPositions = parameterPositions;
|
|
|
+ this._cachedIndex = 0;
|
|
|
|
|
|
-}
|
|
|
+ this.resultBuffer = resultBuffer !== undefined ?
|
|
|
+ resultBuffer : new sampleValues.constructor( sampleSize );
|
|
|
+ this.sampleValues = sampleValues;
|
|
|
+ this.valueSize = sampleSize;
|
|
|
+
|
|
|
+ this.settings = null;
|
|
|
+ this.DefaultSettings_ = {};
|
|
|
|
|
|
-Object.assign( Interpolant.prototype, {
|
|
|
+ }
|
|
|
|
|
|
- evaluate: function ( t ) {
|
|
|
+ evaluate( t ) {
|
|
|
|
|
|
const pp = this.parameterPositions;
|
|
|
let i1 = this._cachedIndex,
|
|
@@ -191,22 +194,15 @@ Object.assign( Interpolant.prototype, {
|
|
|
|
|
|
return this.interpolate_( i1, t0, t, t1 );
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- settings: null, // optional, subclass-specific settings structure
|
|
|
- // Note: The indirection allows central control of many interpolants.
|
|
|
-
|
|
|
- // --- Protected interface
|
|
|
-
|
|
|
- DefaultSettings_: {},
|
|
|
+ }
|
|
|
|
|
|
- getSettings_: function () {
|
|
|
+ getSettings_() {
|
|
|
|
|
|
return this.settings || this.DefaultSettings_;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- copySampleValue_: function ( index ) {
|
|
|
+ copySampleValue_( index ) {
|
|
|
|
|
|
// copies a sample value to the result buffer
|
|
|
|
|
@@ -223,35 +219,28 @@ Object.assign( Interpolant.prototype, {
|
|
|
|
|
|
return result;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
// Template methods for derived classes:
|
|
|
|
|
|
- interpolate_: function ( /* i1, t0, t, t1 */ ) {
|
|
|
+ interpolate_( /* i1, t0, t, t1 */ ) {
|
|
|
|
|
|
throw new Error( 'call to abstract method' );
|
|
|
// implementations shall return this.resultBuffer
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- intervalChanged_: function ( /* i1, t0, t1 */ ) {
|
|
|
+ intervalChanged_( /* i1, t0, t1 */ ) {
|
|
|
|
|
|
// empty
|
|
|
|
|
|
}
|
|
|
|
|
|
-} );
|
|
|
-
|
|
|
-// DECLARE ALIAS AFTER assign prototype
|
|
|
-Object.assign( Interpolant.prototype, {
|
|
|
-
|
|
|
- //( 0, t, t0 ), returns this.resultBuffer
|
|
|
- beforeStart_: Interpolant.prototype.copySampleValue_,
|
|
|
-
|
|
|
- //( N-1, tN-1, t ), returns this.resultBuffer
|
|
|
- afterEnd_: Interpolant.prototype.copySampleValue_,
|
|
|
+}
|
|
|
|
|
|
-} );
|
|
|
+// ALIAS DEFINITIONS
|
|
|
|
|
|
+Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_;
|
|
|
+Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_;
|
|
|
|
|
|
export { Interpolant };
|