@@ -393,71 +393,62 @@ class ExtrudeGeometry extends BufferGeometry {
393393
394394 }
395395
396- const contractedContourVertices = [ ] ;
397- const expandedHoleVertices = [ ] ;
396+ let faces ;
397+ if ( bevelSegments == 0 ) {
398398
399- // Loop bevelSegments, 1 for the front, 1 for the back
399+ faces = ShapeUtils . triangulateShape ( contour , holes ) ;
400400
401- for ( let b = 0 ; b < bevelSegments ; b ++ ) {
401+ } else {
402402
403- //for ( b = bevelSegments; b > 0; b -- ) {
403+ const contractedContourVertices = [ ] ;
404+ const expandedHoleVertices = [ ] ;
404405
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 ;
408-
409- // contract shape
410-
411- for ( let i = 0 , il = contour . length ; i < il ; i ++ ) {
412-
413- const vert = scalePt2 ( contour [ i ] , contourMovements [ i ] , bs ) ;
406+ // Loop bevelSegments, 1 for the front, 1 for the back
414407
415- v ( vert . x , vert . y , - z ) ;
416- if ( t == 0 ) contractedContourVertices . push ( vert ) ;
408+ for ( let b = 0 ; b < bevelSegments ; b ++ ) {
417409
418- }
410+ //for ( b = bevelSegments; b > 0; b -- ) {
419411
420- // expand holes
412+ const t = b / bevelSegments ;
413+ const z = bevelThickness * Math . cos ( t * Math . PI / 2 ) ;
414+ const bs = bevelSize * Math . sin ( t * Math . PI / 2 ) + bevelOffset ;
421415
422- for ( let h = 0 , hl = numHoles ; h < hl ; h ++ ) {
416+ // contract shape
423417
424- const ahole = holes [ h ] ;
425- oneHoleMovements = holesMovements [ h ] ;
426- const oneHoleVertices = [ ] ;
427- for ( let i = 0 , il = ahole . length ; i < il ; i ++ ) {
418+ for ( let i = 0 , il = contour . length ; i < il ; i ++ ) {
428419
429- const vert = scalePt2 ( ahole [ i ] , oneHoleMovements [ i ] , bs ) ;
420+ const vert = scalePt2 ( contour [ i ] , contourMovements [ i ] , bs ) ;
430421
431422 v ( vert . x , vert . y , - z ) ;
432- if ( t == 0 ) oneHoleVertices . push ( vert ) ;
423+ if ( t == 0 ) contractedContourVertices . push ( vert ) ;
433424
434425 }
435426
436- if ( t == 0 ) expandedHoleVertices . push ( oneHoleVertices ) ;
437-
438- }
439-
440- }
427+ // expand holes
441428
442- //When bevelSegments == 0, the modified vert arrays will not have been populated. We do this here.
429+ for ( let h = 0 , hl = numHoles ; h < hl ; h ++ ) {
443430
444- if ( contractedContourVertices . length == 0 ) {
431+ const ahole = holes [ h ] ;
432+ oneHoleMovements = holesMovements [ h ] ;
433+ const oneHoleVertices = [ ] ;
434+ for ( let i = 0 , il = ahole . length ; i < il ; i ++ ) {
445435
446- contractedContourVertices . push ( ... contour ) ;
436+ const vert = scalePt2 ( ahole [ i ] , oneHoleMovements [ i ] , bs ) ;
447437
448- }
438+ v ( vert . x , vert . y , - z ) ;
439+ if ( t == 0 ) oneHoleVertices . push ( vert ) ;
449440
450- if ( expandedHoleVertices . length == 0 ) {
441+ }
451442
452- for ( let h = 0 , hl = numHoles ; h < hl ; h ++ ) {
443+ if ( t == 0 ) expandedHoleVertices . push ( oneHoleVertices ) ;
453444
454- expandedHoleVertices . push ( holes [ h ] ) ; //triangulateShape expects a Vec2[][], ie. an array of holes, with each hole being a Vec2[]
445+ }
455446
456447 }
457448
458- }
449+ faces = ShapeUtils . triangulateShape ( contractedContourVertices , expandedHoleVertices ) ;
459450
460- const faces = ShapeUtils . triangulateShape ( contractedContourVertices , expandedHoleVertices ) ;
451+ }
461452
462453 const flen = faces . length ;
463454
0 commit comments