Browse Source

GridHelper: Fix clone()

Mugen87 6 years ago
parent
commit
cda20c2145
1 changed files with 30 additions and 2 deletions
  1. 30 2
      src/helpers/GridHelper.js

+ 30 - 2
src/helpers/GridHelper.js

@@ -11,6 +11,13 @@ import { Color } from '../math/Color.js';
 
 function GridHelper( size, divisions, color1, color2 ) {
 
+	this.parameters = {
+		size: size,
+		divisions: divisions,
+		color1: color1,
+		color2: color2
+	};
+
 	size = size || 10;
 	divisions = divisions || 10;
 	color1 = new Color( color1 !== undefined ? color1 : 0x444444 );
@@ -46,7 +53,28 @@ function GridHelper( size, divisions, color1, color2 ) {
 
 }
 
-GridHelper.prototype = Object.create( LineSegments.prototype );
-GridHelper.prototype.constructor = GridHelper;
+GridHelper.prototype = Object.assign( Object.create( LineSegments.prototype ), {
+
+	constructor: GridHelper,
+
+	copy( source ) {
+
+		LineSegments.prototype.copy.call( this, source );
+
+		Object.assign( this.parameters, source.parameters );
+
+		return this;
+
+	},
+
+	clone() {
+
+		var paramters = this.parameters;
+
+		return new this.constructor( paramters.size, paramters.divisions, paramters.color1, paramters.color2 );
+
+	}
+
+} );
 
 export { GridHelper };