Переглянути джерело

Merge pull request #15457 from Mugen87/dev11

Lensflare: Perform early out if the lensflare is behind the camera
Mr.doob 6 роки тому
батько
коміт
51d288b29f
1 змінених файлів з 6 додано та 3 видалено
  1. 6 3
      examples/js/objects/Lensflare.js

+ 6 - 3
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