@antv/g-canvas 1.9.14 → 1.9.15

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/index.umd.js CHANGED
@@ -400,238 +400,614 @@
400
400
  return _setPrototypeOf(o, p);
401
401
  }
402
402
 
403
- var toString = {}.toString;
404
- var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
405
-
406
- // isFinite,
407
- var isNil = function (value) {
408
- /**
409
- * isNil(null) => true
410
- * isNil() => true
411
- */
412
- return value === null || value === undefined;
413
- };
403
+ /**
404
+ * Common utilities
405
+ * @module glMatrix
406
+ */
407
+ var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
408
+ if (!Math.hypot) Math.hypot = function () {
409
+ var y = 0,
410
+ i = arguments.length;
414
411
 
415
- var isString = (function (str) {
416
- return isType(str, 'String');
417
- });
412
+ while (i--) {
413
+ y += arguments[i] * arguments[i];
414
+ }
418
415
 
419
- var clamp = function (a, min, max) {
420
- if (a < min) {
421
- return min;
422
- }
423
- else if (a > max) {
424
- return max;
425
- }
426
- return a;
416
+ return Math.sqrt(y);
427
417
  };
428
418
 
429
- function _inheritsLoose$1(subClass, superClass) {
430
- subClass.prototype = Object.create(superClass.prototype);
431
- subClass.prototype.constructor = subClass;
419
+ /**
420
+ * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
421
+ * @module mat4
422
+ */
432
423
 
433
- _setPrototypeOf$1(subClass, superClass);
434
- }
424
+ /**
425
+ * Creates a new identity mat4
426
+ *
427
+ * @returns {mat4} a new 4x4 matrix
428
+ */
435
429
 
436
- function _setPrototypeOf$1(o, p) {
437
- _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
438
- o.__proto__ = p;
439
- return o;
440
- };
441
- return _setPrototypeOf$1(o, p);
442
- }
430
+ function create() {
431
+ var out = new ARRAY_TYPE(16);
443
432
 
444
- function generatePath(context, parsedStyle) {
445
- var r = parsedStyle.r;
446
- context.arc(r, r, r, 0, Math.PI * 2, false);
447
- }
433
+ if (ARRAY_TYPE != Float32Array) {
434
+ out[1] = 0;
435
+ out[2] = 0;
436
+ out[3] = 0;
437
+ out[4] = 0;
438
+ out[6] = 0;
439
+ out[7] = 0;
440
+ out[8] = 0;
441
+ out[9] = 0;
442
+ out[11] = 0;
443
+ out[12] = 0;
444
+ out[13] = 0;
445
+ out[14] = 0;
446
+ }
448
447
 
449
- function generatePath$1(context, parsedStyle) {
450
- var rxInPixels = parsedStyle.rx,
451
- ryInPixels = parsedStyle.ry;
452
- var rx = rxInPixels;
453
- var ry = ryInPixels; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
448
+ out[0] = 1;
449
+ out[5] = 1;
450
+ out[10] = 1;
451
+ out[15] = 1;
452
+ return out;
453
+ }
454
+ /**
455
+ * Copy the values from one mat4 to another
456
+ *
457
+ * @param {mat4} out the receiving matrix
458
+ * @param {ReadonlyMat4} a the source matrix
459
+ * @returns {mat4} out
460
+ */
454
461
 
455
- if (context.ellipse) {
456
- context.ellipse(rx, ry, rx, ry, 0, 0, Math.PI * 2, false);
457
- } else {
458
- // 如果不支持,则使用圆来绘制,进行变形
459
- var r = rx > ry ? rx : ry;
460
- var scaleX = rx > ry ? 1 : rx / ry;
461
- var scaleY = rx > ry ? ry / rx : 1;
462
- context.save();
463
- context.scale(scaleX, scaleY);
464
- context.arc(0, 0, r, 0, Math.PI * 2);
465
- }
462
+ function copy(out, a) {
463
+ out[0] = a[0];
464
+ out[1] = a[1];
465
+ out[2] = a[2];
466
+ out[3] = a[3];
467
+ out[4] = a[4];
468
+ out[5] = a[5];
469
+ out[6] = a[6];
470
+ out[7] = a[7];
471
+ out[8] = a[8];
472
+ out[9] = a[9];
473
+ out[10] = a[10];
474
+ out[11] = a[11];
475
+ out[12] = a[12];
476
+ out[13] = a[13];
477
+ out[14] = a[14];
478
+ out[15] = a[15];
479
+ return out;
466
480
  }
481
+ /**
482
+ * Inverts a mat4
483
+ *
484
+ * @param {mat4} out the receiving matrix
485
+ * @param {ReadonlyMat4} a the source matrix
486
+ * @returns {mat4} out
487
+ */
467
488
 
468
- function generatePath$2(context, parsedStyle) {
469
- var x1 = parsedStyle.x1,
470
- y1 = parsedStyle.y1,
471
- x2 = parsedStyle.x2,
472
- y2 = parsedStyle.y2,
473
- _parsedStyle$defX = parsedStyle.defX,
474
- defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
475
- _parsedStyle$defY = parsedStyle.defY,
476
- defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
477
- markerStart = parsedStyle.markerStart,
478
- markerEnd = parsedStyle.markerEnd,
479
- markerStartOffset = parsedStyle.markerStartOffset,
480
- markerEndOffset = parsedStyle.markerEndOffset;
481
- var startOffsetX = 0;
482
- var startOffsetY = 0;
483
- var endOffsetX = 0;
484
- var endOffsetY = 0;
485
- var rad = 0;
486
- var x;
487
- var y;
489
+ function invert(out, a) {
490
+ var a00 = a[0],
491
+ a01 = a[1],
492
+ a02 = a[2],
493
+ a03 = a[3];
494
+ var a10 = a[4],
495
+ a11 = a[5],
496
+ a12 = a[6],
497
+ a13 = a[7];
498
+ var a20 = a[8],
499
+ a21 = a[9],
500
+ a22 = a[10],
501
+ a23 = a[11];
502
+ var a30 = a[12],
503
+ a31 = a[13],
504
+ a32 = a[14],
505
+ a33 = a[15];
506
+ var b00 = a00 * a11 - a01 * a10;
507
+ var b01 = a00 * a12 - a02 * a10;
508
+ var b02 = a00 * a13 - a03 * a10;
509
+ var b03 = a01 * a12 - a02 * a11;
510
+ var b04 = a01 * a13 - a03 * a11;
511
+ var b05 = a02 * a13 - a03 * a12;
512
+ var b06 = a20 * a31 - a21 * a30;
513
+ var b07 = a20 * a32 - a22 * a30;
514
+ var b08 = a20 * a33 - a23 * a30;
515
+ var b09 = a21 * a32 - a22 * a31;
516
+ var b10 = a21 * a33 - a23 * a31;
517
+ var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
488
518
 
489
- if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
490
- x = x2 - x1;
491
- y = y2 - y1;
492
- rad = Math.atan2(y, x);
493
- startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
494
- startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
495
- }
519
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
496
520
 
497
- if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
498
- x = x1 - x2;
499
- y = y1 - y2;
500
- rad = Math.atan2(y, x);
501
- endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
502
- endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
521
+ if (!det) {
522
+ return null;
503
523
  }
504
524
 
505
- context.moveTo(x1 - defX + startOffsetX, y1 - defY + startOffsetY);
506
- context.lineTo(x2 - defX + endOffsetX, y2 - defY + endOffsetY);
525
+ det = 1.0 / det;
526
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
527
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
528
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
529
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
530
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
531
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
532
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
533
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
534
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
535
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
536
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
537
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
538
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
539
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
540
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
541
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
542
+ return out;
507
543
  }
544
+ /**
545
+ * Multiplies two mat4s
546
+ *
547
+ * @param {mat4} out the receiving matrix
548
+ * @param {ReadonlyMat4} a the first operand
549
+ * @param {ReadonlyMat4} b the second operand
550
+ * @returns {mat4} out
551
+ */
508
552
 
509
- function generatePath$3(context, parsedStyle) {
510
- var _parsedStyle$defX = parsedStyle.defX,
511
- defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
512
- _parsedStyle$defY = parsedStyle.defY,
513
- defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
514
- markerStart = parsedStyle.markerStart,
515
- markerEnd = parsedStyle.markerEnd,
516
- markerStartOffset = parsedStyle.markerStartOffset,
517
- markerEndOffset = parsedStyle.markerEndOffset;
518
- var _parsedStyle$path = parsedStyle.path,
519
- curve = _parsedStyle$path.curve,
520
- zCommandIndexes = _parsedStyle$path.zCommandIndexes;
521
- var path = [].concat(curve);
522
- zCommandIndexes.forEach(function (zIndex, index) {
523
- // @ts-ignore
524
- path.splice(zIndex + index + 1, 0, ['Z']);
525
- }); // @ts-ignore
553
+ function multiply(out, a, b) {
554
+ var a00 = a[0],
555
+ a01 = a[1],
556
+ a02 = a[2],
557
+ a03 = a[3];
558
+ var a10 = a[4],
559
+ a11 = a[5],
560
+ a12 = a[6],
561
+ a13 = a[7];
562
+ var a20 = a[8],
563
+ a21 = a[9],
564
+ a22 = a[10],
565
+ a23 = a[11];
566
+ var a30 = a[12],
567
+ a31 = a[13],
568
+ a32 = a[14],
569
+ a33 = a[15]; // Cache only the current line of the second matrix
526
570
 
527
- var isClosed = path.length && path[path.length - 1][0] === 'Z';
528
- var startOffsetX = 0;
529
- var startOffsetY = 0;
530
- var endOffsetX = 0;
531
- var endOffsetY = 0;
532
- var rad = 0;
533
- var x;
534
- var y;
571
+ var b0 = b[0],
572
+ b1 = b[1],
573
+ b2 = b[2],
574
+ b3 = b[3];
575
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
576
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
577
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
578
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
579
+ b0 = b[4];
580
+ b1 = b[5];
581
+ b2 = b[6];
582
+ b3 = b[7];
583
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
584
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
585
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
586
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
587
+ b0 = b[8];
588
+ b1 = b[9];
589
+ b2 = b[10];
590
+ b3 = b[11];
591
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
592
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
593
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
594
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
595
+ b0 = b[12];
596
+ b1 = b[13];
597
+ b2 = b[14];
598
+ b3 = b[15];
599
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
600
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
601
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
602
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
603
+ return out;
604
+ }
605
+ /**
606
+ * Translate a mat4 by the given vector
607
+ *
608
+ * @param {mat4} out the receiving matrix
609
+ * @param {ReadonlyMat4} a the matrix to translate
610
+ * @param {ReadonlyVec3} v vector to translate by
611
+ * @returns {mat4} out
612
+ */
613
+
614
+ function translate(out, a, v) {
615
+ var x = v[0],
616
+ y = v[1],
617
+ z = v[2];
618
+ var a00, a01, a02, a03;
619
+ var a10, a11, a12, a13;
620
+ var a20, a21, a22, a23;
621
+
622
+ if (a === out) {
623
+ out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
624
+ out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
625
+ out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
626
+ out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
627
+ } else {
628
+ a00 = a[0];
629
+ a01 = a[1];
630
+ a02 = a[2];
631
+ a03 = a[3];
632
+ a10 = a[4];
633
+ a11 = a[5];
634
+ a12 = a[6];
635
+ a13 = a[7];
636
+ a20 = a[8];
637
+ a21 = a[9];
638
+ a22 = a[10];
639
+ a23 = a[11];
640
+ out[0] = a00;
641
+ out[1] = a01;
642
+ out[2] = a02;
643
+ out[3] = a03;
644
+ out[4] = a10;
645
+ out[5] = a11;
646
+ out[6] = a12;
647
+ out[7] = a13;
648
+ out[8] = a20;
649
+ out[9] = a21;
650
+ out[10] = a22;
651
+ out[11] = a23;
652
+ out[12] = a00 * x + a10 * y + a20 * z + a[12];
653
+ out[13] = a01 * x + a11 * y + a21 * z + a[13];
654
+ out[14] = a02 * x + a12 * y + a22 * z + a[14];
655
+ out[15] = a03 * x + a13 * y + a23 * z + a[15];
656
+ }
657
+
658
+ return out;
659
+ }
660
+ /**
661
+ * Creates a matrix from a vector scaling
662
+ * This is equivalent to (but much faster than):
663
+ *
664
+ * mat4.identity(dest);
665
+ * mat4.scale(dest, dest, vec);
666
+ *
667
+ * @param {mat4} out mat4 receiving operation result
668
+ * @param {ReadonlyVec3} v Scaling vector
669
+ * @returns {mat4} out
670
+ */
671
+
672
+ function fromScaling(out, v) {
673
+ out[0] = v[0];
674
+ out[1] = 0;
675
+ out[2] = 0;
676
+ out[3] = 0;
677
+ out[4] = 0;
678
+ out[5] = v[1];
679
+ out[6] = 0;
680
+ out[7] = 0;
681
+ out[8] = 0;
682
+ out[9] = 0;
683
+ out[10] = v[2];
684
+ out[11] = 0;
685
+ out[12] = 0;
686
+ out[13] = 0;
687
+ out[14] = 0;
688
+ out[15] = 1;
689
+ return out;
690
+ }
691
+
692
+ /**
693
+ * 3 Dimensional Vector
694
+ * @module vec3
695
+ */
696
+
697
+ /**
698
+ * Creates a new, empty vec3
699
+ *
700
+ * @returns {vec3} a new 3D vector
701
+ */
702
+
703
+ function create$1() {
704
+ var out = new ARRAY_TYPE(3);
705
+
706
+ if (ARRAY_TYPE != Float32Array) {
707
+ out[0] = 0;
708
+ out[1] = 0;
709
+ out[2] = 0;
710
+ }
711
+
712
+ return out;
713
+ }
714
+ /**
715
+ * Creates a new vec3 initialized with the given values
716
+ *
717
+ * @param {Number} x X component
718
+ * @param {Number} y Y component
719
+ * @param {Number} z Z component
720
+ * @returns {vec3} a new 3D vector
721
+ */
722
+
723
+ function fromValues(x, y, z) {
724
+ var out = new ARRAY_TYPE(3);
725
+ out[0] = x;
726
+ out[1] = y;
727
+ out[2] = z;
728
+ return out;
729
+ }
730
+ /**
731
+ * Set the components of a vec3 to the given values
732
+ *
733
+ * @param {vec3} out the receiving vector
734
+ * @param {Number} x X component
735
+ * @param {Number} y Y component
736
+ * @param {Number} z Z component
737
+ * @returns {vec3} out
738
+ */
739
+
740
+ function set(out, x, y, z) {
741
+ out[0] = x;
742
+ out[1] = y;
743
+ out[2] = z;
744
+ return out;
745
+ }
746
+ /**
747
+ * Transforms the vec3 with a mat4.
748
+ * 4th vector component is implicitly '1'
749
+ *
750
+ * @param {vec3} out the receiving vector
751
+ * @param {ReadonlyVec3} a the vector to transform
752
+ * @param {ReadonlyMat4} m matrix to transform with
753
+ * @returns {vec3} out
754
+ */
755
+
756
+ function transformMat4(out, a, m) {
757
+ var x = a[0],
758
+ y = a[1],
759
+ z = a[2];
760
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
761
+ w = w || 1.0;
762
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
763
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
764
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
765
+ return out;
766
+ }
767
+ /**
768
+ * Transforms the vec3 with a mat3.
769
+ *
770
+ * @param {vec3} out the receiving vector
771
+ * @param {ReadonlyVec3} a the vector to transform
772
+ * @param {ReadonlyMat3} m the 3x3 matrix to transform with
773
+ * @returns {vec3} out
774
+ */
775
+
776
+ function transformMat3(out, a, m) {
777
+ var x = a[0],
778
+ y = a[1],
779
+ z = a[2];
780
+ out[0] = x * m[0] + y * m[3] + z * m[6];
781
+ out[1] = x * m[1] + y * m[4] + z * m[7];
782
+ out[2] = x * m[2] + y * m[5] + z * m[8];
783
+ return out;
784
+ }
785
+ /**
786
+ * Perform some operation over an array of vec3s.
787
+ *
788
+ * @param {Array} a the array of vectors to iterate over
789
+ * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
790
+ * @param {Number} offset Number of elements to skip at the beginning of the array
791
+ * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
792
+ * @param {Function} fn Function to call for each vector in the array
793
+ * @param {Object} [arg] additional argument to pass to fn
794
+ * @returns {Array} a
795
+ * @function
796
+ */
797
+
798
+ var forEach = function () {
799
+ var vec = create$1();
800
+ return function (a, stride, offset, count, fn, arg) {
801
+ var i, l;
802
+
803
+ if (!stride) {
804
+ stride = 3;
805
+ }
806
+
807
+ if (!offset) {
808
+ offset = 0;
809
+ }
810
+
811
+ if (count) {
812
+ l = Math.min(count * stride + offset, a.length);
813
+ } else {
814
+ l = a.length;
815
+ }
816
+
817
+ for (i = offset; i < l; i += stride) {
818
+ vec[0] = a[i];
819
+ vec[1] = a[i + 1];
820
+ vec[2] = a[i + 2];
821
+ fn(vec, vec, arg);
822
+ a[i] = vec[0];
823
+ a[i + 1] = vec[1];
824
+ a[i + 2] = vec[2];
825
+ }
826
+
827
+ return a;
828
+ };
829
+ }();
830
+
831
+ /**
832
+ * 2 Dimensional Vector
833
+ * @module vec2
834
+ */
835
+
836
+ /**
837
+ * Creates a new, empty vec2
838
+ *
839
+ * @returns {vec2} a new 2D vector
840
+ */
841
+
842
+ function create$2() {
843
+ var out = new ARRAY_TYPE(2);
844
+
845
+ if (ARRAY_TYPE != Float32Array) {
846
+ out[0] = 0;
847
+ out[1] = 0;
848
+ }
849
+
850
+ return out;
851
+ }
852
+ /**
853
+ * Normalize a vec2
854
+ *
855
+ * @param {vec2} out the receiving vector
856
+ * @param {ReadonlyVec2} a vector to normalize
857
+ * @returns {vec2} out
858
+ */
859
+
860
+ function normalize(out, a) {
861
+ var x = a[0],
862
+ y = a[1];
863
+ var len = x * x + y * y;
864
+
865
+ if (len > 0) {
866
+ //TODO: evaluate use of glm_invsqrt here?
867
+ len = 1 / Math.sqrt(len);
868
+ }
869
+
870
+ out[0] = a[0] * len;
871
+ out[1] = a[1] * len;
872
+ return out;
873
+ }
874
+ /**
875
+ * Calculates the dot product of two vec2's
876
+ *
877
+ * @param {ReadonlyVec2} a the first operand
878
+ * @param {ReadonlyVec2} b the second operand
879
+ * @returns {Number} dot product of a and b
880
+ */
881
+
882
+ function dot(a, b) {
883
+ return a[0] * b[0] + a[1] * b[1];
884
+ }
885
+ /**
886
+ * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
887
+ *
888
+ * @param {ReadonlyVec2} a The first vector.
889
+ * @param {ReadonlyVec2} b The second vector.
890
+ * @returns {Boolean} True if the vectors are equal, false otherwise.
891
+ */
535
892
 
536
- if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
537
- var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
538
- p1 = _markerStart$parentNo[0],
539
- p2 = _markerStart$parentNo[1];
893
+ function exactEquals(a, b) {
894
+ return a[0] === b[0] && a[1] === b[1];
895
+ }
896
+ /**
897
+ * Perform some operation over an array of vec2s.
898
+ *
899
+ * @param {Array} a the array of vectors to iterate over
900
+ * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
901
+ * @param {Number} offset Number of elements to skip at the beginning of the array
902
+ * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
903
+ * @param {Function} fn Function to call for each vector in the array
904
+ * @param {Object} [arg] additional argument to pass to fn
905
+ * @returns {Array} a
906
+ * @function
907
+ */
540
908
 
541
- x = p1[0] - p2[0];
542
- y = p1[1] - p2[1];
543
- rad = Math.atan2(y, x);
544
- startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
545
- startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
546
- }
909
+ var forEach$1 = function () {
910
+ var vec = create$2();
911
+ return function (a, stride, offset, count, fn, arg) {
912
+ var i, l;
547
913
 
548
- if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
549
- var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
550
- _p = _markerEnd$parentNode[0],
551
- _p2 = _markerEnd$parentNode[1];
914
+ if (!stride) {
915
+ stride = 2;
916
+ }
552
917
 
553
- x = _p[0] - _p2[0];
554
- y = _p[1] - _p2[1];
555
- rad = Math.atan2(y, x);
556
- endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
557
- endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
558
- }
918
+ if (!offset) {
919
+ offset = 0;
920
+ }
559
921
 
560
- for (var i = 0; i < path.length; i++) {
561
- var params = path[i];
562
- var command = params[0];
922
+ if (count) {
923
+ l = Math.min(count * stride + offset, a.length);
924
+ } else {
925
+ l = a.length;
926
+ }
563
927
 
564
- switch (command) {
565
- case 'M':
566
- context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY);
567
- break;
928
+ for (i = offset; i < l; i += stride) {
929
+ vec[0] = a[i];
930
+ vec[1] = a[i + 1];
931
+ fn(vec, vec, arg);
932
+ a[i] = vec[0];
933
+ a[i + 1] = vec[1];
934
+ }
568
935
 
569
- case 'C':
570
- // the last C command
571
- var offsetX = i === path.length - (isClosed ? 2 : 1) ? endOffsetX : 0;
572
- var offsetY = i === path.length - (isClosed ? 2 : 1) ? endOffsetY : 0;
573
- context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX + offsetX, params[6] - defY + offsetY);
574
- break;
575
- // @ts-ignore
936
+ return a;
937
+ };
938
+ }();
576
939
 
