diff --git a/examples/js/objects/Lensflare.js b/examples/js/objects/Lensflare.js index c43f4fdfef0b9046ce28b3e4b90ca8b6b1bc5aef..c50fc49df5e9a8288eebd8a58554b803f9e4a75a 100644 --- a/examples/js/objects/Lensflare.js +++ b/examples/js/objects/Lensflare.js @@ -14,6 +14,7 @@ THREE.Lensflare = function () { // var positionScreen = new THREE.Vector3(); + var positionView = new THREE.Vector3(); // textures @@ -175,10 +176,12 @@ THREE.Lensflare = function () { // calculate position in screen space - positionScreen.setFromMatrixPosition( this.matrixWorld ); + positionView.setFromMatrixPosition( this.matrixWorld ); + positionView.applyMatrix4( camera.matrixWorldInverse ); - positionScreen.applyMatrix4( camera.matrixWorldInverse ); - positionScreen.applyMatrix4( camera.projectionMatrix ); + if ( positionView.z > 0 ) return; // lensflare is behind the camera + + positionScreen.copy( positionView ).applyMatrix4( camera.projectionMatrix ); // horizontal and vertical coordinate of the lower left corner of the pixels to copy