Skip to content
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
14 changes: 14 additions & 0 deletions examples/jsm/curves/NURBSCurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ class NURBSCurve extends Curve {

}

copy( source ) {

super.copy( source );

this.degree = source.degree;
this.knots = [ ...source.knots ];
this.controlPoints = source.controlPoints.map( p => p.clone() );
this.startKnot = source.startKnot;
this.endKnot = source.endKnot;

return this;

}

toJSON() {

const data = super.toJSON();
Expand Down
17 changes: 17 additions & 0 deletions test/unit/addons/curves/NURBSCurve.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ export default QUnit.module( 'Extras', () => {

} );

QUnit.test( 'clone', ( assert ) => {

const clone = _nurbsCurve.clone();

assert.equal( clone.degree, _nurbsCurve.degree, 'clone.degree ok' );
assert.deepEqual( clone.knots, _nurbsCurve.knots, 'clone.knots ok' );
assert.deepEqual( clone.controlPoints, _nurbsCurve.controlPoints, 'clone.controlPoints ok' );
assert.equal( clone.startKnot, _nurbsCurve.startKnot, 'clone.startKnot ok' );
assert.equal( clone.endKnot, _nurbsCurve.endKnot, 'clone.endKnot ok' );

assert.notStrictEqual( clone.knots, _nurbsCurve.knots, 'clone.knots is not shared' );
assert.notStrictEqual( clone.controlPoints[ 0 ], _nurbsCurve.controlPoints[ 0 ], 'clone.controlPoints are not shared' );

assert.deepEqual( clone.getPoint( 0.5 ), _nurbsCurve.getPoint( 0.5 ), 'clone.getPoint() ok' );

} );

QUnit.test( 'toJSON', ( assert ) => {

const json = _nurbsCurve.toJSON();
Expand Down