1 | /**
|
---|
2 | * @author mrdoob / http://mrdoob.com/
|
---|
3 | */
|
---|
4 |
|
---|
5 | THREE.GridHelper = function ( size, step ) {
|
---|
6 |
|
---|
7 | var geometry = new THREE.Geometry();
|
---|
8 | var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
|
---|
9 |
|
---|
10 | this.color1 = new THREE.Color( 0x444444 );
|
---|
11 | this.color2 = new THREE.Color( 0x888888 );
|
---|
12 |
|
---|
13 | for ( var i = - size; i <= size; i += step ) {
|
---|
14 |
|
---|
15 | geometry.vertices.push(
|
---|
16 | new THREE.Vector3( - size, 0, i ), new THREE.Vector3( size, 0, i ),
|
---|
17 | new THREE.Vector3( i, 0, - size ), new THREE.Vector3( i, 0, size )
|
---|
18 | );
|
---|
19 |
|
---|
20 | var color = i === 0 ? this.color1 : this.color2;
|
---|
21 |
|
---|
22 | geometry.colors.push( color, color, color, color );
|
---|
23 |
|
---|
24 | }
|
---|
25 |
|
---|
26 | THREE.Line.call( this, geometry, material, THREE.LinePieces );
|
---|
27 |
|
---|
28 | };
|
---|
29 |
|
---|
30 | THREE.GridHelper.prototype = Object.create( THREE.Line.prototype );
|
---|
31 |
|
---|
32 | THREE.GridHelper.prototype.setColors = function( colorCenterLine, colorGrid ) {
|
---|
33 |
|
---|
34 | this.color1.set( colorCenterLine );
|
---|
35 | this.color2.set( colorGrid );
|
---|
36 |
|
---|
37 | this.geometry.colorsNeedUpdate = true;
|
---|
38 |
|
---|
39 | }
|
---|