|
@@ -377,33 +377,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 ) {
|
|
|
|