@@ -41,7 +41,19 @@ function Viewport( editor ) {
4141
4242 // helpers
4343
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+
4557 var viewHelper = new ViewHelper ( camera , container ) ;
4658 var vr = new VR ( editor ) ;
4759
@@ -357,14 +369,14 @@ function Viewport( editor ) {
357369 mediaQuery . addListener ( function ( event ) {
358370
359371 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 ] ) ;
361373
362374 render ( ) ;
363375
364376 } ) ;
365377
366378 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 ] ) ;
368380
369381 }
370382
@@ -765,27 +777,10 @@ function Viewport( editor ) {
765777
766778}
767779
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 ) {
787781
788- attribute . needsUpdate = true ;
782+ grid1 . material . color . setHex ( colors [ 0 ] ) ;
783+ grid2 . material . color . setHex ( colors [ 1 ] ) ;
789784
790785}
791786
0 commit comments