2
0
Эх сурвалжийг харах

Merge remote-tracking branch 'jsermeno/dev' into dev

Mr.doob 14 жил өмнө
parent
commit
7c20f3f99a

+ 15 - 0
src/core/Object3D.js

@@ -130,6 +130,7 @@ THREE.Object3D.prototype = {
 	},
 	},
 
 
 	remove: function ( object ) {
 	remove: function ( object ) {
+		var scene = this;
 
 
 		var childIndex = this.children.indexOf( object );
 		var childIndex = this.children.indexOf( object );
 
 
@@ -138,6 +139,20 @@ THREE.Object3D.prototype = {
 			object.parent = undefined;
 			object.parent = undefined;
 			this.children.splice( childIndex, 1 );
 			this.children.splice( childIndex, 1 );
 
 
+			// remove from scene
+
+			while ( scene.parent !== undefined ) {
+
+				scene = scene.parent;
+
+			}
+
+			if ( scene !== undefined && scene instanceof THREE.Scene ) {
+
+				scene.removeChildRecurse( object );
+
+			}
+
 		}
 		}
 
 
 	},
 	},