Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 4 additions & 9 deletions src/math/Interpolant.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Interpolant {

i1 = pp.length;
this._cachedIndex = i1;
return this.afterEnd_( i1 - 1, t, t0 );
return this.copySampleValue_( i1 - 1 );

}

Expand Down Expand Up @@ -115,7 +115,7 @@ class Interpolant {
// before start

this._cachedIndex = 0;
return this.beforeStart_( 0, t, t1 );
return this.copySampleValue_( 0 );

}

Expand Down Expand Up @@ -172,15 +172,15 @@ class Interpolant {
if ( t0 === undefined ) {

this._cachedIndex = 0;
return this.beforeStart_( 0, t, t1 );
return this.copySampleValue_( 0 );

}

if ( t1 === undefined ) {

i1 = pp.length;
this._cachedIndex = i1;
return this.afterEnd_( i1 - 1, t0, t );
return this.copySampleValue_( i1 - 1 );

}

Expand Down Expand Up @@ -238,9 +238,4 @@ class Interpolant {

}

// ALIAS DEFINITIONS

Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_;
Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_;

export { Interpolant };
240 changes: 0 additions & 240 deletions test/unit/src/math/Interpolant.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' );

} );

} );

} );