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 612fe6f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 25 deletions.
1 change: 1 addition & 0 deletions editor/js/Editor.js
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
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
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
48 changes: 38 additions & 10 deletions editor/js/Viewport.js
Expand Up @@ -406,26 +406,30 @@ function Viewport( editor ) {

signals.objectSelected.add( function ( object ) {

selectionBox.visible = false;
transformControls.detach();
if ( transformControls.enabled === true ) {

if ( object !== null && object !== scene && object !== camera ) {
selectionBox.visible = false;
transformControls.detach();

if ( object !== null && object !== scene && object !== camera ) {

box.setFromObject( object );
box.setFromObject( object );

if ( box.isEmpty() === false ) {
if ( box.isEmpty() === false ) {

selectionBox.setFromObject( object );
selectionBox.visible = true;
selectionBox.setFromObject( object );
selectionBox.visible = true;

}

transformControls.attach( object );

}

transformControls.attach( object );
render();

}

render();

} );

signals.objectFocused.add( function ( object ) {
Expand Down Expand Up @@ -688,6 +692,30 @@ function Viewport( editor ) {

} );

signals.showHelpersChanged.add( function ( showHelpers ) {

for ( var i = 0, l = sceneHelpers.children.length; i < l; i ++ ) {

var helper = sceneHelpers.children[ i ];

if ( helper.isTransformControls ) {

helper.enabled = showHelpers;

if ( helper.object !== undefined ) helper.visible = showHelpers;

} else {

helper.visible = showHelpers;

}

}

render();

} );

signals.cameraResetted.add( updateAspectRatio );

// animations
Expand Down

0 comments on commit 612fe6f

Please sign in to comment.