@@ -2,40 +2,27 @@ import { LineSegments } from '../objects/LineSegments.js';
2
2
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js' ;
3
3
import { Float32BufferAttribute } from '../core/BufferAttribute.js' ;
4
4
import { BufferGeometry } from '../core/BufferGeometry.js' ;
5
- import { Color } from '../math/Color.js' ;
6
5
7
6
class GridHelper extends LineSegments {
8
7
9
- constructor ( size = 10 , divisions = 10 , color1 = 0x444444 , color2 = 0x888888 ) {
8
+ constructor ( size = 10 , divisions = 10 , color = 0x444444 ) {
10
9
11
- color1 = new Color ( color1 ) ;
12
- color2 = new Color ( color2 ) ;
13
-
14
- const center = divisions / 2 ;
15
10
const step = size / divisions ;
16
11
const halfSize = size / 2 ;
17
12
18
- const vertices = [ ] , colors = [ ] ;
13
+ const vertices = [ ] ;
19
14
20
- for ( let i = 0 , j = 0 , k = - halfSize ; i <= divisions ; i ++ , k += step ) {
15
+ for ( let i = 0 , k = - halfSize ; i <= divisions ; i ++ , k += step ) {
21
16
22
17
vertices . push ( - halfSize , 0 , k , halfSize , 0 , k ) ;
23
18
vertices . push ( k , 0 , - halfSize , k , 0 , halfSize ) ;
24
19
25
- const color = i === center ? color1 : color2 ;
26
-
27
- color . toArray ( colors , j ) ; j += 3 ;
28
- color . toArray ( colors , j ) ; j += 3 ;
29
- color . toArray ( colors , j ) ; j += 3 ;
30
- color . toArray ( colors , j ) ; j += 3 ;
31
-
32
20
}
33
21
34
22
const geometry = new BufferGeometry ( ) ;
35
23
geometry . setAttribute ( 'position' , new Float32BufferAttribute ( vertices , 3 ) ) ;
36
- geometry . setAttribute ( 'color' , new Float32BufferAttribute ( colors , 3 ) ) ;
37
24
38
- const material = new LineBasicMaterial ( { vertexColors : true , toneMapped : false } ) ;
25
+ const material = new LineBasicMaterial ( { color : color , toneMapped : false } ) ;
39
26
40
27
super ( geometry , material ) ;
41
28
0 commit comments