Browse Source

Object3D: Added traverseVisible.

Mr.doob 11 years ago
parent
commit
4ef031b24e
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/core/Object3D.js

+ 14 - 0
src/core/Object3D.js

@@ -406,6 +406,20 @@ THREE.Object3D.prototype = {
 
 	},
 
+	traverseVisible: function ( callback ) {
+
+		if ( this.visible === false ) return;
+
+		callback( this );
+
+		for ( var i = 0, l = this.children.length; i < l; i ++ ) {
+
+			this.children[ i ].traverse( callback );
+
+		}
+
+	},
+
 	getObjectById: function ( id, recursive ) {
 
 		for ( var i = 0, l = this.children.length; i < l; i ++ ) {