Skip to content

Commit cda20c2

Browse files
committed
GridHelper: Fix clone()
1 parent 7946bd5 commit cda20c2

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/helpers/GridHelper.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import { Color } from '../math/Color.js';
1111

1212
function GridHelper( size, divisions, color1, color2 ) {
1313

14+
this.parameters = {
15+
size: size,
16+
divisions: divisions,
17+
color1: color1,
18+
color2: color2
19+
};
20+
1421
size = size || 10;
1522
divisions = divisions || 10;
1623
color1 = new Color( color1 !== undefined ? color1 : 0x444444 );
@@ -46,7 +53,28 @@ function GridHelper( size, divisions, color1, color2 ) {
4653

4754
}
4855

49-
GridHelper.prototype = Object.create( LineSegments.prototype );
50-
GridHelper.prototype.constructor = GridHelper;
56+
GridHelper.prototype = Object.assign( Object.create( LineSegments.prototype ), {
57+
58+
constructor: GridHelper,
59+
60+
copy( source ) {
61+
62+
LineSegments.prototype.copy.call( this, source );
63+
64+
Object.assign( this.parameters, source.parameters );
65+
66+
return this;
67+
68+
},
69+
70+
clone() {
71+
72+
var paramters = this.parameters;
73+
74+
return new this.constructor( paramters.size, paramters.divisions, paramters.color1, paramters.color2 );
75+
76+
}
77+
78+
} );
5179

5280
export { GridHelper };

0 commit comments

Comments
 (0)