import { LineSegments } from '../../objects/LineSegments';
import { VertexColors } from '../../constants';
import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
import { Float32BufferAttribute } from '../../core/BufferAttribute';
import { BufferGeometry } from '../../core/BufferGeometry';
import { Color } from '../../math/Color';

/**
 * @author mrdoob / http://mrdoob.com/
 */

function GridHelper( size, divisions, color1, color2 ) {
	var geometry = new THREE.Geometry()
		, vertices = geometry.vertices
		, center, step, color, i
		;
	if ( size instanceof Object ) {
		i = size;
		size = i.size || 10;
		'step' in i && (step = i.step);
		'divisions' in i && (divisions = i.divisions);
		'color' in i && (color2 = i.color);
		color1 = 'center' in i ? i.center : color2;
	} else {
		size = size || 10;
	}
	
	step ? (divisions = size * 2 / step) : (step = size * 2 / (divisions || (divisions = 10)));
	(color1 || (color1 = 0x444444)) instanceof Color || (color1 = new Color(color1));
	(color2 || (color2 = 0x888888)) instanceof Color || (color2 = new Color(color2));
	center = step * (divisions / 2 | 0);
	vertices = [], colors = [];

	for ( i = -size; i <= size; i += step ) {
		if ( i === center ) continue;
		geometry.vertices.push( new THREE.Vector3( -size, 0, i ) );
		geometry.vertices.push( new THREE.Vector3(  size, 0, i ) );

		geometry.vertices.push( new THREE.Vector3( i, 0, -size ) );
		geometry.vertices.push( new THREE.Vector3( i, 0,  size ) );
	}
	LineSegments.call( this, geometry, new LineBasicMaterial( { color: color2 } ) );
	
	geometry = new THREE.Geometry();
	vertices = geometry.vertices;
	geometry.vertices.push( new THREE.Vector3( -size, 0, center ) );
	geometry.vertices.push( new THREE.Vector3(  size, 0, center ) );

	geometry.vertices.push( new THREE.Vector3( center, 0, -size ) );
	geometry.vertices.push( new THREE.Vector3( center, 0,  size ) );
	LineSegments.call( this, geometry, new LineBasicMaterial( { color: color1 } ) );

	geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
	geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );

}

GridHelper.prototype = Object.create( LineSegments.prototype );
GridHelper.prototype.constructor = GridHelper;

export { GridHelper };

@@ -1,20 +1,65 @@
+import %7B Group %7D from '../../objects/Group';%0A
 import %7B LineSegment
@@ -93,24 +93,24 @@
 eSegments';%0A
-
 import %7B Ver
@@ -497,16 +497,46 @@
 ) %7B%0A%09var
+ group = new THREE.Group()%0A%09%09,
  geometr
@@ -593,16 +593,26 @@
 ertices%0A
+%09%09, lines%0A
 %09%09, cent
@@ -1559,16 +1559,18 @@
 ) );%0A%09%7D%0A
+//
 %09LineSeg
@@ -1643,16 +1643,170 @@
  %7D ) );%0A
+%09lines = new THREE.LineSegments( geometry, new LineBasicMaterial( %7B color: color2 %7D ) );%0A%09Group.prototype.add.call( this, lines );%0A//%09group.add( lines );%0A
 %09%0A%09geome
@@ -2129,16 +2129,18 @@
 ze ) );%0A
+//
 %09LineSeg
@@ -2208,24 +2208,155 @@
 olor1 %7D ) );
+%0A%09lines = new THREE.LineSegments( geometry, new LineBasicMaterial( %7B color: color1 %7D ) );%0A%09Group.prototype.add.call( this, lines );
 %0A%0A%09geometry.

Update GridHelper.js