Browse Source

Adjust logic as suggested by WestLangley.

Felix Fontein 6 năm trước cách đây
mục cha
commit
779784c74c
1 tập tin đã thay đổi với 8 bổ sung15 xóa
  1. 8 15
      src/geometries/ExtrudeGeometry.js

+ 8 - 15
src/geometries/ExtrudeGeometry.js

@@ -392,13 +392,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
 
 			t = b / bevelSegments;
 			z = bevelThickness * Math.cos( t * Math.PI / 2 );
-			bs = Math.abs( bevelSize ) * Math.sin( t * Math.PI / 2 );
-
-			if ( bevelSize < 0 ) {
-
-				bs += bevelSize;
-
-			}
+			var s = Math.sin( t * Math.PI / 2 );
+			bs = ( bevelSize > 0 ) ? bevelSize * s : bevelSize * ( 1 - s );
 
 			// contract shape
 
@@ -429,7 +424,10 @@ function ExtrudeBufferGeometry( shapes, options ) {
 
 		}
 
-		bs = ( bevelSize < 0 ? 0 : bevelSize );
+		// Special case of
+		//   bs = ( bevelSize > 0 ) ? bevelSize * s : bevelSize * ( 1 - s );
+		// with s = 1
+		bs = ( bevelSize > 0 ? bevelSize : 0 );
 
 		// Back facing vertices
 
@@ -496,13 +494,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
 
 			t = b / bevelSegments;
 			z = bevelThickness * Math.cos( t * Math.PI / 2 );
-			bs = Math.abs( bevelSize ) * Math.sin( t * Math.PI / 2 );
-
-			if ( bevelSize < 0 ) {
-
-				bs += bevelSize;
-
-			}
+			var s = Math.sin( t * Math.PI / 2 );
+			bs = ( bevelSize > 0 ) ? bevelSize * s : bevelSize * ( 1 - s );
 
 			// contract shape