poly-extrude 0.13.0 → 0.15.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.
- package/dist/cylinder.d.ts +11 -0
- package/{src → dist}/cylinder.js +108 -111
- package/dist/cylinder.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/math/Curve.d.ts +41 -0
- package/dist/math/Curve.js +142 -0
- package/dist/math/Curve.js.map +1 -0
- package/dist/math/Interpolations.d.ts +8 -0
- package/dist/math/Interpolations.js +48 -0
- package/dist/math/Interpolations.js.map +1 -0
- package/dist/math/Matrix4.d.ts +8 -0
- package/dist/math/Matrix4.js +582 -0
- package/dist/math/Matrix4.js.map +1 -0
- package/dist/math/QuadraticBezierCurve3.d.ts +10 -0
- package/dist/math/QuadraticBezierCurve3.js +22 -0
- package/dist/math/QuadraticBezierCurve3.js.map +1 -0
- package/dist/math/Quaternion.d.ts +46 -0
- package/dist/math/Quaternion.js +415 -0
- package/dist/math/Quaternion.js.map +1 -0
- package/dist/math/Vector3.d.ts +42 -0
- package/dist/math/Vector3.js +403 -0
- package/dist/math/Vector3.js.map +1 -0
- package/dist/path/PathPoint.d.ts +15 -0
- package/dist/path/PathPoint.js +35 -0
- package/dist/path/PathPoint.js.map +1 -0
- package/dist/path/PathPointList.d.ts +27 -0
- package/dist/path/PathPointList.js +212 -0
- package/dist/path/PathPointList.js.map +1 -0
- package/dist/path.d.ts +11 -0
- package/{src → dist}/path.js +334 -360
- package/dist/path.js.map +1 -0
- package/dist/plane.d.ts +2 -0
- package/{src → dist}/plane.js +57 -58
- package/dist/plane.js.map +1 -0
- package/dist/poly-extrude.js +1288 -1581
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +1287 -1582
- package/dist/poly-extrude.mjs.map +1 -0
- package/dist/polygon.d.ts +9 -0
- package/{src → dist}/polygon.js +163 -179
- package/dist/polygon.js.map +1 -0
- package/dist/polyline.d.ts +24 -0
- package/{src → dist}/polyline.js +420 -456
- package/dist/polyline.js.map +1 -0
- package/dist/tube.d.ts +12 -0
- package/{src → dist}/tube.js +124 -142
- package/dist/tube.js.map +1 -0
- package/dist/type.d.ts +9 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/dist/util.d.ts +21 -0
- package/{src → dist}/util.js +217 -242
- package/dist/util.js.map +1 -0
- package/package.json +10 -5
- package/readme.md +12 -2
- package/src/cylinder.ts +124 -0
- package/src/index.ts +13 -0
- package/src/path.ts +385 -0
- package/src/plane.ts +60 -0
- package/src/polygon.ts +189 -0
- package/src/polyline.ts +473 -0
- package/src/tube.ts +155 -0
- package/src/type.ts +9 -0
- package/src/util.ts +243 -0
- package/index.js +0 -7
package/{src → dist}/path.js
RENAMED
@@ -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
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
result
|
32
|
-
|
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
|
43
|
-
const
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
const
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
let
|
64
|
-
let
|
65
|
-
let
|
66
|
-
|
67
|
-
|
68
|
-
const
|
69
|
-
|
70
|
-
const uvDist = pathPoint.dist / sideWidth;
|
71
|
-
// const uvDist2 = pathPoint.dist / totalDistance;
|
72
|
-
|
73
|
-
const
|
74
|
-
const
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
right.set(0, 0, 0);
|
81
|
-
}
|
82
|
-
|
83
|
-
if (side !== 'right') {
|
84
|
-
left.copy(_right).multiplyScalar(-halfWidth * pathPoint.widthScale);
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
right.add(pathPoint.pos);
|
90
|
-
left.add(pathPoint.pos);
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
const
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
longerOffset =
|
104
|
-
longEdge =
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
position[++pIndex] =
|
123
|
-
position[++pIndex] =
|
124
|
-
position[++pIndex] =
|
125
|
-
position[++pIndex] = right.
|
126
|
-
position[++pIndex] = right.
|
127
|
-
position[++pIndex] =
|
128
|
-
position[++pIndex] =
|
129
|
-
position[++pIndex] =
|
130
|
-
position[++pIndex] =
|
131
|
-
position[++pIndex] = right.
|
132
|
-
position[++pIndex] = right.
|
133
|
-
position
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
//
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
verticesCount
|
150
|
-
|
151
|
-
indices[++iIndex] = verticesCount -
|
152
|
-
indices[++iIndex] = verticesCount -
|
153
|
-
indices[++iIndex] = verticesCount -
|
154
|
-
indices
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
position[++pIndex] =
|
175
|
-
position[++pIndex] = left.
|
176
|
-
position[++pIndex] = left.
|
177
|
-
position[++pIndex] =
|
178
|
-
position[++pIndex] =
|
179
|
-
position[++pIndex] =
|
180
|
-
position[++pIndex] =
|
181
|
-
position
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
verticesCount
|
202
|
-
indices
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
//
|
236
|
-
//
|
237
|
-
//
|
238
|
-
//
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
//
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
//
|
262
|
-
//
|
263
|
-
//
|
264
|
-
//
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
//
|
280
|
-
//
|
281
|
-
//
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
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
|