Просмотр исходного кода

ExtrudeGeometry: Fix regression introduced by #30750. (#30822)

* Fix vertex lists not being generated correctly when bevelSegments == 0

* Removed superfluous scope block around new code

* Fixed using the wrong variable to populate contractedContourVertices

The variable "vertices" could probably use renaming for clarity.

* Restructured fix for efficiency and clarity

Now branches based on bevelSegments ?= 0, bypassing contractedContourVertices/expandedHoleVertices  generation when there is no bevel.

* Update ExtrudeGeometry.js

* Update ExtrudeGeometry.js

---------

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Micah LaSala 10 месяцев назад
Родитель
Сommit
05e77b0877
1 измененных файлов с 37 добавлено и 27 удалено
  1. 37 27
      src/geometries/ExtrudeGeometry.js

+ 37 - 27
src/geometries/ExtrudeGeometry.js

@@ -393,53 +393,63 @@ class ExtrudeGeometry extends BufferGeometry {
 
 
 			}
 			}
 
 
-			const contractedContourVertices = [];
-			const expandedHoleVertices = [];
+			let faces;
 
 
-			// Loop bevelSegments, 1 for the front, 1 for the back
+			if ( bevelSegments === 0 ) {
 
 
-			for ( let b = 0; b < bevelSegments; b ++ ) {
+				faces = ShapeUtils.triangulateShape( contour, holes );
 
 
-				//for ( b = bevelSegments; b > 0; b -- ) {
+			} else {
 
 
-				const t = b / bevelSegments;
-				const z = bevelThickness * Math.cos( t * Math.PI / 2 );
-				const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
+				const contractedContourVertices = [];
+				const expandedHoleVertices = [];
 
 
-				// contract shape
+				// Loop bevelSegments, 1 for the front, 1 for the back
 
 
-				for ( let i = 0, il = contour.length; i < il; i ++ ) {
+				for ( let b = 0; b < bevelSegments; b ++ ) {
 
 
-					const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
+					//for ( b = bevelSegments; b > 0; b -- ) {
 
 
-					v( vert.x, vert.y, - z );
-					if ( t == 0 ) contractedContourVertices.push( vert );
+					const t = b / bevelSegments;
+					const z = bevelThickness * Math.cos( t * Math.PI / 2 );
+					const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
 
 
-				}
+					// contract shape
 
 
-				// expand holes
-
-				for ( let h = 0, hl = numHoles; h < hl; h ++ ) {
+					for ( let i = 0, il = contour.length; i < il; i ++ ) {
 
 
-					const ahole = holes[ h ];
-					oneHoleMovements = holesMovements[ h ];
-					const oneHoleVertices = [];
-					for ( let i = 0, il = ahole.length; i < il; i ++ ) {
-
-						const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
+						const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
 
 
 						v( vert.x, vert.y, - z );
 						v( vert.x, vert.y, - z );
-						if ( t == 0 ) oneHoleVertices.push( vert );
+						if ( t === 0 ) contractedContourVertices.push( vert );
 
 
 					}
 					}
 
 
-					if ( t == 0 ) expandedHoleVertices.push( oneHoleVertices );
+					// expand holes
+
+					for ( let h = 0, hl = numHoles; h < hl; h ++ ) {
+
+						const ahole = holes[ h ];
+						oneHoleMovements = holesMovements[ h ];
+						const oneHoleVertices = [];
+						for ( let i = 0, il = ahole.length; i < il; i ++ ) {
+
+							const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
+
+							v( vert.x, vert.y, - z );
+							if ( t === 0 ) oneHoleVertices.push( vert );
+
+						}
+
+						if ( t === 0 ) expandedHoleVertices.push( oneHoleVertices );
+
+					}
 
 
 				}
 				}
 
 
-			}
+				faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );
 
 
-			const faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );
+			}
 
 
 			const flen = faces.length;
 			const flen = faces.length;
 
 

粤ICP备19079148号