Explorar el Código

Sending target in the deallocate event.
Still unsure of whether to rename it to dispose instead.
I guess a problem of the world deallocate is that you're unsure wether it is dealocate or deallocate.

Mr.doob hace 12 años
padre
commit
fdb737d078

+ 1 - 1
src/core/BufferGeometry.js

@@ -546,7 +546,7 @@ THREE.BufferGeometry.prototype = {
 
 	deallocate: function () {
 
-		this.dispatchEvent( { type: 'deallocate' } );
+		this.dispatchEvent( { type: 'deallocate', target: this } );
 
 	}
 

+ 1 - 1
src/core/Geometry.js

@@ -738,7 +738,7 @@ THREE.Geometry.prototype = {
 
 	deallocate: function () {
 
-		this.dispatchEvent( { type: 'deallocate' } );
+		this.dispatchEvent( { type: 'deallocate', target: this } );
 
 	}
 

+ 1 - 1
src/materials/Material.js

@@ -118,7 +118,7 @@ THREE.Material.prototype.clone = function ( material ) {
 
 THREE.Material.prototype.deallocate = function () {
 
-	this.dispatchEvent( { type: 'deallocate' } );
+	this.dispatchEvent( { type: 'deallocate', target: this } );
 
 };
 

+ 1 - 1
src/renderers/WebGLRenderTarget.js

@@ -66,6 +66,6 @@ THREE.WebGLRenderTarget.prototype.clone = function() {
 
 THREE.WebGLRenderTarget.prototype.deallocate = function () {
 
-	this.dispatchEvent( { type: 'deallocate' } );
+	this.dispatchEvent( { type: 'deallocate', target: this } );
 
 };

+ 20 - 12
src/renderers/WebGLRenderer.js

@@ -462,42 +462,50 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	// Events
 
-	var onGeometryDeallocate = function () {
+	var onGeometryDeallocate = function ( event ) {
 
-		this.removeEventListener( 'deallocate', onGeometryDeallocate );
+		var geometry = event.target;
 
-		deallocateGeometry( this );
+		geometry.removeEventListener( 'deallocate', onGeometryDeallocate );
+
+		deallocateGeometry( geometry );
 
 		_this.info.memory.geometries --;
 
 	};
 
-	var onTextureDeallocate = function () {
+	var onTextureDeallocate = function ( event ) {
+
+		var texture = event.target;
 
-		this.removeEventListener( 'deallocate', onTextureDeallocate );
+		texture.removeEventListener( 'deallocate', onTextureDeallocate );
 
-		deallocateTexture( this );
+		deallocateTexture( texture );
 
 		_this.info.memory.textures --;
 
 
 	};
 
-	var onRenderTargetDeallocate = function () {
+	var onRenderTargetDeallocate = function ( event ) {
 
-		this.removeEventListener( 'deallocate', onRenderTargetDeallocate );
+		var renderTarget = event.target;
 
-		deallocateRenderTarget( this );
+		renderTarget.removeEventListener( 'deallocate', onRenderTargetDeallocate );
+
+		deallocateRenderTarget( renderTarget );
 
 		_this.info.memory.textures --;
 
 	};
 
-	var onMaterialDeallocate = function () {
+	var onMaterialDeallocate = function ( event ) {
+
+		var material = event.target;
 
-		this.removeEventListener( 'deallocate', onMaterialDeallocate );
+		material.removeEventListener( 'deallocate', onMaterialDeallocate );
 
-		deallocateMaterial( this );
+		deallocateMaterial( material );
 
 	};
 

+ 1 - 1
src/textures/Texture.js

@@ -79,7 +79,7 @@ THREE.Texture.prototype = {
 
 	deallocate: function () {
 
-		this.dispatchEvent( { type: 'deallocate' } );
+		this.dispatchEvent( { type: 'deallocate', target: this } );
 
 	}