Bläddra i källkod

Interpolant: Remove beforeStart_() and afterEnd_() alias definitions. (#24076)

Michael Herzog 3 år sedan
förälder
incheckning
8b315e1078
3 ändrade filer med 4 tillägg och 253 borttagningar
  1. 0 4
      examples/jsm/loaders/GLTFLoader.js
  2. 4 9
      src/math/Interpolant.js
  3. 0 240
      test/unit/src/math/Interpolant.tests.js

+ 0 - 4
examples/jsm/loaders/GLTFLoader.js

@@ -1862,10 +1862,6 @@ class GLTFCubicSplineInterpolant extends Interpolant {
 
 }
 
-GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
-
-GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
-
 GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) {
 
 	const result = this.resultBuffer;

+ 4 - 9
src/math/Interpolant.js

@@ -67,7 +67,7 @@ class Interpolant {
 
 								i1 = pp.length;
 								this._cachedIndex = i1;
-								return this.afterEnd_( i1 - 1, t, t0 );
+								return this.copySampleValue_( i1 - 1 );
 
 							}
 
@@ -115,7 +115,7 @@ class Interpolant {
 								// before start
 
 								this._cachedIndex = 0;
-								return this.beforeStart_( 0, t, t1 );
+								return this.copySampleValue_( 0 );
 
 							}
 
@@ -172,7 +172,7 @@ class Interpolant {
 				if ( t0 === undefined ) {
 
 					this._cachedIndex = 0;
-					return this.beforeStart_( 0, t, t1 );
+					return this.copySampleValue_( 0 );
 
 				}
 
@@ -180,7 +180,7 @@ class Interpolant {
 
 					i1 = pp.length;
 					this._cachedIndex = i1;
-					return this.afterEnd_( i1 - 1, t0, t );
+					return this.copySampleValue_( i1 - 1 );
 
 				}
 
@@ -238,9 +238,4 @@ class Interpolant {
 
 }
 
-// ALIAS DEFINITIONS
-
-Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_;
-Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_;
-
 export { Interpolant };

+ 0 - 240
test/unit/src/math/Interpolant.tests.js

@@ -47,36 +47,6 @@ export default QUnit.module( 'Maths', () => {
 
 		};
 
-		Mock.prototype.beforeStart_ = function beforeStart( i, t, t0 ) {
-
-			if ( Mock.calls !== null ) {
-
-				Mock.calls.push( {
-					func: 'beforeStart',
-					args: [ i, t, t0 ]
-				} );
-
-			}
-
-			return this.copySampleValue_( i );
-
-		};
-
-		Mock.prototype.afterEnd_ = function afterEnd( i, tN, t ) {
-
-			if ( Mock.calls !== null ) {
-
-				Mock.calls.push( {
-					func: 'afterEnd',
-					args: [ i, tN, t ]
-				} );
-
-			}
-
-			return this.copySampleValue_( i );
-
-		};
-
 		// Call capturing facility
 
 		Mock.calls = null;
@@ -323,216 +293,6 @@ export default QUnit.module( 'Maths', () => {
 
 		} );
 
-		QUnit.test( 'evaulate -> beforeStart_ [once]', ( assert ) => {
-
-			var actual, expect;
-
-			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );
-
-			Mock.calls = [];
-			interpolant.evaluate( 10 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'beforeStart',
-				args: [ 0, 10, 11 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			// Check operation resumes normally and intervalChanged gets called
-			Mock.calls = [];
-			interpolant.evaluate( 11 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'intervalChanged',
-				args: [ 1, 11, 22 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			actual = Mock.calls[ 1 ];
-			expect = {
-				func: 'interpolate',
-				args: [ 1, 11, 11, 22 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 2, 'no further calls' );
-
-			// Back off-bounds
-			Mock.calls = [];
-			interpolant.evaluate( 10 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'beforeStart',
-				args: [ 0, 10, 11 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-		} );
-
-		QUnit.test( 'evaluate -> beforeStart_ [twice]', ( assert ) => {
-
-			var actual, expect;
-
-			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );
-
-			Mock.calls = [];
-			interpolant.evaluate( 10 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'beforeStart',
-				args: [ 0, 10, 11 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			Mock.calls = []; // again - consider changed state
-			interpolant.evaluate( 10 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'beforeStart',
-				args: [ 0, 10, 11 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			// Check operation resumes normally and intervalChanged gets called
-			Mock.calls = [];
-			interpolant.evaluate( 11 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'intervalChanged',
-				args: [ 1, 11, 22 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			actual = Mock.calls[ 1 ];
-			expect = {
-				func: 'interpolate',
-				args: [ 1, 11, 11, 22 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 2, 'no further calls' );
-
-		} );
-
-		QUnit.test( 'evaluate -> afterEnd_ [once]', ( assert ) => {
-
-			var actual, expect;
-
-			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );
-
-			Mock.calls = [];
-			interpolant.evaluate( 33 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'afterEnd',
-				args: [ 2, 33, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			// Check operation resumes normally and intervalChanged gets called
-			Mock.calls = [];
-			interpolant.evaluate( 32 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'intervalChanged',
-				args: [ 2, 22, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			actual = Mock.calls[ 1 ];
-			expect = {
-				func: 'interpolate',
-				args: [ 2, 22, 32, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 2, 'no further calls' );
-
-			// Back off-bounds
-			Mock.calls = [];
-			interpolant.evaluate( 33 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'afterEnd',
-				args: [ 2, 33, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-		} );
-
-		QUnit.test( 'evaluate -> afterEnd_ [twice]', ( assert ) => {
-
-			var actual, expect;
-
-			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );
-
-			Mock.calls = [];
-			interpolant.evaluate( 33 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'afterEnd',
-				args: [ 2, 33, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			Mock.calls = []; // again - consider changed state
-			interpolant.evaluate( 33 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'afterEnd',
-				args: [ 2, 33, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 1, 'no further calls' );
-
-			// Check operation resumes normally and intervalChanged gets called
-			Mock.calls = [];
-			interpolant.evaluate( 32 );
-
-			actual = Mock.calls[ 0 ];
-			expect = {
-				func: 'intervalChanged',
-				args: [ 2, 22, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			actual = Mock.calls[ 1 ];
-			expect = {
-				func: 'interpolate',
-				args: [ 2, 22, 32, 33 ]
-			};
-			assert.deepEqual( actual, expect, JSON.stringify( expect ) );
-
-			assert.ok( Mock.calls.length === 2, 'no further calls' );
-
-		} );
-
 	} );
 
 } );