diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 1d54b33c86078601a0beb6fa273e70f116a36819..e7aeca9225d9098ffcb68a1d36b30552b0c11467 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -379,33 +379,24 @@ THREE.Object3D.prototype = { getObjectById: function ( id, recursive ) { - if ( this.id === id ) return this; + return this.getObjectByProperty('id', id, recursive); - for ( var i = 0, l = this.children.length; i < l; i ++ ) { - - var child = this.children[ i ]; - var object = child.getObjectById( id, recursive ); - - if ( object !== undefined ) { - - return object; - - } + }, - } + getObjectByName: function ( name, recursive ) { - return undefined; + return this.getObjectByProperty('name', name, recursive); }, + + getObjectByProperty: function ( name, value, recursive ) { - getObjectByName: function ( name, recursive ) { - - if ( this.name === name ) return this; + if ( this[name] === value ) return this; for ( var i = 0, l = this.children.length; i < l; i ++ ) { var child = this.children[ i ]; - var object = child.getObjectByName( name, recursive ); + var object = child.getObjectByProperty( name, value, recursive ); if ( object !== undefined ) {