577
- case 'Z':
578
- context.closePath();
579
- break;
940
+ var toString = {}.toString;
941
+ var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
942
+
943
+ // isFinite,
944
+ var isNil = function (value) {
945
+ /**
946
+ * isNil(null) => true
947
+ * isNil() => true
948
+ */
949
+ return value === null || value === undefined;
950
+ };
951
+
952
+ var isString = (function (str) {
953
+ return isType(str, 'String');
954
+ });
955
+
956
+ var clamp = function (a, min, max) {
957
+ if (a < min) {
958
+ return min;
580
959
  }
581
- }
582
- }
960
+ else if (a > max) {
961
+ return max;
962
+ }
963
+ return a;
964
+ };
583
965
 
584
- function generatePath$4(context, parsedStyle) {
585
- var _parsedStyle$defX = parsedStyle.defX,
586
- defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
587
- _parsedStyle$defY = parsedStyle.defY,
588
- defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
589
- markerStart = parsedStyle.markerStart,
590
- markerEnd = parsedStyle.markerEnd,
591
- markerStartOffset = parsedStyle.markerStartOffset,
592
- markerEndOffset = parsedStyle.markerEndOffset;
593
- var points = parsedStyle.points.points;
594
- var length = points.length;
595
- var x1 = points[0][0] - defX;
596
- var y1 = points[0][1] - defY;
597
- var x2 = points[length - 1][0] - defX;
598
- var y2 = points[length - 1][1] - defY;
599
- var startOffsetX = 0;
600
- var startOffsetY = 0;
601
- var endOffsetX = 0;
602
- var endOffsetY = 0;
603
- var rad = 0;
604
- var x;
605
- var y;
966
+ function _inheritsLoose$1(subClass, superClass) {
967
+ subClass.prototype = Object.create(superClass.prototype);
968
+ subClass.prototype.constructor = subClass;
606
969
 
607
- if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
608
- x = points[1][0] - points[0][0];
609
- y = points[1][1] - points[0][1];
610
- rad = Math.atan2(y, x);
611
- startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
612
- startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
613
- }
970
+ _setPrototypeOf$1(subClass, superClass);
971
+ }
614
972
 
615
- if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
616
- x = points[length - 1][0] - points[0][0];
617
- y = points[length - 1][1] - points[0][1];
618
- rad = Math.atan2(y, x);
619
- endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
620
- endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
621
- }
973
+ function _setPrototypeOf$1(o, p) {
974
+ _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
975
+ o.__proto__ = p;
976
+ return o;
977
+ };
978
+ return _setPrototypeOf$1(o, p);
979
+ }
622
980
 
623
- context.moveTo(x1 + (startOffsetX || endOffsetX), y1 + (startOffsetY || endOffsetY));
981
+ function generatePath(context, parsedStyle) {
982
+ var r = parsedStyle.r;
983
+ context.arc(r, r, r, 0, Math.PI * 2, false);
984
+ }
624
985
 
625
- for (var i = 1; i < length - 1; i++) {
626
- var point = points[i];
627
- context.lineTo(point[0] - defX, point[1] - defY);
628
- }
986
+ function generatePath$1(context, parsedStyle) {
987
+ var rxInPixels = parsedStyle.rx,
988
+ ryInPixels = parsedStyle.ry;
989
+ var rx = rxInPixels;
990
+ var ry = ryInPixels; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
629
991
 
630
- context.lineTo(x2, y2);
992
+ if (context.ellipse) {
993
+ context.ellipse(rx, ry, rx, ry, 0, 0, Math.PI * 2, false);
994
+ } else {
995
+ // 如果不支持,则使用圆来绘制,进行变形
996
+ var r = rx > ry ? rx : ry;
997
+ var scaleX = rx > ry ? 1 : rx / ry;
998
+ var scaleY = rx > ry ? ry / rx : 1;
999
+ context.save();
1000
+ context.scale(scaleX, scaleY);
1001
+ context.arc(0, 0, r, 0, Math.PI * 2);
1002
+ }
631
1003
  }
632
1004
 
