Przeglądaj źródła

Allowing to subtract bevel instead of adding it.

Felix Fontein 7 lat temu
rodzic
commit
df448bb986
2 zmienionych plików z 16 dodań i 2 usunięć
  1. 15 2
      src/geometries/ExtrudeGeometry.js
  2. 1 0
      src/geometries/TextGeometry.js

+ 15 - 2
src/geometries/ExtrudeGeometry.js

@@ -13,6 +13,7 @@
  *  bevelThickness: <float>, // how deep into the original shape bevel goes
  *  bevelSize: <float>, // how far from shape outline is bevel
  *  bevelSegments: <int>, // number of bevel layers
+ *  bevelSubtract: <bool>, // subtract bevel instead of adding it
  *
  *  extrudePath: <THREE.Curve> // curve to extrude shape along
  *
@@ -110,6 +111,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
 		var bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
 		var bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 2;
 		var bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
+		var bevelSubtract = options.bevelSubtract !== undefined ? options.bevelSubtract : false;
 
 		var extrudePath = options.extrudePath;
 
@@ -384,7 +386,6 @@ function ExtrudeBufferGeometry( shapes, options ) {
 
 		}
 
-
 		// Loop bevelSegments, 1 for the front, 1 for the back
 
 		for ( b = 0; b < bevelSegments; b ++ ) {
@@ -395,6 +396,12 @@ function ExtrudeBufferGeometry( shapes, options ) {
 			z = bevelThickness * Math.cos( t * Math.PI / 2 );
 			bs = bevelSize * Math.sin( t * Math.PI / 2 );
 
+			if ( bevelSubtract ) {
+
+				bs -= bevelSize;
+
+			}
+
 			// contract shape
 
 			for ( i = 0, il = contour.length; i < il; i ++ ) {
@@ -424,7 +431,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
 
 		}
 
-		bs = bevelSize;
+		bs = ( bevelSubtract ? 0 : bevelSize );
 
 		// Back facing vertices
 
@@ -493,6 +500,12 @@ function ExtrudeBufferGeometry( shapes, options ) {
 			z = bevelThickness * Math.cos( t * Math.PI / 2 );
 			bs = bevelSize * Math.sin( t * Math.PI / 2 );
 
+			if ( bevelSubtract ) {
+
+				bs -= bevelSize;
+
+			}
+
 			// contract shape
 
 			for ( i = 0, il = contour.length; i < il; i ++ ) {

+ 1 - 0
src/geometries/TextGeometry.js

@@ -14,6 +14,7 @@
  *  bevelEnabled: <bool>, // turn on bevel
  *  bevelThickness: <float>, // how deep into text bevel goes
  *  bevelSize: <float> // how far from text outline is bevel
+ *  bevelSubtract: <bool>, // subtract bevel instead of adding it
  * }
  */