提交 990b43a2 编写于 作者: M Mr.doob

Editor: Focus object on double click in scene inspector.

上级 19213aba
......@@ -32,6 +32,8 @@ var Editor = function () {
geometryChanged: new SIGNALS.Signal(),
objectSelected: new SIGNALS.Signal(),
objectFocused: new SIGNALS.Signal(),
objectAdded: new SIGNALS.Signal(),
objectChanged: new SIGNALS.Signal(),
objectRemoved: new SIGNALS.Signal(),
......@@ -283,35 +285,26 @@ Editor.prototype = {
select: function ( object ) {
this.selected = object;
if ( object !== null ) {
if ( this.selected === object ) return;
this.config.setKey( 'selected', object.uuid );
var uuid = null;
} else {
if ( object !== null ) {
this.config.setKey( 'selected', null );
uuid = object.uuid;
}
this.selected = object;
this.config.setKey( 'selected', uuid );
this.signals.objectSelected.dispatch( object );
},
selectById: function ( id ) {
var scope = this;
this.scene.traverse( function ( child ) {
if ( child.id === id ) {
scope.select( child );
}
} );
this.select( this.scene.getObjectById( id, true ) );
},
......@@ -335,6 +328,18 @@ Editor.prototype = {
this.select( null );
},
focus: function ( object ) {
this.signals.objectFocused.dispatch( object );
},
focusById: function ( id ) {
this.focus( this.scene.getObjectById( id, true ) );
}
}
......@@ -24,6 +24,11 @@ Sidebar.Scene = function ( editor ) {
ignoreObjectSelectedSignal = false;
} );
outliner.onDblClick( function () {
editor.focusById( parseInt( outliner.getValue() ) );
} );
container.add( outliner );
container.add( new UI.Break() );
......
......@@ -149,9 +149,11 @@ var Viewport = function ( editor ) {
var intersects = getIntersects( event, objects );
if ( intersects.length > 0 && intersects[ 0 ].object === editor.selected ) {
if ( intersects.length > 0 ) {
controls.focus( editor.selected );
var intersect = intersects[ 0 ];
signals.objectFocused.dispatch( intersect.object );
}
......@@ -164,7 +166,7 @@ var Viewport = function ( editor ) {
// otherwise controls.enabled doesn't work.
var controls = new THREE.EditorControls( camera, container.dom );
controls.center.fromArray( editor.config.getKey( 'camera/target' ) )
controls.center.fromArray( editor.config.getKey( 'camera/target' ) );
controls.addEventListener( 'change', function () {
transformControls.update();
......@@ -283,6 +285,12 @@ var Viewport = function ( editor ) {
} );
signals.objectFocused.add( function ( object ) {
controls.focus( object );
} );
signals.geometryChanged.add( render );
signals.objectAdded.add( function ( object ) {
......
......@@ -69,7 +69,7 @@ properties.forEach( function ( property ) {
// events
var events = [ 'KeyUp', 'KeyDown', 'MouseOver', 'MouseOut', 'Click', 'Change' ];
var events = [ 'KeyUp', 'KeyDown', 'MouseOver', 'MouseOut', 'Click', 'DblClick', 'Change' ];
events.forEach( function ( event ) {
......
......@@ -404,25 +404,16 @@ THREE.Object3D.prototype = {
getObjectById: function ( id, recursive ) {
if ( this.id === id ) return this;
for ( var i = 0, l = this.children.length; i < l; i ++ ) {
var child = this.children[ i ];
var object = child.getObjectById( id, recursive );
if ( child.id === id ) {
return child;
}
if ( recursive === true ) {
if ( object !== undefined ) {
child = child.getObjectById( id, recursive );
if ( child !== undefined ) {
return child;
}
return object;
}
......@@ -434,25 +425,16 @@ THREE.Object3D.prototype = {
getObjectByName: function ( name, recursive ) {
if ( this.name === name ) return this;
for ( var i = 0, l = this.children.length; i < l; i ++ ) {
var child = this.children[ i ];
var object = child.getObjectByName( name, recursive );
if ( child.name === name ) {
return child;
}
if ( recursive === true ) {
if ( object !== undefined ) {
child = child.getObjectByName( name, recursive );
if ( child !== undefined ) {
return child;
}
return object;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册