633
- function generatePath$5(context, parsedStyle) {
634
- var _parsedStyle$defX = parsedStyle.defX,
1005
+ function generatePath$2(context, parsedStyle) {
1006
+ var x1 = parsedStyle.x1,
1007
+ y1 = parsedStyle.y1,
1008
+ x2 = parsedStyle.x2,
1009
+ y2 = parsedStyle.y2,
1010
+ _parsedStyle$defX = parsedStyle.defX,
635
1011
  defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
636
1012
  _parsedStyle$defY = parsedStyle.defY,
637
1013
  defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
@@ -639,12 +1015,6 @@
639
1015
  markerEnd = parsedStyle.markerEnd,
640
1016
  markerStartOffset = parsedStyle.markerStartOffset,
641
1017
  markerEndOffset = parsedStyle.markerEndOffset;
642
- var points = parsedStyle.points.points;
643
- var length = points.length;
644
- var x1 = points[0][0] - defX;
645
- var y1 = points[0][1] - defY;
646
- var x2 = points[length - 1][0] - defX;
647
- var y2 = points[length - 1][1] - defY;
648
1018
  var startOffsetX = 0;
649
1019
  var startOffsetY = 0;
650
1020
  var endOffsetX = 0;
@@ -654,935 +1024,786 @@
654
1024
  var y;
655
1025
 
656
1026
  if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
657
- x = points[1][0] - points[0][0];
658
- y = points[1][1] - points[0][1];
1027
+ x = x2 - x1;
1028
+ y = y2 - y1;
659
1029
  rad = Math.atan2(y, x);
660
1030
  startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
661
- startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
662
- }
663
-
664
- if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
665
- x = points[length - 2][0] - points[length - 1][0];
666
- y = points[length - 2][1] - points[length - 1][1];
667
- rad = Math.atan2(y, x);
668
- endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
669
- endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
670
- }
671
-
672
- context.moveTo(x1 + startOffsetX, y1 + startOffsetY);
673
-
674
- for (var i = 1; i < length - 1; i++) {
675
- var point = points[i];
676
- context.lineTo(point[0] - defX, point[1] - defY);
677
- }
678
-
679
- context.lineTo(x2 + endOffsetX, y2 + endOffsetY);
680
- }
681
-
682
- function generatePath$6(context, parsedStyle) {
683
- var radius = parsedStyle.radius,
684
- width = parsedStyle.width,
685
- height = parsedStyle.height;
686
- var w = width;
687
- var h = height;
688
- var hasRadius = radius && radius.some(function (r) {
689
- return r !== 0;
690
- });
691
-
692
- if (!hasRadius) {
693
- // Canvas support negative width/height of rect
694
- context.rect(0, 0, w, h);
695
- } else {
696
- var signX = width > 0 ? 1 : -1;
697
- var signY = height > 0 ? 1 : -1;
698
- var sweepFlag = signX + signY === 0;
699
-
700
- var _radius$map = radius.map(function (r) {
701
- return clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
702
- }),
703
- tlr = _radius$map[0],
704
- trr = _radius$map[1],
705
- brr = _radius$map[2],
706
- blr = _radius$map[3];
707
-
708
- context.moveTo(signX * tlr, 0);
709
- context.lineTo(w - signX * trr, 0);
710
-
711
- if (trr !== 0) {
712
- context.arc(w - signX * trr, signY * trr, trr, -signY * Math.PI / 2, signX > 0 ? 0 : Math.PI, sweepFlag);
713
- }
714
-
715
- context.lineTo(w, h - signY * brr);
716
-
717
- if (brr !== 0) {
718
- context.arc(w - signX * brr, h - signY * brr, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag);
719
- }
720
-
721
- context.lineTo(signX * blr, h);
722
-
723
- if (blr !== 0) {
724
- context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag);
725
- }
726
-
727
- context.lineTo(0, signY * tlr);
1031
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
1032
+ }
728
1033
 
729
- if (tlr !== 0) {
730
- context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag);
731
- }
1034
+ if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
1035
+ x = x1 - x2;
1036
+ y = y1 - y2;
1037
+ rad = Math.atan2(y, x);
1038
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
1039
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
732
1040
  }
733
- }
734
1041
 
735
- var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
736
- _inheritsLoose$1(Plugin, _AbstractRendererPlug);
1042
+ context.moveTo(x1 - defX + startOffsetX, y1 - defY + startOffsetY);
1043
+ context.lineTo(x2 - defX + endOffsetX, y2 - defY + endOffsetY);
1044
+ }
737
1045
 
738
- function Plugin() {
739
- var _this;
1046
+ function generatePath$3(context, parsedStyle) {
1047
+ var _parsedStyle$defX = parsedStyle.defX,
1048
+ defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1049
+ _parsedStyle$defY = parsedStyle.defY,
1050
+ defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
1051
+ markerStart = parsedStyle.markerStart,
1052
+ markerEnd = parsedStyle.markerEnd,
1053
+ markerStartOffset = parsedStyle.markerStartOffset,
1054
+ markerEndOffset = parsedStyle.markerEndOffset;
1055
+ var _parsedStyle$path = parsedStyle.path,
1056
+ absolutePath = _parsedStyle$path.absolutePath,
1057
+ segments = _parsedStyle$path.segments;
1058
+ var startOffsetX = 0;
1059
+ var startOffsetY = 0;
1060
+ var endOffsetX = 0;
1061
+ var endOffsetY = 0;
1062
+ var rad = 0;
1063
+ var x;
1064
+ var y;
740
1065
 
741
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
742
- args[_key] = arguments[_key];
743
- }
1066
+ if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
1067
+ var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
1068
+ p1 = _markerStart$parentNo[0],
1069
+ p2 = _markerStart$parentNo[1];
744
1070
 
745
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
746
- _this.name = 'canvas-path-generator';
747
- return _this;
1071
+ x = p1[0] - p2[0];
1072
+ y = p1[1] - p2[1];
1073
+ rad = Math.atan2(y, x);
1074
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
1075
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
748
1076
  }
749
1077
 
750
- var _proto = Plugin.prototype;
751
-
752
- _proto.init = function init() {
753
- var _pathGeneratorFactory;
1078
+ if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
1079
+ var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
1080
+ _p = _markerEnd$parentNode[0],
1081
+ _p2 = _markerEnd$parentNode[1];
754
1082
 
755
- var pathGeneratorFactory = (_pathGeneratorFactory = {}, _pathGeneratorFactory[gLite.Shape.CIRCLE] = generatePath, _pathGeneratorFactory[gLite.Shape.ELLIPSE] = generatePath$1, _pathGeneratorFactory[gLite.Shape.RECT] = generatePath$6, _pathGeneratorFactory[gLite.Shape.LINE] = generatePath$2, _pathGeneratorFactory[gLite.Shape.POLYLINE] = generatePath$5, _pathGeneratorFactory[gLite.Shape.POLYGON] = generatePath$4, _pathGeneratorFactory[gLite.Shape.PATH] = generatePath$3, _pathGeneratorFactory[gLite.Shape.TEXT] = undefined, _pathGeneratorFactory[gLite.Shape.GROUP] = undefined, _pathGeneratorFactory[gLite.Shape.IMAGE] = undefined, _pathGeneratorFactory[gLite.Shape.HTML] = undefined, _pathGeneratorFactory[gLite.Shape.MESH] = undefined, _pathGeneratorFactory); // @ts-ignore
1083
+ x = _p[0] - _p2[0];
1084
+ y = _p[1] - _p2[1];
1085
+ rad = Math.atan2(y, x);
1086
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
1087
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
1088
+ }
756
1089
 
757
- this.context.pathGeneratorFactory = pathGeneratorFactory;
758
- };
1090
+ for (var i = 0; i < absolutePath.length; i++) {
1091
+ var params = absolutePath[i];
1092
+ var command = params[0];
1093
+ var nextSegment = absolutePath[i + 1];
1094
+ var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0;
1095
+ var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0;
759
1096
 
760
- _proto.destroy = function destroy() {
761
- // @ts-ignore
762
- delete this.context.pathGeneratorFactory;
763
- };
1097
+ switch (command) {
1098
+ case 'M':
1099
+ // Use start marker offset
1100
+ if (useStartOffset) {
1101
+ context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY);
1102
+ context.lineTo(params[1] - defX, params[2] - defY);
1103
+ } else {
1104
+ context.moveTo(params[1] - defX, params[2] - defY);
1105
+ }
764
1106
 
765
- return Plugin;
766
- }(gLite.AbstractRendererPlugin);
1107
+ break;
767
1108
 
768
- var index_esm = /*#__PURE__*/Object.freeze({
769
- __proto__: null,
770
- Plugin: Plugin
771
- });
1109
+ case 'L':
1110
+ if (useEndOffset) {
1111
+ context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY);
1112
+ } else {
1113
+ context.lineTo(params[1] - defX, params[2] - defY);
1114
+ }
772
1115
 
773
- function _regeneratorRuntime$1() {
774
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
775
- _regeneratorRuntime$1 = function _regeneratorRuntime() {
776
- return exports;
777
- };
1116
+ break;
778
1117
 
779
- var exports = {},
780
- Op = Object.prototype,
781
- hasOwn = Op.hasOwnProperty,
782
- $Symbol = "function" == typeof Symbol ? Symbol : {},
783
- iteratorSymbol = $Symbol.iterator || "@@iterator",
784
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
785
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1118
+ case 'Q':
1119
+ context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY);
786
1120
 
787
- function define(obj, key, value) {
788
- return Object.defineProperty(obj, key, {
789
- value: value,
790
- enumerable: !0,
791
- configurable: !0,
792
- writable: !0
793
- }), obj[key];
794
- }
1121
+ if (useEndOffset) {
1122
+ context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY);
1123
+ }
795
1124
 
796
- try {
797
- define({}, "");
798
- } catch (err) {
799
- define = function define(obj, key, value) {
800
- return obj[key] = value;
801
- };
802
- }
1125
+ break;
803
1126
 
804
- function wrap(innerFn, outerFn, self, tryLocsList) {
805
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
806
- generator = Object.create(protoGenerator.prototype),
807
- context = new Context(tryLocsList || []);
808
- return generator._invoke = function (innerFn, self, context) {
809
- var state = "suspendedStart";
810
- return function (method, arg) {
811
- if ("executing" === state) throw new Error("Generator is already running");
1127
+ case 'C':
1128
+ context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY);
812
1129
 
813
- if ("completed" === state) {
814
- if ("throw" === method) throw arg;
815
- return doneResult();
1130
+ if (useEndOffset) {
1131
+ context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY);
816
1132
  }
817
1133
 
818
- for (context.method = method, context.arg = arg;;) {
819
- var delegate = context.delegate;
820
-
821
- if (delegate) {
822
- var delegateResult = maybeInvokeDelegate(delegate, context);
1134
+ break;
823
1135
 
824
- if (delegateResult) {
825
- if (delegateResult === ContinueSentinel) continue;
826
- return delegateResult;
827
- }
1136
+ case 'A':
1137
+ {
1138
+ var arcParams = segments[i].arcParams;
1139
+ var cx = arcParams.cx,
1140
+ cy = arcParams.cy,
1141
+ rx = arcParams.rx,
1142
+ ry = arcParams.ry,
1143
+ startAngle = arcParams.startAngle,
1144
+ endAngle = arcParams.endAngle,
1145
+ xRotation = arcParams.xRotation,
1146
+ sweepFlag = arcParams.sweepFlag; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
1147
+
1148
+ if (context.ellipse) {
1149
+ context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag));
1150
+ } else {
1151
+ // @see https://stackoverflow.com/a/47494351
1152
+ var r = rx > ry ? rx : ry;
1153
+ var scaleX = rx > ry ? 1 : rx / ry;
1154
+ var scaleY = rx > ry ? ry / rx : 1;
1155
+ context.translate(cx - defX, cy - defY);
1156
+ context.rotate(xRotation);
1157
+ context.scale(scaleX, scaleY);
1158
+ context.arc(0, 0, r, startAngle, endAngle, !!(1 - sweepFlag));
1159
+ context.scale(1 / scaleX, 1 / scaleY);
1160
+ context.rotate(-xRotation);
1161
+ context.translate(-(cx - defX), -(cy - defY));
828
1162
  }
829
1163
 
830
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
831
- if ("suspendedStart" === state) throw state = "completed", context.arg;
832
- context.dispatchException(context.arg);
833
- } else "return" === context.method && context.abrupt("return", context.arg);
834
- state = "executing";
835
- var record = tryCatch(innerFn, self, context);
836
-
837
- if ("normal" === record.type) {
838
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
839
- return {
840
- value: record.arg,
841
- done: context.done
842
- };
1164
+ if (useEndOffset) {
1165
+ context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY);
843
1166
  }
844
1167
 
845
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
1168
+ break;
846
1169
  }
847
- };
848
- }(innerFn, self, context), generator;
849
- }
850
-
851
- function tryCatch(fn, obj, arg) {
852
- try {
853
- return {
854
- type: "normal",
855
- arg: fn.call(obj, arg)
856
- };
857
- } catch (err) {
858
- return {
859
- type: "throw",
860
- arg: err
861
- };
862
- }
863
- }
864
-
865
- exports.wrap = wrap;
866
- var ContinueSentinel = {};
867
-
868
- function Generator() {}
869
-
870
- function GeneratorFunction() {}
871
-
872
- function GeneratorFunctionPrototype() {}
873
-
874
- var IteratorPrototype = {};
875
- define(IteratorPrototype, iteratorSymbol, function () {
876
- return this;
877
- });
878
- var getProto = Object.getPrototypeOf,
879
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
880
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
881
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
882
1170
 
883
- function defineIteratorMethods(prototype) {
884
- ["next", "throw", "return"].forEach(function (method) {
885
- define(prototype, method, function (arg) {
886
- return this._invoke(method, arg);
887
- });
888
- });
889
- }
890
-
891
- function AsyncIterator(generator, PromiseImpl) {
892
- function invoke(method, arg, resolve, reject) {
893
- var record = tryCatch(generator[method], generator, arg);
894
-
895
- if ("throw" !== record.type) {
896
- var result = record.arg,
897
- value = result.value;
898
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
899
- invoke("next", value, resolve, reject);
900
- }, function (err) {
901
- invoke("throw", err, resolve, reject);
902
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
903
- result.value = unwrapped, resolve(result);
904
- }, function (error) {
905
- return invoke("throw", error, resolve, reject);
906
- });
907
- }
908
-
909
- reject(record.arg);
1171
+ case 'Z':
1172
+ context.closePath();
1173
+ break;
910
1174
  }
