Browse Source

Projector: Fixed triangle culling breakage.

Mr.doob 11 years ago
parent
commit
423548e5dc
1 changed files with 14 additions and 18 deletions
  1. 14 18
      src/core/Projector.js

+ 14 - 18
src/core/Projector.js

@@ -195,28 +195,24 @@ THREE.Projector = function () {
 
 
 		};
 		};
 
 
-		var checkVerticesVisibility = function ( v1, v2, v3 ) {
-
-			return v1.visible === true && v2.visible === true && v3.visible === true;
-
-		};
-
 		var checkTriangleVisibility = function ( v1, v2, v3 ) {
 		var checkTriangleVisibility = function ( v1, v2, v3 ) {
 
 
+			if ( v1.visible === true || v2.visible === true || v3.visible === true ) return true;
+
 			_points3[ 0 ] = v1.positionScreen;
 			_points3[ 0 ] = v1.positionScreen;
 			_points3[ 1 ] = v2.positionScreen;
 			_points3[ 1 ] = v2.positionScreen;
 			_points3[ 2 ] = v3.positionScreen;
 			_points3[ 2 ] = v3.positionScreen;
 
 
-			if ( _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) {
+			return _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) );
 
 
-				return ( ( v3.positionScreen.x - v1.positionScreen.x ) *
-					    ( v2.positionScreen.y - v1.positionScreen.y ) -
-					    ( v3.positionScreen.y - v1.positionScreen.y ) *
-					    ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
+		};
 
 
-			}
+		var checkBackfaceCulling = function ( v1, v2, v3 ) {
 
 
-			return false;
+			return ( ( v3.positionScreen.x - v1.positionScreen.x ) *
+				    ( v2.positionScreen.y - v1.positionScreen.y ) -
+				    ( v3.positionScreen.y - v1.positionScreen.y ) *
+				    ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
 
 
 		};
 		};
 
 
@@ -244,9 +240,9 @@ THREE.Projector = function () {
 			var v2 = _vertexPool[ b ];
 			var v2 = _vertexPool[ b ];
 			var v3 = _vertexPool[ c ];
 			var v3 = _vertexPool[ c ];
 
 
-			if ( checkVerticesVisibility( v1, v2, v3 ) === false ) return;
+			if ( checkTriangleVisibility( v1, v2, v3 ) === false ) return;
 
 
-			if ( material.side === THREE.DoubleSide || checkTriangleVisibility( v1, v2, v3 ) === true ) {
+			if ( material.side === THREE.DoubleSide || checkBackfaceCulling( v1, v2, v3 ) === true ) {
 
 
 				_face = getNextFaceInPool();
 				_face = getNextFaceInPool();
 
 
@@ -279,8 +275,8 @@ THREE.Projector = function () {
 		return {
 		return {
 			setObject: setObject,
 			setObject: setObject,
 			projectVertex: projectVertex,
 			projectVertex: projectVertex,
-			checkVerticesVisibility: checkVerticesVisibility,
 			checkTriangleVisibility: checkTriangleVisibility,
 			checkTriangleVisibility: checkTriangleVisibility,
+			checkBackfaceCulling: checkBackfaceCulling,
 			pushVertex: pushVertex,
 			pushVertex: pushVertex,
 			pushNormal: pushNormal,
 			pushNormal: pushNormal,
 			pushLine: pushLine,
 			pushLine: pushLine,
@@ -470,9 +466,9 @@ THREE.Projector = function () {
 
 
 						}
 						}
 
 
-						if ( renderList.checkVerticesVisibility( v1, v2, v3 ) === false ) continue;
+						if ( renderList.checkTriangleVisibility( v1, v2, v3 ) === false ) continue;
 
 
-						var visible = renderList.checkTriangleVisibility( v1, v2, v3 );
+						var visible = renderList.checkBackfaceCulling( v1, v2, v3 );
 
 
 						if ( side !== THREE.DoubleSide ) {
 						if ( side !== THREE.DoubleSide ) {
 							if ( side === THREE.FrontSide && visible === false ) continue;
 							if ( side === THREE.FrontSide && visible === false ) continue;