Skip to content

Commit

Permalink
Editor: Add option for toggle rendering of helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jul 16, 2020
1 parent 0aa4a84 commit 04811c4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
1 change: 1 addition & 0 deletions editor/js/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function Editor() {
windowResize: new Signal(),

showGridChanged: new Signal(),
showHelpersChanged: new Signal(),
refreshSidebarObject3D: new Signal(),
historyChanged: new Signal(),

Expand Down
36 changes: 21 additions & 15 deletions editor/js/Sidebar.Settings.Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/

import { UIDiv, UIBreak, UIText } from './libs/ui.js';
import { UIDiv, UIText, UIRow } from './libs/ui.js';
import { UIBoolean } from './libs/ui.three.js';


Expand All @@ -12,28 +12,34 @@ function SidebarSettingsViewport( editor ) {
var strings = editor.strings;

var container = new UIDiv();
container.add( new UIBreak() );

container.add( new UIText( strings.getKey( 'sidebar/settings/viewport/grid' ) ).setWidth( '90px' ) );
// grid

var show = new UIBoolean( true ).onChange( update );
container.add( show );
var showGridRow = new UIRow();

/*
var snapSize = new UI.Number( 25 ).setWidth( '40px' ).onChange( update );
container.add( snapSize );
showGridRow.add( new UIText( strings.getKey( 'sidebar/settings/viewport/grid' ) ).setWidth( '90px' ) );

var snap = new UI.THREE.Boolean( false, 'snap' ).onChange( update );
container.add( snap );
*/
var showGrid = new UIBoolean( true ).onChange( function () {

function update() {
signals.showGridChanged.dispatch( showGrid.getValue() );

signals.showGridChanged.dispatch( show.getValue() );
} );
showGridRow.add( showGrid );
container.add( showGridRow );

// signals.snapChanged.dispatch( snap.getValue() === true ? snapSize.getValue() : null );
// helpers

}
var showHelpersRow = new UIRow();

showHelpersRow.add( new UIText( strings.getKey( 'sidebar/settings/viewport/helpers' ) ).setWidth( '90px' ) );

var showHelpers = new UIBoolean( true ).onChange( function () {

signals.showHelpersChanged.dispatch( showHelpers.getValue() );

} );
showHelpersRow.add( showHelpers );
container.add( showHelpersRow );

return container;

Expand Down
3 changes: 3 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function Strings( config ) {
'sidebar/settings/shortcuts/focus': 'Focus',

'sidebar/settings/viewport/grid': 'Grid',
'sidebar/settings/viewport/helpers': 'Helpers',

'sidebar/history': 'History',
'sidebar/history/persistent': 'persistent',
Expand Down Expand Up @@ -628,6 +629,7 @@ function Strings( config ) {
'sidebar/settings/shortcuts/focus': 'Focus',

'sidebar/settings/viewport/grid': 'Grille',
'sidebar/settings/viewport/helpers': 'Helpers',

'sidebar/history': 'Historique',
'sidebar/history/persistent': 'permanent',
Expand Down Expand Up @@ -920,6 +922,7 @@ function Strings( config ) {
'sidebar/settings/shortcuts/focus': '聚焦',

'sidebar/settings/viewport/grid': '网格',
'sidebar/settings/viewport/helpers': 'Helpers',

'sidebar/history': '历史记录',
'sidebar/history/persistent': '本地存储',
Expand Down
12 changes: 11 additions & 1 deletion editor/js/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function Viewport( editor ) {
var camera = editor.camera;
var scene = editor.scene;
var sceneHelpers = editor.sceneHelpers;
var showSceneHelpers = true;

var objects = [];

Expand Down Expand Up @@ -688,6 +689,15 @@ function Viewport( editor ) {

} );

signals.showHelpersChanged.add( function ( showHelpers ) {

showSceneHelpers = showHelpers;
transformControls.enabled = showHelpers;

render();

} );

signals.cameraResetted.add( updateAspectRatio );

// animations
Expand Down Expand Up @@ -743,7 +753,7 @@ function Viewport( editor ) {
if ( camera === editor.viewportCamera ) {

renderer.autoClear = false;
renderer.render( sceneHelpers, camera );
if ( showSceneHelpers === true ) renderer.render( sceneHelpers, camera );
viewHelper.render( renderer );
renderer.autoClear = true;

Expand Down

0 comments on commit 04811c4

Please sign in to comment.