911
-
912
- var previousPromise;
913
-
914
- this._invoke = function (method, arg) {
915
- function callInvokeWithMethodAndArg() {
916
- return new PromiseImpl(function (resolve, reject) {
917
- invoke(method, arg, resolve, reject);
918
- });
919
- }
920
-
921
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
922
- };
923
1175
  }
1176
+ }
924
1177
 
925
- function maybeInvokeDelegate(delegate, context) {
926
- var method = delegate.iterator[context.method];
927
-
928
- if (undefined === method) {
929
- if (context.delegate = null, "throw" === context.method) {
930
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
931
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
932
- }
933
-
934
- return ContinueSentinel;
935
- }
1178
+ function generatePath$4(context, parsedStyle) {
1179
+ var _parsedStyle$defX = parsedStyle.defX,
1180
+ defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1181
+ _parsedStyle$defY = parsedStyle.defY,
1182
+ defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
1183
+ markerStart = parsedStyle.markerStart,
1184
+ markerEnd = parsedStyle.markerEnd,
1185
+ markerStartOffset = parsedStyle.markerStartOffset,
1186
+ markerEndOffset = parsedStyle.markerEndOffset;
1187
+ var points = parsedStyle.points.points;
1188
+ var length = points.length;
1189
+ var x1 = points[0][0] - defX;
1190
+ var y1 = points[0][1] - defY;
1191
+ var x2 = points[length - 1][0] - defX;
1192
+ var y2 = points[length - 1][1] - defY;
1193
+ var startOffsetX = 0;
1194
+ var startOffsetY = 0;
1195
+ var endOffsetX = 0;
1196
+ var endOffsetY = 0;
1197
+ var rad = 0;
1198
+ var x;
1199
+ var y;
936
1200
 
937
- var record = tryCatch(method, delegate.iterator, context.arg);
938
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
939
- var info = record.arg;
940
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
1201
+ if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
1202
+ x = points[1][0] - points[0][0];
1203
+ y = points[1][1] - points[0][1];
1204
+ rad = Math.atan2(y, x);
1205
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
1206
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
941
1207
  }
942
1208
 
943
- function pushTryEntry(locs) {
944
- var entry = {
945
- tryLoc: locs[0]
946
- };
947
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
1209
+ if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
1210
+ x = points[length - 1][0] - points[0][0];
1211
+ y = points[length - 1][1] - points[0][1];
1212
+ rad = Math.atan2(y, x);
1213
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
1214
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
948
1215
  }
949
1216
 
950
- function resetTryEntry(entry) {
951
- var record = entry.completion || {};
952
- record.type = "normal", delete record.arg, entry.completion = record;
953
- }
1217
+ context.moveTo(x1 + (startOffsetX || endOffsetX), y1 + (startOffsetY || endOffsetY));
954
1218
 
955
- function Context(tryLocsList) {
956
- this.tryEntries = [{
957
- tryLoc: "root"
958
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
1219
+ for (var i = 1; i < length - 1; i++) {
1220
+ var point = points[i];
1221
+ context.lineTo(point[0] - defX, point[1] - defY);
959
1222
  }
960
1223
 
961
- function values(iterable) {
962
- if (iterable) {
963
- var iteratorMethod = iterable[iteratorSymbol];
964
- if (iteratorMethod) return iteratorMethod.call(iterable);
965
- if ("function" == typeof iterable.next) return iterable;
966
-
967
- if (!isNaN(iterable.length)) {
968
- var i = -1,
969
- next = function next() {
970
- for (; ++i < iterable.length;) {
971
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
972
- }
973
-
974
- return next.value = undefined, next.done = !0, next;
975
- };
1224
+ context.lineTo(x2, y2);
1225
+ }
976
1226
 
977
- return next.next = next;
978
- }
979
- }
1227
+ function generatePath$5(context, parsedStyle) {
1228
+ var _parsedStyle$defX = parsedStyle.defX,
1229
+ defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1230
+ _parsedStyle$defY = parsedStyle.defY,
1231
+ defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
1232
+ markerStart = parsedStyle.markerStart,
1233
+ markerEnd = parsedStyle.markerEnd,
1234
+ markerStartOffset = parsedStyle.markerStartOffset,
1235
+ markerEndOffset = parsedStyle.markerEndOffset;
1236
+ var points = parsedStyle.points.points;
1237
+ var length = points.length;
1238
+ var x1 = points[0][0] - defX;
1239
+ var y1 = points[0][1] - defY;
1240
+ var x2 = points[length - 1][0] - defX;
1241
+ var y2 = points[length - 1][1] - defY;
1242
+ var startOffsetX = 0;
1243
+ var startOffsetY = 0;
1244
+ var endOffsetX = 0;
1245
+ var endOffsetY = 0;
1246
+ var rad = 0;
1247
+ var x;
1248
+ var y;
980
1249
 
981
- return {
982
- next: doneResult
983
- };
1250
+ if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
1251
+ x = points[1][0] - points[0][0];
1252
+ y = points[1][1] - points[0][1];
1253
+ rad = Math.atan2(y, x);
1254
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
1255
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
984
1256
  }
985
1257
 
986
- function doneResult() {
987
- return {
988
- value: undefined,
989
- done: !0
990
- };
1258
+ if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
1259
+ x = points[length - 2][0] - points[length - 1][0];
1260
+ y = points[length - 2][1] - points[length - 1][1];
1261
+ rad = Math.atan2(y, x);
1262
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
1263
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
991
1264
  }
992
1265
 
993
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
994
- var ctor = "function" == typeof genFun && genFun.constructor;
995
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
996
- }, exports.mark = function (genFun) {
997
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
998
- }, exports.awrap = function (arg) {
999
- return {
1000
- __await: arg
1001
- };
1002
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1003
- return this;
1004
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1005
- void 0 === PromiseImpl && (PromiseImpl = Promise);
1006
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1007
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
1008
- return result.done ? result.value : iter.next();
1009
- });
1010
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
1011
- return this;
1012
- }), define(Gp, "toString", function () {
1013
- return "[object Generator]";
1014
- }), exports.keys = function (object) {
1015
- var keys = [];
1266
+ context.moveTo(x1 + startOffsetX, y1 + startOffsetY);
1016
1267
 
1017
- for (var key in object) {
1018
- keys.push(key);
1019
- }
1268
+ for (var i = 1; i < length - 1; i++) {
1269
+ var point = points[i];
1270
+ context.lineTo(point[0] - defX, point[1] - defY);
1271
+ }
1020
1272
 
1021
- return keys.reverse(), function next() {
1022
- for (; keys.length;) {
1023
- var key = keys.pop();
1024
- if (key in object) return next.value = key, next.done = !1, next;
1025
- }
1273
+ context.lineTo(x2 + endOffsetX, y2 + endOffsetY);
1274
+ }
1026
1275
 
1027
- return next.done = !0, next;
1028
- };
1029
- }, exports.values = values, Context.prototype = {
1030
- constructor: Context,
1031
- reset: function reset(skipTempReset) {
1032
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
1033
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1034
- }
1035
- },
1036
- stop: function stop() {
1037
- this.done = !0;
1038
- var rootRecord = this.tryEntries[0].completion;
1039
- if ("throw" === rootRecord.type) throw rootRecord.arg;
1040
- return this.rval;
1041
- },
1042
- dispatchException: function dispatchException(exception) {
1043
- if (this.done) throw exception;
1044
- var context = this;
1276
+ function generatePath$6(context, parsedStyle) {
1277
+ var radius = parsedStyle.radius,
1278
+ width = parsedStyle.width,
1279
+ height = parsedStyle.height;
1280
+ var w = width;
1281
+ var h = height;
1282
+ var hasRadius = radius && radius.some(function (r) {
1283
+ return r !== 0;
1284
+ });
1045
1285
 
1046
- function handle(loc, caught) {
1047
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
1048
- }
1286
+ if (!hasRadius) {
1287
+ // Canvas support negative width/height of rect
1288
+ context.rect(0, 0, w, h);
1289
+ } else {
1290
+ var signX = width > 0 ? 1 : -1;
1291
+ var signY = height > 0 ? 1 : -1;
1292
+ var sweepFlag = signX + signY === 0;
1049
1293
 
1050
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1051
- var entry = this.tryEntries[i],
1052
- record = entry.completion;
1053
- if ("root" === entry.tryLoc) return handle("end");
1294
+ var _radius$map = radius.map(function (r) {
1295
+ return clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
1296
+ }),
1297
+ tlr = _radius$map[0],
1298
+ trr = _radius$map[1],
1299
+ brr = _radius$map[2],
1300
+ blr = _radius$map[3];
1054
1301
 
1055
- if (entry.tryLoc <= this.prev) {
1056
- var hasCatch = hasOwn.call(entry, "catchLoc"),
1057
- hasFinally = hasOwn.call(entry, "finallyLoc");
1302
+ context.moveTo(signX * tlr, 0);
1303
+ context.lineTo(w - signX * trr, 0);
1058
1304
 
1059
- if (hasCatch && hasFinally) {
1060
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1061
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1062
- } else if (hasCatch) {
1063
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1064
- } else {
1065
- if (!hasFinally) throw new Error("try statement without catch or finally");
1066
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1067
- }
1068
- }
1069
- }
1070
- },
1071
- abrupt: function abrupt(type, arg) {
1072
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1073
- var entry = this.tryEntries[i];
1305
+ if (trr !== 0) {
1306
+ context.arc(w - signX * trr, signY * trr, trr, -signY * Math.PI / 2, signX > 0 ? 0 : Math.PI, sweepFlag);
1307
+ }
1074
1308
 
1075
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1076
- var finallyEntry = entry;
1077
- break;
1078
- }
1079
- }
1309
+ context.lineTo(w, h - signY * brr);
1080
1310
 
1081
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
1082
- var record = finallyEntry ? finallyEntry.completion : {};
1083
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
1084
- },
1085
- complete: function complete(record, afterLoc) {
1086
- if ("throw" === record.type) throw record.arg;
1087
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
1088
- },
1089
- finish: function finish(finallyLoc) {
1090
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1091
- var entry = this.tryEntries[i];
1092
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
1093
- }
1094
- },
1095
- catch: function _catch(tryLoc) {
1096
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1097
- var entry = this.tryEntries[i];
1311
+ if (brr !== 0) {
1312
+ context.arc(w - signX * brr, h - signY * brr, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag);
1313
+ }
1098
1314
 
1099
- if (entry.tryLoc === tryLoc) {
1100
- var record = entry.completion;
1315
+ context.lineTo(signX * blr, h);
1101
1316
 
1102
- if ("throw" === record.type) {
1103
- var thrown = record.arg;
1104
- resetTryEntry(entry);
1105
- }
1317
+ if (blr !== 0) {
1318
+ context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag);
1319
+ }
1106
1320
 
1107
- return thrown;
1108
- }
1109
- }
1321
+ context.lineTo(0, signY * tlr);
1110
1322
 
1111
- throw new Error("illegal catch attempt");
1112
- },
1113
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1114
- return this.delegate = {
1115
- iterator: values(iterable),
1116
- resultName: resultName,
1117
- nextLoc: nextLoc
1118
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
1323
+ if (tlr !== 0) {
1324
+ context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag);
1119
1325
  }
1120
- }, exports;
1326
+ }
1121
1327
  }
1122
1328
 
1123
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1124
- try {
1125
- var info = gen[key](arg);
1126
- var value = info.value;
1127
- } catch (error) {
1128
- reject(error);
1129
- return;
1130
- }
1329
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
1330
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
1131
1331
 
1132
- if (info.done) {
1133
- resolve(value);
1134
- } else {
1135
- Promise.resolve(value).then(_next, _throw);
1332
+ function Plugin() {
1333
+ var _this;
1334
+
1335
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1336
+ args[_key] = arguments[_key];
1337
+ }
1338
+
1339
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1340
+ _this.name = 'canvas-path-generator';
1341
+ return _this;
1136
1342
  }
1137
- }
1138
1343
 
1139
- function _asyncToGenerator$1(fn) {
1140
- return function () {
1141
- var self = this,
1142
- args = arguments;
1143
- return new Promise(function (resolve, reject) {
1144
- var gen = fn.apply(self, args);
1344
+ var _proto = Plugin.prototype;
1145
1345
 
1146
- function _next(value) {
1147
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1148
- }
1346
+ _proto.init = function init() {
1347
+ var _pathGeneratorFactory;
1149
1348
 
1150
- function _throw(err) {
1151
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1152
- }
1349
+ var pathGeneratorFactory = (_pathGeneratorFactory = {}, _pathGeneratorFactory[gLite.Shape.CIRCLE] = generatePath, _pathGeneratorFactory[gLite.Shape.ELLIPSE] = generatePath$1, _pathGeneratorFactory[gLite.Shape.RECT] = generatePath$6, _pathGeneratorFactory[gLite.Shape.LINE] = generatePath$2, _pathGeneratorFactory[gLite.Shape.POLYLINE] = generatePath$5, _pathGeneratorFactory[gLite.Shape.POLYGON] = generatePath$4, _pathGeneratorFactory[gLite.Shape.PATH] = generatePath$3, _pathGeneratorFactory[gLite.Shape.TEXT] = undefined, _pathGeneratorFactory[gLite.Shape.GROUP] = undefined, _pathGeneratorFactory[gLite.Shape.IMAGE] = undefined, _pathGeneratorFactory[gLite.Shape.HTML] = undefined, _pathGeneratorFactory[gLite.Shape.MESH] = undefined, _pathGeneratorFactory); // @ts-ignore
1153
1350
 
1154
- _next(undefined);
1155
- });
1351
+ this.context.pathGeneratorFactory = pathGeneratorFactory;
1156
1352
  };
1157
- }
1158
1353
 
1159
- function _inheritsLoose$2(subClass, superClass) {
1160
- subClass.prototype = Object.create(superClass.prototype);
1161
- subClass.prototype.constructor = subClass;
1354
+ _proto.destroy = function destroy() {
1355
+ // @ts-ignore
1356
+ delete this.context.pathGeneratorFactory;
1357
+ };
1162
1358
 
1163
- _setPrototypeOf$2(subClass, superClass);
1164
- }
1359
+ return Plugin;
1360
+ }(gLite.AbstractRendererPlugin);
1165
1361
 
