From d5ddcc7254ffb938479a8d4c132b1c5ddd2fa7ee Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Tue, 17 May 2022 11:35:52 +0200 Subject: [PATCH] Interpolant: Remove beforeStart_() and afterEnd_() alias definitions. --- examples/jsm/loaders/GLTFLoader.js | 4 - src/math/Interpolant.js | 13 +- test/unit/src/math/Interpolant.tests.js | 240 ------------------------ 3 files changed, 4 insertions(+), 253 deletions(-) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index c41e1ad51812bf..4498dc52112c39 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/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; diff --git a/src/math/Interpolant.js b/src/math/Interpolant.js index dcc550f51e723b..826b40cfb9db4d 100644 --- a/src/math/Interpolant.js +++ b/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 }; diff --git a/test/unit/src/math/Interpolant.tests.js b/test/unit/src/math/Interpolant.tests.js index 9e2b7576aaf910..9c5cc904462558 100644 --- a/test/unit/src/math/Interpolant.tests.js +++ b/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' ); - - } ); - } ); } );