Browse Source

Added dispose methods for cleaning up light helpers

MiiBond 12 years ago
parent
commit
df59090998

+ 8 - 0
src/extras/helpers/DirectionalLightHelper.js

@@ -37,6 +37,14 @@ THREE.DirectionalLightHelper = function ( light, size ) {
 
 
 THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 
 
+THREE.DirectionalLightHelper.prototype.dispose = function () {
+	
+	this.lightPlane.geometry.dispose();
+	this.lightPlane.material.dispose();
+	this.targetLine.geometry.dispose();
+	this.targetLine.material.dispose();
+};
+
 THREE.DirectionalLightHelper.prototype.update = function () {
 THREE.DirectionalLightHelper.prototype.update = function () {
 
 
 	var vector = new THREE.Vector3();
 	var vector = new THREE.Vector3();

+ 5 - 0
src/extras/helpers/HemisphereLightHelper.js

@@ -35,6 +35,11 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
 
 
 THREE.HemisphereLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 THREE.HemisphereLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 
 
+THREE.HemisphereLightHelper.prototype.dispose = function () {
+	this.lightSphere.geometry.dispose();
+	this.lightSphere.material.dispose();
+};
+
 THREE.HemisphereLightHelper.prototype.update = function () {
 THREE.HemisphereLightHelper.prototype.update = function () {
 
 
 	var vector = new THREE.Vector3();
 	var vector = new THREE.Vector3();

+ 6 - 0
src/extras/helpers/PointLightHelper.js

@@ -43,6 +43,12 @@ THREE.PointLightHelper = function ( light, sphereSize ) {
 
 
 THREE.PointLightHelper.prototype = Object.create( THREE.Mesh.prototype );
 THREE.PointLightHelper.prototype = Object.create( THREE.Mesh.prototype );
 
 
+THREE.PointLightHelper.prototype.dispose = function () {
+	
+	this.geometry.dispose();
+	this.material.dispose();
+};
+
 THREE.PointLightHelper.prototype.update = function () {
 THREE.PointLightHelper.prototype.update = function () {
 
 
 	this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
 	this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );

+ 5 - 0
src/extras/helpers/SpotLightHelper.js

@@ -30,6 +30,11 @@ THREE.SpotLightHelper = function ( light ) {
 
 
 THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 
 
+THREE.SpotLightHelper.prototype.dispose = function () {
+	this.cone.geometry.dispose();
+	this.cone.material.dispose();
+};
+
 THREE.SpotLightHelper.prototype.update = function () {
 THREE.SpotLightHelper.prototype.update = function () {
 
 
 	var vector = new THREE.Vector3();
 	var vector = new THREE.Vector3();