1166
- function _setPrototypeOf$2(o, p) {
1167
- _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1168
- o.__proto__ = p;
1169
- return o;
1362
+ var index_esm = /*#__PURE__*/Object.freeze({
1363
+ __proto__: null,
1364
+ Plugin: Plugin
1365
+ });
1366
+
1367
+ function _regeneratorRuntime$1() {
1368
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1369
+ _regeneratorRuntime$1 = function _regeneratorRuntime() {
1370
+ return exports;
1170
1371
  };
1171
- return _setPrototypeOf$2(o, p);
1172
- }
1173
1372
 
1174
- function _unsupportedIterableToArray(o, minLen) {
1175
- if (!o) return;
1176
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1177
- var n = Object.prototype.toString.call(o).slice(8, -1);
1178
- if (n === "Object" && o.constructor) n = o.constructor.name;
1179
- if (n === "Map" || n === "Set") return Array.from(o);
1180
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1181
- }
1373
+ var exports = {},
1374
+ Op = Object.prototype,
1375
+ hasOwn = Op.hasOwnProperty,
1376
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
1377
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
1378
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
1379
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1182
1380
 
1183
- function _arrayLikeToArray(arr, len) {
1184
- if (len == null || len > arr.length) len = arr.length;
1381
+ function define(obj, key, value) {
1382
+ return Object.defineProperty(obj, key, {
1383
+ value: value,
1384
+ enumerable: !0,
1385
+ configurable: !0,
1386
+ writable: !0
1387
+ }), obj[key];
1388
+ }
1185
1389
 
1186
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
1187
- arr2[i] = arr[i];
1390
+ try {
1391
+ define({}, "");
1392
+ } catch (err) {
1393
+ define = function define(obj, key, value) {
1394
+ return obj[key] = value;
1395
+ };
1188
1396
  }
1189
1397
 
1190
- return arr2;
1191
- }
1398
+ function wrap(innerFn, outerFn, self, tryLocsList) {
1399
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
1400
+ generator = Object.create(protoGenerator.prototype),
1401
+ context = new Context(tryLocsList || []);
1402
+ return generator._invoke = function (innerFn, self, context) {
1403
+ var state = "suspendedStart";
1404
+ return function (method, arg) {
1405
+ if ("executing" === state) throw new Error("Generator is already running");
1192
1406
 
1193
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1194
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1195
- if (it) return (it = it.call(o)).next.bind(it);
1407
+ if ("completed" === state) {
1408
+ if ("throw" === method) throw arg;
1409
+ return doneResult();
1410
+ }
1196
1411
 
1197
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1198
- if (it) o = it;
1199
- var i = 0;
1200
- return function () {
1201
- if (i >= o.length) return {
1202
- done: true
1203
- };
1204
- return {
1205
- done: false,
1206
- value: o[i++]
1207
- };
1208
- };
1209
- }
1412
+ for (context.method = method, context.arg = arg;;) {
1413
+ var delegate = context.delegate;
1210
1414
 
1211
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1212
- }
1213
- /**
1214
- * Common utilities
1215
- * @module glMatrix
1216
- */
1415
+ if (delegate) {
1416
+ var delegateResult = maybeInvokeDelegate(delegate, context);
1417
+
1418
+ if (delegateResult) {
1419
+ if (delegateResult === ContinueSentinel) continue;
1420
+ return delegateResult;
1421
+ }
1422
+ }
1217
1423
 
1424
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
1425
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
1426
+ context.dispatchException(context.arg);
1427
+ } else "return" === context.method && context.abrupt("return", context.arg);
1428
+ state = "executing";
1429
+ var record = tryCatch(innerFn, self, context);
1218
1430
 
1219
- var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1220
- if (!Math.hypot) Math.hypot = function () {
1221
- var y = 0,
1222
- i = arguments.length;
1431
+ if ("normal" === record.type) {
1432
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
1433
+ return {
1434
+ value: record.arg,
1435
+ done: context.done
1436
+ };
1437
+ }
1223
1438
 
1224
- while (i--) {
1225
- y += arguments[i] * arguments[i];
1439
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
1440
+ }
1441
+ };
1442
+ }(innerFn, self, context), generator;
1226
1443
  }
1227
1444
 
1228
- return Math.sqrt(y);
1229
- };
1230
- /**
1231
- * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
1232
- * @module mat4
1233
- */
1445
+ function tryCatch(fn, obj, arg) {
1446
+ try {
1447
+ return {
1448
+ type: "normal",
1449
+ arg: fn.call(obj, arg)
1450
+ };
1451
+ } catch (err) {
1452
+ return {
1453
+ type: "throw",
1454
+ arg: err
1455
+ };
1456
+ }
1457
+ }
1234
1458
 
1235
- /**
1236
- * Creates a new identity mat4
1237
- *
1238
- * @returns {mat4} a new 4x4 matrix
1239
- */
1459
+ exports.wrap = wrap;
1460
+ var ContinueSentinel = {};
1240
1461
 
1241
- function create() {
1242
- var out = new ARRAY_TYPE(16);
1462
+ function Generator() {}
1243
1463
 
1244
- if (ARRAY_TYPE != Float32Array) {
1245
- out[1] = 0;
1246
- out[2] = 0;
1247
- out[3] = 0;
1248
- out[4] = 0;
1249
- out[6] = 0;
1250
- out[7] = 0;
1251
- out[8] = 0;
1252
- out[9] = 0;
1253
- out[11] = 0;
1254
- out[12] = 0;
1255
- out[13] = 0;
1256
- out[14] = 0;
1257
- }
1464
+ function GeneratorFunction() {}
1258
1465
 
1259
- out[0] = 1;
1260
- out[5] = 1;
1261
- out[10] = 1;
1262
- out[15] = 1;
1263
- return out;
1264
- }
1265
- /**
1266
- * Inverts a mat4
1267
- *
1268
- * @param {mat4} out the receiving matrix
1269
- * @param {ReadonlyMat4} a the source matrix
1270
- * @returns {mat4} out
1271
- */
1466
+ function GeneratorFunctionPrototype() {}
1467
+
1468
+ var IteratorPrototype = {};
1469
+ define(IteratorPrototype, iteratorSymbol, function () {
1470
+ return this;
1471
+ });
1472
+ var getProto = Object.getPrototypeOf,
1473
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1474
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
1475
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1476
+
1477
+ function defineIteratorMethods(prototype) {
1478
+ ["next", "throw", "return"].forEach(function (method) {
1479
+ define(prototype, method, function (arg) {
1480
+ return this._invoke(method, arg);
1481
+ });
1482
+ });
1483
+ }
1272
1484
 
1485
+ function AsyncIterator(generator, PromiseImpl) {
1486
+ function invoke(method, arg, resolve, reject) {
1487
+ var record = tryCatch(generator[method], generator, arg);
1273
1488
 
1274
- function invert(out, a) {
1275
- var a00 = a[0],
1276
- a01 = a[1],
1277
- a02 = a[2],
1278
- a03 = a[3];
1279
- var a10 = a[4],
1280
- a11 = a[5],
1281
- a12 = a[6],
1282
- a13 = a[7];
1283
- var a20 = a[8],
1284
- a21 = a[9],
1285
- a22 = a[10],
1286
- a23 = a[11];
1287
- var a30 = a[12],
1288
- a31 = a[13],
1289
- a32 = a[14],
1290
- a33 = a[15];
1291
- var b00 = a00 * a11 - a01 * a10;
1292
- var b01 = a00 * a12 - a02 * a10;
1293
- var b02 = a00 * a13 - a03 * a10;
1294
- var b03 = a01 * a12 - a02 * a11;
1295
- var b04 = a01 * a13 - a03 * a11;
1296
- var b05 = a02 * a13 - a03 * a12;
1297
- var b06 = a20 * a31 - a21 * a30;
1298
- var b07 = a20 * a32 - a22 * a30;
1299
- var b08 = a20 * a33 - a23 * a30;
1300
- var b09 = a21 * a32 - a22 * a31;
1301
- var b10 = a21 * a33 - a23 * a31;
1302
- var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
1489
+ if ("throw" !== record.type) {
1490
+ var result = record.arg,
1491
+ value = result.value;
1492
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1493
+ invoke("next", value, resolve, reject);
1494
+ }, function (err) {
1495
+ invoke("throw", err, resolve, reject);
1496
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
1497
+ result.value = unwrapped, resolve(result);
1498
+ }, function (error) {
1499
+ return invoke("throw", error, resolve, reject);
1500
+ });
1501
+ }
1303
1502
 
1304
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1503
+ reject(record.arg);
1504
+ }
1305
1505
 
1306
- if (!det) {
1307
- return null;
1506
+ var previousPromise;
1507
+
1508
+ this._invoke = function (method, arg) {
1509
+ function callInvokeWithMethodAndArg() {
1510
+ return new PromiseImpl(function (resolve, reject) {
1511
+ invoke(method, arg, resolve, reject);
1512
+ });
1513
+ }
1514
+
1515
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1516
+ };
1308
1517
  }
1309
1518
 
