mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-09 04:56:01 +10:00
Remove Object3D child from scene too
This commit is contained in:
+17
-2
@@ -130,14 +130,29 @@ THREE.Object3D.prototype = {
|
||||
},
|
||||
|
||||
remove: function ( object ) {
|
||||
var scene = this;
|
||||
|
||||
var childIndex = this.children.indexOf( object );
|
||||
var childIndex = this.children.indexOf( child );
|
||||
|
||||
if ( childIndex !== - 1 ) {
|
||||
|
||||
object.parent = undefined;
|
||||
child.parent = undefined;
|
||||
this.children.splice( childIndex, 1 );
|
||||
|
||||
// remove from scene
|
||||
|
||||
while ( scene.parent !== undefined ) {
|
||||
|
||||
scene = scene.parent;
|
||||
|
||||
}
|
||||
|
||||
if ( scene !== undefined && scene instanceof THREE.Scene ) {
|
||||
|
||||
scene.removeChildRecurse( child );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user