@@ -59,6 +59,7 @@ export const extrudeRotate = (options, geometry) => {
5959 // convert geometry to an array of sides, easier to deal with
6060 let shapeSides = geom2 . toSides ( geometry )
6161 if ( shapeSides . length === 0 ) throw new Error ( 'the given geometry cannot be empty' )
62+ let sliceGeometry = geometry
6263
6364 // determine if the extrusion can be computed in the first place
6465 // ie all the points have to be either x > 0 or x < 0
@@ -87,8 +88,8 @@ export const extrudeRotate = (options, geometry) => {
8788 return [ point0 , point1 ]
8889 } )
8990 // recreate the geometry from the (-) capped points
90- geometry = geom2 . reverse ( geom2 . fromSides ( shapeSides ) )
91- geometry = mirrorX ( geometry )
91+ sliceGeometry = geom2 . reverse ( geom2 . fromSides ( shapeSides ) )
92+ sliceGeometry = mirrorX ( sliceGeometry )
9293 } else if ( pointsWithPositiveX . length >= pointsWithNegativeX . length ) {
9394 shapeSides = shapeSides . map ( ( side ) => {
9495 let point0 = side [ 0 ]
@@ -98,13 +99,13 @@ export const extrudeRotate = (options, geometry) => {
9899 return [ point0 , point1 ]
99100 } )
100101 // recreate the geometry from the (+) capped points
101- geometry = geom2 . fromSides ( shapeSides )
102+ sliceGeometry = geom2 . fromSides ( shapeSides )
102103 }
103104 }
104105
105106 const rotationPerSlice = totalRotation / segments
106107 const isCapped = Math . abs ( totalRotation ) < TAU
107- let baseSlice = slice . fromGeom2 ( geometry )
108+ let baseSlice = slice . fromGeom2 ( sliceGeometry )
108109 baseSlice = slice . reverse ( baseSlice )
109110
110111 const matrix = mat4 . create ( )
@@ -126,5 +127,7 @@ export const extrudeRotate = (options, geometry) => {
126127 close : ! isCapped ,
127128 callback : createSlice
128129 }
129- return extrudeFromSlices ( options , baseSlice )
130+ const output = extrudeFromSlices ( options , baseSlice )
131+ if ( geometry . color ) output . color = geometry . color
132+ return output
130133}
0 commit comments