1310
- det = 1.0 / det;
1311
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
1312
- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
1313
- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
1314
- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
1315
- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
1316
- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
1317
- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
1318
- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
1319
- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
1320
- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
1321
- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
1322
- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
1323
- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
1324
- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
1325
- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
1326
- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
1327
- return out;
1328
- }
1329
- /**
1330
- * 3 Dimensional Vector
1331
- * @module vec3
1332
- */
1519
+ function maybeInvokeDelegate(delegate, context) {
1520
+ var method = delegate.iterator[context.method];
1333
1521
 
1334
- /**
1335
- * Creates a new, empty vec3
1336
- *
1337
- * @returns {vec3} a new 3D vector
1338
- */
1522
+ if (undefined === method) {
1523
+ if (context.delegate = null, "throw" === context.method) {
1524
+ if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
1525
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
1526
+ }
1339
1527
 
1528
+ return ContinueSentinel;
1529
+ }
1340
1530
 
1341
- function create$1() {
1342
- var out = new ARRAY_TYPE(3);
1531
+ var record = tryCatch(method, delegate.iterator, context.arg);
1532
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
1533
+ var info = record.arg;
1534
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
1535
+ }
1343
1536
 
1344
- if (ARRAY_TYPE != Float32Array) {
1345
- out[0] = 0;
1346
- out[1] = 0;
1347
- out[2] = 0;
1537
+ function pushTryEntry(locs) {
1538
+ var entry = {
1539
+ tryLoc: locs[0]
1540
+ };
1541
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
1348
1542
  }
1349
1543
 
1350
- return out;
1351
- }
1352
- /**
1353
- * Creates a new vec3 initialized with the given values
1354
- *
1355
- * @param {Number} x X component
1356
- * @param {Number} y Y component
1357
- * @param {Number} z Z component
1358
- * @returns {vec3} a new 3D vector
1359
- */
1544
+ function resetTryEntry(entry) {
1545
+ var record = entry.completion || {};
1546
+ record.type = "normal", delete record.arg, entry.completion = record;
1547
+ }
1360
1548
 
1549
+ function Context(tryLocsList) {
1550
+ this.tryEntries = [{
1551
+ tryLoc: "root"
1552
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
1553
+ }
1361
1554
 
1362
- function fromValues(x, y, z) {
1363
- var out = new ARRAY_TYPE(3);
1364
- out[0] = x;
1365
- out[1] = y;
1366
- out[2] = z;
1367
- return out;
1368
- }
1369
- /**
1370
- * Set the components of a vec3 to the given values
1371
- *
1372
- * @param {vec3} out the receiving vector
1373
- * @param {Number} x X component
1374
- * @param {Number} y Y component
1375
- * @param {Number} z Z component
1376
- * @returns {vec3} out
1377
- */
1555
+ function values(iterable) {
1556
+ if (iterable) {
1557
+ var iteratorMethod = iterable[iteratorSymbol];
1558
+ if (iteratorMethod) return iteratorMethod.call(iterable);
1559
+ if ("function" == typeof iterable.next) return iterable;
1378
1560
 
1561
+ if (!isNaN(iterable.length)) {
1562
+ var i = -1,
1563
+ next = function next() {
1564
+ for (; ++i < iterable.length;) {
1565
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1566
+ }
1379
1567
 
1380
- function set(out, x, y, z) {
1381
- out[0] = x;
1382
- out[1] = y;
1383
- out[2] = z;
1384
- return out;
1385
- }
1386
- /**
1387
- * Transforms the vec3 with a mat4.
1388
- * 4th vector component is implicitly '1'
1389
- *
1390
- * @param {vec3} out the receiving vector
1391
- * @param {ReadonlyVec3} a the vector to transform
1392
- * @param {ReadonlyMat4} m matrix to transform with
1393
- * @returns {vec3} out
1394
- */
1568
+ return next.value = undefined, next.done = !0, next;
1569
+ };
1395
1570
 
1571
+ return next.next = next;
1572
+ }
1573
+ }
1396
1574
 
1397
- function transformMat4(out, a, m) {
1398
- var x = a[0],
1399
- y = a[1],
1400
- z = a[2];
1401
- var w = m[3] * x + m[7] * y + m[11] * z + m[15];
1402
- w = w || 1.0;
1403
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
1404
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
1405
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
1406
- return out;
1407
- }
1408
- /**
1409
- * Transforms the vec3 with a mat3.
1410
- *
1411
- * @param {vec3} out the receiving vector
1412
- * @param {ReadonlyVec3} a the vector to transform
1413
- * @param {ReadonlyMat3} m the 3x3 matrix to transform with
1414
- * @returns {vec3} out
1415
- */
1575
+ return {
1576
+ next: doneResult
1577
+ };
1578
+ }
1416
1579
 
1580
+ function doneResult() {
1581
+ return {
1582
+ value: undefined,
1583
+ done: !0
1584
+ };
1585
+ }
1417
1586
 
1418
- function transformMat3(out, a, m) {
1419
- var x = a[0],
1420
- y = a[1],
1421
- z = a[2];
1422
- out[0] = x * m[0] + y * m[3] + z * m[6];
1423
- out[1] = x * m[1] + y * m[4] + z * m[7];
1424
- out[2] = x * m[2] + y * m[5] + z * m[8];
1425
- return out;
1426
- }
1427
- /**
1428
- * Perform some operation over an array of vec3s.
1429
- *
1430
- * @param {Array} a the array of vectors to iterate over
1431
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
1432
- * @param {Number} offset Number of elements to skip at the beginning of the array
1433
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
1434
- * @param {Function} fn Function to call for each vector in the array
1435
- * @param {Object} [arg] additional argument to pass to fn
1436
- * @returns {Array} a
1437
- * @function
1438
- */
1587
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
1588
+ var ctor = "function" == typeof genFun && genFun.constructor;
1589
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
1590
+ }, exports.mark = function (genFun) {
1591
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
1592
+ }, exports.awrap = function (arg) {
1593
+ return {
1594
+ __await: arg
1595
+ };
1596
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1597
+ return this;
1598
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1599
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
1600
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1601
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
1602
+ return result.done ? result.value : iter.next();
1603
+ });
1604
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
1605
+ return this;
1606
+ }), define(Gp, "toString", function () {
1607
+ return "[object Generator]";
1608
+ }), exports.keys = function (object) {
1609
+ var keys = [];
1439
1610
 
1611
+ for (var key in object) {
1612
+ keys.push(key);
1613
+ }
1440
1614
 
1441
- var forEach = function () {
1442
- var vec = create$1();
1443
- return function (a, stride, offset, count, fn, arg) {
1444
- var i, l;
1615
+ return keys.reverse(), function next() {
1616
+ for (; keys.length;) {
1617
+ var key = keys.pop();
1618
+ if (key in object) return next.value = key, next.done = !1, next;
1619
+ }
1445
1620
 
1446
- if (!stride) {
1447
- stride = 3;
1448
- }
1621
+ return next.done = !0, next;
1622
+ };
1623
+ }, exports.values = values, Context.prototype = {
1624
+ constructor: Context,
1625
+ reset: function reset(skipTempReset) {
1626
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
1627
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1628
+ }
1629
+ },
1630
+ stop: function stop() {
1631
+ this.done = !0;
1632
+ var rootRecord = this.tryEntries[0].completion;
1633
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
1634
+ return this.rval;
1635
+ },
1636
+ dispatchException: function dispatchException(exception) {
1637
+ if (this.done) throw exception;
1638
+ var context = this;
1449
1639
 
1450
- if (!offset) {
1451
- offset = 0;
1452
- }
1640
+ function handle(loc, caught) {
1641
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
1642
+ }
1453
1643
 
1454
- if (count) {
1455
- l = Math.min(count * stride + offset, a.length);
1456
- } else {
1457
- l = a.length;
1458
- }
1644
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1645
+ var entry = this.tryEntries[i],
1646
+ record = entry.completion;
1647
+ if ("root" === entry.tryLoc) return handle("end");
1459
1648
 
1460
- for (i = offset; i < l; i += stride) {
1461
- vec[0] = a[i];
1462
- vec[1] = a[i + 1];
1463
- vec[2] = a[i + 2];
1464
- fn(vec, vec, arg);
1465
- a[i] = vec[0];
1466
- a[i + 1] = vec[1];
1467
- a[i + 2] = vec[2];
1468
- }
1649
+ if (entry.tryLoc <= this.prev) {
1650
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
1651
+ hasFinally = hasOwn.call(entry, "finallyLoc");
1469
1652
 
1470
- return a;
1471
- };
1472
- }();
1473
- /**
1474
- * 2 Dimensional Vector
1475
- * @module vec2
1476
- */
1653
+ if (hasCatch && hasFinally) {
1654
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1655
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1656
+ } else if (hasCatch) {
1657
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1658
+ } else {
1659
+ if (!hasFinally) throw new Error("try statement without catch or finally");
1660
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1661
+ }
1662
+ }
1663
+ }
1664
+ },
1665
+ abrupt: function abrupt(type, arg) {
1666
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1667
+ var entry = this.tryEntries[i];
1477
1668
 
1478
- /**
1479
- * Creates a new, empty vec2
1480
- *
1481
- * @returns {vec2} a new 2D vector
1482
- */
1669
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1670
+ var finallyEntry = entry;
1671
+ break;
1672
+ }
1673
+ }
1674
+
1675
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
1676
+ var record = finallyEntry ? finallyEntry.completion : {};
1677
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
1678
+ },
1679
+ complete: function complete(record, afterLoc) {
1680
+ if ("throw" === record.type) throw record.arg;
1681
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
1682
+ },
1683
+ finish: function finish(finallyLoc) {
1684
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1685
+ var entry = this.tryEntries[i];
1686
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
1687
+ }
1688
+ },
1689
+ catch: function _catch(tryLoc) {
1690
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1691
+ var entry = this.tryEntries[i];
1692
+
1693
+ if (entry.tryLoc === tryLoc) {
1694
+ var record = entry.completion;
1483
1695
 
1696
+ if ("throw" === record.type) {
1697
+ var thrown = record.arg;
1698
+ resetTryEntry(entry);
1699
+ }
1484
1700
 
1485
- function create$2() {
1486
- var out = new ARRAY_TYPE(2);
1701
+ return thrown;
1702
+ }
1703
+ }
1487
1704
 
1488
- if (ARRAY_TYPE != Float32Array) {
1489
- out[0] = 0;
1490
- out[1] = 0;
1705
+ throw new Error("illegal catch attempt");
1706
+ },
1707
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1708
+ return this.delegate = {
1709
+ iterator: values(iterable),
1710
+ resultName: resultName,
1711
+ nextLoc: nextLoc
1712
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
1713
+ }
1714
+ }, exports;
1715
+ }
1716
+
1717
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1718
+ try {
1719
+ var info = gen[key](arg);
1720
+ var value = info.value;
1721
+ } catch (error) {
1722
+ reject(error);
1723
+ return;
1491
1724
  }
1492
1725
 
1493
- return out;
1726
+ if (info.done) {
1727
+ resolve(value);
1728
+ } else {
1729
+ Promise.resolve(value).then(_next, _throw);
1730
+ }
1494
1731
  }
1495
- /**
1496
- * Normalize a vec2
1497
- *
1498
- * @param {vec2} out the receiving vector
1499
- * @param {ReadonlyVec2} a vector to normalize
1500
- * @returns {vec2} out
1501
- */
1502
1732
 
1733
+ function _asyncToGenerator$1(fn) {
1734
+ return function () {
1735
+ var self = this,
1736
+ args = arguments;
1737
+ return new Promise(function (resolve, reject) {
1738
+ var gen = fn.apply(self, args);
1503
1739
 
1504
- function normalize(out, a) {
1505
- var x = a[0],
1506
- y = a[1];
1507
- var len = x * x + y * y;
1740
+ function _next(value) {
1741
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1742
+ }
1508
1743
 
1509
- if (len > 0) {
1510
- //TODO: evaluate use of glm_invsqrt here?
1511
- len = 1 / Math.sqrt(len);
1512
- }
1744
+ function _throw(err) {
1745
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1746
+ }
1513
1747
 
1514
- out[0] = a[0] * len;
1515
- out[1] = a[1] * len;
1516
- return out;
1748
+ _next(undefined);
1749
+ });
1750
+ };
1517
1751
  }
1518
- /**
1519
- * Calculates the dot product of two vec2's
1520
- *
1521
- * @param {ReadonlyVec2} a the first operand
1522
- * @param {ReadonlyVec2} b the second operand
1523
- * @returns {Number} dot product of a and b
1524
- */
1525
1752
 
1753
+ function _inheritsLoose$2(subClass, superClass) {
1754
+ subClass.prototype = Object.create(superClass.prototype);
1755
+ subClass.prototype.constructor = subClass;
1526
1756
 
1527
- function dot(a, b) {
1528
- return a[0] * b[0] + a[1] * b[1];
1757
+ _setPrototypeOf$2(subClass, superClass);
1529
1758
  }
1530
- /**
1531
- * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
1532
- *
1533
- * @param {ReadonlyVec2} a The first vector.
1534
- * @param {ReadonlyVec2} b The second vector.
1535
- * @returns {Boolean} True if the vectors are equal, false otherwise.
1536
- */
1537
1759
 
1538
-
1539
- function exactEquals(a, b) {
1540
- return a[0] === b[0] && a[1] === b[1];
1760
+ function _setPrototypeOf$2(o, p) {
1761
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1762
+ o.__proto__ = p;
1763
+ return o;
1764
+ };
1765
+ return _setPrototypeOf$2(o, p);
1541
1766
  }
1542
- /**
1543
- * Perform some operation over an array of vec2s.
1544
- *
1545
- * @param {Array} a the array of vectors to iterate over
1546
- * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
1547
- * @param {Number} offset Number of elements to skip at the beginning of the array
1548
- * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
1549
- * @param {Function} fn Function to call for each vector in the array
1550
- * @param {Object} [arg] additional argument to pass to fn
1551
- * @returns {Array} a
1552
- * @function
1553
- */
1554
1767
 
1768
+ function _unsupportedIterableToArray(o, minLen) {
1769
+ if (!o) return;
1770
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1771
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1772
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1773
+ if (n === "Map" || n === "Set") return Array.from(o);
1774
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1775
+ }
1555
1776
 
1556
- var forEach$1 = function () {
1557
- var vec = create$2();
1558
- return function (a, stride, offset, count, fn, arg) {
1559
- var i, l;
1777
+ function _arrayLikeToArray(arr, len) {
1778
+ if (len == null || len > arr.length) len = arr.length;
1560
1779
 
1561
- if (!stride) {
1562
- stride = 2;
1563
- }
1780
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
1781
+ arr2[i] = arr[i];
1782
+ }
1564
1783
 
1565
- if (!offset) {
1566
- offset = 0;
1567
- }
1784
+ return arr2;
1785
+ }
1568
1786
 
1569
- if (count) {
1570
- l = Math.min(count * stride + offset, a.length);
1571
- } else {
1572
- l = a.length;
1573
- }
1787
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1788
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1789
+ if (it) return (it = it.call(o)).next.bind(it);
1574
1790
 
1575
- for (i = offset; i < l; i += stride) {
1576
- vec[0] = a[i];
1577
- vec[1] = a[i + 1];
1578
- fn(vec, vec, arg);
1579
- a[i] = vec[0];
1580
- a[i + 1] = vec[1];
1581
- }
1791
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1792
+ if (it) o = it;
1793
+ var i = 0;
1794
+ return function () {
1795
+ if (i >= o.length) return {
1796
+ done: true
1797
+ };
1798
+ return {
1799
+ done: false,
1800
+ value: o[i++]
1801
+ };
1802
+ };
1803
+ }
1582
1804
 
1583
- return a;
1584
- };
1585
- }();
1805
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1806
+ }
1586
1807
 
1587
1808
  var tmpVec3a = create$1();
1588
1809
  var tmpVec3b = create$1();
@@ -2219,10 +2440,9 @@
2219
2440
 
