|
@@ -2,14 +2,14 @@
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mrdoob / http://mrdoob.com/
|
|
*/
|
|
*/
|
|
|
|
|
|
-THREE.GridHelper = function ( size, step, color1, color2) {
|
|
|
|
-
|
|
|
|
- color1 = new THREE.Color( color1 === undefined ? 0x444444: color1 );
|
|
|
|
- color2 = new THREE.Color( color2 === undefined ? 0x888888: color2 );
|
|
|
|
|
|
+THREE.GridHelper = function ( size, step ) {
|
|
|
|
|
|
var geometry = new THREE.Geometry();
|
|
var geometry = new THREE.Geometry();
|
|
var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
|
|
var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
|
|
|
|
|
|
|
|
+ this.color1 = new THREE.Color( 0x444444 );
|
|
|
|
+ this.color2 = new THREE.Color( 0x888888 );
|
|
|
|
+
|
|
for ( var i = - size; i <= size; i += step ) {
|
|
for ( var i = - size; i <= size; i += step ) {
|
|
|
|
|
|
geometry.vertices.push(
|
|
geometry.vertices.push(
|
|
@@ -17,7 +17,7 @@ THREE.GridHelper = function ( size, step, color1, color2) {
|
|
new THREE.Vector3( i, 0, - size ), new THREE.Vector3( i, 0, size )
|
|
new THREE.Vector3( i, 0, - size ), new THREE.Vector3( i, 0, size )
|
|
);
|
|
);
|
|
|
|
|
|
- var color = i === 0 ? color1 : color2;
|
|
|
|
|
|
+ var color = i === 0 ? this.color1 : this.color2;
|
|
|
|
|
|
geometry.colors.push( color, color, color, color );
|
|
geometry.colors.push( color, color, color, color );
|
|
|
|
|
|
@@ -28,3 +28,12 @@ THREE.GridHelper = function ( size, step, color1, color2) {
|
|
};
|
|
};
|
|
|
|
|
|
THREE.GridHelper.prototype = Object.create( THREE.Line.prototype );
|
|
THREE.GridHelper.prototype = Object.create( THREE.Line.prototype );
|
|
|
|
+
|
|
|
|
+THREE.GridHelper.prototype.setColors = function( colorCenterLine, colorGrid ) {
|
|
|
|
+
|
|
|
|
+ this.color1.set( colorCenterLine );
|
|
|
|
+ this.color2.set( colorGrid );
|
|
|
|
+
|
|
|
|
+ this.geometry.colorsNeedUpdate = true;
|
|
|
|
+
|
|
|
|
+}
|