Browse Source

Added 'addedToScene', 'removedFromScene', 'objectAdded', and 'objectRemoved' events

Gheric Speiginer 11 years ago
parent
commit
2b6fdf00d6
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/scenes/Scene.js

+ 6 - 0
src/scenes/Scene.js

@@ -53,6 +53,9 @@ THREE.Scene.prototype.__addObject = function ( object ) {
 
 	}
 
+	this.dispatchEvent( { type: 'objectAdded', object: object } );
+	object.dispatchEvent( { type: 'addedToScene', scene: this } );
+
 	for ( var c = 0; c < object.children.length; c ++ ) {
 
 		this.__addObject( object.children[ c ] );
@@ -99,6 +102,9 @@ THREE.Scene.prototype.__removeObject = function ( object ) {
 
 	}
 
+	this.dispatchEvent( { type: 'objectRemoved', object: object } );
+	object.dispatchEvent( { type: 'removedFromScene', scene: this } );
+
 	for ( var c = 0; c < object.children.length; c ++ ) {
 
 		this.__removeObject( object.children[ c ] );