Răsfoiți Sursa

More disposing.

Mr.doob 12 ani în urmă
părinte
comite
fdea8942ca

+ 2 - 0
examples/webgl_test_memory.html

@@ -88,7 +88,9 @@
 				// clean up
 
 				geometry.dispose();
+				material.dispose();
 				texture.dispose();
+				mesh.dispose();
 
 			}
 

+ 2 - 2
src/core/EventDispatcher.js

@@ -39,7 +39,7 @@ THREE.EventDispatcher = function () {
 		var listenerArray = listeners[ event.type ];
 
 		if ( listenerArray !== undefined ) {
-			
+
 			event.target = this;
 
 			for ( var i = 0, l = listenerArray.length; i < l; i ++ ) {
@@ -52,4 +52,4 @@ THREE.EventDispatcher = function () {
 
 	};
 
-};
+};

+ 6 - 0
src/core/Geometry.js

@@ -740,6 +740,12 @@ THREE.Geometry.prototype = {
 
 		this.dispatchEvent( { type: 'dispose' } );
 
+		for ( var property in this ) {
+
+			delete this[ property ];
+
+		}
+
 	}
 
 };

+ 10 - 0
src/core/Object3D.js

@@ -349,6 +349,16 @@ THREE.Object3D.prototype = {
 
 		return object;
 
+	},
+
+	dispose: function () {
+
+		for ( var property in this ) {
+
+			delete this[ property ];
+
+		}
+
 	}
 
 };

+ 6 - 0
src/materials/Material.js

@@ -120,6 +120,12 @@ THREE.Material.prototype.dispose = function () {
 
 	this.dispatchEvent( { type: 'dispose' } );
 
+	for ( var property in this ) {
+
+		delete this[ property ];
+
+	}
+
 };
 
 THREE.MaterialIdCount = 0;

+ 6 - 0
src/textures/Texture.js

@@ -81,6 +81,12 @@ THREE.Texture.prototype = {
 
 		this.dispatchEvent( { type: 'dispose' } );
 
+		for ( var property in this ) {
+
+			delete this[ property ];
+
+		}
+
 	}
 
 };