poly-extrude 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/cylinder.d.ts +11 -0
  2. package/{src → dist}/cylinder.js +108 -111
  3. package/dist/cylinder.js.map +1 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +8 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/math/Curve.d.ts +41 -0
  8. package/dist/math/Curve.js +142 -0
  9. package/dist/math/Curve.js.map +1 -0
  10. package/dist/math/Interpolations.d.ts +8 -0
  11. package/dist/math/Interpolations.js +48 -0
  12. package/dist/math/Interpolations.js.map +1 -0
  13. package/dist/math/Matrix4.d.ts +8 -0
  14. package/dist/math/Matrix4.js +582 -0
  15. package/dist/math/Matrix4.js.map +1 -0
  16. package/dist/math/QuadraticBezierCurve3.d.ts +10 -0
  17. package/dist/math/QuadraticBezierCurve3.js +22 -0
  18. package/dist/math/QuadraticBezierCurve3.js.map +1 -0
  19. package/dist/math/Quaternion.d.ts +46 -0
  20. package/dist/math/Quaternion.js +415 -0
  21. package/dist/math/Quaternion.js.map +1 -0
  22. package/dist/math/Vector3.d.ts +42 -0
  23. package/dist/math/Vector3.js +403 -0
  24. package/dist/math/Vector3.js.map +1 -0
  25. package/dist/path/PathPoint.d.ts +15 -0
  26. package/dist/path/PathPoint.js +35 -0
  27. package/dist/path/PathPoint.js.map +1 -0
  28. package/dist/path/PathPointList.d.ts +27 -0
  29. package/dist/path/PathPointList.js +212 -0
  30. package/dist/path/PathPointList.js.map +1 -0
  31. package/dist/path.d.ts +11 -0
  32. package/{src → dist}/path.js +334 -360
  33. package/dist/path.js.map +1 -0
  34. package/dist/plane.d.ts +2 -0
  35. package/{src → dist}/plane.js +57 -58
  36. package/dist/plane.js.map +1 -0
  37. package/dist/poly-extrude.js +1286 -1581
  38. package/dist/poly-extrude.js.map +1 -1
  39. package/dist/poly-extrude.min.js +2 -2
  40. package/dist/poly-extrude.mjs +1286 -1581
  41. package/dist/poly-extrude.mjs.map +1 -0
  42. package/dist/polygon.d.ts +9 -0
  43. package/{src → dist}/polygon.js +163 -179
  44. package/dist/polygon.js.map +1 -0
  45. package/dist/polyline.d.ts +24 -0
  46. package/{src → dist}/polyline.js +420 -456
  47. package/dist/polyline.js.map +1 -0
  48. package/dist/tube.d.ts +12 -0
  49. package/{src → dist}/tube.js +124 -142
  50. package/dist/tube.js.map +1 -0
  51. package/dist/type.d.ts +9 -0
  52. package/dist/type.js +2 -0
  53. package/dist/type.js.map +1 -0
  54. package/dist/util.d.ts +20 -0
  55. package/dist/util.js +217 -0
  56. package/dist/util.js.map +1 -0
  57. package/package.json +53 -48
  58. package/readme.md +12 -2
  59. package/src/cylinder.ts +124 -0
  60. package/src/index.ts +7 -0
  61. package/src/path.ts +385 -0
  62. package/src/plane.ts +60 -0
  63. package/src/polygon.ts +189 -0
  64. package/src/polyline.ts +473 -0
  65. package/src/tube.ts +155 -0
  66. package/src/type.ts +9 -0
  67. package/src/{util.js → util.ts} +1 -1
  68. package/index.js +0 -7
