瀏覽代碼

Merge branch 'patch-2' of https://github.com/speigg/three.js into dev

Mr.doob 11 年之前
父節點
當前提交
f4cf8d741e
共有 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 ++ ) {
 
 		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 ] );