ExtrudeGeometry.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. /**
  2. * Creates extruded geometry from a path shape.
  3. *
  4. * parameters = {
  5. *
  6. * curveSegments: <int>, // number of points on the curves
  7. * steps: <int>, // number of points for z-side extrusions / used for subdividing segments of extrude spline too
  8. * depth: <float>, // Depth to extrude the shape
  9. *
  10. * bevelEnabled: <bool>, // turn on bevel
  11. * bevelThickness: <float>, // how deep into the original shape bevel goes
  12. * bevelSize: <float>, // how far from shape outline (including bevelOffset) is bevel
  13. * bevelOffset: <float>, // how far from shape outline does bevel start
  14. * bevelSegments: <int>, // number of bevel layers
  15. *
  16. * extrudePath: <THREE.Curve> // curve to extrude shape along
  17. *
  18. * UVGenerator: <Object> // object that provides UV generator functions
  19. *
  20. * }
  21. */
  22. import { BufferGeometry } from '../core/BufferGeometry.js';
  23. import { Float32BufferAttribute } from '../core/BufferAttribute.js';
  24. import * as Curves from '../extras/curves/Curves.js';
  25. import { Vector2 } from '../math/Vector2.js';
  26. import { Vector3 } from '../math/Vector3.js';
  27. import { Shape } from '../extras/core/Shape.js';
  28. import { ShapeUtils } from '../extras/ShapeUtils.js';
  29. class ExtrudeGeometry extends BufferGeometry {
  30. constructor( shapes = new Shape( [ new Vector2( 0.5, 0.5 ), new Vector2( - 0.5, 0.5 ), new Vector2( - 0.5, - 0.5 ), new Vector2( 0.5, - 0.5 ) ] ), options = {} ) {
  31. super();
  32. this.type = 'ExtrudeGeometry';
  33. this.parameters = {
  34. shapes: shapes,
  35. options: options
  36. };
  37. shapes = Array.isArray( shapes ) ? shapes : [ shapes ];
  38. const scope = this;
  39. const verticesArray = [];
  40. const uvArray = [];
  41. for ( let i = 0, l = shapes.length; i < l; i ++ ) {
  42. const shape = shapes[ i ];
  43. addShape( shape );
  44. }
  45. // build geometry
  46. this.setAttribute( 'position', new Float32BufferAttribute( verticesArray, 3 ) );
  47. this.setAttribute( 'uv', new Float32BufferAttribute( uvArray, 2 ) );
  48. this.computeVertexNormals();
  49. // functions
  50. function addShape( shape ) {
  51. const placeholder = [];
  52. // options
  53. const curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;
  54. const steps = options.steps !== undefined ? options.steps : 1;
  55. const depth = options.depth !== undefined ? options.depth : 1;
  56. let bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;
  57. let bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 0.2;
  58. let bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 0.1;
  59. let bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
  60. let bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
  61. const extrudePath = options.extrudePath;
  62. const uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator;
  63. //
  64. let extrudePts, extrudeByPath = false;
  65. let splineTube, binormal, normal, position2;
  66. if ( extrudePath ) {
  67. extrudePts = extrudePath.getSpacedPoints( steps );
  68. extrudeByPath = true;
  69. bevelEnabled = false; // bevels not supported for path extrusion
  70. // SETUP TNB variables
  71. // TODO1 - have a .isClosed in spline?
  72. splineTube = extrudePath.computeFrenetFrames( steps, false );
  73. // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
  74. binormal = new Vector3();
  75. normal = new Vector3();
  76. position2 = new Vector3();
  77. }
  78. // Safeguards if bevels are not enabled
  79. if ( ! bevelEnabled ) {
  80. bevelSegments = 0;
  81. bevelThickness = 0;
  82. bevelSize = 0;
  83. bevelOffset = 0;
  84. }
  85. // Variables initialization
  86. const shapePoints = shape.extractPoints( curveSegments );
  87. let vertices = shapePoints.shape;
  88. const holes = shapePoints.holes;
  89. const reverse = ! ShapeUtils.isClockWise( vertices );
  90. if ( reverse ) {
  91. vertices = vertices.reverse();
  92. // Maybe we should also check if holes are in the opposite direction, just to be safe ...
  93. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  94. const ahole = holes[ h ];
  95. if ( ShapeUtils.isClockWise( ahole ) ) {
  96. holes[ h ] = ahole.reverse();
  97. }
  98. }
  99. }
  100. const faces = ShapeUtils.triangulateShape( vertices, holes );
  101. /* Vertices */
  102. const contour = vertices; // vertices has all points but contour has only points of circumference
  103. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  104. const ahole = holes[ h ];
  105. vertices = vertices.concat( ahole );
  106. }
  107. function scalePt2( pt, vec, size ) {
  108. if ( ! vec ) console.error( 'THREE.ExtrudeGeometry: vec does not exist' );
  109. return pt.clone().addScaledVector( vec, size );
  110. }
  111. const vlen = vertices.length, flen = faces.length;
  112. // Find directions for point movement
  113. function getBevelVec( inPt, inPrev, inNext ) {
  114. // computes for inPt the corresponding point inPt' on a new contour
  115. // shifted by 1 unit (length of normalized vector) to the left
  116. // if we walk along contour clockwise, this new contour is outside the old one
  117. //
  118. // inPt' is the intersection of the two lines parallel to the two
  119. // adjacent edges of inPt at a distance of 1 unit on the left side.
  120. let v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt
  121. // good reading for geometry algorithms (here: line-line intersection)
  122. // http://geomalgorithms.com/a05-_intersect-1.html
  123. const v_prev_x = inPt.x - inPrev.x,
  124. v_prev_y = inPt.y - inPrev.y;
  125. const v_next_x = inNext.x - inPt.x,
  126. v_next_y = inNext.y - inPt.y;
  127. const v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y );
  128. // check for collinear edges
  129. const collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
  130. if ( Math.abs( collinear0 ) > Number.EPSILON ) {
  131. // not collinear
  132. // length of vectors for normalizing
  133. const v_prev_len = Math.sqrt( v_prev_lensq );
  134. const v_next_len = Math.sqrt( v_next_x * v_next_x + v_next_y * v_next_y );
  135. // shift adjacent points by unit vectors to the left
  136. const ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len );
  137. const ptPrevShift_y = ( inPrev.y + v_prev_x / v_prev_len );
  138. const ptNextShift_x = ( inNext.x - v_next_y / v_next_len );
  139. const ptNextShift_y = ( inNext.y + v_next_x / v_next_len );
  140. // scaling factor for v_prev to intersection point
  141. const sf = ( ( ptNextShift_x - ptPrevShift_x ) * v_next_y -
  142. ( ptNextShift_y - ptPrevShift_y ) * v_next_x ) /
  143. ( v_prev_x * v_next_y - v_prev_y * v_next_x );
  144. // vector from inPt to intersection point
  145. v_trans_x = ( ptPrevShift_x + v_prev_x * sf - inPt.x );
  146. v_trans_y = ( ptPrevShift_y + v_prev_y * sf - inPt.y );
  147. // Don't normalize!, otherwise sharp corners become ugly
  148. // but prevent crazy spikes
  149. const v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y );
  150. if ( v_trans_lensq <= 2 ) {
  151. return new Vector2( v_trans_x, v_trans_y );
  152. } else {
  153. shrink_by = Math.sqrt( v_trans_lensq / 2 );
  154. }
  155. } else {
  156. // handle special case of collinear edges
  157. let direction_eq = false; // assumes: opposite
  158. if ( v_prev_x > Number.EPSILON ) {
  159. if ( v_next_x > Number.EPSILON ) {
  160. direction_eq = true;
  161. }
  162. } else {
  163. if ( v_prev_x < - Number.EPSILON ) {
  164. if ( v_next_x < - Number.EPSILON ) {
  165. direction_eq = true;
  166. }
  167. } else {
  168. if ( Math.sign( v_prev_y ) === Math.sign( v_next_y ) ) {
  169. direction_eq = true;
  170. }
  171. }
  172. }
  173. if ( direction_eq ) {
  174. // console.log("Warning: lines are a straight sequence");
  175. v_trans_x = - v_prev_y;
  176. v_trans_y = v_prev_x;
  177. shrink_by = Math.sqrt( v_prev_lensq );
  178. } else {
  179. // console.log("Warning: lines are a straight spike");
  180. v_trans_x = v_prev_x;
  181. v_trans_y = v_prev_y;
  182. shrink_by = Math.sqrt( v_prev_lensq / 2 );
  183. }
  184. }
  185. return new Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by );
  186. }
  187. const contourMovements = [];
  188. for ( let i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
  189. if ( j === il ) j = 0;
  190. if ( k === il ) k = 0;
  191. // (j)---(i)---(k)
  192. // console.log('i,j,k', i, j , k)
  193. contourMovements[ i ] = getBevelVec( contour[ i ], contour[ j ], contour[ k ] );
  194. }
  195. const holesMovements = [];
  196. let oneHoleMovements, verticesMovements = contourMovements.concat();
  197. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  198. const ahole = holes[ h ];
  199. oneHoleMovements = [];
  200. for ( let i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
  201. if ( j === il ) j = 0;
  202. if ( k === il ) k = 0;
  203. // (j)---(i)---(k)
  204. oneHoleMovements[ i ] = getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] );
  205. }
  206. holesMovements.push( oneHoleMovements );
  207. verticesMovements = verticesMovements.concat( oneHoleMovements );
  208. }
  209. // Loop bevelSegments, 1 for the front, 1 for the back
  210. for ( let b = 0; b < bevelSegments; b ++ ) {
  211. //for ( b = bevelSegments; b > 0; b -- ) {
  212. const t = b / bevelSegments;
  213. const z = bevelThickness * Math.cos( t * Math.PI / 2 );
  214. const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
  215. // contract shape
  216. for ( let i = 0, il = contour.length; i < il; i ++ ) {
  217. const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
  218. v( vert.x, vert.y, - z );
  219. }
  220. // expand holes
  221. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  222. const ahole = holes[ h ];
  223. oneHoleMovements = holesMovements[ h ];
  224. for ( let i = 0, il = ahole.length; i < il; i ++ ) {
  225. const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
  226. v( vert.x, vert.y, - z );
  227. }
  228. }
  229. }
  230. const bs = bevelSize + bevelOffset;
  231. // Back facing vertices
  232. for ( let i = 0; i < vlen; i ++ ) {
  233. const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
  234. if ( ! extrudeByPath ) {
  235. v( vert.x, vert.y, 0 );
  236. } else {
  237. // v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x );
  238. normal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x );
  239. binormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y );
  240. position2.copy( extrudePts[ 0 ] ).add( normal ).add( binormal );
  241. v( position2.x, position2.y, position2.z );
  242. }
  243. }
  244. // Add stepped vertices...
  245. // Including front facing vertices
  246. for ( let s = 1; s <= steps; s ++ ) {
  247. for ( let i = 0; i < vlen; i ++ ) {
  248. const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
  249. if ( ! extrudeByPath ) {
  250. v( vert.x, vert.y, depth / steps * s );
  251. } else {
  252. // v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x );
  253. normal.copy( splineTube.normals[ s ] ).multiplyScalar( vert.x );
  254. binormal.copy( splineTube.binormals[ s ] ).multiplyScalar( vert.y );
  255. position2.copy( extrudePts[ s ] ).add( normal ).add( binormal );
  256. v( position2.x, position2.y, position2.z );
  257. }
  258. }
  259. }
  260. // Add bevel segments planes
  261. //for ( b = 1; b <= bevelSegments; b ++ ) {
  262. for ( let b = bevelSegments - 1; b >= 0; b -- ) {
  263. const t = b / bevelSegments;
  264. const z = bevelThickness * Math.cos( t * Math.PI / 2 );
  265. const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
  266. // contract shape
  267. for ( let i = 0, il = contour.length; i < il; i ++ ) {
  268. const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
  269. v( vert.x, vert.y, depth + z );
  270. }
  271. // expand holes
  272. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  273. const ahole = holes[ h ];
  274. oneHoleMovements = holesMovements[ h ];
  275. for ( let i = 0, il = ahole.length; i < il; i ++ ) {
  276. const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
  277. if ( ! extrudeByPath ) {
  278. v( vert.x, vert.y, depth + z );
  279. } else {
  280. v( vert.x, vert.y + extrudePts[ steps - 1 ].y, extrudePts[ steps - 1 ].x + z );
  281. }
  282. }
  283. }
  284. }
  285. /* Faces */
  286. // Top and bottom faces
  287. buildLidFaces();
  288. // Sides faces
  289. buildSideFaces();
  290. ///// Internal functions
  291. function buildLidFaces() {
  292. const start = verticesArray.length / 3;
  293. if ( bevelEnabled ) {
  294. let layer = 0; // steps + 1
  295. let offset = vlen * layer;
  296. // Bottom faces
  297. for ( let i = 0; i < flen; i ++ ) {
  298. const face = faces[ i ];
  299. f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );
  300. }
  301. layer = steps + bevelSegments * 2;
  302. offset = vlen * layer;
  303. // Top faces
  304. for ( let i = 0; i < flen; i ++ ) {
  305. const face = faces[ i ];
  306. f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );
  307. }
  308. } else {
  309. // Bottom faces
  310. for ( let i = 0; i < flen; i ++ ) {
  311. const face = faces[ i ];
  312. f3( face[ 2 ], face[ 1 ], face[ 0 ] );
  313. }
  314. // Top faces
  315. for ( let i = 0; i < flen; i ++ ) {
  316. const face = faces[ i ];
  317. f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );
  318. }
  319. }
  320. scope.addGroup( start, verticesArray.length / 3 - start, 0 );
  321. }
  322. // Create faces for the z-sides of the shape
  323. function buildSideFaces() {
  324. const start = verticesArray.length / 3;
  325. let layeroffset = 0;
  326. sidewalls( contour, layeroffset );
  327. layeroffset += contour.length;
  328. for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
  329. const ahole = holes[ h ];
  330. sidewalls( ahole, layeroffset );
  331. //, true
  332. layeroffset += ahole.length;
  333. }
  334. scope.addGroup( start, verticesArray.length / 3 - start, 1 );
  335. }
  336. function sidewalls( contour, layeroffset ) {
  337. let i = contour.length;
  338. while ( -- i >= 0 ) {
  339. const j = i;
  340. let k = i - 1;
  341. if ( k < 0 ) k = contour.length - 1;
  342. //console.log('b', i,j, i-1, k,vertices.length);
  343. for ( let s = 0, sl = ( steps + bevelSegments * 2 ); s < sl; s ++ ) {
  344. const slen1 = vlen * s;
  345. const slen2 = vlen * ( s + 1 );
  346. const a = layeroffset + j + slen1,
  347. b = layeroffset + k + slen1,
  348. c = layeroffset + k + slen2,
  349. d = layeroffset + j + slen2;
  350. f4( a, b, c, d );
  351. }
  352. }
  353. }
  354. function v( x, y, z ) {
  355. placeholder.push( x );
  356. placeholder.push( y );
  357. placeholder.push( z );
  358. }
  359. function f3( a, b, c ) {
  360. addVertex( a );
  361. addVertex( b );
  362. addVertex( c );
  363. const nextIndex = verticesArray.length / 3;
  364. const uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
  365. addUV( uvs[ 0 ] );
  366. addUV( uvs[ 1 ] );
  367. addUV( uvs[ 2 ] );
  368. }
  369. function f4( a, b, c, d ) {
  370. addVertex( a );
  371. addVertex( b );
  372. addVertex( d );
  373. addVertex( b );
  374. addVertex( c );
  375. addVertex( d );
  376. const nextIndex = verticesArray.length / 3;
  377. const uvs = uvgen.generateSideWallUV( scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
  378. addUV( uvs[ 0 ] );
  379. addUV( uvs[ 1 ] );
  380. addUV( uvs[ 3 ] );
  381. addUV( uvs[ 1 ] );
  382. addUV( uvs[ 2 ] );
  383. addUV( uvs[ 3 ] );
  384. }
  385. function addVertex( index ) {
  386. verticesArray.push( placeholder[ index * 3 + 0 ] );
  387. verticesArray.push( placeholder[ index * 3 + 1 ] );
  388. verticesArray.push( placeholder[ index * 3 + 2 ] );
  389. }
  390. function addUV( vector2 ) {
  391. uvArray.push( vector2.x );
  392. uvArray.push( vector2.y );
  393. }
  394. }
  395. }
  396. copy( source ) {
  397. super.copy( source );
  398. this.parameters = Object.assign( {}, source.parameters );
  399. return this;
  400. }
  401. toJSON() {
  402. const data = super.toJSON();
  403. const shapes = this.parameters.shapes;
  404. const options = this.parameters.options;
  405. return toJSON( shapes, options, data );
  406. }
  407. static fromJSON( data, shapes ) {
  408. const geometryShapes = [];
  409. for ( let j = 0, jl = data.shapes.length; j < jl; j ++ ) {
  410. const shape = shapes[ data.shapes[ j ] ];
  411. geometryShapes.push( shape );
  412. }
  413. const extrudePath = data.options.extrudePath;
  414. if ( extrudePath !== undefined ) {
  415. data.options.extrudePath = new Curves[ extrudePath.type ]().fromJSON( extrudePath );
  416. }
  417. return new ExtrudeGeometry( geometryShapes, data.options );
  418. }
  419. }
  420. const WorldUVGenerator = {
  421. generateTopUV: function ( geometry, vertices, indexA, indexB, indexC ) {
  422. const a_x = vertices[ indexA * 3 ];
  423. const a_y = vertices[ indexA * 3 + 1 ];
  424. const b_x = vertices[ indexB * 3 ];
  425. const b_y = vertices[ indexB * 3 + 1 ];
  426. const c_x = vertices[ indexC * 3 ];
  427. const c_y = vertices[ indexC * 3 + 1 ];
  428. return [
  429. new Vector2( a_x, a_y ),
  430. new Vector2( b_x, b_y ),
  431. new Vector2( c_x, c_y )
  432. ];
  433. },
  434. generateSideWallUV: function ( geometry, vertices, indexA, indexB, indexC, indexD ) {
  435. const a_x = vertices[ indexA * 3 ];
  436. const a_y = vertices[ indexA * 3 + 1 ];
  437. const a_z = vertices[ indexA * 3 + 2 ];
  438. const b_x = vertices[ indexB * 3 ];
  439. const b_y = vertices[ indexB * 3 + 1 ];
  440. const b_z = vertices[ indexB * 3 + 2 ];
  441. const c_x = vertices[ indexC * 3 ];
  442. const c_y = vertices[ indexC * 3 + 1 ];
  443. const c_z = vertices[ indexC * 3 + 2 ];
  444. const d_x = vertices[ indexD * 3 ];
  445. const d_y = vertices[ indexD * 3 + 1 ];
  446. const d_z = vertices[ indexD * 3 + 2 ];
  447. if ( Math.abs( a_y - b_y ) < Math.abs( a_x - b_x ) ) {
  448. return [
  449. new Vector2( a_x, 1 - a_z ),
  450. new Vector2( b_x, 1 - b_z ),
  451. new Vector2( c_x, 1 - c_z ),
  452. new Vector2( d_x, 1 - d_z )
  453. ];
  454. } else {
  455. return [
  456. new Vector2( a_y, 1 - a_z ),
  457. new Vector2( b_y, 1 - b_z ),
  458. new Vector2( c_y, 1 - c_z ),
  459. new Vector2( d_y, 1 - d_z )
  460. ];
  461. }
  462. }
  463. };
  464. function toJSON( shapes, options, data ) {
  465. data.shapes = [];
  466. if ( Array.isArray( shapes ) ) {
  467. for ( let i = 0, l = shapes.length; i < l; i ++ ) {
  468. const shape = shapes[ i ];
  469. data.shapes.push( shape.uuid );
  470. }
  471. } else {
  472. data.shapes.push( shapes.uuid );
  473. }
  474. data.options = Object.assign( {}, options );
  475. if ( options.extrudePath !== undefined ) data.options.extrudePath = options.extrudePath.toJSON();
  476. return data;
  477. }
  478. export { ExtrudeGeometry };