Skip to content

Commit 05e77b0

Browse files
mlasala45Mugen87
andauthored
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 <[email protected]>
1 parent 62bb685 commit 05e77b0

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

src/geometries/ExtrudeGeometry.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -393,53 +393,63 @@ class ExtrudeGeometry extends BufferGeometry {
393393

394394
}
395395

396-
const contractedContourVertices = [];
397-
const expandedHoleVertices = [];
396+
let faces;
398397

399-
// Loop bevelSegments, 1 for the front, 1 for the back
398+
if ( bevelSegments === 0 ) {
400399

401-
for ( let b = 0; b < bevelSegments; b ++ ) {
400+
faces = ShapeUtils.triangulateShape( contour, holes );
402401

403-
//for ( b = bevelSegments; b > 0; b -- ) {
402+
} else {
404403

405-
const t = b / bevelSegments;
406-
const z = bevelThickness * Math.cos( t * Math.PI / 2 );
407-
const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
404+
const contractedContourVertices = [];
405+
const expandedHoleVertices = [];
408406

409-
// contract shape
407+
// Loop bevelSegments, 1 for the front, 1 for the back
410408

411-
for ( let i = 0, il = contour.length; i < il; i ++ ) {
409+
for ( let b = 0; b < bevelSegments; b ++ ) {
412410

413-
const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
411+
//for ( b = bevelSegments; b > 0; b -- ) {
414412

415-
v( vert.x, vert.y, - z );
416-
if ( t == 0 ) contractedContourVertices.push( vert );
413+
const t = b / bevelSegments;
414+
const z = bevelThickness * Math.cos( t * Math.PI / 2 );
415+
const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
417416

418-
}
417+
// contract shape
419418

420-
// expand holes
421-
422-
for ( let h = 0, hl = numHoles; h < hl; h ++ ) {
419+
for ( let i = 0, il = contour.length; i < il; i ++ ) {
423420

424-
const ahole = holes[ h ];
425-
oneHoleMovements = holesMovements[ h ];
426-
const oneHoleVertices = [];
427-
for ( let i = 0, il = ahole.length; i < il; i ++ ) {
428-
429-
const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
421+
const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
430422

431423
v( vert.x, vert.y, - z );
432-
if ( t == 0 ) oneHoleVertices.push( vert );
424+
if ( t === 0 ) contractedContourVertices.push( vert );
433425

434426
}
435427

436-
if ( t == 0 ) expandedHoleVertices.push( oneHoleVertices );
428+
// expand holes
429+
430+
for ( let h = 0, hl = numHoles; h < hl; h ++ ) {
431+
432+
const ahole = holes[ h ];
433+
oneHoleMovements = holesMovements[ h ];
434+
const oneHoleVertices = [];
435+
for ( let i = 0, il = ahole.length; i < il; i ++ ) {
436+
437+
const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
438+
439+
v( vert.x, vert.y, - z );
440+
if ( t === 0 ) oneHoleVertices.push( vert );
441+
442+
}
443+
444+
if ( t === 0 ) expandedHoleVertices.push( oneHoleVertices );
445+
446+
}
437447

438448
}
439449

440-
}
450+
faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );
441451

442-
const faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );
452+
}
443453

444454
const flen = faces.length;
445455

0 commit comments

Comments
 (0)