浏览代码

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

Gheric Speiginer 11 年之前
父节点
当前提交
2b6fdf00d6
共有 1 个文件被更改,包括 6 次插入0 次删除
  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 ++ ) {
 	for ( var c = 0; c < object.children.length; c ++ ) {
 
 
 		this.__addObject( object.children[ 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 ++ ) {
 	for ( var c = 0; c < object.children.length; c ++ ) {
 
 
 		this.__removeObject( object.children[ c ] );
 		this.__removeObject( object.children[ c ] );