2220
2441
  function inArc(cx, cy, r, startAngle, endAngle, lineWidth, x, y) {
2221
2442
  var angle = (Math.atan2(y - cy, x - cx) + Math.PI * 2) % (Math.PI * 2); // 转换到 0 - 2 * Math.PI 之间
2222
-
2223
- if (angle < startAngle || angle > endAngle) {
2224
- return false;
2225
- }
2443
+ // if (angle < startAngle || angle > endAngle) {
2444
+ // return false;
2445
+ // }
2226
2446
 
2227
2447
  var point = {
2228
2448
  x: cx + r * Math.cos(angle),
@@ -2895,589 +3115,251 @@
2895
3115
 
2896
3116
  function pushTryEntry(locs) {
2897
3117
  var entry = {
2898
- tryLoc: locs[0]
2899
- };
2900
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
2901
- }
2902
-
2903
- function resetTryEntry(entry) {
2904
- var record = entry.completion || {};
2905
- record.type = "normal", delete record.arg, entry.completion = record;
2906
- }
2907
-
2908
- function Context(tryLocsList) {
2909
- this.tryEntries = [{
2910
- tryLoc: "root"
2911
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
2912
- }
2913
-
2914
- function values(iterable) {
2915
- if (iterable) {
2916
- var iteratorMethod = iterable[iteratorSymbol];
2917
- if (iteratorMethod) return iteratorMethod.call(iterable);
2918
- if ("function" == typeof iterable.next) return iterable;
2919
-
2920
- if (!isNaN(iterable.length)) {
2921
- var i = -1,
2922
- next = function next() {
2923
- for (; ++i < iterable.length;) {
2924
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
2925
- }
2926
-
2927
- return next.value = undefined, next.done = !0, next;
2928
- };
2929
-
2930
- return next.next = next;
2931
- }
2932
- }
2933
-
2934
- return {
2935
- next: doneResult
2936
- };
2937
- }
2938
-
2939
- function doneResult() {
2940
- return {
2941
- value: undefined,
2942
- done: !0
2943
- };
2944
- }
2945
-
2946
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
2947
- var ctor = "function" == typeof genFun && genFun.constructor;
2948
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
2949
- }, exports.mark = function (genFun) {
2950
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
2951
- }, exports.awrap = function (arg) {
2952
- return {
2953
- __await: arg
2954
- };
2955
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
2956
- return this;
2957
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
2958
- void 0 === PromiseImpl && (PromiseImpl = Promise);
2959
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
2960
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
2961
- return result.done ? result.value : iter.next();
2962
- });
2963
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
2964
- return this;
2965
- }), define(Gp, "toString", function () {
2966
- return "[object Generator]";
2967
- }), exports.keys = function (object) {
2968
- var keys = [];
2969
-
2970
- for (var key in object) {
2971
- keys.push(key);
2972
- }
2973
-
2974
- return keys.reverse(), function next() {
2975
- for (; keys.length;) {
2976
- var key = keys.pop();
2977
- if (key in object) return next.value = key, next.done = !1, next;
2978
- }
2979
-
2980
- return next.done = !0, next;
2981
- };
2982
- }, exports.values = values, Context.prototype = {
2983
- constructor: Context,
2984
- reset: function reset(skipTempReset) {
2985
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
2986
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
2987
- }
2988
- },
2989
- stop: function stop() {
2990
- this.done = !0;
2991
- var rootRecord = this.tryEntries[0].completion;
2992
- if ("throw" === rootRecord.type) throw rootRecord.arg;
2993
- return this.rval;
2994
- },
2995
- dispatchException: function dispatchException(exception) {
2996
- if (this.done) throw exception;
2997
- var context = this;
2998
-
2999
- function handle(loc, caught) {
3000
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
3001
- }
3002
-
3003
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3004
- var entry = this.tryEntries[i],
3005
- record = entry.completion;
3006
- if ("root" === entry.tryLoc) return handle("end");
3007
-
3008
- if (entry.tryLoc <= this.prev) {
3009
- var hasCatch = hasOwn.call(entry, "catchLoc"),
3010
- hasFinally = hasOwn.call(entry, "finallyLoc");
3011
-
3012
- if (hasCatch && hasFinally) {
3013
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
3014
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
3015
- } else if (hasCatch) {
3016
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
3017
- } else {
3018
- if (!hasFinally) throw new Error("try statement without catch or finally");
3019
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
3020
- }
3021
- }
3022
- }
3023
- },
3024
- abrupt: function abrupt(type, arg) {
3025
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3026
- var entry = this.tryEntries[i];
3027
-
3028
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
3029
- var finallyEntry = entry;
3030
- break;
3031
- }
3032
- }
3033
-
3034
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
3035
- var record = finallyEntry ? finallyEntry.completion : {};
3036
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
3037
- },
3038
- complete: function complete(record, afterLoc) {
3039
- if ("throw" === record.type) throw record.arg;
3040
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
3041
- },
3042
- finish: function finish(finallyLoc) {
3043
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3044
- var entry = this.tryEntries[i];
3045
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
3046
- }
3047
- },
3048
- catch: function _catch(tryLoc) {
3049
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3050
- var entry = this.tryEntries[i];
3051
-
3052
- if (entry.tryLoc === tryLoc) {
3053
- var record = entry.completion;
3054
-
3055
- if ("throw" === record.type) {
3056
- var thrown = record.arg;
3057
- resetTryEntry(entry);
3058
- }
3059
-
3060
- return thrown;
3061
- }
3062
- }
3063
-
3064
- throw new Error("illegal catch attempt");
3065
- },
3066
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
3067
- return this.delegate = {
3068
- iterator: values(iterable),
3069
- resultName: resultName,
3070
- nextLoc: nextLoc
3071
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
3072
- }
3073
- }, exports;
3074
- }
3075
-
3076
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
3077
- try {
3078
- var info = gen[key](arg);
3079
- var value = info.value;
3080
- } catch (error) {
3081
- reject(error);
3082
- return;
3083
- }
3084
-
3085
- if (info.done) {
3086
- resolve(value);
3087
- } else {
3088
- Promise.resolve(value).then(_next, _throw);
3089
- }
3090
- }
3091
-
3092
- function _asyncToGenerator$2(fn) {
3093
- return function () {
3094
- var self = this,
3095
- args = arguments;
3096
- return new Promise(function (resolve, reject) {
3097
- var gen = fn.apply(self, args);
3098
-
3099
- function _next(value) {
3100
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
3101
- }
3102
-
3103
- function _throw(err) {
3104
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
3105
- }
3106
-
3107
- _next(undefined);
3108
- });
3109
- };
3110
- }
3111
-
3112
- function _extends() {
3113
- _extends = Object.assign ? Object.assign.bind() : function (target) {
3114
- for (var i = 1; i < arguments.length; i++) {
3115
- var source = arguments[i];
3116
-
3117
- for (var key in source) {
3118
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3119
- target[key] = source[key];
3120
- }
3121
- }
3122
- }
3118
+ tryLoc: locs[0]
3119
+ };
3120
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
3121
+ }
3123
3122
 
3124
- return target;
3125
- };
3126
- return _extends.apply(this, arguments);
3127
- }
3123
+ function resetTryEntry(entry) {
3124
+ var record = entry.completion || {};
3125
+ record.type = "normal", delete record.arg, entry.completion = record;
3126
+ }
3128
3127
 
3129
- function _inheritsLoose$3(subClass, superClass) {
3130
- subClass.prototype = Object.create(superClass.prototype);
3131
- subClass.prototype.constructor = subClass;
3128
+ function Context(tryLocsList) {
3129
+ this.tryEntries = [{
3130
+ tryLoc: "root"
3131
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
3132
+ }
3132
3133
 
3133
- _setPrototypeOf$3(subClass, superClass);
3134
- }
3134
+ function values(iterable) {
3135
+ if (iterable) {
3136
+ var iteratorMethod = iterable[iteratorSymbol];
3137
+ if (iteratorMethod) return iteratorMethod.call(iterable);
3138
+ if ("function" == typeof iterable.next) return iterable;
3135
3139
 
3136
- function _setPrototypeOf$3(o, p) {
3137
- _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3138
- o.__proto__ = p;
3139
- return o;
3140
- };
3141
- return _setPrototypeOf$3(o, p);
3142
- }
3143
- /**
3144
- * Common utilities
3145
- * @module glMatrix
3146
- */
3140
+ if (!isNaN(iterable.length)) {
3141
+ var i = -1,
3142
+ next = function next() {
3143
+ for (; ++i < iterable.length;) {
3144
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
3145
+ }
3147
3146
 
3147
+ return next.value = undefined, next.done = !0, next;
3148
+ };
3148
3149
 
3149
- var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
3150
- if (!Math.hypot) Math.hypot = function () {
3151
- var y = 0,
3152
- i = arguments.length;
3150
+ return next.next = next;
3151
+ }
3152
+ }
3153
3153
 
3154
- while (i--) {
3155
- y += arguments[i] * arguments[i];
3154
+ return {
3155
+ next: doneResult
3156
+ };
3156
3157
  }
3157
3158
 
3158
- return Math.sqrt(y);
3159
- };
3160
- /**
3161
- * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
3162
- * @module mat4
3163
- */
3164
-
3165
- /**
3166
- * Creates a new identity mat4
3167
- *
3168
- * @returns {mat4} a new 4x4 matrix
3169
- */
3159
+ function doneResult() {
3160
+ return {
3161
+ value: undefined,
3162
+ done: !0
3163
+ };
3164
+ }
3170
3165
 
3171
- function create$3() {
3172
- var out = new ARRAY_TYPE$1(16);
3166
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
3167
+ var ctor = "function" == typeof genFun && genFun.constructor;
3168
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
3169
+ }, exports.mark = function (genFun) {
3170
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
3171
+ }, exports.awrap = function (arg) {
3172
+ return {
3173
+ __await: arg
3174
+ };
3175
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
3176
+ return this;
3177
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
3178
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
3179
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
3180
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
3181
+ return result.done ? result.value : iter.next();
3182
+ });
3183
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
3184
+ return this;
3185
+ }), define(Gp, "toString", function () {
3186
+ return "[object Generator]";
3187
+ }), exports.keys = function (object) {
3188
+ var keys = [];
3173
3189
 
3174
- if (ARRAY_TYPE$1 != Float32Array) {
3175
- out[1] = 0;
3176
- out[2] = 0;
3177
- out[3] = 0;
3178
- out[4] = 0;
3179
- out[6] = 0;
3180
- out[7] = 0;
3181
- out[8] = 0;
3182
- out[9] = 0;
3183
- out[11] = 0;
3184
- out[12] = 0;
3185
- out[13] = 0;
3186
- out[14] = 0;
3187
- }
3190
+ for (var key in object) {
3191
+ keys.push(key);
3192
+ }
3188
3193
 
3189
- out[0] = 1;
3190
- out[5] = 1;
3191
- out[10] = 1;
3192
- out[15] = 1;
3193
- return out;
3194
- }
3195
- /**
3196
- * Copy the values from one mat4 to another
3197
- *
3198
- * @param {mat4} out the receiving matrix
3199
- * @param {ReadonlyMat4} a the source matrix
3200
- * @returns {mat4} out
3201
- */
3194
+ return keys.reverse(), function next() {
3195
+ for (; keys.length;) {
3196
+ var key = keys.pop();
3197
+ if (key in object) return next.value = key, next.done = !1, next;
3198
+ }
3202
3199
 
3200
+ return next.done = !0, next;
3201
+ };
3202
+ }, exports.values = values, Context.prototype = {
3203
+ constructor: Context,
3204
+ reset: function reset(skipTempReset) {
3205
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
3206
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
3207
+ }
3208
+ },
3209
+ stop: function stop() {
3210
+ this.done = !0;
3211
+ var rootRecord = this.tryEntries[0].completion;
3212
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
3213
+ return this.rval;
3214
+ },
3215
+ dispatchException: function dispatchException(exception) {
3216
+ if (this.done) throw exception;
3217
+ var context = this;
3203
3218
 
3204
- function copy(out, a) {
3205
- out[0] = a[0];
3206
- out[1] = a[1];
3207
- out[2] = a[2];
3208
- out[3] = a[3];
3209
- out[4] = a[4];
3210
- out[5] = a[5];
3211
- out[6] = a[6];
3212
- out[7] = a[7];
3213
- out[8] = a[8];
3214
- out[9] = a[9];
3215
- out[10] = a[10];
3216
- out[11] = a[11];
3217
- out[12] = a[12];
3218
- out[13] = a[13];
3219
- out[14] = a[14];
3220
- out[15] = a[15];
3221
- return out;
3222
- }
3223
- /**
3224
- * Multiplies two mat4s
3225
- *
3226
- * @param {mat4} out the receiving matrix
3227
- * @param {ReadonlyMat4} a the first operand
3228
- * @param {ReadonlyMat4} b the second operand
3229
- * @returns {mat4} out
3230
- */
3219
+ function handle(loc, caught) {
3220
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
3221
+ }
3231
3222
 
3223
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3224
+ var entry = this.tryEntries[i],
3225
+ record = entry.completion;
3226
+ if ("root" === entry.tryLoc) return handle("end");
3232
3227
 
3233
- function multiply(out, a, b) {
3234
- var a00 = a[0],
3235
- a01 = a[1],
3236
- a02 = a[2],
3237
- a03 = a[3];
3238
- var a10 = a[4],
3239
- a11 = a[5],
3240
- a12 = a[6],
3241
- a13 = a[7];
3242
- var a20 = a[8],
3243
- a21 = a[9],
3244
- a22 = a[10],
3245
- a23 = a[11];
3246
- var a30 = a[12],
3247
- a31 = a[13],
3248
- a32 = a[14],
3249
- a33 = a[15]; // Cache only the current line of the second matrix
3228
+ if (entry.tryLoc <= this.prev) {
3229
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
3230
+ hasFinally = hasOwn.call(entry, "finallyLoc");
3250
3231
 
3251
- var b0 = b[0],
3252
- b1 = b[1],
3253
- b2 = b[2],
3254
- b3 = b[3];
3255
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
3256
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
3257
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
3258
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
3259
- b0 = b[4];
3260
- b1 = b[5];
3261
- b2 = b[6];
3262
- b3 = b[7];
3263
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
3264
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
3265
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
3266
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
3267
- b0 = b[8];
3268
- b1 = b[9];
3269
- b2 = b[10];
3270
- b3 = b[11];
3271
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
3272
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
3273
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
3274
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
3275
- b0 = b[12];
3276
- b1 = b[13];
3277
- b2 = b[14];
3278
- b3 = b[15];
3279
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
3280
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
3281
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
3282
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
3283
- return out;
3284
- }
3285
- /**
3286
- * Translate a mat4 by the given vector
3287
- *
3288
- * @param {mat4} out the receiving matrix
3289
- * @param {ReadonlyMat4} a the matrix to translate
3290
- * @param {ReadonlyVec3} v vector to translate by
3291
- * @returns {mat4} out
3292
- */
3232
+ if (hasCatch && hasFinally) {
3233
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
3234
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
3235
+ } else if (hasCatch) {
3236
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
3237
+ } else {
3238
+ if (!hasFinally) throw new Error("try statement without catch or finally");
3239
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
3240
+ }
3241
+ }
3242
+ }
3243
+ },
3244
+ abrupt: function abrupt(type, arg) {
3245
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3246
+ var entry = this.tryEntries[i];
3293
3247
 
3248
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
3249
+ var finallyEntry = entry;
3250
+ break;
3251
+ }
3252
+ }
3294
3253
 
