From df5909099836bff35f1892684a64a16c8cc35d8c Mon Sep 17 00:00:00 2001 From: MiiBond Date: Thu, 29 Aug 2013 10:32:08 -0400 Subject: [PATCH] Added dispose methods for cleaning up light helpers --- src/extras/helpers/DirectionalLightHelper.js | 8 ++++++++ src/extras/helpers/HemisphereLightHelper.js | 5 +++++ src/extras/helpers/PointLightHelper.js | 6 ++++++ src/extras/helpers/SpotLightHelper.js | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/src/extras/helpers/DirectionalLightHelper.js b/src/extras/helpers/DirectionalLightHelper.js index 8e72ce6c4e..a438e2d642 100644 --- a/src/extras/helpers/DirectionalLightHelper.js +++ b/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.dispose = function () { + + this.lightPlane.geometry.dispose(); + this.lightPlane.material.dispose(); + this.targetLine.geometry.dispose(); + this.targetLine.material.dispose(); +}; + THREE.DirectionalLightHelper.prototype.update = function () { var vector = new THREE.Vector3(); diff --git a/src/extras/helpers/HemisphereLightHelper.js b/src/extras/helpers/HemisphereLightHelper.js index e117776525..7f2b5fcf1c 100644 --- a/src/extras/helpers/HemisphereLightHelper.js +++ b/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.dispose = function () { + this.lightSphere.geometry.dispose(); + this.lightSphere.material.dispose(); +}; + THREE.HemisphereLightHelper.prototype.update = function () { var vector = new THREE.Vector3(); diff --git a/src/extras/helpers/PointLightHelper.js b/src/extras/helpers/PointLightHelper.js index 91adefed2e..14d29074bb 100644 --- a/src/extras/helpers/PointLightHelper.js +++ b/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.dispose = function () { + + this.geometry.dispose(); + this.material.dispose(); +}; + THREE.PointLightHelper.prototype.update = function () { this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); diff --git a/src/extras/helpers/SpotLightHelper.js b/src/extras/helpers/SpotLightHelper.js index f674086356..3376216f4a 100644 --- a/src/extras/helpers/SpotLightHelper.js +++ b/src/extras/helpers/SpotLightHelper.js @@ -30,6 +30,11 @@ THREE.SpotLightHelper = function ( light ) { 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 () { var vector = new THREE.Vector3(); -- GitLab