@@ -41,7 +41,19 @@ function Viewport( editor ) {
41
41
42
42
// helpers
43
43
44
- var grid = new THREE . GridHelper ( 30 , 30 , 0x444444 , 0x888888 ) ;
44
+ var grid = new THREE . Group ( ) ;
45
+
46
+ var grid1 = new THREE . GridHelper ( 30 , 30 , 0x888888 ) ;
47
+ grid1 . material . color . setHex ( 0x888888 ) ;
48
+ grid1 . material . vertexColors = false ;
49
+ grid . add ( grid1 ) ;
50
+
51
+ var grid2 = new THREE . GridHelper ( 30 , 6 , 0x222222 ) ;
52
+ grid2 . material . color . setHex ( 0x222222 ) ;
53
+ grid2 . material . depthFunc = THREE . AlwaysDepth ;
54
+ grid2 . material . vertexColors = false ;
55
+ grid . add ( grid2 ) ;
56
+
45
57
var viewHelper = new ViewHelper ( camera , container ) ;
46
58
var vr = new VR ( editor ) ;
47
59
@@ -357,14 +369,14 @@ function Viewport( editor ) {
357
369
mediaQuery . addListener ( function ( event ) {
358
370
359
371
renderer . setClearColor ( event . matches ? 0x333333 : 0xaaaaaa ) ;
360
- updateGridColors ( grid , event . matches ? [ 0x888888 , 0x222222 ] : [ 0x282828 , 0x888888 ] ) ;
372
+ updateGridColors ( grid1 , grid2 , event . matches ? [ 0x222222 , 0x888888 ] : [ 0x888888 , 0x282828 ] ) ;
361
373
362
374
render ( ) ;
363
375
364
376
} ) ;
365
377
366
378
renderer . setClearColor ( mediaQuery . matches ? 0x333333 : 0xaaaaaa ) ;
367
- updateGridColors ( grid , mediaQuery . matches ? [ 0x888888 , 0x222222 ] : [ 0x282828 , 0x888888 ] ) ;
379
+ updateGridColors ( grid1 , grid2 , mediaQuery . matches ? [ 0x222222 , 0x888888 ] : [ 0x888888 , 0x282828 ] ) ;
368
380
369
381
}
370
382
@@ -765,27 +777,10 @@ function Viewport( editor ) {
765
777
766
778
}
767
779
768
- function updateGridColors ( grid , colors ) {
769
-
770
- const color1 = new THREE . Color ( colors [ 0 ] ) ;
771
- const color2 = new THREE . Color ( colors [ 1 ] ) ;
772
-
773
- const attribute = grid . geometry . attributes . color ;
774
- const array = attribute . array ;
775
-
776
- for ( var i = 0 ; i < array . length ; i += 12 ) {
777
-
778
- const color = ( i % ( 12 * 5 ) === 0 ) ? color1 : color2 ;
779
-
780
- for ( var j = 0 ; j < 12 ; j += 3 ) {
781
-
782
- color . toArray ( array , i + j ) ;
783
-
784
- }
785
-
786
- }
780
+ function updateGridColors ( grid1 , grid2 , colors ) {
787
781
788
- attribute . needsUpdate = true ;
782
+ grid1 . material . color . setHex ( colors [ 0 ] ) ;
783
+ grid2 . material . color . setHex ( colors [ 1 ] ) ;
789
784
790
785
}
791
786
0 commit comments