3295
- function translate(out, a, v) {
3296
- var x = v[0],
3297
- y = v[1],
3298
- z = v[2];
3299
- var a00, a01, a02, a03;
3300
- var a10, a11, a12, a13;
3301
- var a20, a21, a22, a23;
3254
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
3255
+ var record = finallyEntry ? finallyEntry.completion : {};
3256
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
3257
+ },
3258
+ complete: function complete(record, afterLoc) {
3259
+ if ("throw" === record.type) throw record.arg;
3260
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
3261
+ },
3262
+ finish: function finish(finallyLoc) {
3263
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3264
+ var entry = this.tryEntries[i];
3265
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
3266
+ }
3267
+ },
3268
+ catch: function _catch(tryLoc) {
3269
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3270
+ var entry = this.tryEntries[i];
3302
3271
 
3303
- if (a === out) {
3304
- out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
3305
- out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
3306
- out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
3307
- out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
3308
- } else {
3309
- a00 = a[0];
3310
- a01 = a[1];
3311
- a02 = a[2];
3312
- a03 = a[3];
3313
- a10 = a[4];
3314
- a11 = a[5];
3315
- a12 = a[6];
3316
- a13 = a[7];
3317
- a20 = a[8];
3318
- a21 = a[9];
3319
- a22 = a[10];
3320
- a23 = a[11];
3321
- out[0] = a00;
3322
- out[1] = a01;
3323
- out[2] = a02;
3324
- out[3] = a03;
3325
- out[4] = a10;
3326
- out[5] = a11;
3327
- out[6] = a12;
3328
- out[7] = a13;
3329
- out[8] = a20;
3330
- out[9] = a21;
3331
- out[10] = a22;
3332
- out[11] = a23;
3333
- out[12] = a00 * x + a10 * y + a20 * z + a[12];
3334
- out[13] = a01 * x + a11 * y + a21 * z + a[13];
3335
- out[14] = a02 * x + a12 * y + a22 * z + a[14];
3336
- out[15] = a03 * x + a13 * y + a23 * z + a[15];
3337
- }
3272
+ if (entry.tryLoc === tryLoc) {
3273
+ var record = entry.completion;
3338
3274
 
3339
- return out;
3340
- }
3341
- /**
3342
- * Creates a matrix from a vector scaling
3343
- * This is equivalent to (but much faster than):
3344
- *
3345
- * mat4.identity(dest);
3346
- * mat4.scale(dest, dest, vec);
3347
- *
3348
- * @param {mat4} out mat4 receiving operation result
3349
- * @param {ReadonlyVec3} v Scaling vector
3350
- * @returns {mat4} out
3351
- */
3275
+ if ("throw" === record.type) {
3276
+ var thrown = record.arg;
3277
+ resetTryEntry(entry);
3278
+ }
3352
3279
 
3280
+ return thrown;
3281
+ }
3282
+ }
3353
3283
 
3354
- function fromScaling(out, v) {
3355
- out[0] = v[0];
3356
- out[1] = 0;
3357
- out[2] = 0;
3358
- out[3] = 0;
3359
- out[4] = 0;
3360
- out[5] = v[1];
3361
- out[6] = 0;
3362
- out[7] = 0;
3363
- out[8] = 0;
3364
- out[9] = 0;
3365
- out[10] = v[2];
3366
- out[11] = 0;
3367
- out[12] = 0;
3368
- out[13] = 0;
3369
- out[14] = 0;
3370
- out[15] = 1;
3371
- return out;
3284
+ throw new Error("illegal catch attempt");
3285
+ },
3286
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
3287
+ return this.delegate = {
3288
+ iterator: values(iterable),
3289
+ resultName: resultName,
3290
+ nextLoc: nextLoc
3291
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
3292
+ }
3293
+ }, exports;
3372
3294
  }
3373
- /**
3374
- * 3 Dimensional Vector
3375
- * @module vec3
3376
- */
3377
-
3378
- /**
3379
- * Creates a new, empty vec3
3380
- *
3381
- * @returns {vec3} a new 3D vector
3382
- */
3383
-
3384
3295
 
3385
- function create$1$1() {
3386
- var out = new ARRAY_TYPE$1(3);
3387
-
3388
- if (ARRAY_TYPE$1 != Float32Array) {
3389
- out[0] = 0;
3390
- out[1] = 0;
3391
- out[2] = 0;
3296
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
3297
+ try {
3298
+ var info = gen[key](arg);
3299
+ var value = info.value;
3300
+ } catch (error) {
3301
+ reject(error);
3302
+ return;
3392
3303
  }
3393
3304
 
3394
- return out;
3305
+ if (info.done) {
3306
+ resolve(value);
3307
+ } else {
3308
+ Promise.resolve(value).then(_next, _throw);
3309
+ }
3395
3310
  }
3396
- /**
3397
- * Creates a new vec3 initialized with the given values
3398
- *
3399
- * @param {Number} x X component
3400
- * @param {Number} y Y component
3401
- * @param {Number} z Z component
3402
- * @returns {vec3} a new 3D vector
3403
- */
3404
3311
 
3312
+ function _asyncToGenerator$2(fn) {
3313
+ return function () {
3314
+ var self = this,
3315
+ args = arguments;
3316
+ return new Promise(function (resolve, reject) {
3317
+ var gen = fn.apply(self, args);
3405
3318
 
3406
- function fromValues$1(x, y, z) {
3407
- var out = new ARRAY_TYPE$1(3);
3408
- out[0] = x;
3409
- out[1] = y;
3410
- out[2] = z;
3411
- return out;
3412
- }
3413
- /**
3414
- * Transforms the vec3 with a mat4.
3415
- * 4th vector component is implicitly '1'
3416
- *
3417
- * @param {vec3} out the receiving vector
3418
- * @param {ReadonlyVec3} a the vector to transform
3419
- * @param {ReadonlyMat4} m matrix to transform with
3420
- * @returns {vec3} out
3421
- */
3319
+ function _next(value) {
3320
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
3321
+ }
3422
3322
 
3323
+ function _throw(err) {
3324
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
3325
+ }
3423
3326
 
3424
- function transformMat4$1(out, a, m) {
3425
- var x = a[0],
3426
- y = a[1],
3427
- z = a[2];
3428
- var w = m[3] * x + m[7] * y + m[11] * z + m[15];
3429
- w = w || 1.0;
3430
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
3431
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
3432
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
3433
- return out;
3327
+ _next(undefined);
3328
+ });
3329
+ };
3434
3330
  }
3435
- /**
3436
- * Perform some operation over an array of vec3s.
3437
- *
3438
- * @param {Array} a the array of vectors to iterate over
3439
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
3440
- * @param {Number} offset Number of elements to skip at the beginning of the array
3441
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
3442
- * @param {Function} fn Function to call for each vector in the array
3443
- * @param {Object} [arg] additional argument to pass to fn
3444
- * @returns {Array} a
3445
- * @function
3446
- */
3447
-
3448
3331
 
3449
- var forEach$2 = function () {
3450
- var vec = create$1$1();
3451
- return function (a, stride, offset, count, fn, arg) {
3452
- var i, l;
3332
+ function _extends() {
3333
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
3334
+ for (var i = 1; i < arguments.length; i++) {
3335
+ var source = arguments[i];
3453
3336
 
3454
- if (!stride) {
3455
- stride = 3;
3337
+ for (var key in source) {
3338
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3339
+ target[key] = source[key];
3340
+ }
3341
+ }
3456
3342
  }
3457
3343
 
3458
- if (!offset) {
3459
- offset = 0;
3460
- }
3344
+ return target;
3345
+ };
3346
+ return _extends.apply(this, arguments);
3347
+ }
3461
3348
 
3462
- if (count) {
3463
- l = Math.min(count * stride + offset, a.length);
3464
- } else {
3465
- l = a.length;
3466
- }
3349
+ function _inheritsLoose$3(subClass, superClass) {
3350
+ subClass.prototype = Object.create(superClass.prototype);
3351
+ subClass.prototype.constructor = subClass;
3467
3352
 
3468
- for (i = offset; i < l; i += stride) {
3469
- vec[0] = a[i];
3470
- vec[1] = a[i + 1];
3471
- vec[2] = a[i + 2];
3472
- fn(vec, vec, arg);
3473
- a[i] = vec[0];
3474
- a[i + 1] = vec[1];
3475
- a[i + 2] = vec[2];
3476
- }
3353
+ _setPrototypeOf$3(subClass, superClass);
3354
+ }
3477
3355
 
3478
- return a;
3356
+ function _setPrototypeOf$3(o, p) {
3357
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3358
+ o.__proto__ = p;
3359
+ return o;
3479
3360
  };
3480
- }();
3361
+ return _setPrototypeOf$3(o, p);
3362
+ }
3481
3363
  /**
3482
3364
  * support 2 modes in rendering:
3483
3365
  * * immediate
@@ -3498,13 +3380,13 @@
3498
3380
  this.renderQueue = [];
3499
3381
  this.restoreStack = [];
3500
3382
  this.clearFullScreen = false;
3501
- this.vpMatrix = create$3();
3502
- this.dprMatrix = create$3();
3503
- this.tmpMat4 = create$3();
3504
- this.vec3a = create$1$1();
3505
- this.vec3b = create$1$1();
3506
- this.vec3c = create$1$1();
3507
- this.vec3d = create$1$1();
3383
+ this.vpMatrix = create();
3384
+ this.dprMatrix = create();
3385
+ this.tmpMat4 = create();
3386
+ this.vec3a = create$1();
3387
+ this.vec3b = create$1();
3388
+ this.vec3c = create$1();
3389
+ this.vec3d = create$1();
3508
3390
  this.canvasRendererPluginOptions = canvasRendererPluginOptions;
3509
3391
  }
3510
3392
 
@@ -3620,7 +3502,7 @@
3620
3502
  var context = contextService.getContext(); // clear & clip dirty rectangle
3621
3503
 
3622
3504
  var dpr = contextService.getDPR();
3623
- fromScaling(_this.dprMatrix, fromValues$1(dpr, dpr, 1));
3505
+ fromScaling(_this.dprMatrix, fromValues(dpr, dpr, 1));
3624
3506
  multiply(_this.vpMatrix, _this.dprMatrix, camera.getOrthoMatrix());
3625
3507
 
3626
3508
  if (_this.clearFullScreen) {
@@ -3633,7 +3515,7 @@
3633
3515
  maxX = _ref2.maxX,
3634
3516
  maxY = _ref2.maxY;
3635
3517
  var aabb = new gLite.AABB();
3636
- aabb.setMinMax(fromValues$1(minX, minY, 0), fromValues$1(maxX, maxY, 0));
3518
+ aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0));
3637
3519
  return aabb;
3638
3520
  })));
3639
3521
 
@@ -3650,10 +3532,10 @@
3650
3532
  y = dirtyRect.y,
3651
3533
  width = dirtyRect.width,
3652
3534
  height = dirtyRect.height;
3653
- var tl = transformMat4$1(_this.vec3a, fromValues$1(x, y, 0), _this.vpMatrix);
3654
- var tr = transformMat4$1(_this.vec3b, fromValues$1(x + width, y, 0), _this.vpMatrix);
3655
- var bl = transformMat4$1(_this.vec3c, fromValues$1(x, y + height, 0), _this.vpMatrix);
3656
- var br = transformMat4$1(_this.vec3d, fromValues$1(x + width, y + height, 0), _this.vpMatrix);
3535
+ var tl = transformMat4(_this.vec3a, fromValues(x, y, 0), _this.vpMatrix);
3536
+ var tr = transformMat4(_this.vec3b, fromValues(x + width, y, 0), _this.vpMatrix);
3537
+ var bl = transformMat4(_this.vec3c, fromValues(x, y + height, 0), _this.vpMatrix);
3538
+ var br = transformMat4(_this.vec3d, fromValues(x + width, y + height, 0), _this.vpMatrix);
3657
3539
  var minx = Math.min(tl[0], tr[0], br[0], bl[0]);
3658
3540
  var miny = Math.min(tl[1], tr[1], br[1], bl[1]);
3659
3541
  var maxx = Math.max(tl[0], tr[0], br[0], bl[0]);
@@ -6515,13 +6397,6 @@
6515
6397
  Plugin: Plugin$5
6516
6398
  });
6517
6399
 
6518
- var toString$1 = {}.toString;
6519
- var isType$1 = function (value, type) { return toString$1.call(value) === '[object ' + type + ']'; };
6520
-
6521
- var isString$1 = (function (str) {
6522
- return isType$1(str, 'String');
6523
- });
6524
-
6525
6400
  var Canvas2DContextService = /*#__PURE__*/function () {
6526
6401
  function Canvas2DContextService(context) {
6527
6402
  this.$container = void 0;
@@ -6557,7 +6432,7 @@
6557
6432
  this.canvasConfig.container = this.$container;
6558
6433
  } else if (container) {
6559
6434
  // create container
6560
- this.$container = isString$1(container) ? document.getElementById(container) : container;
6435
+ this.$container = isString(container) ? document.getElementById(container) : container;
6561
6436
 
6562
6437
  if (this.$container) {
6563
6438
  // create canvas