Browse Source

Object3D: Add `childadded` and `childremoved` events. (#16934)

* Add addchild and removechild events

* rename events
Garrett Johnson 1 year ago
parent
commit
a15b926a71
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/core/Object3D.js

+ 2 - 0
src/core/Object3D.js

@@ -340,6 +340,7 @@ class Object3D extends EventDispatcher {
 			this.children.push( object );
 
 			object.dispatchEvent( _addedEvent );
+			this.dispatchEvent( { type: 'childadded', child: object } );
 
 		} else {
 
@@ -373,6 +374,7 @@ class Object3D extends EventDispatcher {
 			this.children.splice( index, 1 );
 
 			object.dispatchEvent( _removedEvent );
+			this.dispatchEvent( { type: 'childremoved', child: object } );
 
 		}