Kaynağa Gözat

Add a button to show/hide the grid.

Chris Jubb 11 yıl önce
ebeveyn
işleme
4c9a7f6fd1
3 değiştirilmiş dosya ile 15 ekleme ve 1 silme
  1. 3 1
      editor/js/Editor.js
  2. 5 0
      editor/js/Toolbar.js
  3. 7 0
      editor/js/Viewport.js

+ 3 - 1
editor/js/Editor.js

@@ -36,7 +36,9 @@ var Editor = function () {
 		fogTypeChanged: new SIGNALS.Signal(),
 		fogColorChanged: new SIGNALS.Signal(),
 		fogParametersChanged: new SIGNALS.Signal(),
-		windowResize: new SIGNALS.Signal()
+		windowResize: new SIGNALS.Signal(),
+
+		showGridChanged: new SIGNALS.Signal()
 
 	};
 	

+ 5 - 0
editor/js/Toolbar.js

@@ -45,10 +45,15 @@ var Toolbar = function ( editor ) {
 	buttons.add( local );
 	buttons.add( new UI.Text( 'local' ) );
 
+	var showGrid = new UI.Checkbox().onChange( update ).setValue( true );
+	buttons.add( showGrid );
+	buttons.add( new UI.Text( 'show' ) );
+
 	function update() {
 
 		signals.snapChanged.dispatch( snap.getValue() === true ? grid.getValue() : null );
 		signals.spaceChanged.dispatch( local.getValue() === true ? "local" : "world" );
+		signals.showGridChanged.dispatch( showGrid.getValue() );
 
 	}
 

+ 7 - 0
editor/js/Viewport.js

@@ -430,6 +430,13 @@ var Viewport = function ( editor ) {
 
 	} );
 
+	signals.showGridChanged.add( function ( showGrid ) {
+
+		grid.visible = showGrid;
+		render();
+
+	} );
+
 	var animations = [];
 
 	signals.playAnimation.add( function ( animation ) {