浏览代码

fixed: in-frame adding and removing same objects from scene leads to missing objects

Ivo Benner 14 年之前
父节点
当前提交
92f406bbcc
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      src/scenes/Scene.js

+ 19 - 0
src/scenes/Scene.js

@@ -50,6 +50,16 @@ THREE.Scene.prototype.addChildRecurse = function ( child ) {
 
 			this.objects.push( child );
 			this.__objectsAdded.push( child );
+			
+			// check if previously removed
+			
+			var i = this.__objectsRemoved.indexOf( child );
+			
+			if ( i !== -1 ) {
+				
+				this.__objectsRemoved.splice( i, 1 );
+				
+			}
 
 		}
 
@@ -91,6 +101,15 @@ THREE.Scene.prototype.removeChildRecurse = function ( child ) {
 			this.objects.splice( i, 1 );
 			this.__objectsRemoved.push( child );
 
+			// check if previously added
+
+			var ai = this.__objectsAdded.indexOf( child );
+			
+			if ( ai !== -1 ) {
+				
+				this.__objectsAdded.splice( ai, 1 );
+				
+			}
 		}
 
 	}