@@ -1,360 +1,334 @@
1
- import { Vector3 } from './math/Vector3';
2
- import { PathPoint } from './path/PathPoint';
3
- import { PathPointList } from './path/PathPointList';
4
- import { line2Vectors, merge } from './util';
5
- const UP = new Vector3(0, 0, 1);
6
-
7
- const right = new Vector3();
8
- const left = new Vector3();
9
-
10
- // for sharp corners
11
- const leftOffset = new Vector3();
12
- const rightOffset = new Vector3();
13
- const tempPoint1 = new Vector3();
14
- const tempPoint2 = new Vector3();
15
-
16
- export function expandPaths(lines, options) {
17
- options = Object.assign({}, { lineWidth: 1, cornerRadius: 0, cornerSplit: 10 }, options);
18
- const results = lines.map(line => {
19
- const points = line2Vectors(line);
20
- const pathPointList = new PathPointList();
21
- pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
22
- const result = generatePathVertexData(pathPointList, options);
23
- result.line = line;
24
- result.position = new Float32Array(result.position);
25
- result.indices = new Uint32Array(result.indices);
26
- result.uv = new Float32Array(result.uv);
27
- result.normal = new Float32Array(result.normal);
28
- return result;
29
- });
30
- const result = merge(results);
31
- result.lines = lines;
32
- return result;
33
- }
34
-
35
- // Vertex Data Generate Functions
36
- // code copy from https://github.com/shawn0326/three.path/blob/master/src/PathGeometry.js
37
- function generatePathVertexData(pathPointList, options) {
38
- const width = options.lineWidth || 0.1;
39
- const progress = 1;
40
- const side = 'both';
41
-
42
- const halfWidth = width / 2;
43
- const sideWidth = (side !== 'both' ? width / 2 : width);
44
- const totalDistance = pathPointList.distance();
45
- const progressDistance = progress * totalDistance;
46
- if (totalDistance === 0) {
47
- return null;
48
- }
49
-
50
- const sharpUvOffset = halfWidth / sideWidth;
51
- // const sharpUvOffset2 = halfWidth / totalDistance;
52
-
53
- let count = 0;
54
-
55
- // modify data
56
- const position = [];
57
- const normal = [];
58
- const uv = [];
59
- const indices = [];
60
- let verticesCount = 0;
61
-
62
- let pIndex = position.length - 1;
63
- let nIndex = normal.length - 1;
64
- let uIndex = uv.length - 1;
65
- let iIndex = indices.length - 1;
66
- function addVertices(pathPoint) {
67
- const first = position.length === 0;
68
- const sharpCorner = pathPoint.sharp && !first;
69
-
70
- const uvDist = pathPoint.dist / sideWidth;
71
- // const uvDist2 = pathPoint.dist / totalDistance;
72
-
73
- const dir = pathPoint.dir;
74
- const up = pathPoint.up;
75
- const _right = pathPoint.right;
76
-
77
- if (side !== 'left') {
78
- right.copy(_right).multiplyScalar(halfWidth * pathPoint.widthScale);
79
- } else {
80
- right.set(0, 0, 0);
81
- }
82
-
83
- if (side !== 'right') {
84
- left.copy(_right).multiplyScalar(-halfWidth * pathPoint.widthScale);
85
- } else {
86
- left.set(0, 0, 0);
87
- }
88
-
89
- right.add(pathPoint.pos);
90
- left.add(pathPoint.pos);
91
-
92
- if (sharpCorner) {
93
- leftOffset.fromArray(position, position.length - 6).sub(left);
94
- rightOffset.fromArray(position, position.length - 3).sub(right);
95
-
96
- const leftDist = leftOffset.length();
97
- const rightDist = rightOffset.length();
98
-
99
- const sideOffset = leftDist - rightDist;
100
- let longerOffset, longEdge;
101
-
102
- if (sideOffset > 0) {
103
- longerOffset = leftOffset;
104
- longEdge = left;
105
- } else {
106
- longerOffset = rightOffset;
107
- longEdge = right;
108
- }
109
-
110
- tempPoint1.copy(longerOffset).setLength(Math.abs(sideOffset)).add(longEdge);
111
-
112
- // eslint-disable-next-line prefer-const
113
- let _cos = tempPoint2.copy(longEdge).sub(tempPoint1).normalize().dot(dir);
114
- // eslint-disable-next-line prefer-const
115
- let _len = tempPoint2.copy(longEdge).sub(tempPoint1).length();
116
- // eslint-disable-next-line prefer-const
117
- let _dist = _cos * _len * 2;
118
-
119
- tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
120
-
121
- if (sideOffset > 0) {
122
- position[++pIndex] = tempPoint1.x;
123
- position[++pIndex] = tempPoint1.y;
124
- position[++pIndex] = tempPoint1.z;
125
- position[++pIndex] = right.x;
126
- position[++pIndex] = right.y;
127
- position[++pIndex] = right.z;
128
- position[++pIndex] = left.x;
129
- position[++pIndex] = left.y;
130
- position[++pIndex] = left.z;
131
- position[++pIndex] = right.x;
132
- position[++pIndex] = right.y;
133
- position[++pIndex] = right.z;
134
- position[++pIndex] = tempPoint2.x;
135
- position[++pIndex] = tempPoint2.y;
136
- position[++pIndex] = tempPoint2.z;
137
- position[++pIndex] = right.x;
138
- position[++pIndex] = right.y;
139
- position[++pIndex] = right.z;
140
- // position.push(
141
- // tempPoint1.x, tempPoint1.y, tempPoint1.z, // 6
142
- // right.x, right.y, right.z, // 5
143
- // left.x, left.y, left.z, // 4
144
- // right.x, right.y, right.z, // 3
145
- // tempPoint2.x, tempPoint2.y, tempPoint2.z, // 2
146
- // right.x, right.y, right.z // 1
147
- // );
148
-
149
- verticesCount += 6;
150
-
151
- indices[++iIndex] = verticesCount - 6;
152
- indices[++iIndex] = verticesCount - 8;
153
- indices[++iIndex] = verticesCount - 7;
154
- indices[++iIndex] = verticesCount - 6;
155
- indices[++iIndex] = verticesCount - 7;
156
- indices[++iIndex] = verticesCount - 5;
157
- indices[++iIndex] = verticesCount - 4;
158
- indices[++iIndex] = verticesCount - 6;
159
- indices[++iIndex] = verticesCount - 5;
160
- indices[++iIndex] = verticesCount - 2;
161
- indices[++iIndex] = verticesCount - 4;
162
- indices[++iIndex] = verticesCount - 1;
163
-
164
- // indices.push(
165
- // verticesCount - 6, verticesCount - 8, verticesCount - 7,
166
- // verticesCount - 6, verticesCount - 7, verticesCount - 5,
167
-
168
- // verticesCount - 4, verticesCount - 6, verticesCount - 5,
169
- // verticesCount - 2, verticesCount - 4, verticesCount - 1
170
- // );
171
-
172
- count += 12;
173
- } else {
174
- position[++pIndex] = left.x;
175
- position[++pIndex] = left.y;
176
- position[++pIndex] = left.z;
177
- position[++pIndex] = tempPoint1.x;
178
- position[++pIndex] = tempPoint1.y;
179
- position[++pIndex] = tempPoint1.z;
180
- position[++pIndex] = left.x;
181
- position[++pIndex] = left.y;
182
- position[++pIndex] = left.z;
183
- position[++pIndex] = right.x;
184
- position[++pIndex] = right.y;
185
- position[++pIndex] = right.z;
186
- position[++pIndex] = left.x;
187
- position[++pIndex] = left.y;
188
- position[++pIndex] = left.z;
189
- position[++pIndex] = tempPoint2.x;
190
- position[++pIndex] = tempPoint2.y;
191
- position[++pIndex] = tempPoint2.z;
192
- // position.push(
193
- // left.x, left.y, left.z, // 6
194
- // tempPoint1.x, tempPoint1.y, tempPoint1.z, // 5
195
- // left.x, left.y, left.z, // 4
196
- // right.x, right.y, right.z, // 3
197
- // left.x, left.y, left.z, // 2
198
- // tempPoint2.x, tempPoint2.y, tempPoint2.z // 1
199
- // );
200
-
201
- verticesCount += 6;
202
- indices[++iIndex] = verticesCount - 6;
203
- indices[++iIndex] = verticesCount - 8;
204
- indices[++iIndex] = verticesCount - 7;
205
- indices[++iIndex] = verticesCount - 6;
206
- indices[++iIndex] = verticesCount - 7;
207
- indices[++iIndex] = verticesCount - 5;
208
- indices[++iIndex] = verticesCount - 6;
209
- indices[++iIndex] = verticesCount - 5;
210
- indices[++iIndex] = verticesCount - 3;
211
- indices[++iIndex] = verticesCount - 2;
212
- indices[++iIndex] = verticesCount - 3;
213
- indices[++iIndex] = verticesCount - 1;
214
-
215
- // indices.push(
216
- // verticesCount - 6, verticesCount - 8, verticesCount - 7,
217
- // verticesCount - 6, verticesCount - 7, verticesCount - 5,
218
-
219
- // verticesCount - 6, verticesCount - 5, verticesCount - 3,
220
- // verticesCount - 2, verticesCount - 3, verticesCount - 1
221
- // );
222
-
223
- count += 12;
224
- }
225
- for (let i = 0; i < 6; i++) {
226
- normal[++nIndex] = up.x;
227
- normal[++nIndex] = up.y;
228
- normal[++nIndex] = up.z;
229
- }
230
-
231
- // normal.push(
232
- // up.x, up.y, up.z,
233
- // up.x, up.y, up.z,
234
- // up.x, up.y, up.z,
235
- // up.x, up.y, up.z,
236
- // up.x, up.y, up.z,
237
- // up.x, up.y, up.z
238
- // );
239
-
240
- uv[++uIndex] = uvDist - sharpUvOffset;
241
- uv[++uIndex] = 0;
242
- uv[++uIndex] = uvDist - sharpUvOffset;
243
- uv[++uIndex] = 1;
244
- uv[++uIndex] = uvDist;
245
- uv[++uIndex] = 0;
246
- uv[++uIndex] = uvDist;
247
- uv[++uIndex] = 1;
248
- uv[++uIndex] = uvDist + sharpUvOffset;
249
- uv[++uIndex] = 0;
250
- uv[++uIndex] = uvDist + sharpUvOffset;
251
- uv[++uIndex] = 1;
252
- // uv.push(
253
- // uvDist - sharpUvOffset, 0,
254
- // uvDist - sharpUvOffset, 1,
255
- // uvDist, 0,
256
- // uvDist, 1,
257
- // uvDist + sharpUvOffset, 0,
258
- // uvDist + sharpUvOffset, 1
259
- // );
260
-
261
- // if (generateUv2) {
262
- // uv2.push(
263
- // uvDist2 - sharpUvOffset2, 0,
264
- // uvDist2 - sharpUvOffset2, 1,
265
- // uvDist2, 0,
266
- // uvDist2, 1,
267
- // uvDist2 + sharpUvOffset2, 0,
268
- // uvDist2 + sharpUvOffset2, 1
269
- // );
270
- // }
271
- } else {
272
- position[++pIndex] = left.x;
273
- position[++pIndex] = left.y;
274
- position[++pIndex] = left.z;
275
- position[++pIndex] = right.x;
276
- position[++pIndex] = right.y;
277
- position[++pIndex] = right.z;
278
- // position.push(
279
- // left.x, left.y, left.z,
280
- // right.x, right.y, right.z
281
- // );
282
-
283
- normal[++nIndex] = up.x;
284
- normal[++nIndex] = up.y;
285
- normal[++nIndex] = up.z;
286
- normal[++nIndex] = up.x;
287
- normal[++nIndex] = up.y;
288
- normal[++nIndex] = up.z;
289
- // normal.push(
290
- // up.x, up.y, up.z,
291
- // up.x, up.y, up.z
292
- // );
293
-
294
- uv[++uIndex] = uvDist;
295
- uv[++uIndex] = 0;
296
- uv[++uIndex] = uvDist;
297
- uv[++uIndex] = 1;
298
- // uv.push(
299
- // uvDist, 0,
300
- // uvDist, 1
301
- // );
302
-
303
- // if (generateUv2) {
304
- // uv2.push(
305
- // uvDist2, 0,
306
- // uvDist2, 1
307
- // );
308
- // }
309
-
310
- verticesCount += 2;
311
-
312
- if (!first) {
313
- indices[++iIndex] = verticesCount - 2;
314
- indices[++iIndex] = verticesCount - 4;
315
- indices[++iIndex] = verticesCount - 3;
316
- indices[++iIndex] = verticesCount - 2;
317
- indices[++iIndex] = verticesCount - 3;
318
- indices[++iIndex] = verticesCount - 1;
319
- // indices.push(
320
- // verticesCount - 2, verticesCount - 4, verticesCount - 3,
321
- // verticesCount - 2, verticesCount - 3, verticesCount - 1
322
- // );
323
-
324
- count += 6;
325
- }
326
- }
327
- }
328
-
329
- let lastPoint;
330
-
331
- if (progressDistance > 0) {
332
- for (let i = 0; i < pathPointList.count; i++) {
333
- const pathPoint = pathPointList.array[i];
334
-
335
- if (pathPoint.dist > progressDistance) {
336
- const prevPoint = pathPointList.array[i - 1];
337
- lastPoint = new PathPoint();
338
-
339
- // linear lerp for progress
340
- const alpha = (progressDistance - prevPoint.dist) / (pathPoint.dist - prevPoint.dist);
341
- lastPoint.lerpPathPoints(prevPoint, pathPoint, alpha);
342
-
343
- addVertices(lastPoint);
344
- break;
345
- } else {
346
- addVertices(pathPoint);
347
- }
348
- }
349
- } else {
350
- lastPoint = pathPointList.array[0];
351
- }
352
-
353
- return {
354
- position: position,
355
- normal,
356
- uv: uv,
357
- indices: indices,
358
- count
359
- };
360
- }
1
+ import { Vector3 } from './math/Vector3';
2
+ import { PathPoint } from './path/PathPoint';
3
+ import { PathPointList } from './path/PathPointList';
4
+ import { line2Vectors, merge } from './util';
5
+ const UP = new Vector3(0, 0, 1);
6
+ const right = new Vector3();
7
+ const left = new Vector3();
8
+ // for sharp corners
9
+ const leftOffset = new Vector3();
10
+ const rightOffset = new Vector3();
11
+ const tempPoint1 = new Vector3();
12
+ const tempPoint2 = new Vector3();
13
+ export function expandPaths(lines, options) {
14
+ options = Object.assign({}, { lineWidth: 1, cornerRadius: 0, cornerSplit: 10 }, options);
15
+ const results = lines.map(line => {
16
+ const points = line2Vectors(line);
17
+ const pathPointList = new PathPointList();
18
+ //@ts-ignore
19
+ pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
20
+ const params = generatePathVertexData(pathPointList, options);
21
+ const result = {
22
+ position: new Float32Array(params.position),
23
+ indices: new Uint32Array(params.indices),
24
+ uv: new Float32Array(params.uv),
25
+ normal: new Float32Array(params.normal),
26
+ line,
27
+ count: params.count
28
+ };
29
+ return result;
30
+ });
31
+ const result = merge(results);
32
+ result.lines = lines;
33
+ return result;
34
+ }
35
+ // Vertex Data Generate Functions
36
+ // code copy from https://github.com/shawn0326/three.path/blob/master/src/PathGeometry.js
37
+ function generatePathVertexData(pathPointList, options) {
38
+ const width = options.lineWidth || 0.1;
39
+ const progress = 1;
40
+ const side = 'both';
41
+ const halfWidth = width / 2;
42
+ const sideWidth = (side !== 'both' ? width / 2 : width);
43
+ const totalDistance = pathPointList.distance();
44
+ const progressDistance = progress * totalDistance;
45
+ let count = 0;
46
+ // modify data
47
+ const position = [];
48
+ const normal = [];
49
+ const uv = [];
50
+ const indices = [];
51
+ let verticesCount = 0;
52
+ if (totalDistance === 0) {
53
+ return {
54
+ position: position,
55
+ normal,
56
+ uv: uv,
57
+ indices: indices,
58
+ count
59
+ };
60
+ }
61
+ const sharpUvOffset = halfWidth / sideWidth;
62
+ // const sharpUvOffset2 = halfWidth / totalDistance;
63
+ let pIndex = position.length - 1;
64
+ let nIndex = normal.length - 1;
65
+ let uIndex = uv.length - 1;
66
+ let iIndex = indices.length - 1;
67
+ function addVertices(pathPoint) {
68
+ const first = position.length === 0;
69
+ const sharpCorner = pathPoint.sharp && !first;
70
+ const uvDist = pathPoint.dist / sideWidth;
71
+ // const uvDist2 = pathPoint.dist / totalDistance;
72
+ const dir = pathPoint.dir;
73
+ const up = pathPoint.up;
74
+ const _right = pathPoint.right;
75
+ //@ts-ignore
76
+ if (side !== 'left') {
77
+ right.copy(_right).multiplyScalar(halfWidth * pathPoint.widthScale);
78
+ }
79
+ else {
80
+ right.set(0, 0, 0);
81
+ }
82
+ //@ts-ignore
83
+ if (side !== 'right') {
84
+ left.copy(_right).multiplyScalar(-halfWidth * pathPoint.widthScale);
85
+ }
86
+ else {
87
+ left.set(0, 0, 0);
88
+ }
89
+ right.add(pathPoint.pos);
90
+ left.add(pathPoint.pos);
91
+ if (sharpCorner) {
92
+ leftOffset.fromArray(position, position.length - 6).sub(left);
93
+ rightOffset.fromArray(position, position.length - 3).sub(right);
94
+ const leftDist = leftOffset.length();
95
+ const rightDist = rightOffset.length();
96
+ const sideOffset = leftDist - rightDist;
97
+ let longerOffset, longEdge;
98
+ if (sideOffset > 0) {
99
+ longerOffset = leftOffset;
100
+ longEdge = left;
101
+ }
102
+ else {
103
+ longerOffset = rightOffset;
104
+ longEdge = right;
105
+ }
106
+ tempPoint1.copy(longerOffset).setLength(Math.abs(sideOffset)).add(longEdge);
107
+ // eslint-disable-next-line prefer-const
108
+ let _cos = tempPoint2.copy(longEdge).sub(tempPoint1).normalize().dot(dir);
109
+ // eslint-disable-next-line prefer-const
110
+ let _len = tempPoint2.copy(longEdge).sub(tempPoint1).length();
111
+ // eslint-disable-next-line prefer-const
112
+ let _dist = _cos * _len * 2;
113
+ tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
114
+ if (sideOffset > 0) {
115
+ position[++pIndex] = tempPoint1.x;
116
+ position[++pIndex] = tempPoint1.y;
117
+ position[++pIndex] = tempPoint1.z;
118
+ position[++pIndex] = right.x;
119
+ position[++pIndex] = right.y;
120
+ position[++pIndex] = right.z;
121
+ position[++pIndex] = left.x;
122
+ position[++pIndex] = left.y;
123
+ position[++pIndex] = left.z;
124
+ position[++pIndex] = right.x;
125
+ position[++pIndex] = right.y;
126
+ position[++pIndex] = right.z;
127
+ position[++pIndex] = tempPoint2.x;
128
+ position[++pIndex] = tempPoint2.y;
129
+ position[++pIndex] = tempPoint2.z;
130
+ position[++pIndex] = right.x;
131
+ position[++pIndex] = right.y;
132
+ position[++pIndex] = right.z;
133
+ // position.push(
134
+ // tempPoint1.x, tempPoint1.y, tempPoint1.z, // 6
135
+ // right.x, right.y, right.z, // 5
136
+ // left.x, left.y, left.z, // 4
137
+ // right.x, right.y, right.z, // 3
138
+ // tempPoint2.x, tempPoint2.y, tempPoint2.z, // 2
139
+ // right.x, right.y, right.z // 1
140
+ // );
141
+ verticesCount += 6;
142
+ indices[++iIndex] = verticesCount - 6;
143
+ indices[++iIndex] = verticesCount - 8;
144
+ indices[++iIndex] = verticesCount - 7;
145
+ indices[++iIndex] = verticesCount - 6;
146
+ indices[++iIndex] = verticesCount - 7;
147
+ indices[++iIndex] = verticesCount - 5;
148
+ indices[++iIndex] = verticesCount - 4;
149
+ indices[++iIndex] = verticesCount - 6;
150
+ indices[++iIndex] = verticesCount - 5;
151
+ indices[++iIndex] = verticesCount - 2;
152
+ indices[++iIndex] = verticesCount - 4;
153
+ indices[++iIndex] = verticesCount - 1;
154
+ // indices.push(
155
+ // verticesCount - 6, verticesCount - 8, verticesCount - 7,
156
+ // verticesCount - 6, verticesCount - 7, verticesCount - 5,
157
+ // verticesCount - 4, verticesCount - 6, verticesCount - 5,
158
+ // verticesCount - 2, verticesCount - 4, verticesCount - 1
159
+ // );
160
+ count += 12;
161
+ }
162
+ else {
163
+ position[++pIndex] = left.x;
164
+ position[++pIndex] = left.y;
165
+ position[++pIndex] = left.z;
166
+ position[++pIndex] = tempPoint1.x;
167
+ position[++pIndex] = tempPoint1.y;
168
+ position[++pIndex] = tempPoint1.z;
169
+ position[++pIndex] = left.x;
170
+ position[++pIndex] = left.y;
171
+ position[++pIndex] = left.z;
172
+ position[++pIndex] = right.x;
173
+ position[++pIndex] = right.y;
174
+ position[++pIndex] = right.z;
175
+ position[++pIndex] = left.x;
176
+ position[++pIndex] = left.y;
177
+ position[++pIndex] = left.z;
178
+ position[++pIndex] = tempPoint2.x;
179
+ position[++pIndex] = tempPoint2.y;
180
+ position[++pIndex] = tempPoint2.z;
181
+ // position.push(
182
+ // left.x, left.y, left.z, // 6
183
+ // tempPoint1.x, tempPoint1.y, tempPoint1.z, // 5
184
+ // left.x, left.y, left.z, // 4
185
+ // right.x, right.y, right.z, // 3
186
+ // left.x, left.y, left.z, // 2
187
+ // tempPoint2.x, tempPoint2.y, tempPoint2.z // 1
188
+ // );
189
+ verticesCount += 6;
190
+ indices[++iIndex] = verticesCount - 6;
191
+ indices[++iIndex] = verticesCount - 8;
192
+ indices[++iIndex] = verticesCount - 7;
193
+ indices[++iIndex] = verticesCount - 6;
194
+ indices[++iIndex] = verticesCount - 7;
195
+ indices[++iIndex] = verticesCount - 5;
196
+ indices[++iIndex] = verticesCount - 6;
197
+ indices[++iIndex] = verticesCount - 5;
198
+ indices[++iIndex] = verticesCount - 3;
199
+ indices[++iIndex] = verticesCount - 2;
200
+ indices[++iIndex] = verticesCount - 3;
201
+ indices[++iIndex] = verticesCount - 1;
202
+ // indices.push(
203
+ // verticesCount - 6, verticesCount - 8, verticesCount - 7,
204
+ // verticesCount - 6, verticesCount - 7, verticesCount - 5,
205
+ // verticesCount - 6, verticesCount - 5, verticesCount - 3,
206
+ // verticesCount - 2, verticesCount - 3, verticesCount - 1
207
+ // );
208
+ count += 12;
209
+ }
210
+ for (let i = 0; i < 6; i++) {
211
+ normal[++nIndex] = up.x;
212
+ normal[++nIndex] = up.y;
213
+ normal[++nIndex] = up.z;
214
+ }
215
+ // normal.push(
216
+ // up.x, up.y, up.z,
217
+ // up.x, up.y, up.z,
218
+ // up.x, up.y, up.z,
219
+ // up.x, up.y, up.z,
220
+ // up.x, up.y, up.z,
221
+ // up.x, up.y, up.z
222
+ // );
223
+ uv[++uIndex] = uvDist - sharpUvOffset;
224
+ uv[++uIndex] = 0;
225
+ uv[++uIndex] = uvDist - sharpUvOffset;
226
+ uv[++uIndex] = 1;
227
+ uv[++uIndex] = uvDist;
228
+ uv[++uIndex] = 0;
229
+ uv[++uIndex] = uvDist;
230
+ uv[++uIndex] = 1;
231
+ uv[++uIndex] = uvDist + sharpUvOffset;
232
+ uv[++uIndex] = 0;
233
+ uv[++uIndex] = uvDist + sharpUvOffset;
234
+ uv[++uIndex] = 1;
235
+ // uv.push(
236
+ // uvDist - sharpUvOffset, 0,
237
+ // uvDist - sharpUvOffset, 1,
238
+ // uvDist, 0,
239
+ // uvDist, 1,
240
+ // uvDist + sharpUvOffset, 0,
241
+ // uvDist + sharpUvOffset, 1
242
+ // );
243
+ // if (generateUv2) {
244
+ // uv2.push(
245
+ // uvDist2 - sharpUvOffset2, 0,
246
+ // uvDist2 - sharpUvOffset2, 1,
247
+ // uvDist2, 0,
248
+ // uvDist2, 1,
249
+ // uvDist2 + sharpUvOffset2, 0,
250
+ // uvDist2 + sharpUvOffset2, 1
251
+ // );
252
+ // }
253
+ }
254
+ else {
255
+ position[++pIndex] = left.x;
256
+ position[++pIndex] = left.y;
257
+ position[++pIndex] = left.z;
258
+ position[++pIndex] = right.x;
259
+ position[++pIndex] = right.y;
260
+ position[++pIndex] = right.z;
261
+ // position.push(
262
+ // left.x, left.y, left.z,
263
+ // right.x, right.y, right.z
264
+ // );
265
+ normal[++nIndex] = up.x;
266
+ normal[++nIndex] = up.y;
267
+ normal[++nIndex] = up.z;
268
+ normal[++nIndex] = up.x;
269
+ normal[++nIndex] = up.y;
270
+ normal[++nIndex] = up.z;
271
+ // normal.push(
272
+ // up.x, up.y, up.z,
273
+ // up.x, up.y, up.z
274
+ // );
275
+ uv[++uIndex] = uvDist;
276
+ uv[++uIndex] = 0;
277
+ uv[++uIndex] = uvDist;
278
+ uv[++uIndex] = 1;
279
+ // uv.push(
280
+ // uvDist, 0,
281
+ // uvDist, 1
282
+ // );
283
+ // if (generateUv2) {
284
+ // uv2.push(
285
+ // uvDist2, 0,
286
+ // uvDist2, 1
287
+ // );
288
+ // }
289
+ verticesCount += 2;
290
+ if (!first) {
291
+ indices[++iIndex] = verticesCount - 2;
292
+ indices[++iIndex] = verticesCount - 4;
293
+ indices[++iIndex] = verticesCount - 3;
294
+ indices[++iIndex] = verticesCount - 2;
295
+ indices[++iIndex] = verticesCount - 3;
296
+ indices[++iIndex] = verticesCount - 1;
297
+ // indices.push(
298
+ // verticesCount - 2, verticesCount - 4, verticesCount - 3,
299
+ // verticesCount - 2, verticesCount - 3, verticesCount - 1
300
+ // );
301
+ count += 6;
302
+ }
303
+ }
304
+ }
305
+ let lastPoint;
306
+ if (progressDistance > 0) {
307
+ for (let i = 0; i < pathPointList.count; i++) {
308
+ const pathPoint = pathPointList.array[i];
309
+ if (pathPoint.dist > progressDistance) {
310
+ const prevPoint = pathPointList.array[i - 1];
311
+ lastPoint = new PathPoint();
312
+ // linear lerp for progress
313
+ const alpha = (progressDistance - prevPoint.dist) / (pathPoint.dist - prevPoint.dist);
314
+ lastPoint.lerpPathPoints(prevPoint, pathPoint, alpha);
315
+ addVertices(lastPoint);
316
+ break;
317
+ }
318
+ else {
319
+ addVertices(pathPoint);
320
+ }
321
+ }
322
+ }
323
+ else {
324
+ lastPoint = pathPointList.array[0];
325
+ }
326
+ return {
327
+ position: position,
328
+ normal,
329
+ uv: uv,
330
+ indices: indices,
331
+ count
332
+ };
333
+ }
334
+ //# sourceMappingURL=path.js.map