@remotion/svg-3d-engine 4.0.251 → 4.0.252
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/.turbo/turbo-make.log +2 -1
- package/bundle.ts +1 -0
- package/dist/cjs/elements.d.ts +2 -8
- package/dist/cjs/elements.js +6 -22
- package/dist/cjs/extrude-element.d.ts +3 -7
- package/dist/cjs/extrude-element.js +7 -30
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/map-face.d.ts +1 -7
- package/dist/cjs/map-face.js +2 -12
- package/dist/cjs/matrix.d.ts +3 -1
- package/dist/cjs/matrix.js +11 -1
- package/dist/esm/index.mjs +20 -1353
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/elements.ts +7 -35
- package/src/extrude-element.ts +9 -46
- package/src/index.ts +2 -1
- package/src/map-face.ts +0 -21
- package/src/matrix.ts +11 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// src/truthy.ts
|
|
2
|
+
function truthy(value) {
|
|
3
|
+
return Boolean(value);
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// src/matrix.ts
|
|
2
7
|
var stride = function({
|
|
3
8
|
v,
|
|
@@ -44,7 +49,7 @@ var multiplyMatrices = (matrix1, matrix2) => {
|
|
|
44
49
|
return result;
|
|
45
50
|
};
|
|
46
51
|
var reduceMatrices = (matrices) => {
|
|
47
|
-
return matrices.slice().reverse().reduce((acc, cur) => {
|
|
52
|
+
return matrices.filter(truthy).slice().reverse().reduce((acc, cur) => {
|
|
48
53
|
return multiplyMatrices(acc, cur);
|
|
49
54
|
}, identity4());
|
|
50
55
|
};
|
|
@@ -95,6 +100,12 @@ var scaled = function(value) {
|
|
|
95
100
|
const vec = typeof value === "number" ? [value, value, value] : value;
|
|
96
101
|
return stride({ v: vec, m: identity4(), width: 4, offset: 0, colStride: 1 });
|
|
97
102
|
};
|
|
103
|
+
var scaleX = (x) => {
|
|
104
|
+
return scaled([x, 1, 1]);
|
|
105
|
+
};
|
|
106
|
+
var scaleY = (y) => {
|
|
107
|
+
return scaled([1, y, 1]);
|
|
108
|
+
};
|
|
98
109
|
var rotatedUnitSinCos = function(axisVec, sinAngle, cosAngle) {
|
|
99
110
|
const x = axisVec[0];
|
|
100
111
|
const y = axisVec[1];
|
|
@@ -231,1029 +242,7 @@ var serializeThreeDReducedInstruction = (instruction) => {
|
|
|
231
242
|
throw new Error("Unknown instruction type");
|
|
232
243
|
};
|
|
233
244
|
var threeDIntoSvgPath = (instructions) => instructions.map((instruction) => serializeThreeDReducedInstruction(instruction)).join(" ");
|
|
234
|
-
// src/make-id.ts
|
|
235
|
-
var makeId = () => {
|
|
236
|
-
return Math.random().toString().replace(".", "");
|
|
237
|
-
};
|
|
238
|
-
|
|
239
245
|
// ../paths/dist/esm/index.mjs
|
|
240
|
-
var cutLInstruction = ({
|
|
241
|
-
instruction,
|
|
242
|
-
lastPoint,
|
|
243
|
-
progress
|
|
244
|
-
}) => {
|
|
245
|
-
const x = lastPoint.x + (instruction.x - lastPoint.x) * progress;
|
|
246
|
-
const y = lastPoint.y + (instruction.y - lastPoint.y) * progress;
|
|
247
|
-
return {
|
|
248
|
-
type: "L",
|
|
249
|
-
x,
|
|
250
|
-
y
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
function interpolatePoint(pA, pB, factor) {
|
|
254
|
-
return {
|
|
255
|
-
x: pA.x + (pB.x - pA.x) * factor,
|
|
256
|
-
y: pA.y + (pB.y - pA.y) * factor
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function cutCInstruction({
|
|
260
|
-
progress,
|
|
261
|
-
lastPoint,
|
|
262
|
-
instruction
|
|
263
|
-
}) {
|
|
264
|
-
const u = progress;
|
|
265
|
-
const p0 = { x: lastPoint.x, y: lastPoint.y };
|
|
266
|
-
const p1 = { x: instruction.cp1x, y: instruction.cp1y };
|
|
267
|
-
const p2 = { x: instruction.cp2x, y: instruction.cp2y };
|
|
268
|
-
const p3 = { x: instruction.x, y: instruction.y };
|
|
269
|
-
const p01 = interpolatePoint(p0, p1, u);
|
|
270
|
-
const p12 = interpolatePoint(p1, p2, u);
|
|
271
|
-
const p23 = interpolatePoint(p2, p3, u);
|
|
272
|
-
const p012 = interpolatePoint(p01, p12, u);
|
|
273
|
-
const p123 = interpolatePoint(p12, p23, u);
|
|
274
|
-
const p0123 = interpolatePoint(p012, p123, u);
|
|
275
|
-
return {
|
|
276
|
-
type: "C",
|
|
277
|
-
cp1x: p01.x,
|
|
278
|
-
cp1y: p01.y,
|
|
279
|
-
cp2x: p012.x,
|
|
280
|
-
cp2y: p012.y,
|
|
281
|
-
x: p0123.x,
|
|
282
|
-
y: p0123.y
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
var cutInstruction = ({
|
|
286
|
-
instruction,
|
|
287
|
-
lastPoint,
|
|
288
|
-
progress
|
|
289
|
-
}) => {
|
|
290
|
-
if (instruction.type === "M") {
|
|
291
|
-
return instruction;
|
|
292
|
-
}
|
|
293
|
-
if (instruction.type === "L") {
|
|
294
|
-
return cutLInstruction({ instruction, lastPoint, progress });
|
|
295
|
-
}
|
|
296
|
-
if (instruction.type === "C") {
|
|
297
|
-
return cutCInstruction({ instruction, lastPoint, progress });
|
|
298
|
-
}
|
|
299
|
-
if (instruction.type === "Z") {
|
|
300
|
-
return instruction;
|
|
301
|
-
}
|
|
302
|
-
throw new TypeError(`${instruction.type} is not supported.`);
|
|
303
|
-
};
|
|
304
|
-
var tValues = [
|
|
305
|
-
[],
|
|
306
|
-
[],
|
|
307
|
-
[
|
|
308
|
-
-0.5773502691896257,
|
|
309
|
-
0.5773502691896257
|
|
310
|
-
],
|
|
311
|
-
[
|
|
312
|
-
0,
|
|
313
|
-
-0.7745966692414834,
|
|
314
|
-
0.7745966692414834
|
|
315
|
-
],
|
|
316
|
-
[
|
|
317
|
-
-0.33998104358485626,
|
|
318
|
-
0.33998104358485626,
|
|
319
|
-
-0.8611363115940526,
|
|
320
|
-
0.8611363115940526
|
|
321
|
-
],
|
|
322
|
-
[
|
|
323
|
-
0,
|
|
324
|
-
-0.5384693101056831,
|
|
325
|
-
0.5384693101056831,
|
|
326
|
-
-0.906179845938664,
|
|
327
|
-
0.906179845938664
|
|
328
|
-
],
|
|
329
|
-
[
|
|
330
|
-
0.6612093864662645,
|
|
331
|
-
-0.6612093864662645,
|
|
332
|
-
-0.2386191860831969,
|
|
333
|
-
0.2386191860831969,
|
|
334
|
-
-0.932469514203152,
|
|
335
|
-
0.932469514203152
|
|
336
|
-
],
|
|
337
|
-
[
|
|
338
|
-
0,
|
|
339
|
-
0.4058451513773972,
|
|
340
|
-
-0.4058451513773972,
|
|
341
|
-
-0.7415311855993945,
|
|
342
|
-
0.7415311855993945,
|
|
343
|
-
-0.9491079123427585,
|
|
344
|
-
0.9491079123427585
|
|
345
|
-
],
|
|
346
|
-
[
|
|
347
|
-
-0.1834346424956498,
|
|
348
|
-
0.1834346424956498,
|
|
349
|
-
-0.525532409916329,
|
|
350
|
-
0.525532409916329,
|
|
351
|
-
-0.7966664774136267,
|
|
352
|
-
0.7966664774136267,
|
|
353
|
-
-0.9602898564975363,
|
|
354
|
-
0.9602898564975363
|
|
355
|
-
],
|
|
356
|
-
[
|
|
357
|
-
0,
|
|
358
|
-
-0.8360311073266358,
|
|
359
|
-
0.8360311073266358,
|
|
360
|
-
-0.9681602395076261,
|
|
361
|
-
0.9681602395076261,
|
|
362
|
-
-0.3242534234038089,
|
|
363
|
-
0.3242534234038089,
|
|
364
|
-
-0.6133714327005904,
|
|
365
|
-
0.6133714327005904
|
|
366
|
-
],
|
|
367
|
-
[
|
|
368
|
-
-0.14887433898163122,
|
|
369
|
-
0.14887433898163122,
|
|
370
|
-
-0.4333953941292472,
|
|
371
|
-
0.4333953941292472,
|
|
372
|
-
-0.6794095682990244,
|
|
373
|
-
0.6794095682990244,
|
|
374
|
-
-0.8650633666889845,
|
|
375
|
-
0.8650633666889845,
|
|
376
|
-
-0.9739065285171717,
|
|
377
|
-
0.9739065285171717
|
|
378
|
-
],
|
|
379
|
-
[
|
|
380
|
-
0,
|
|
381
|
-
-0.26954315595234496,
|
|
382
|
-
0.26954315595234496,
|
|
383
|
-
-0.5190961292068118,
|
|
384
|
-
0.5190961292068118,
|
|
385
|
-
-0.7301520055740494,
|
|
386
|
-
0.7301520055740494,
|
|
387
|
-
-0.8870625997680953,
|
|
388
|
-
0.8870625997680953,
|
|
389
|
-
-0.978228658146057,
|
|
390
|
-
0.978228658146057
|
|
391
|
-
],
|
|
392
|
-
[
|
|
393
|
-
-0.1252334085114689,
|
|
394
|
-
0.1252334085114689,
|
|
395
|
-
-0.3678314989981802,
|
|
396
|
-
0.3678314989981802,
|
|
397
|
-
-0.5873179542866175,
|
|
398
|
-
0.5873179542866175,
|
|
399
|
-
-0.7699026741943047,
|
|
400
|
-
0.7699026741943047,
|
|
401
|
-
-0.9041172563704749,
|
|
402
|
-
0.9041172563704749,
|
|
403
|
-
-0.9815606342467192,
|
|
404
|
-
0.9815606342467192
|
|
405
|
-
],
|
|
406
|
-
[
|
|
407
|
-
0,
|
|
408
|
-
-0.2304583159551348,
|
|
409
|
-
0.2304583159551348,
|
|
410
|
-
-0.44849275103644687,
|
|
411
|
-
0.44849275103644687,
|
|
412
|
-
-0.6423493394403402,
|
|
413
|
-
0.6423493394403402,
|
|
414
|
-
-0.8015780907333099,
|
|
415
|
-
0.8015780907333099,
|
|
416
|
-
-0.9175983992229779,
|
|
417
|
-
0.9175983992229779,
|
|
418
|
-
-0.9841830547185881,
|
|
419
|
-
0.9841830547185881
|
|
420
|
-
],
|
|
421
|
-
[
|
|
422
|
-
-0.10805494870734367,
|
|
423
|
-
0.10805494870734367,
|
|
424
|
-
-0.31911236892788974,
|
|
425
|
-
0.31911236892788974,
|
|
426
|
-
-0.5152486363581541,
|
|
427
|
-
0.5152486363581541,
|
|
428
|
-
-0.6872929048116855,
|
|
429
|
-
0.6872929048116855,
|
|
430
|
-
-0.827201315069765,
|
|
431
|
-
0.827201315069765,
|
|
432
|
-
-0.9284348836635735,
|
|
433
|
-
0.9284348836635735,
|
|
434
|
-
-0.9862838086968123,
|
|
435
|
-
0.9862838086968123
|
|
436
|
-
],
|
|
437
|
-
[
|
|
438
|
-
0,
|
|
439
|
-
-0.20119409399743451,
|
|
440
|
-
0.20119409399743451,
|
|
441
|
-
-0.3941513470775634,
|
|
442
|
-
0.3941513470775634,
|
|
443
|
-
-0.5709721726085388,
|
|
444
|
-
0.5709721726085388,
|
|
445
|
-
-0.7244177313601701,
|
|
446
|
-
0.7244177313601701,
|
|
447
|
-
-0.8482065834104272,
|
|
448
|
-
0.8482065834104272,
|
|
449
|
-
-0.937273392400706,
|
|
450
|
-
0.937273392400706,
|
|
451
|
-
-0.9879925180204854,
|
|
452
|
-
0.9879925180204854
|
|
453
|
-
],
|
|
454
|
-
[
|
|
455
|
-
-0.09501250983763744,
|
|
456
|
-
0.09501250983763744,
|
|
457
|
-
-0.2816035507792589,
|
|
458
|
-
0.2816035507792589,
|
|
459
|
-
-0.45801677765722737,
|
|
460
|
-
0.45801677765722737,
|
|
461
|
-
-0.6178762444026438,
|
|
462
|
-
0.6178762444026438,
|
|
463
|
-
-0.755404408355003,
|
|
464
|
-
0.755404408355003,
|
|
465
|
-
-0.8656312023878318,
|
|
466
|
-
0.8656312023878318,
|
|
467
|
-
-0.9445750230732326,
|
|
468
|
-
0.9445750230732326,
|
|
469
|
-
-0.9894009349916499,
|
|
470
|
-
0.9894009349916499
|
|
471
|
-
],
|
|
472
|
-
[
|
|
473
|
-
0,
|
|
474
|
-
-0.17848418149584785,
|
|
475
|
-
0.17848418149584785,
|
|
476
|
-
-0.3512317634538763,
|
|
477
|
-
0.3512317634538763,
|
|
478
|
-
-0.5126905370864769,
|
|
479
|
-
0.5126905370864769,
|
|
480
|
-
-0.6576711592166907,
|
|
481
|
-
0.6576711592166907,
|
|
482
|
-
-0.7815140038968014,
|
|
483
|
-
0.7815140038968014,
|
|
484
|
-
-0.8802391537269859,
|
|
485
|
-
0.8802391537269859,
|
|
486
|
-
-0.9506755217687678,
|
|
487
|
-
0.9506755217687678,
|
|
488
|
-
-0.9905754753144174,
|
|
489
|
-
0.9905754753144174
|
|
490
|
-
],
|
|
491
|
-
[
|
|
492
|
-
-0.0847750130417353,
|
|
493
|
-
0.0847750130417353,
|
|
494
|
-
-0.2518862256915055,
|
|
495
|
-
0.2518862256915055,
|
|
496
|
-
-0.41175116146284263,
|
|
497
|
-
0.41175116146284263,
|
|
498
|
-
-0.5597708310739475,
|
|
499
|
-
0.5597708310739475,
|
|
500
|
-
-0.6916870430603532,
|
|
501
|
-
0.6916870430603532,
|
|
502
|
-
-0.8037049589725231,
|
|
503
|
-
0.8037049589725231,
|
|
504
|
-
-0.8926024664975557,
|
|
505
|
-
0.8926024664975557,
|
|
506
|
-
-0.9558239495713977,
|
|
507
|
-
0.9558239495713977,
|
|
508
|
-
-0.9915651684209309,
|
|
509
|
-
0.9915651684209309
|
|
510
|
-
],
|
|
511
|
-
[
|
|
512
|
-
0,
|
|
513
|
-
-0.16035864564022537,
|
|
514
|
-
0.16035864564022537,
|
|
515
|
-
-0.31656409996362983,
|
|
516
|
-
0.31656409996362983,
|
|
517
|
-
-0.46457074137596094,
|
|
518
|
-
0.46457074137596094,
|
|
519
|
-
-0.600545304661681,
|
|
520
|
-
0.600545304661681,
|
|
521
|
-
-0.7209661773352294,
|
|
522
|
-
0.7209661773352294,
|
|
523
|
-
-0.8227146565371428,
|
|
524
|
-
0.8227146565371428,
|
|
525
|
-
-0.9031559036148179,
|
|
526
|
-
0.9031559036148179,
|
|
527
|
-
-0.96020815213483,
|
|
528
|
-
0.96020815213483,
|
|
529
|
-
-0.9924068438435844,
|
|
530
|
-
0.9924068438435844
|
|
531
|
-
],
|
|
532
|
-
[
|
|
533
|
-
-0.07652652113349734,
|
|
534
|
-
0.07652652113349734,
|
|
535
|
-
-0.22778585114164507,
|
|
536
|
-
0.22778585114164507,
|
|
537
|
-
-0.37370608871541955,
|
|
538
|
-
0.37370608871541955,
|
|
539
|
-
-0.5108670019508271,
|
|
540
|
-
0.5108670019508271,
|
|
541
|
-
-0.636053680726515,
|
|
542
|
-
0.636053680726515,
|
|
543
|
-
-0.7463319064601508,
|
|
544
|
-
0.7463319064601508,
|
|
545
|
-
-0.8391169718222188,
|
|
546
|
-
0.8391169718222188,
|
|
547
|
-
-0.912234428251326,
|
|
548
|
-
0.912234428251326,
|
|
549
|
-
-0.9639719272779138,
|
|
550
|
-
0.9639719272779138,
|
|
551
|
-
-0.9931285991850949,
|
|
552
|
-
0.9931285991850949
|
|
553
|
-
],
|
|
554
|
-
[
|
|
555
|
-
0,
|
|
556
|
-
-0.1455618541608951,
|
|
557
|
-
0.1455618541608951,
|
|
558
|
-
-0.2880213168024011,
|
|
559
|
-
0.2880213168024011,
|
|
560
|
-
-0.4243421202074388,
|
|
561
|
-
0.4243421202074388,
|
|
562
|
-
-0.5516188358872198,
|
|
563
|
-
0.5516188358872198,
|
|
564
|
-
-0.6671388041974123,
|
|
565
|
-
0.6671388041974123,
|
|
566
|
-
-0.7684399634756779,
|
|
567
|
-
0.7684399634756779,
|
|
568
|
-
-0.8533633645833173,
|
|
569
|
-
0.8533633645833173,
|
|
570
|
-
-0.9200993341504008,
|
|
571
|
-
0.9200993341504008,
|
|
572
|
-
-0.9672268385663063,
|
|
573
|
-
0.9672268385663063,
|
|
574
|
-
-0.9937521706203895,
|
|
575
|
-
0.9937521706203895
|
|
576
|
-
],
|
|
577
|
-
[
|
|
578
|
-
-0.06973927331972223,
|
|
579
|
-
0.06973927331972223,
|
|
580
|
-
-0.20786042668822127,
|
|
581
|
-
0.20786042668822127,
|
|
582
|
-
-0.34193582089208424,
|
|
583
|
-
0.34193582089208424,
|
|
584
|
-
-0.469355837986757,
|
|
585
|
-
0.469355837986757,
|
|
586
|
-
-0.5876404035069116,
|
|
587
|
-
0.5876404035069116,
|
|
588
|
-
-0.6944872631866827,
|
|
589
|
-
0.6944872631866827,
|
|
590
|
-
-0.7878168059792081,
|
|
591
|
-
0.7878168059792081,
|
|
592
|
-
-0.8658125777203002,
|
|
593
|
-
0.8658125777203002,
|
|
594
|
-
-0.926956772187174,
|
|
595
|
-
0.926956772187174,
|
|
596
|
-
-0.9700604978354287,
|
|
597
|
-
0.9700604978354287,
|
|
598
|
-
-0.9942945854823992,
|
|
599
|
-
0.9942945854823992
|
|
600
|
-
],
|
|
601
|
-
[
|
|
602
|
-
0,
|
|
603
|
-
-0.1332568242984661,
|
|
604
|
-
0.1332568242984661,
|
|
605
|
-
-0.26413568097034495,
|
|
606
|
-
0.26413568097034495,
|
|
607
|
-
-0.3903010380302908,
|
|
608
|
-
0.3903010380302908,
|
|
609
|
-
-0.5095014778460075,
|
|
610
|
-
0.5095014778460075,
|
|
611
|
-
-0.6196098757636461,
|
|
612
|
-
0.6196098757636461,
|
|
613
|
-
-0.7186613631319502,
|
|
614
|
-
0.7186613631319502,
|
|
615
|
-
-0.8048884016188399,
|
|
616
|
-
0.8048884016188399,
|
|
617
|
-
-0.8767523582704416,
|
|
618
|
-
0.8767523582704416,
|
|
619
|
-
-0.9329710868260161,
|
|
620
|
-
0.9329710868260161,
|
|
621
|
-
-0.9725424712181152,
|
|
622
|
-
0.9725424712181152,
|
|
623
|
-
-0.9947693349975522,
|
|
624
|
-
0.9947693349975522
|
|
625
|
-
],
|
|
626
|
-
[
|
|
627
|
-
-0.06405689286260563,
|
|
628
|
-
0.06405689286260563,
|
|
629
|
-
-0.1911188674736163,
|
|
630
|
-
0.1911188674736163,
|
|
631
|
-
-0.3150426796961634,
|
|
632
|
-
0.3150426796961634,
|
|
633
|
-
-0.4337935076260451,
|
|
634
|
-
0.4337935076260451,
|
|
635
|
-
-0.5454214713888396,
|
|
636
|
-
0.5454214713888396,
|
|
637
|
-
-0.6480936519369755,
|
|
638
|
-
0.6480936519369755,
|
|
639
|
-
-0.7401241915785544,
|
|
640
|
-
0.7401241915785544,
|
|
641
|
-
-0.820001985973903,
|
|
642
|
-
0.820001985973903,
|
|
643
|
-
-0.8864155270044011,
|
|
644
|
-
0.8864155270044011,
|
|
645
|
-
-0.9382745520027328,
|
|
646
|
-
0.9382745520027328,
|
|
647
|
-
-0.9747285559713095,
|
|
648
|
-
0.9747285559713095,
|
|
649
|
-
-0.9951872199970213,
|
|
650
|
-
0.9951872199970213
|
|
651
|
-
]
|
|
652
|
-
];
|
|
653
|
-
var cValues = [
|
|
654
|
-
[],
|
|
655
|
-
[],
|
|
656
|
-
[1, 1],
|
|
657
|
-
[
|
|
658
|
-
0.8888888888888888,
|
|
659
|
-
0.5555555555555556,
|
|
660
|
-
0.5555555555555556
|
|
661
|
-
],
|
|
662
|
-
[
|
|
663
|
-
0.6521451548625461,
|
|
664
|
-
0.6521451548625461,
|
|
665
|
-
0.34785484513745385,
|
|
666
|
-
0.34785484513745385
|
|
667
|
-
],
|
|
668
|
-
[
|
|
669
|
-
0.5688888888888889,
|
|
670
|
-
0.47862867049936647,
|
|
671
|
-
0.47862867049936647,
|
|
672
|
-
0.23692688505618908,
|
|
673
|
-
0.23692688505618908
|
|
674
|
-
],
|
|
675
|
-
[
|
|
676
|
-
0.3607615730481386,
|
|
677
|
-
0.3607615730481386,
|
|
678
|
-
0.46791393457269104,
|
|
679
|
-
0.46791393457269104,
|
|
680
|
-
0.17132449237917036,
|
|
681
|
-
0.17132449237917036
|
|
682
|
-
],
|
|
683
|
-
[
|
|
684
|
-
0.4179591836734694,
|
|
685
|
-
0.3818300505051189,
|
|
686
|
-
0.3818300505051189,
|
|
687
|
-
0.27970539148927664,
|
|
688
|
-
0.27970539148927664,
|
|
689
|
-
0.1294849661688697,
|
|
690
|
-
0.1294849661688697
|
|
691
|
-
],
|
|
692
|
-
[
|
|
693
|
-
0.362683783378362,
|
|
694
|
-
0.362683783378362,
|
|
695
|
-
0.31370664587788727,
|
|
696
|
-
0.31370664587788727,
|
|
697
|
-
0.22238103445337448,
|
|
698
|
-
0.22238103445337448,
|
|
699
|
-
0.10122853629037626,
|
|
700
|
-
0.10122853629037626
|
|
701
|
-
],
|
|
702
|
-
[
|
|
703
|
-
0.3302393550012598,
|
|
704
|
-
0.1806481606948574,
|
|
705
|
-
0.1806481606948574,
|
|
706
|
-
0.08127438836157441,
|
|
707
|
-
0.08127438836157441,
|
|
708
|
-
0.31234707704000286,
|
|
709
|
-
0.31234707704000286,
|
|
710
|
-
0.26061069640293544,
|
|
711
|
-
0.26061069640293544
|
|
712
|
-
],
|
|
713
|
-
[
|
|
714
|
-
0.29552422471475287,
|
|
715
|
-
0.29552422471475287,
|
|
716
|
-
0.26926671930999635,
|
|
717
|
-
0.26926671930999635,
|
|
718
|
-
0.21908636251598204,
|
|
719
|
-
0.21908636251598204,
|
|
720
|
-
0.1494513491505806,
|
|
721
|
-
0.1494513491505806,
|
|
722
|
-
0.06667134430868814,
|
|
723
|
-
0.06667134430868814
|
|
724
|
-
],
|
|
725
|
-
[
|
|
726
|
-
0.2729250867779006,
|
|
727
|
-
0.26280454451024665,
|
|
728
|
-
0.26280454451024665,
|
|
729
|
-
0.23319376459199048,
|
|
730
|
-
0.23319376459199048,
|
|
731
|
-
0.18629021092773426,
|
|
732
|
-
0.18629021092773426,
|
|
733
|
-
0.1255803694649046,
|
|
734
|
-
0.1255803694649046,
|
|
735
|
-
0.05566856711617366,
|
|
736
|
-
0.05566856711617366
|
|
737
|
-
],
|
|
738
|
-
[
|
|
739
|
-
0.24914704581340277,
|
|
740
|
-
0.24914704581340277,
|
|
741
|
-
0.2334925365383548,
|
|
742
|
-
0.2334925365383548,
|
|
743
|
-
0.20316742672306592,
|
|
744
|
-
0.20316742672306592,
|
|
745
|
-
0.16007832854334622,
|
|
746
|
-
0.16007832854334622,
|
|
747
|
-
0.10693932599531843,
|
|
748
|
-
0.10693932599531843,
|
|
749
|
-
0.04717533638651183,
|
|
750
|
-
0.04717533638651183
|
|
751
|
-
],
|
|
752
|
-
[
|
|
753
|
-
0.2325515532308739,
|
|
754
|
-
0.22628318026289723,
|
|
755
|
-
0.22628318026289723,
|
|
756
|
-
0.2078160475368885,
|
|
757
|
-
0.2078160475368885,
|
|
758
|
-
0.17814598076194574,
|
|
759
|
-
0.17814598076194574,
|
|
760
|
-
0.13887351021978725,
|
|
761
|
-
0.13887351021978725,
|
|
762
|
-
0.09212149983772845,
|
|
763
|
-
0.09212149983772845,
|
|
764
|
-
0.04048400476531588,
|
|
765
|
-
0.04048400476531588
|
|
766
|
-
],
|
|
767
|
-
[
|
|
768
|
-
0.2152638534631578,
|
|
769
|
-
0.2152638534631578,
|
|
770
|
-
0.2051984637212956,
|
|
771
|
-
0.2051984637212956,
|
|
772
|
-
0.18553839747793782,
|
|
773
|
-
0.18553839747793782,
|
|
774
|
-
0.15720316715819355,
|
|
775
|
-
0.15720316715819355,
|
|
776
|
-
0.12151857068790319,
|
|
777
|
-
0.12151857068790319,
|
|
778
|
-
0.08015808715976021,
|
|
779
|
-
0.08015808715976021,
|
|
780
|
-
0.03511946033175186,
|
|
781
|
-
0.03511946033175186
|
|
782
|
-
],
|
|
783
|
-
[
|
|
784
|
-
0.2025782419255613,
|
|
785
|
-
0.19843148532711158,
|
|
786
|
-
0.19843148532711158,
|
|
787
|
-
0.1861610000155622,
|
|
788
|
-
0.1861610000155622,
|
|
789
|
-
0.16626920581699392,
|
|
790
|
-
0.16626920581699392,
|
|
791
|
-
0.13957067792615432,
|
|
792
|
-
0.13957067792615432,
|
|
793
|
-
0.10715922046717194,
|
|
794
|
-
0.10715922046717194,
|
|
795
|
-
0.07036604748810812,
|
|
796
|
-
0.07036604748810812,
|
|
797
|
-
0.03075324199611727,
|
|
798
|
-
0.03075324199611727
|
|
799
|
-
],
|
|
800
|
-
[
|
|
801
|
-
0.1894506104550685,
|
|
802
|
-
0.1894506104550685,
|
|
803
|
-
0.18260341504492358,
|
|
804
|
-
0.18260341504492358,
|
|
805
|
-
0.16915651939500254,
|
|
806
|
-
0.16915651939500254,
|
|
807
|
-
0.14959598881657674,
|
|
808
|
-
0.14959598881657674,
|
|
809
|
-
0.12462897125553388,
|
|
810
|
-
0.12462897125553388,
|
|
811
|
-
0.09515851168249279,
|
|
812
|
-
0.09515851168249279,
|
|
813
|
-
0.062253523938647894,
|
|
814
|
-
0.062253523938647894,
|
|
815
|
-
0.027152459411754096,
|
|
816
|
-
0.027152459411754096
|
|
817
|
-
],
|
|
818
|
-
[
|
|
819
|
-
0.17944647035620653,
|
|
820
|
-
0.17656270536699264,
|
|
821
|
-
0.17656270536699264,
|
|
822
|
-
0.16800410215645004,
|
|
823
|
-
0.16800410215645004,
|
|
824
|
-
0.15404576107681028,
|
|
825
|
-
0.15404576107681028,
|
|
826
|
-
0.13513636846852548,
|
|
827
|
-
0.13513636846852548,
|
|
828
|
-
0.11188384719340397,
|
|
829
|
-
0.11188384719340397,
|
|
830
|
-
0.08503614831717918,
|
|
831
|
-
0.08503614831717918,
|
|
832
|
-
0.0554595293739872,
|
|
833
|
-
0.0554595293739872,
|
|
834
|
-
0.02414830286854793,
|
|
835
|
-
0.02414830286854793
|
|
836
|
-
],
|
|
837
|
-
[
|
|
838
|
-
0.1691423829631436,
|
|
839
|
-
0.1691423829631436,
|
|
840
|
-
0.16427648374583273,
|
|
841
|
-
0.16427648374583273,
|
|
842
|
-
0.15468467512626524,
|
|
843
|
-
0.15468467512626524,
|
|
844
|
-
0.14064291467065065,
|
|
845
|
-
0.14064291467065065,
|
|
846
|
-
0.12255520671147846,
|
|
847
|
-
0.12255520671147846,
|
|
848
|
-
0.10094204410628717,
|
|
849
|
-
0.10094204410628717,
|
|
850
|
-
0.07642573025488905,
|
|
851
|
-
0.07642573025488905,
|
|
852
|
-
0.0497145488949698,
|
|
853
|
-
0.0497145488949698,
|
|
854
|
-
0.02161601352648331,
|
|
855
|
-
0.02161601352648331
|
|
856
|
-
],
|
|
857
|
-
[
|
|
858
|
-
0.1610544498487837,
|
|
859
|
-
0.15896884339395434,
|
|
860
|
-
0.15896884339395434,
|
|
861
|
-
0.15276604206585967,
|
|
862
|
-
0.15276604206585967,
|
|
863
|
-
0.1426067021736066,
|
|
864
|
-
0.1426067021736066,
|
|
865
|
-
0.12875396253933621,
|
|
866
|
-
0.12875396253933621,
|
|
867
|
-
0.11156664554733399,
|
|
868
|
-
0.11156664554733399,
|
|
869
|
-
0.09149002162245,
|
|
870
|
-
0.09149002162245,
|
|
871
|
-
0.06904454273764123,
|
|
872
|
-
0.06904454273764123,
|
|
873
|
-
0.0448142267656996,
|
|
874
|
-
0.0448142267656996,
|
|
875
|
-
0.019461788229726478,
|
|
876
|
-
0.019461788229726478
|
|
877
|
-
],
|
|
878
|
-
[
|
|
879
|
-
0.15275338713072584,
|
|
880
|
-
0.15275338713072584,
|
|
881
|
-
0.14917298647260374,
|
|
882
|
-
0.14917298647260374,
|
|
883
|
-
0.14209610931838204,
|
|
884
|
-
0.14209610931838204,
|
|
885
|
-
0.13168863844917664,
|
|
886
|
-
0.13168863844917664,
|
|
887
|
-
0.11819453196151841,
|
|
888
|
-
0.11819453196151841,
|
|
889
|
-
0.10193011981724044,
|
|
890
|
-
0.10193011981724044,
|
|
891
|
-
0.08327674157670475,
|
|
892
|
-
0.08327674157670475,
|
|
893
|
-
0.06267204833410907,
|
|
894
|
-
0.06267204833410907,
|
|
895
|
-
0.04060142980038694,
|
|
896
|
-
0.04060142980038694,
|
|
897
|
-
0.017614007139152118,
|
|
898
|
-
0.017614007139152118
|
|
899
|
-
],
|
|
900
|
-
[
|
|
901
|
-
0.14608113364969041,
|
|
902
|
-
0.14452440398997005,
|
|
903
|
-
0.14452440398997005,
|
|
904
|
-
0.13988739479107315,
|
|
905
|
-
0.13988739479107315,
|
|
906
|
-
0.13226893863333747,
|
|
907
|
-
0.13226893863333747,
|
|
908
|
-
0.12183141605372853,
|
|
909
|
-
0.12183141605372853,
|
|
910
|
-
0.10879729916714838,
|
|
911
|
-
0.10879729916714838,
|
|
912
|
-
0.09344442345603386,
|
|
913
|
-
0.09344442345603386,
|
|
914
|
-
0.0761001136283793,
|
|
915
|
-
0.0761001136283793,
|
|
916
|
-
0.057134425426857205,
|
|
917
|
-
0.057134425426857205,
|
|
918
|
-
0.036953789770852494,
|
|
919
|
-
0.036953789770852494,
|
|
920
|
-
0.016017228257774335,
|
|
921
|
-
0.016017228257774335
|
|
922
|
-
],
|
|
923
|
-
[
|
|
924
|
-
0.13925187285563198,
|
|
925
|
-
0.13925187285563198,
|
|
926
|
-
0.13654149834601517,
|
|
927
|
-
0.13654149834601517,
|
|
928
|
-
0.13117350478706238,
|
|
929
|
-
0.13117350478706238,
|
|
930
|
-
0.12325237681051242,
|
|
931
|
-
0.12325237681051242,
|
|
932
|
-
0.11293229608053922,
|
|
933
|
-
0.11293229608053922,
|
|
934
|
-
0.10041414444288096,
|
|
935
|
-
0.10041414444288096,
|
|
936
|
-
0.08594160621706773,
|
|
937
|
-
0.08594160621706773,
|
|
938
|
-
0.06979646842452049,
|
|
939
|
-
0.06979646842452049,
|
|
940
|
-
0.052293335152683286,
|
|
941
|
-
0.052293335152683286,
|
|
942
|
-
0.03377490158481415,
|
|
943
|
-
0.03377490158481415,
|
|
944
|
-
0.0146279952982722,
|
|
945
|
-
0.0146279952982722
|
|
946
|
-
],
|
|
947
|
-
[
|
|
948
|
-
0.13365457218610619,
|
|
949
|
-
0.1324620394046966,
|
|
950
|
-
0.1324620394046966,
|
|
951
|
-
0.12890572218808216,
|
|
952
|
-
0.12890572218808216,
|
|
953
|
-
0.12304908430672953,
|
|
954
|
-
0.12304908430672953,
|
|
955
|
-
0.11499664022241136,
|
|
956
|
-
0.11499664022241136,
|
|
957
|
-
0.10489209146454141,
|
|
958
|
-
0.10489209146454141,
|
|
959
|
-
0.09291576606003515,
|
|
960
|
-
0.09291576606003515,
|
|
961
|
-
0.07928141177671895,
|
|
962
|
-
0.07928141177671895,
|
|
963
|
-
0.06423242140852585,
|
|
964
|
-
0.06423242140852585,
|
|
965
|
-
0.04803767173108467,
|
|
966
|
-
0.04803767173108467,
|
|
967
|
-
0.030988005856979445,
|
|
968
|
-
0.030988005856979445,
|
|
969
|
-
0.013411859487141771,
|
|
970
|
-
0.013411859487141771
|
|
971
|
-
],
|
|
972
|
-
[
|
|
973
|
-
0.12793819534675216,
|
|
974
|
-
0.12793819534675216,
|
|
975
|
-
0.1258374563468283,
|
|
976
|
-
0.1258374563468283,
|
|
977
|
-
0.12167047292780339,
|
|
978
|
-
0.12167047292780339,
|
|
979
|
-
0.1155056680537256,
|
|
980
|
-
0.1155056680537256,
|
|
981
|
-
0.10744427011596563,
|
|
982
|
-
0.10744427011596563,
|
|
983
|
-
0.09761865210411388,
|
|
984
|
-
0.09761865210411388,
|
|
985
|
-
0.08619016153195327,
|
|
986
|
-
0.08619016153195327,
|
|
987
|
-
0.0733464814110803,
|
|
988
|
-
0.0733464814110803,
|
|
989
|
-
0.05929858491543678,
|
|
990
|
-
0.05929858491543678,
|
|
991
|
-
0.04427743881741981,
|
|
992
|
-
0.04427743881741981,
|
|
993
|
-
0.028531388628933663,
|
|
994
|
-
0.028531388628933663,
|
|
995
|
-
0.0123412297999872,
|
|
996
|
-
0.0123412297999872
|
|
997
|
-
]
|
|
998
|
-
];
|
|
999
|
-
var binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
|
|
1000
|
-
var cubicPoint = (xs, ys, t) => {
|
|
1001
|
-
const x = (1 - t) * (1 - t) * (1 - t) * xs[0] + 3 * (1 - t) * (1 - t) * t * xs[1] + 3 * (1 - t) * t * t * xs[2] + t * t * t * xs[3];
|
|
1002
|
-
const y = (1 - t) * (1 - t) * (1 - t) * ys[0] + 3 * (1 - t) * (1 - t) * t * ys[1] + 3 * (1 - t) * t * t * ys[2] + t * t * t * ys[3];
|
|
1003
|
-
return { x, y };
|
|
1004
|
-
};
|
|
1005
|
-
var getDerivative = (derivative, t, vs) => {
|
|
1006
|
-
const n = vs.length - 1;
|
|
1007
|
-
let value;
|
|
1008
|
-
if (n === 0) {
|
|
1009
|
-
return 0;
|
|
1010
|
-
}
|
|
1011
|
-
if (derivative === 0) {
|
|
1012
|
-
value = 0;
|
|
1013
|
-
for (let k = 0;k <= n; k++) {
|
|
1014
|
-
value += binomialCoefficients[n][k] * (1 - t) ** (n - k) * t ** k * vs[k];
|
|
1015
|
-
}
|
|
1016
|
-
return value;
|
|
1017
|
-
}
|
|
1018
|
-
const _vs = new Array(n);
|
|
1019
|
-
for (let k = 0;k < n; k++) {
|
|
1020
|
-
_vs[k] = n * (vs[k + 1] - vs[k]);
|
|
1021
|
-
}
|
|
1022
|
-
return getDerivative(derivative - 1, t, _vs);
|
|
1023
|
-
};
|
|
1024
|
-
function bFunc(xs, ys, t) {
|
|
1025
|
-
const xbase = getDerivative(1, t, xs);
|
|
1026
|
-
const ybase = getDerivative(1, t, ys);
|
|
1027
|
-
const combined = xbase * xbase + ybase * ybase;
|
|
1028
|
-
return Math.sqrt(combined);
|
|
1029
|
-
}
|
|
1030
|
-
var getCubicArcLength = ({
|
|
1031
|
-
sx,
|
|
1032
|
-
sy,
|
|
1033
|
-
t
|
|
1034
|
-
}) => {
|
|
1035
|
-
let correctedT;
|
|
1036
|
-
const n = 20;
|
|
1037
|
-
const z = t / 2;
|
|
1038
|
-
let sum = 0;
|
|
1039
|
-
for (let i = 0;i < n; i++) {
|
|
1040
|
-
correctedT = z * tValues[n][i] + z;
|
|
1041
|
-
sum += cValues[n][i] * bFunc(sx, sy, correctedT);
|
|
1042
|
-
}
|
|
1043
|
-
return z * sum;
|
|
1044
|
-
};
|
|
1045
|
-
var quadraticPoint = (xs, ys, t) => {
|
|
1046
|
-
const x = (1 - t) * (1 - t) * xs[0] + 2 * (1 - t) * t * xs[1] + t * t * xs[2];
|
|
1047
|
-
const y = (1 - t) * (1 - t) * ys[0] + 2 * (1 - t) * t * ys[1] + t * t * ys[2];
|
|
1048
|
-
return { x, y };
|
|
1049
|
-
};
|
|
1050
|
-
var cubicDerivative = (xs, ys, t) => {
|
|
1051
|
-
const derivative = quadraticPoint([3 * (xs[1] - xs[0]), 3 * (xs[2] - xs[1]), 3 * (xs[3] - xs[2])], [3 * (ys[1] - ys[0]), 3 * (ys[2] - ys[1]), 3 * (ys[3] - ys[2])], t);
|
|
1052
|
-
return derivative;
|
|
1053
|
-
};
|
|
1054
|
-
var t2length = ({
|
|
1055
|
-
length,
|
|
1056
|
-
totalLength,
|
|
1057
|
-
func
|
|
1058
|
-
}) => {
|
|
1059
|
-
let error = 1;
|
|
1060
|
-
let t = length / totalLength;
|
|
1061
|
-
let step = (length - func(t)) / totalLength;
|
|
1062
|
-
let numIterations = 0;
|
|
1063
|
-
while (error > 0.001) {
|
|
1064
|
-
const increasedTLength = func(t + step);
|
|
1065
|
-
const increasedTError = Math.abs(length - increasedTLength) / totalLength;
|
|
1066
|
-
if (increasedTError < error) {
|
|
1067
|
-
error = increasedTError;
|
|
1068
|
-
t += step;
|
|
1069
|
-
} else {
|
|
1070
|
-
const decreasedTLength = func(t - step);
|
|
1071
|
-
const decreasedTError = Math.abs(length - decreasedTLength) / totalLength;
|
|
1072
|
-
if (decreasedTError < error) {
|
|
1073
|
-
error = decreasedTError;
|
|
1074
|
-
t -= step;
|
|
1075
|
-
} else {
|
|
1076
|
-
step /= 2;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
numIterations++;
|
|
1080
|
-
if (numIterations > 500) {
|
|
1081
|
-
break;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
return t;
|
|
1085
|
-
};
|
|
1086
|
-
var makeCubic = ({
|
|
1087
|
-
startX,
|
|
1088
|
-
startY,
|
|
1089
|
-
cp1x,
|
|
1090
|
-
cp1y,
|
|
1091
|
-
cp2x,
|
|
1092
|
-
cp2y,
|
|
1093
|
-
x,
|
|
1094
|
-
y
|
|
1095
|
-
}) => {
|
|
1096
|
-
const a = { x: startX, y: startY };
|
|
1097
|
-
const b = { x: cp1x, y: cp1y };
|
|
1098
|
-
const c = { x: cp2x, y: cp2y };
|
|
1099
|
-
const d = { x, y };
|
|
1100
|
-
const length = getCubicArcLength({
|
|
1101
|
-
sx: [a.x, b.x, c.x, d.x],
|
|
1102
|
-
sy: [a.y, b.y, c.y, d.y],
|
|
1103
|
-
t: 1
|
|
1104
|
-
});
|
|
1105
|
-
const getTotalLength = () => {
|
|
1106
|
-
return length;
|
|
1107
|
-
};
|
|
1108
|
-
const getPointAtLength = (len) => {
|
|
1109
|
-
const sx = [a.x, b.x, c.x, d.x];
|
|
1110
|
-
const sy = [a.y, b.y, c.y, d.y];
|
|
1111
|
-
const t = t2length({
|
|
1112
|
-
length: len,
|
|
1113
|
-
totalLength: length,
|
|
1114
|
-
func: (i) => {
|
|
1115
|
-
return getCubicArcLength({ sx, sy, t: i });
|
|
1116
|
-
}
|
|
1117
|
-
});
|
|
1118
|
-
return cubicPoint(sx, sy, t);
|
|
1119
|
-
};
|
|
1120
|
-
const getTangentAtLength = (len) => {
|
|
1121
|
-
const xs = [a.x, b.x, c.x, d.x];
|
|
1122
|
-
const xy = [a.y, b.y, c.y, d.y];
|
|
1123
|
-
const t = t2length({
|
|
1124
|
-
length: len,
|
|
1125
|
-
totalLength: length,
|
|
1126
|
-
func: (i) => getCubicArcLength({ sx: xs, sy: xy, t: i })
|
|
1127
|
-
});
|
|
1128
|
-
const derivative = cubicDerivative(xs, xy, t);
|
|
1129
|
-
const mdl = Math.sqrt(derivative.x * derivative.x + derivative.y * derivative.y);
|
|
1130
|
-
let tangent;
|
|
1131
|
-
if (mdl > 0) {
|
|
1132
|
-
tangent = { x: derivative.x / mdl, y: derivative.y / mdl };
|
|
1133
|
-
} else {
|
|
1134
|
-
tangent = { x: 0, y: 0 };
|
|
1135
|
-
}
|
|
1136
|
-
return tangent;
|
|
1137
|
-
};
|
|
1138
|
-
const getC = () => {
|
|
1139
|
-
return c;
|
|
1140
|
-
};
|
|
1141
|
-
const getD = () => {
|
|
1142
|
-
return d;
|
|
1143
|
-
};
|
|
1144
|
-
return {
|
|
1145
|
-
getPointAtLength,
|
|
1146
|
-
getTangentAtLength,
|
|
1147
|
-
getTotalLength,
|
|
1148
|
-
getC,
|
|
1149
|
-
getD,
|
|
1150
|
-
type: "cubic-bezier"
|
|
1151
|
-
};
|
|
1152
|
-
};
|
|
1153
|
-
var makeLinearPosition = ({
|
|
1154
|
-
x0,
|
|
1155
|
-
x1,
|
|
1156
|
-
y0,
|
|
1157
|
-
y1
|
|
1158
|
-
}) => {
|
|
1159
|
-
return {
|
|
1160
|
-
getTotalLength: () => {
|
|
1161
|
-
return Math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2);
|
|
1162
|
-
},
|
|
1163
|
-
getPointAtLength: (pos) => {
|
|
1164
|
-
let fraction = pos / Math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2);
|
|
1165
|
-
fraction = Number.isNaN(fraction) ? 1 : fraction;
|
|
1166
|
-
const newDeltaX = (x1 - x0) * fraction;
|
|
1167
|
-
const newDeltaY = (y1 - y0) * fraction;
|
|
1168
|
-
return { x: x0 + newDeltaX, y: y0 + newDeltaY };
|
|
1169
|
-
},
|
|
1170
|
-
getTangentAtLength: () => {
|
|
1171
|
-
const module = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
|
|
1172
|
-
return { x: (x1 - x0) / module, y: (y1 - y0) / module };
|
|
1173
|
-
},
|
|
1174
|
-
type: "linear"
|
|
1175
|
-
};
|
|
1176
|
-
};
|
|
1177
|
-
var conductAnalysis = (instructions) => {
|
|
1178
|
-
let currentPoint = { x: 0, y: 0 };
|
|
1179
|
-
let moveStart = { x: 0, y: 0 };
|
|
1180
|
-
const segments = [];
|
|
1181
|
-
for (let i = 0;i < instructions.length; i++) {
|
|
1182
|
-
const instruction = instructions[i];
|
|
1183
|
-
if (instruction.type === "M") {
|
|
1184
|
-
currentPoint = { x: instruction.x, y: instruction.y };
|
|
1185
|
-
moveStart = { x: currentPoint.x, y: currentPoint.y };
|
|
1186
|
-
segments.push({
|
|
1187
|
-
startPoint: { x: instruction.x, y: instruction.y },
|
|
1188
|
-
instructionsAndInfo: [
|
|
1189
|
-
{
|
|
1190
|
-
instruction,
|
|
1191
|
-
function: null,
|
|
1192
|
-
length: 0,
|
|
1193
|
-
startPoint: currentPoint
|
|
1194
|
-
}
|
|
1195
|
-
]
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
if (instruction.type === "L") {
|
|
1199
|
-
if (segments.length > 0) {
|
|
1200
|
-
const length = Math.sqrt((currentPoint.x - instruction.x) ** 2 + (currentPoint.y - instruction.y) ** 2);
|
|
1201
|
-
segments[segments.length - 1].instructionsAndInfo.push({
|
|
1202
|
-
instruction,
|
|
1203
|
-
length,
|
|
1204
|
-
function: makeLinearPosition({
|
|
1205
|
-
x0: currentPoint.x,
|
|
1206
|
-
x1: instruction.x,
|
|
1207
|
-
y0: currentPoint.y,
|
|
1208
|
-
y1: instruction.y
|
|
1209
|
-
}),
|
|
1210
|
-
startPoint: currentPoint
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
currentPoint = { x: instruction.x, y: instruction.y };
|
|
1214
|
-
}
|
|
1215
|
-
if (instruction.type === "Z") {
|
|
1216
|
-
if (segments.length > 0) {
|
|
1217
|
-
const length = Math.sqrt((segments[segments.length - 1].startPoint.x - currentPoint.x) ** 2 + (segments[segments.length - 1].startPoint.y - currentPoint.y) ** 2);
|
|
1218
|
-
segments[segments.length - 1].instructionsAndInfo.push({
|
|
1219
|
-
instruction,
|
|
1220
|
-
function: makeLinearPosition({
|
|
1221
|
-
x0: currentPoint.x,
|
|
1222
|
-
x1: moveStart.x,
|
|
1223
|
-
y0: currentPoint.y,
|
|
1224
|
-
y1: moveStart.y
|
|
1225
|
-
}),
|
|
1226
|
-
length,
|
|
1227
|
-
startPoint: { ...currentPoint }
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
currentPoint = { x: moveStart.x, y: moveStart.y };
|
|
1231
|
-
}
|
|
1232
|
-
if (instruction.type === "C") {
|
|
1233
|
-
const curve = makeCubic({
|
|
1234
|
-
startX: currentPoint.x,
|
|
1235
|
-
startY: currentPoint.y,
|
|
1236
|
-
cp1x: instruction.cp1x,
|
|
1237
|
-
cp1y: instruction.cp1y,
|
|
1238
|
-
cp2x: instruction.cp2x,
|
|
1239
|
-
cp2y: instruction.cp2y,
|
|
1240
|
-
x: instruction.x,
|
|
1241
|
-
y: instruction.y
|
|
1242
|
-
});
|
|
1243
|
-
const length = curve.getTotalLength();
|
|
1244
|
-
if (segments.length > 0) {
|
|
1245
|
-
segments[segments.length - 1].instructionsAndInfo.push({
|
|
1246
|
-
instruction,
|
|
1247
|
-
length,
|
|
1248
|
-
function: curve,
|
|
1249
|
-
startPoint: { ...currentPoint }
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
currentPoint = { x: instruction.x, y: instruction.y };
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
return segments;
|
|
1256
|
-
};
|
|
1257
246
|
var length = {
|
|
1258
247
|
a: 7,
|
|
1259
248
|
A: 7,
|
|
@@ -1851,71 +840,6 @@ var removeATSHVQInstructions = (segments) => {
|
|
|
1851
840
|
}
|
|
1852
841
|
});
|
|
1853
842
|
};
|
|
1854
|
-
var serializeInstruction = (instruction) => {
|
|
1855
|
-
if (instruction.type === "A") {
|
|
1856
|
-
return `A ${instruction.rx} ${instruction.ry} ${instruction.xAxisRotation} ${Number(instruction.largeArcFlag)} ${Number(instruction.sweepFlag)} ${instruction.x} ${instruction.y}`;
|
|
1857
|
-
}
|
|
1858
|
-
if (instruction.type === "a") {
|
|
1859
|
-
return `a ${instruction.rx} ${instruction.ry} ${instruction.xAxisRotation} ${Number(instruction.largeArcFlag)} ${Number(instruction.sweepFlag)} ${instruction.dx} ${instruction.dy}`;
|
|
1860
|
-
}
|
|
1861
|
-
if (instruction.type === "C") {
|
|
1862
|
-
return `C ${instruction.cp1x} ${instruction.cp1y} ${instruction.cp2x} ${instruction.cp2y} ${instruction.x} ${instruction.y}`;
|
|
1863
|
-
}
|
|
1864
|
-
if (instruction.type === "c") {
|
|
1865
|
-
return `c ${instruction.cp1dx} ${instruction.cp1dy} ${instruction.cp2dx} ${instruction.cp2dy} ${instruction.dx} ${instruction.dy}`;
|
|
1866
|
-
}
|
|
1867
|
-
if (instruction.type === "S") {
|
|
1868
|
-
return `S ${instruction.cpx} ${instruction.cpy} ${instruction.x} ${instruction.y}`;
|
|
1869
|
-
}
|
|
1870
|
-
if (instruction.type === "s") {
|
|
1871
|
-
return `s ${instruction.cpdx} ${instruction.cpdy} ${instruction.dx} ${instruction.dy}`;
|
|
1872
|
-
}
|
|
1873
|
-
if (instruction.type === "Q") {
|
|
1874
|
-
return `Q ${instruction.cpx} ${instruction.cpy} ${instruction.x} ${instruction.y}`;
|
|
1875
|
-
}
|
|
1876
|
-
if (instruction.type === "q") {
|
|
1877
|
-
return `q ${instruction.cpdx} ${instruction.cpdy} ${instruction.dx} ${instruction.dy}`;
|
|
1878
|
-
}
|
|
1879
|
-
if (instruction.type === "Z") {
|
|
1880
|
-
return "Z";
|
|
1881
|
-
}
|
|
1882
|
-
if (instruction.type === "H") {
|
|
1883
|
-
return `H ${instruction.x}`;
|
|
1884
|
-
}
|
|
1885
|
-
if (instruction.type === "h") {
|
|
1886
|
-
return `h ${instruction.dx}`;
|
|
1887
|
-
}
|
|
1888
|
-
if (instruction.type === "V") {
|
|
1889
|
-
return `V ${instruction.y}`;
|
|
1890
|
-
}
|
|
1891
|
-
if (instruction.type === "v") {
|
|
1892
|
-
return `v ${instruction.dy}`;
|
|
1893
|
-
}
|
|
1894
|
-
if (instruction.type === "L") {
|
|
1895
|
-
return `L ${instruction.x} ${instruction.y}`;
|
|
1896
|
-
}
|
|
1897
|
-
if (instruction.type === "l") {
|
|
1898
|
-
return `l ${instruction.dx} ${instruction.dy}`;
|
|
1899
|
-
}
|
|
1900
|
-
if (instruction.type === "M") {
|
|
1901
|
-
return `M ${instruction.x} ${instruction.y}`;
|
|
1902
|
-
}
|
|
1903
|
-
if (instruction.type === "m") {
|
|
1904
|
-
return `m ${instruction.dx} ${instruction.dy}`;
|
|
1905
|
-
}
|
|
1906
|
-
if (instruction.type === "T") {
|
|
1907
|
-
return `T ${instruction.x} ${instruction.y}`;
|
|
1908
|
-
}
|
|
1909
|
-
if (instruction.type === "t") {
|
|
1910
|
-
return `t ${instruction.dx} ${instruction.dy}`;
|
|
1911
|
-
}
|
|
1912
|
-
throw new Error(`Unknown instruction type: ${instruction.type}`);
|
|
1913
|
-
};
|
|
1914
|
-
var serializeInstructions = (path) => {
|
|
1915
|
-
return path.map((p) => {
|
|
1916
|
-
return serializeInstruction(p);
|
|
1917
|
-
}).join(" ");
|
|
1918
|
-
};
|
|
1919
843
|
var normalizeInstructions = (instructions) => {
|
|
1920
844
|
const normalized = [];
|
|
1921
845
|
let x = 0;
|
|
@@ -2052,210 +976,6 @@ var reduceInstructions = (instruction) => {
|
|
|
2052
976
|
const simplified = normalizeInstructions(instruction);
|
|
2053
977
|
return removeATSHVQInstructions(simplified);
|
|
2054
978
|
};
|
|
2055
|
-
var cutPath = (d, length2) => {
|
|
2056
|
-
const parsed = parsePath(d);
|
|
2057
|
-
const reduced = reduceInstructions(parsed);
|
|
2058
|
-
const constructed = conductAnalysis(reduced);
|
|
2059
|
-
const newInstructions = [];
|
|
2060
|
-
let summedUpLength = 0;
|
|
2061
|
-
for (const segment of constructed) {
|
|
2062
|
-
for (const instructionAndInfo of segment.instructionsAndInfo) {
|
|
2063
|
-
if (summedUpLength + instructionAndInfo.length > length2) {
|
|
2064
|
-
const remainingLength = length2 - summedUpLength;
|
|
2065
|
-
const progress = remainingLength / instructionAndInfo.length;
|
|
2066
|
-
const cut = cutInstruction({
|
|
2067
|
-
instruction: instructionAndInfo.instruction,
|
|
2068
|
-
lastPoint: instructionAndInfo.startPoint,
|
|
2069
|
-
progress
|
|
2070
|
-
});
|
|
2071
|
-
newInstructions.push(cut);
|
|
2072
|
-
return serializeInstructions(newInstructions);
|
|
2073
|
-
}
|
|
2074
|
-
summedUpLength += instructionAndInfo.length;
|
|
2075
|
-
newInstructions.push(instructionAndInfo.instruction);
|
|
2076
|
-
if (summedUpLength === length2) {
|
|
2077
|
-
return serializeInstructions(newInstructions);
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
return serializeInstructions(newInstructions);
|
|
2082
|
-
};
|
|
2083
|
-
var debugPath = (d) => {
|
|
2084
|
-
const instructions = normalizeInstructions(parsePath(d));
|
|
2085
|
-
return instructions.map((inst, i) => {
|
|
2086
|
-
if (inst.type === "Z") {
|
|
2087
|
-
return null;
|
|
2088
|
-
}
|
|
2089
|
-
if (inst.type === "H" || inst.type === "V") {
|
|
2090
|
-
return null;
|
|
2091
|
-
}
|
|
2092
|
-
const topLeft = [inst.x - 5, inst.y - 5];
|
|
2093
|
-
const topRight = [inst.x + 5, inst.y - 5];
|
|
2094
|
-
const bottomLeft = [inst.x - 5, inst.y + 5];
|
|
2095
|
-
const bottomRight = [inst.x + 5, inst.y + 5];
|
|
2096
|
-
const triangle = [
|
|
2097
|
-
{
|
|
2098
|
-
type: "M",
|
|
2099
|
-
x: topLeft[0],
|
|
2100
|
-
y: topLeft[1]
|
|
2101
|
-
},
|
|
2102
|
-
{
|
|
2103
|
-
type: "L",
|
|
2104
|
-
x: topRight[0],
|
|
2105
|
-
y: topRight[1]
|
|
2106
|
-
},
|
|
2107
|
-
{
|
|
2108
|
-
type: "L",
|
|
2109
|
-
x: bottomRight[0],
|
|
2110
|
-
y: bottomRight[1]
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
type: "L",
|
|
2114
|
-
x: bottomLeft[0],
|
|
2115
|
-
y: bottomLeft[1]
|
|
2116
|
-
},
|
|
2117
|
-
{
|
|
2118
|
-
type: "Z"
|
|
2119
|
-
}
|
|
2120
|
-
];
|
|
2121
|
-
return {
|
|
2122
|
-
d: serializeInstructions(triangle),
|
|
2123
|
-
color: i === instructions.length - 1 ? "red" : inst.type === "M" ? "blue" : "green"
|
|
2124
|
-
};
|
|
2125
|
-
}).filter(Boolean);
|
|
2126
|
-
};
|
|
2127
|
-
var CBEZIER_MINMAX_EPSILON = 0.00000001;
|
|
2128
|
-
function minmaxQ(A) {
|
|
2129
|
-
const min = Math.min(A[0], A[2]);
|
|
2130
|
-
const max = Math.max(A[0], A[2]);
|
|
2131
|
-
if (A[1] > A[0] ? A[2] >= A[1] : A[2] <= A[1]) {
|
|
2132
|
-
return [min, max];
|
|
2133
|
-
}
|
|
2134
|
-
const E = (A[0] * A[2] - A[1] * A[1]) / (A[0] - 2 * A[1] + A[2]);
|
|
2135
|
-
return E < min ? [E, max] : [min, E];
|
|
2136
|
-
}
|
|
2137
|
-
function minmaxC(A) {
|
|
2138
|
-
const K = A[0] - 3 * A[1] + 3 * A[2] - A[3];
|
|
2139
|
-
if (Math.abs(K) < CBEZIER_MINMAX_EPSILON) {
|
|
2140
|
-
if (A[0] === A[3] && A[0] === A[1]) {
|
|
2141
|
-
return [A[0], A[3]];
|
|
2142
|
-
}
|
|
2143
|
-
return minmaxQ([
|
|
2144
|
-
A[0],
|
|
2145
|
-
-0.5 * A[0] + 1.5 * A[1],
|
|
2146
|
-
A[0] - 3 * A[1] + 3 * A[2]
|
|
2147
|
-
]);
|
|
2148
|
-
}
|
|
2149
|
-
const T = -A[0] * A[2] + A[0] * A[3] - A[1] * A[2] - A[1] * A[3] + A[1] * A[1] + A[2] * A[2];
|
|
2150
|
-
if (T <= 0) {
|
|
2151
|
-
return [Math.min(A[0], A[3]), Math.max(A[0], A[3])];
|
|
2152
|
-
}
|
|
2153
|
-
const S = Math.sqrt(T);
|
|
2154
|
-
let min = Math.min(A[0], A[3]);
|
|
2155
|
-
let max = Math.max(A[0], A[3]);
|
|
2156
|
-
const L = A[0] - 2 * A[1] + A[2];
|
|
2157
|
-
for (let R = (L + S) / K, i = 1;i <= 2; R = (L - S) / K, i++) {
|
|
2158
|
-
if (R > 0 && R < 1) {
|
|
2159
|
-
const Q = A[0] * (1 - R) * (1 - R) * (1 - R) + A[1] * 3 * (1 - R) * (1 - R) * R + A[2] * 3 * (1 - R) * R * R + A[3] * R * R * R;
|
|
2160
|
-
if (Q < min) {
|
|
2161
|
-
min = Q;
|
|
2162
|
-
}
|
|
2163
|
-
if (Q > max) {
|
|
2164
|
-
max = Q;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
return [min, max];
|
|
2169
|
-
}
|
|
2170
|
-
var getBoundingBoxFromInstructions = (instructions) => {
|
|
2171
|
-
let minX = Infinity;
|
|
2172
|
-
let minY = Infinity;
|
|
2173
|
-
let maxX = -Infinity;
|
|
2174
|
-
let maxY = -Infinity;
|
|
2175
|
-
let x = 0;
|
|
2176
|
-
let y = 0;
|
|
2177
|
-
let lastMoveX = 0;
|
|
2178
|
-
let lastMoveY = 0;
|
|
2179
|
-
for (const seg of instructions) {
|
|
2180
|
-
switch (seg.type) {
|
|
2181
|
-
case "M": {
|
|
2182
|
-
lastMoveX = seg.x;
|
|
2183
|
-
lastMoveY = seg.y;
|
|
2184
|
-
if (minX > seg.x) {
|
|
2185
|
-
minX = seg.x;
|
|
2186
|
-
}
|
|
2187
|
-
if (minY > seg.y) {
|
|
2188
|
-
minY = seg.y;
|
|
2189
|
-
}
|
|
2190
|
-
if (maxX < seg.x) {
|
|
2191
|
-
maxX = seg.x;
|
|
2192
|
-
}
|
|
2193
|
-
if (maxY < seg.y) {
|
|
2194
|
-
maxY = seg.y;
|
|
2195
|
-
}
|
|
2196
|
-
x = seg.x;
|
|
2197
|
-
y = seg.y;
|
|
2198
|
-
break;
|
|
2199
|
-
}
|
|
2200
|
-
case "L": {
|
|
2201
|
-
if (minX > seg.x) {
|
|
2202
|
-
minX = seg.x;
|
|
2203
|
-
}
|
|
2204
|
-
if (minY > seg.y) {
|
|
2205
|
-
minY = seg.y;
|
|
2206
|
-
}
|
|
2207
|
-
if (maxX < seg.x) {
|
|
2208
|
-
maxX = seg.x;
|
|
2209
|
-
}
|
|
2210
|
-
if (maxY < seg.y) {
|
|
2211
|
-
maxY = seg.y;
|
|
2212
|
-
}
|
|
2213
|
-
x = seg.x;
|
|
2214
|
-
y = seg.y;
|
|
2215
|
-
break;
|
|
2216
|
-
}
|
|
2217
|
-
case "C": {
|
|
2218
|
-
const cxMinMax = minmaxC([x, seg.cp1x, seg.cp2x, seg.x]);
|
|
2219
|
-
if (minX > cxMinMax[0]) {
|
|
2220
|
-
minX = cxMinMax[0];
|
|
2221
|
-
}
|
|
2222
|
-
if (maxX < cxMinMax[1]) {
|
|
2223
|
-
maxX = cxMinMax[1];
|
|
2224
|
-
}
|
|
2225
|
-
const cyMinMax = minmaxC([y, seg.cp1y, seg.cp2y, seg.y]);
|
|
2226
|
-
if (minY > cyMinMax[0]) {
|
|
2227
|
-
minY = cyMinMax[0];
|
|
2228
|
-
}
|
|
2229
|
-
if (maxY < cyMinMax[1]) {
|
|
2230
|
-
maxY = cyMinMax[1];
|
|
2231
|
-
}
|
|
2232
|
-
x = seg.x;
|
|
2233
|
-
y = seg.y;
|
|
2234
|
-
break;
|
|
2235
|
-
}
|
|
2236
|
-
case "Z":
|
|
2237
|
-
x = lastMoveX;
|
|
2238
|
-
y = lastMoveY;
|
|
2239
|
-
break;
|
|
2240
|
-
default:
|
|
2241
|
-
throw new Error(`Unknown instruction ${seg.type}`);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
return {
|
|
2245
|
-
x1: minX,
|
|
2246
|
-
y1: minY,
|
|
2247
|
-
x2: maxX,
|
|
2248
|
-
y2: maxY,
|
|
2249
|
-
viewBox: `${minX} ${minY} ${maxX - minX} ${maxY - minY}`,
|
|
2250
|
-
width: maxX - minX,
|
|
2251
|
-
height: maxY - minY
|
|
2252
|
-
};
|
|
2253
|
-
};
|
|
2254
|
-
var PathInternals = {
|
|
2255
|
-
getBoundingBoxFromInstructions,
|
|
2256
|
-
debugPath,
|
|
2257
|
-
cutPath
|
|
2258
|
-
};
|
|
2259
979
|
|
|
2260
980
|
// src/fix-z.ts
|
|
2261
981
|
var turnInto3D = (instructions) => {
|
|
@@ -2397,29 +1117,6 @@ var transformFace = (face, transformations) => {
|
|
|
2397
1117
|
};
|
|
2398
1118
|
};
|
|
2399
1119
|
|
|
2400
|
-
// src/elements.ts
|
|
2401
|
-
var makeElement = ({
|
|
2402
|
-
face: faces,
|
|
2403
|
-
centerPoint,
|
|
2404
|
-
description
|
|
2405
|
-
}) => {
|
|
2406
|
-
return {
|
|
2407
|
-
faces,
|
|
2408
|
-
id: makeId(),
|
|
2409
|
-
centerPoint,
|
|
2410
|
-
description
|
|
2411
|
-
};
|
|
2412
|
-
};
|
|
2413
|
-
var transformElement = (element, transformations) => {
|
|
2414
|
-
return {
|
|
2415
|
-
...element,
|
|
2416
|
-
faces: element.faces.map((face) => {
|
|
2417
|
-
return transformFace(face, transformations);
|
|
2418
|
-
}),
|
|
2419
|
-
id: makeId(),
|
|
2420
|
-
centerPoint: transformations.reduce((point, transformation) => multiplyMatrix(transformation, point), element.centerPoint)
|
|
2421
|
-
};
|
|
2422
|
-
};
|
|
2423
1120
|
// src/subdivide-instructions.ts
|
|
2424
1121
|
var subdivideLOrMInstruction = (from, instruction) => {
|
|
2425
1122
|
if (instruction.type !== "L" && instruction.type !== "M") {
|
|
@@ -2547,11 +1244,6 @@ var subdivideInstructions = (instructions) => {
|
|
|
2547
1244
|
return newInstructions;
|
|
2548
1245
|
};
|
|
2549
1246
|
|
|
2550
|
-
// src/truthy.ts
|
|
2551
|
-
function truthy(value) {
|
|
2552
|
-
return Boolean(value);
|
|
2553
|
-
}
|
|
2554
|
-
|
|
2555
1247
|
// src/extrude-element.ts
|
|
2556
1248
|
var inverseInstruction = (instruction, comingFrom) => {
|
|
2557
1249
|
if (instruction.type === "M") {
|
|
@@ -2592,29 +1284,17 @@ var inverseInstruction = (instruction, comingFrom) => {
|
|
|
2592
1284
|
var extrudeElement = ({
|
|
2593
1285
|
depth,
|
|
2594
1286
|
sideColor,
|
|
2595
|
-
frontFaceColor,
|
|
2596
|
-
backFaceColor,
|
|
2597
1287
|
points,
|
|
2598
|
-
strokeWidth,
|
|
2599
|
-
description = "extruded",
|
|
2600
|
-
strokeColor,
|
|
2601
1288
|
crispEdges
|
|
2602
1289
|
}) => {
|
|
2603
|
-
const boundingBox = PathInternals.getBoundingBoxFromInstructions(reduceInstructions(points));
|
|
2604
|
-
const centerX = (boundingBox.x2 - boundingBox.x1) / 2 + boundingBox.x1;
|
|
2605
|
-
const centerY = (boundingBox.y2 - boundingBox.y1) / 2 + boundingBox.y1;
|
|
2606
1290
|
const threeD = turnInto3D(points);
|
|
2607
1291
|
const instructions = {
|
|
2608
1292
|
centerPoint: [0, 0, 0, 1],
|
|
2609
1293
|
points: subdivideInstructions(subdivideInstructions(subdivideInstructions(threeD))),
|
|
2610
|
-
strokeWidth,
|
|
2611
|
-
strokeColor,
|
|
2612
1294
|
color: "black",
|
|
2613
|
-
description: description ?? "extruded",
|
|
2614
1295
|
crispEdges
|
|
2615
1296
|
};
|
|
2616
|
-
const unscaledBackFace = transformFace(instructions, []);
|
|
2617
|
-
const unscaledFrontFace = transformFace(instructions, [translateZ(-depth)]);
|
|
1297
|
+
const unscaledBackFace = transformFace(instructions, [translateZ(depth / 2)]);
|
|
2618
1298
|
const inbetween = unscaledBackFace.points.map((t, i) => {
|
|
2619
1299
|
const nextInstruction = i === unscaledBackFace.points.length - 1 ? unscaledBackFace.points[0] : unscaledBackFace.points[i + 1];
|
|
2620
1300
|
const currentPoint = t.point;
|
|
@@ -2650,39 +1330,26 @@ var extrudeElement = ({
|
|
|
2650
1330
|
points: newInstructions,
|
|
2651
1331
|
color: sideColor,
|
|
2652
1332
|
centerPoint: [0, 0, 0, 1],
|
|
2653
|
-
strokeWidth: 0,
|
|
2654
|
-
strokeColor: "black",
|
|
2655
|
-
description: description + "inbetween",
|
|
2656
1333
|
crispEdges: true
|
|
2657
1334
|
};
|
|
2658
1335
|
});
|
|
2659
|
-
|
|
2660
|
-
...unscaledFrontFace,
|
|
2661
|
-
color: frontFaceColor,
|
|
2662
|
-
description: description + "(front)"
|
|
2663
|
-
};
|
|
2664
|
-
const scaledBackFace = {
|
|
2665
|
-
...unscaledBackFace,
|
|
2666
|
-
color: backFaceColor,
|
|
2667
|
-
description: description + "(back)"
|
|
2668
|
-
};
|
|
2669
|
-
return makeElement({
|
|
2670
|
-
face: [...inbetween, scaledFrontFace, scaledBackFace],
|
|
2671
|
-
centerPoint: [centerX, centerY, 0, 1],
|
|
2672
|
-
description
|
|
2673
|
-
});
|
|
1336
|
+
return inbetween;
|
|
2674
1337
|
};
|
|
2675
1338
|
var extrudeAndTransformElement = (options) => {
|
|
2676
|
-
|
|
1339
|
+
const inbetween = extrudeElement(options);
|
|
1340
|
+
return inbetween.map((face) => ({
|
|
1341
|
+
...transformFace(face, [options.transformations])
|
|
1342
|
+
}));
|
|
2677
1343
|
};
|
|
2678
1344
|
export {
|
|
2679
1345
|
translateZ,
|
|
2680
1346
|
translateY,
|
|
2681
1347
|
translateX,
|
|
2682
1348
|
transformPath,
|
|
2683
|
-
transformElement,
|
|
2684
1349
|
threeDIntoSvgPath,
|
|
2685
1350
|
scaled,
|
|
1351
|
+
scaleY,
|
|
1352
|
+
scaleX,
|
|
2686
1353
|
rotateZ,
|
|
2687
1354
|
rotateY,
|
|
2688
1355
|
rotateX,
|