poly-extrude 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.1.0
2
+ * poly-extrude v0.3.0
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -1107,28 +1107,30 @@
1107
1107
  var idx0 = i * 3;
1108
1108
  var _leftPoints$i = leftPoints[i],
1109
1109
  x1 = _leftPoints$i[0],
1110
- y1 = _leftPoints$i[1];
1110
+ y1 = _leftPoints$i[1],
1111
+ z1 = _leftPoints$i[2];
1111
1112
  points[idx0] = x1;
1112
1113
  points[idx0 + 1] = y1;
1113
- points[idx0 + 2] = z; // top right
1114
+ points[idx0 + 2] = z + z1; // top right
1114
1115
 
1115
1116
  var _rightPoints$i = rightPoints[i],
1116
1117
  x2 = _rightPoints$i[0],
1117
- y2 = _rightPoints$i[1];
1118
+ y2 = _rightPoints$i[1],
1119
+ z2 = _rightPoints$i[2];
1118
1120
  var idx1 = len * 3 + idx0;
1119
1121
  points[idx1] = x2;
1120
1122
  points[idx1 + 1] = y2;
1121
- points[idx1 + 2] = z; // bottom left
1123
+ points[idx1 + 2] = z + z2; // bottom left
1122
1124
 
1123
1125
  var idx2 = len * 2 * 3 + idx0;
1124
1126
  points[idx2] = x1;
1125
1127
  points[idx2 + 1] = y1;
1126
- points[idx2 + 2] = 0; // bottom right
1128
+ points[idx2 + 2] = z1; // bottom right
1127
1129
 
1128
1130
  var idx3 = len * 2 * 3 + len * 3 + idx0;
1129
1131
  points[idx3] = x2;
1130
1132
  points[idx3 + 1] = y2;
1131
- points[idx3 + 2] = 0;
1133
+ points[idx3 + 2] = z2;
1132
1134
  i++;
1133
1135
  }
1134
1136
 
@@ -1182,7 +1184,7 @@
1182
1184
 
1183
1185
  function addOneSideIndex(v1, v2) {
1184
1186
  var idx = points.length / 3;
1185
- points.push(v1[0], v1[1], z, v2[0], v2[1], z, v1[0], v1[1], 0, v2[0], v2[1], 0);
1187
+ points.push(v1[0], v1[1], z + v1[2], v2[0], v2[1], z + v2[2], v1[0], v1[1], v1[2], v2[0], v2[1], v2[2]);
1186
1188
  var a = idx + 2,
1187
1189
  b = idx + 3,
1188
1190
  c = idx,
@@ -1311,13 +1313,14 @@
1311
1313
  function calOffsetPoint(rad, radius, p) {
1312
1314
  var x = p[0],
1313
1315
  y = p[1];
1316
+ var z = p[2] || 0;
1314
1317
  var x1 = Math.cos(rad) * radius,
1315
1318
  y1 = Math.sin(rad) * radius;
1316
- var p1 = [x + x1, y + y1];
1319
+ var p1 = [x + x1, y + y1, z];
1317
1320
  var rad1 = rad += Math.PI;
1318
1321
  var x2 = Math.cos(rad1) * radius,
1319
1322
  y2 = Math.sin(rad1) * radius;
1320
- var p2 = [x + x2, y + y2];
1323
+ var p2 = [x + x2, y + y2, z];
1321
1324
  return [p1, p2];
1322
1325
  }
1323
1326
 
@@ -1460,8 +1463,1978 @@
1460
1463
  };
1461
1464
  }
1462
1465
 
1466
+ // import * as MathUtils from './MathUtils.js';
1467
+ // code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Vector3.js
1468
+ var Vector3 = /*#__PURE__*/function () {
1469
+ function Vector3(x, y, z) {
1470
+ if (x === void 0) {
1471
+ x = 0;
1472
+ }
1473
+
1474
+ if (y === void 0) {
1475
+ y = 0;
1476
+ }
1477
+
1478
+ if (z === void 0) {
1479
+ z = 0;
1480
+ }
1481
+
1482
+ this.x = x;
1483
+ this.y = y;
1484
+ this.z = z;
1485
+ }
1486
+
1487
+ var _proto = Vector3.prototype;
1488
+
1489
+ _proto.set = function set(x, y, z) {
1490
+ if (z === undefined) z = this.z; // sprite.scale.set(x,y)
1491
+
1492
+ this.x = x;
1493
+ this.y = y;
1494
+ this.z = z;
1495
+ return this;
1496
+ } // setScalar(scalar) {
1497
+ // this.x = scalar;
1498
+ // this.y = scalar;
1499
+ // this.z = scalar;
1500
+ // return this;
1501
+ // }
1502
+ // setX(x) {
1503
+ // this.x = x;
1504
+ // return this;
1505
+ // }
1506
+ // setY(y) {
1507
+ // this.y = y;
1508
+ // return this;
1509
+ // }
1510
+ // setZ(z) {
1511
+ // this.z = z;
1512
+ // return this;
1513
+ // }
1514
+ // setComponent(index, value) {
1515
+ // switch (index) {
1516
+ // case 0: this.x = value; break;
1517
+ // case 1: this.y = value; break;
1518
+ // case 2: this.z = value; break;
1519
+ // default: throw new Error('index is out of range: ' + index);
1520
+ // }
1521
+ // return this;
1522
+ // }
1523
+ // getComponent(index) {
1524
+ // switch (index) {
1525
+ // case 0: return this.x;
1526
+ // case 1: return this.y;
1527
+ // case 2: return this.z;
1528
+ // default: throw new Error('index is out of range: ' + index);
1529
+ // }
1530
+ // }
1531
+ ;
1532
+
1533
+ _proto.clone = function clone() {
1534
+ return new this.constructor(this.x, this.y, this.z);
1535
+ };
1536
+
1537
+ _proto.copy = function copy(v) {
1538
+ this.x = v.x;
1539
+ this.y = v.y;
1540
+ this.z = v.z;
1541
+ return this;
1542
+ };
1543
+
1544
+ _proto.add = function add(v) {
1545
+ this.x += v.x;
1546
+ this.y += v.y;
1547
+ this.z += v.z;
1548
+ return this;
1549
+ };
1550
+
1551
+ _proto.addScalar = function addScalar(s) {
1552
+ this.x += s;
1553
+ this.y += s;
1554
+ this.z += s;
1555
+ return this;
1556
+ };
1557
+
1558
+ _proto.addVectors = function addVectors(a, b) {
1559
+ this.x = a.x + b.x;
1560
+ this.y = a.y + b.y;
1561
+ this.z = a.z + b.z;
1562
+ return this;
1563
+ };
1564
+
1565
+ _proto.addScaledVector = function addScaledVector(v, s) {
1566
+ this.x += v.x * s;
1567
+ this.y += v.y * s;
1568
+ this.z += v.z * s;
1569
+ return this;
1570
+ };
1571
+
1572
+ _proto.sub = function sub(v) {
1573
+ this.x -= v.x;
1574
+ this.y -= v.y;
1575
+ this.z -= v.z;
1576
+ return this;
1577
+ };
1578
+
1579
+ _proto.subScalar = function subScalar(s) {
1580
+ this.x -= s;
1581
+ this.y -= s;
1582
+ this.z -= s;
1583
+ return this;
1584
+ };
1585
+
1586
+ _proto.subVectors = function subVectors(a, b) {
1587
+ this.x = a.x - b.x;
1588
+ this.y = a.y - b.y;
1589
+ this.z = a.z - b.z;
1590
+ return this;
1591
+ };
1592
+
1593
+ _proto.multiply = function multiply(v) {
1594
+ this.x *= v.x;
1595
+ this.y *= v.y;
1596
+ this.z *= v.z;
1597
+ return this;
1598
+ };
1599
+
1600
+ _proto.multiplyScalar = function multiplyScalar(scalar) {
1601
+ this.x *= scalar;
1602
+ this.y *= scalar;
1603
+ this.z *= scalar;
1604
+ return this;
1605
+ };
1606
+
1607
+ _proto.multiplyVectors = function multiplyVectors(a, b) {
1608
+ this.x = a.x * b.x;
1609
+ this.y = a.y * b.y;
1610
+ this.z = a.z * b.z;
1611
+ return this;
1612
+ } // applyEuler(euler) {
1613
+ // return this.applyQuaternion(_quaternion.setFromEuler(euler));
1614
+ // }
1615
+ // applyAxisAngle(axis, angle) {
1616
+ // return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
1617
+ // }
1618
+ // applyMatrix3(m) {
1619
+ // const x = this.x, y = this.y, z = this.z;
1620
+ // const e = m.elements;
1621
+ // this.x = e[0] * x + e[3] * y + e[6] * z;
1622
+ // this.y = e[1] * x + e[4] * y + e[7] * z;
1623
+ // this.z = e[2] * x + e[5] * y + e[8] * z;
1624
+ // return this;
1625
+ // }
1626
+ // applyNormalMatrix(m) {
1627
+ // return this.applyMatrix3(m).normalize();
1628
+ // }
1629
+ ;
1630
+
1631
+ _proto.applyMatrix4 = function applyMatrix4(m) {
1632
+ var x = this.x,
1633
+ y = this.y,
1634
+ z = this.z;
1635
+ var e = m.elements;
1636
+ var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
1637
+ this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
1638
+ this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
1639
+ this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
1640
+ return this;
1641
+ } // applyQuaternion(q) {
1642
+ // const x = this.x, y = this.y, z = this.z;
1643
+ // const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
1644
+ // // calculate quat * vector
1645
+ // const ix = qw * x + qy * z - qz * y;
1646
+ // const iy = qw * y + qz * x - qx * z;
1647
+ // const iz = qw * z + qx * y - qy * x;
1648
+ // const iw = - qx * x - qy * y - qz * z;
1649
+ // // calculate result * inverse quat
1650
+ // this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
1651
+ // this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
1652
+ // this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
1653
+ // return this;
1654
+ // }
1655
+ // project(camera) {
1656
+ // return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
1657
+ // }
1658
+ // unproject(camera) {
1659
+ // return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
1660
+ // }
1661
+ // transformDirection(m) {
1662
+ // // input: THREE.Matrix4 affine matrix
1663
+ // // vector interpreted as a direction
1664
+ // const x = this.x, y = this.y, z = this.z;
1665
+ // const e = m.elements;
1666
+ // this.x = e[0] * x + e[4] * y + e[8] * z;
1667
+ // this.y = e[1] * x + e[5] * y + e[9] * z;
1668
+ // this.z = e[2] * x + e[6] * y + e[10] * z;
1669
+ // return this.normalize();
1670
+ // }
1671
+ ;
1672
+
1673
+ _proto.divide = function divide(v) {
1674
+ this.x /= v.x;
1675
+ this.y /= v.y;
1676
+ this.z /= v.z;
1677
+ return this;
1678
+ };
1679
+
1680
+ _proto.divideScalar = function divideScalar(scalar) {
1681
+ return this.multiplyScalar(1 / scalar);
1682
+ };
1683
+
1684
+ _proto.min = function min(v) {
1685
+ this.x = Math.min(this.x, v.x);
1686
+ this.y = Math.min(this.y, v.y);
1687
+ this.z = Math.min(this.z, v.z);
1688
+ return this;
1689
+ };
1690
+
1691
+ _proto.max = function max(v) {
1692
+ this.x = Math.max(this.x, v.x);
1693
+ this.y = Math.max(this.y, v.y);
1694
+ this.z = Math.max(this.z, v.z);
1695
+ return this;
1696
+ };
1697
+
1698
+ _proto.clamp = function clamp(min, max) {
1699
+ // assumes min < max, componentwise
1700
+ this.x = Math.max(min.x, Math.min(max.x, this.x));
1701
+ this.y = Math.max(min.y, Math.min(max.y, this.y));
1702
+ this.z = Math.max(min.z, Math.min(max.z, this.z));
1703
+ return this;
1704
+ };
1705
+
1706
+ _proto.clampScalar = function clampScalar(minVal, maxVal) {
1707
+ this.x = Math.max(minVal, Math.min(maxVal, this.x));
1708
+ this.y = Math.max(minVal, Math.min(maxVal, this.y));
1709
+ this.z = Math.max(minVal, Math.min(maxVal, this.z));
1710
+ return this;
1711
+ };
1712
+
1713
+ _proto.clampLength = function clampLength(min, max) {
1714
+ var length = this.length();
1715
+ return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
1716
+ } // floor() {
1717
+ // this.x = Math.floor(this.x);
1718
+ // this.y = Math.floor(this.y);
1719
+ // this.z = Math.floor(this.z);
1720
+ // return this;
1721
+ // }
1722
+ // ceil() {
1723
+ // this.x = Math.ceil(this.x);
1724
+ // this.y = Math.ceil(this.y);
1725
+ // this.z = Math.ceil(this.z);
1726
+ // return this;
1727
+ // }
1728
+ // round() {
1729
+ // this.x = Math.round(this.x);
1730
+ // this.y = Math.round(this.y);
1731
+ // this.z = Math.round(this.z);
1732
+ // return this;
1733
+ // }
1734
+ // roundToZero() {
1735
+ // this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x);
1736
+ // this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y);
1737
+ // this.z = (this.z < 0) ? Math.ceil(this.z) : Math.floor(this.z);
1738
+ // return this;
1739
+ // }
1740
+ // negate() {
1741
+ // this.x = -this.x;
1742
+ // this.y = -this.y;
1743
+ // this.z = -this.z;
1744
+ // return this;
1745
+ // }
1746
+ ;
1747
+
1748
+ _proto.dot = function dot(v) {
1749
+ return this.x * v.x + this.y * v.y + this.z * v.z;
1750
+ } // TODO lengthSquared?
1751
+ ;
1752
+
1753
+ _proto.lengthSq = function lengthSq() {
1754
+ return this.x * this.x + this.y * this.y + this.z * this.z;
1755
+ };
1756
+
1757
+ _proto.length = function length() {
1758
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
1759
+ } // manhattanLength() {
1760
+ // return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
1761
+ // }
1762
+ ;
1763
+
1764
+ _proto.normalize = function normalize() {
1765
+ return this.divideScalar(this.length() || 1);
1766
+ };
1767
+
1768
+ _proto.setLength = function setLength(length) {
1769
+ return this.normalize().multiplyScalar(length);
1770
+ };
1771
+
1772
+ _proto.lerp = function lerp(v, alpha) {
1773
+ this.x += (v.x - this.x) * alpha;
1774
+ this.y += (v.y - this.y) * alpha;
1775
+ this.z += (v.z - this.z) * alpha;
1776
+ return this;
1777
+ };
1778
+
1779
+ _proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
1780
+ this.x = v1.x + (v2.x - v1.x) * alpha;
1781
+ this.y = v1.y + (v2.y - v1.y) * alpha;
1782
+ this.z = v1.z + (v2.z - v1.z) * alpha;
1783
+ return this;
1784
+ };
1785
+
1786
+ _proto.cross = function cross(v) {
1787
+ return this.crossVectors(this, v);
1788
+ };
1789
+
1790
+ _proto.crossVectors = function crossVectors(a, b) {
1791
+ var ax = a.x,
1792
+ ay = a.y,
1793
+ az = a.z;
1794
+ var bx = b.x,
1795
+ by = b.y,
1796
+ bz = b.z;
1797
+ this.x = ay * bz - az * by;
1798
+ this.y = az * bx - ax * bz;
1799
+ this.z = ax * by - ay * bx;
1800
+ return this;
1801
+ } // projectOnVector(v) {
1802
+ // const denominator = v.lengthSq();
1803
+ // if (denominator === 0) return this.set(0, 0, 0);
1804
+ // const scalar = v.dot(this) / denominator;
1805
+ // return this.copy(v).multiplyScalar(scalar);
1806
+ // }
1807
+ // projectOnPlane(planeNormal) {
1808
+ // _vector.copy(this).projectOnVector(planeNormal);
1809
+ // return this.sub(_vector);
1810
+ // }
1811
+ // reflect(normal) {
1812
+ // // reflect incident vector off plane orthogonal to normal
1813
+ // // normal is assumed to have unit length
1814
+ // return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
1815
+ // }
1816
+ // angleTo(v) {
1817
+ // const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
1818
+ // if (denominator === 0) return Math.PI / 2;
1819
+ // const theta = this.dot(v) / denominator;
1820
+ // // clamp, to handle numerical problems
1821
+ // return Math.acos(MathUtils.clamp(theta, -1, 1));
1822
+ // }
1823
+ ;
1824
+
1825
+ _proto.distanceTo = function distanceTo(v) {
1826
+ return Math.sqrt(this.distanceToSquared(v));
1827
+ } // distanceToSquared(v) {
1828
+ // const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
1829
+ // return dx * dx + dy * dy + dz * dz;
1830
+ // }
1831
+ // manhattanDistanceTo(v) {
1832
+ // return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
1833
+ // }
1834
+ // setFromSpherical(s) {
1835
+ // return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
1836
+ // }
1837
+ // setFromSphericalCoords(radius, phi, theta) {
1838
+ // const sinPhiRadius = Math.sin(phi) * radius;
1839
+ // this.x = sinPhiRadius * Math.sin(theta);
1840
+ // this.y = Math.cos(phi) * radius;
1841
+ // this.z = sinPhiRadius * Math.cos(theta);
1842
+ // return this;
1843
+ // }
1844
+ // setFromCylindrical(c) {
1845
+ // return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
1846
+ // }
1847
+ // setFromCylindricalCoords(radius, theta, y) {
1848
+ // this.x = radius * Math.sin(theta);
1849
+ // this.y = y;
1850
+ // this.z = radius * Math.cos(theta);
1851
+ // return this;
1852
+ // }
1853
+ // setFromMatrixPosition(m) {
1854
+ // const e = m.elements;
1855
+ // this.x = e[12];
1856
+ // this.y = e[13];
1857
+ // this.z = e[14];
1858
+ // return this;
1859
+ // }
1860
+ // setFromMatrixScale(m) {
1861
+ // const sx = this.setFromMatrixColumn(m, 0).length();
1862
+ // const sy = this.setFromMatrixColumn(m, 1).length();
1863
+ // const sz = this.setFromMatrixColumn(m, 2).length();
1864
+ // this.x = sx;
1865
+ // this.y = sy;
1866
+ // this.z = sz;
1867
+ // return this;
1868
+ // }
1869
+ // setFromMatrixColumn(m, index) {
1870
+ // return this.fromArray(m.elements, index * 4);
1871
+ // }
1872
+ // setFromMatrix3Column(m, index) {
1873
+ // return this.fromArray(m.elements, index * 3);
1874
+ // }
1875
+ // setFromEuler(e) {
1876
+ // this.x = e._x;
1877
+ // this.y = e._y;
1878
+ // this.z = e._z;
1879
+ // return this;
1880
+ // }
1881
+ // setFromColor(c) {
1882
+ // this.x = c.r;
1883
+ // this.y = c.g;
1884
+ // this.z = c.b;
1885
+ // return this;
1886
+ // }
1887
+ ;
1888
+
1889
+ _proto.equals = function equals(v) {
1890
+ return v.x === this.x && v.y === this.y && v.z === this.z;
1891
+ };
1892
+
1893
+ _proto.fromArray = function fromArray(array, offset) {
1894
+ if (offset === void 0) {
1895
+ offset = 0;
1896
+ }
1897
+
1898
+ this.x = array[offset];
1899
+ this.y = array[offset + 1];
1900
+ this.z = array[offset + 2];
1901
+ return this;
1902
+ } // toArray(array = [], offset = 0) {
1903
+ // array[offset] = this.x;
1904
+ // array[offset + 1] = this.y;
1905
+ // array[offset + 2] = this.z;
1906
+ // return array;
1907
+ // }
1908
+ // fromBufferAttribute(attribute, index) {
1909
+ // this.x = attribute.getX(index);
1910
+ // this.y = attribute.getY(index);
1911
+ // this.z = attribute.getZ(index);
1912
+ // return this;
1913
+ // }
1914
+ ;
1915
+
1916
+ _proto.random = function random() {
1917
+ this.x = Math.random();
1918
+ this.y = Math.random();
1919
+ this.z = Math.random();
1920
+ return this;
1921
+ } // randomDirection() {
1922
+ // // Derived from https://mathworld.wolfram.com/SpherePointPicking.html
1923
+ // const u = (Math.random() - 0.5) * 2;
1924
+ // const t = Math.random() * Math.PI * 2;
1925
+ // const f = Math.sqrt(1 - u ** 2);
1926
+ // this.x = f * Math.cos(t);
1927
+ // this.y = f * Math.sin(t);
1928
+ // this.z = u;
1929
+ // return this;
1930
+ // }
1931
+ ;
1932
+
1933
+ return Vector3;
1934
+ }();
1935
+
1936
+ /* eslint-disable no-tabs */
1937
+ /**
1938
+ * PathPoint
1939
+ */
1940
+
1941
+ var PathPoint = /*#__PURE__*/function () {
1942
+ function PathPoint() {
1943
+ this.pos = new Vector3();
1944
+ this.dir = new Vector3();
1945
+ this.right = new Vector3();
1946
+ this.up = new Vector3(); // normal
1947
+
1948
+ this.dist = 0; // distance from start
1949
+
1950
+ this.widthScale = 1; // for corner
1951
+
1952
+ this.sharp = false; // marks as sharp corner
1953
+ }
1954
+
1955
+ var _proto = PathPoint.prototype;
1956
+
1957
+ _proto.lerpPathPoints = function lerpPathPoints(p1, p2, alpha) {
1958
+ this.pos.lerpVectors(p1.pos, p2.pos, alpha);
1959
+ this.dir.lerpVectors(p1.dir, p2.dir, alpha);
1960
+ this.up.lerpVectors(p1.up, p2.up, alpha);
1961
+ this.right.lerpVectors(p1.right, p2.right, alpha);
1962
+ this.dist = (p2.dist - p1.dist) * alpha + p1.dist;
1963
+ this.widthScale = (p2.widthScale - p1.widthScale) * alpha + p1.widthScale;
1964
+ };
1965
+
1966
+ _proto.copy = function copy(source) {
1967
+ this.pos.copy(source.pos);
1968
+ this.dir.copy(source.dir);
1969
+ this.up.copy(source.up);
1970
+ this.right.copy(source.right);
1971
+ this.dist = source.dist;
1972
+ this.widthScale = source.widthScale;
1973
+ };
1974
+
1975
+ return PathPoint;
1976
+ }();
1977
+
1978
+ // code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Matrix4.js
1979
+ // import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
1980
+ // import { Vector3 } from './Vector3.js';
1981
+ var Matrix4 = /*#__PURE__*/function () {
1982
+ function Matrix4(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
1983
+ this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
1984
+
1985
+ if (n11 !== undefined) {
1986
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
1987
+ }
1988
+ }
1989
+
1990
+ var _proto = Matrix4.prototype;
1991
+
1992
+ _proto.set = function set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
1993
+ var te = this.elements;
1994
+ te[0] = n11;
1995
+ te[4] = n12;
1996
+ te[8] = n13;
1997
+ te[12] = n14;
1998
+ te[1] = n21;
1999
+ te[5] = n22;
2000
+ te[9] = n23;
2001
+ te[13] = n24;
2002
+ te[2] = n31;
2003
+ te[6] = n32;
2004
+ te[10] = n33;
2005
+ te[14] = n34;
2006
+ te[3] = n41;
2007
+ te[7] = n42;
2008
+ te[11] = n43;
2009
+ te[15] = n44;
2010
+ return this;
2011
+ } // identity() {
2012
+ // this.set(
2013
+ // 1, 0, 0, 0,
2014
+ // 0, 1, 0, 0,
2015
+ // 0, 0, 1, 0,
2016
+ // 0, 0, 0, 1
2017
+ // );
2018
+ // return this;
2019
+ // }
2020
+ // clone() {
2021
+ // return new Matrix4().fromArray(this.elements);
2022
+ // }
2023
+ // copy(m) {
2024
+ // const te = this.elements;
2025
+ // const me = m.elements;
2026
+ // te[0] = me[0]; te[1] = me[1]; te[2] = me[2]; te[3] = me[3];
2027
+ // te[4] = me[4]; te[5] = me[5]; te[6] = me[6]; te[7] = me[7];
2028
+ // te[8] = me[8]; te[9] = me[9]; te[10] = me[10]; te[11] = me[11];
2029
+ // te[12] = me[12]; te[13] = me[13]; te[14] = me[14]; te[15] = me[15];
2030
+ // return this;
2031
+ // }
2032
+ // copyPosition(m) {
2033
+ // const te = this.elements, me = m.elements;
2034
+ // te[12] = me[12];
2035
+ // te[13] = me[13];
2036
+ // te[14] = me[14];
2037
+ // return this;
2038
+ // }
2039
+ // setFromMatrix3(m) {
2040
+ // const me = m.elements;
2041
+ // this.set(
2042
+ // me[0], me[3], me[6], 0,
2043
+ // me[1], me[4], me[7], 0,
2044
+ // me[2], me[5], me[8], 0,
2045
+ // 0, 0, 0, 1
2046
+ // );
2047
+ // return this;
2048
+ // }
2049
+ // extractBasis(xAxis, yAxis, zAxis) {
2050
+ // xAxis.setFromMatrixColumn(this, 0);
2051
+ // yAxis.setFromMatrixColumn(this, 1);
2052
+ // zAxis.setFromMatrixColumn(this, 2);
2053
+ // return this;
2054
+ // }
2055
+ // makeBasis(xAxis, yAxis, zAxis) {
2056
+ // this.set(
2057
+ // xAxis.x, yAxis.x, zAxis.x, 0,
2058
+ // xAxis.y, yAxis.y, zAxis.y, 0,
2059
+ // xAxis.z, yAxis.z, zAxis.z, 0,
2060
+ // 0, 0, 0, 1
2061
+ // );
2062
+ // return this;
2063
+ // }
2064
+ // extractRotation(m) {
2065
+ // // this method does not support reflection matrices
2066
+ // const te = this.elements;
2067
+ // const me = m.elements;
2068
+ // const scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
2069
+ // const scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
2070
+ // const scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
2071
+ // te[0] = me[0] * scaleX;
2072
+ // te[1] = me[1] * scaleX;
2073
+ // te[2] = me[2] * scaleX;
2074
+ // te[3] = 0;
2075
+ // te[4] = me[4] * scaleY;
2076
+ // te[5] = me[5] * scaleY;
2077
+ // te[6] = me[6] * scaleY;
2078
+ // te[7] = 0;
2079
+ // te[8] = me[8] * scaleZ;
2080
+ // te[9] = me[9] * scaleZ;
2081
+ // te[10] = me[10] * scaleZ;
2082
+ // te[11] = 0;
2083
+ // te[12] = 0;
2084
+ // te[13] = 0;
2085
+ // te[14] = 0;
2086
+ // te[15] = 1;
2087
+ // return this;
2088
+ // }
2089
+ // makeRotationFromEuler(euler) {
2090
+ // const te = this.elements;
2091
+ // const x = euler.x, y = euler.y, z = euler.z;
2092
+ // const a = Math.cos(x), b = Math.sin(x);
2093
+ // const c = Math.cos(y), d = Math.sin(y);
2094
+ // const e = Math.cos(z), f = Math.sin(z);
2095
+ // if (euler.order === 'XYZ') {
2096
+ // const ae = a * e, af = a * f, be = b * e, bf = b * f;
2097
+ // te[0] = c * e;
2098
+ // te[4] = -c * f;
2099
+ // te[8] = d;
2100
+ // te[1] = af + be * d;
2101
+ // te[5] = ae - bf * d;
2102
+ // te[9] = -b * c;
2103
+ // te[2] = bf - ae * d;
2104
+ // te[6] = be + af * d;
2105
+ // te[10] = a * c;
2106
+ // } else if (euler.order === 'YXZ') {
2107
+ // const ce = c * e, cf = c * f, de = d * e, df = d * f;
2108
+ // te[0] = ce + df * b;
2109
+ // te[4] = de * b - cf;
2110
+ // te[8] = a * d;
2111
+ // te[1] = a * f;
2112
+ // te[5] = a * e;
2113
+ // te[9] = -b;
2114
+ // te[2] = cf * b - de;
2115
+ // te[6] = df + ce * b;
2116
+ // te[10] = a * c;
2117
+ // } else if (euler.order === 'ZXY') {
2118
+ // const ce = c * e, cf = c * f, de = d * e, df = d * f;
2119
+ // te[0] = ce - df * b;
2120
+ // te[4] = -a * f;
2121
+ // te[8] = de + cf * b;
2122
+ // te[1] = cf + de * b;
2123
+ // te[5] = a * e;
2124
+ // te[9] = df - ce * b;
2125
+ // te[2] = -a * d;
2126
+ // te[6] = b;
2127
+ // te[10] = a * c;
2128
+ // } else if (euler.order === 'ZYX') {
2129
+ // const ae = a * e, af = a * f, be = b * e, bf = b * f;
2130
+ // te[0] = c * e;
2131
+ // te[4] = be * d - af;
2132
+ // te[8] = ae * d + bf;
2133
+ // te[1] = c * f;
2134
+ // te[5] = bf * d + ae;
2135
+ // te[9] = af * d - be;
2136
+ // te[2] = -d;
2137
+ // te[6] = b * c;
2138
+ // te[10] = a * c;
2139
+ // } else if (euler.order === 'YZX') {
2140
+ // const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
2141
+ // te[0] = c * e;
2142
+ // te[4] = bd - ac * f;
2143
+ // te[8] = bc * f + ad;
2144
+ // te[1] = f;
2145
+ // te[5] = a * e;
2146
+ // te[9] = -b * e;
2147
+ // te[2] = -d * e;
2148
+ // te[6] = ad * f + bc;
2149
+ // te[10] = ac - bd * f;
2150
+ // } else if (euler.order === 'XZY') {
2151
+ // const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
2152
+ // te[0] = c * e;
2153
+ // te[4] = -f;
2154
+ // te[8] = d * e;
2155
+ // te[1] = ac * f + bd;
2156
+ // te[5] = a * e;
2157
+ // te[9] = ad * f - bc;
2158
+ // te[2] = bc * f - ad;
2159
+ // te[6] = b * e;
2160
+ // te[10] = bd * f + ac;
2161
+ // }
2162
+ // // bottom row
2163
+ // te[3] = 0;
2164
+ // te[7] = 0;
2165
+ // te[11] = 0;
2166
+ // // last column
2167
+ // te[12] = 0;
2168
+ // te[13] = 0;
2169
+ // te[14] = 0;
2170
+ // te[15] = 1;
2171
+ // return this;
2172
+ // }
2173
+ // makeRotationFromQuaternion(q) {
2174
+ // return this.compose(_zero, q, _one);
2175
+ // }
2176
+ // lookAt(eye, target, up) {
2177
+ // const te = this.elements;
2178
+ // _z.subVectors(eye, target);
2179
+ // if (_z.lengthSq() === 0) {
2180
+ // // eye and target are in the same position
2181
+ // _z.z = 1;
2182
+ // }
2183
+ // _z.normalize();
2184
+ // _x.crossVectors(up, _z);
2185
+ // if (_x.lengthSq() === 0) {
2186
+ // // up and z are parallel
2187
+ // if (Math.abs(up.z) === 1) {
2188
+ // _z.x += 0.0001;
2189
+ // } else {
2190
+ // _z.z += 0.0001;
2191
+ // }
2192
+ // _z.normalize();
2193
+ // _x.crossVectors(up, _z);
2194
+ // }
2195
+ // _x.normalize();
2196
+ // _y.crossVectors(_z, _x);
2197
+ // te[0] = _x.x; te[4] = _y.x; te[8] = _z.x;
2198
+ // te[1] = _x.y; te[5] = _y.y; te[9] = _z.y;
2199
+ // te[2] = _x.z; te[6] = _y.z; te[10] = _z.z;
2200
+ // return this;
2201
+ // }
2202
+ ;
2203
+
2204
+ _proto.multiply = function multiply(m) {
2205
+ return this.multiplyMatrices(this, m);
2206
+ } // premultiply(m) {
2207
+ // return this.multiplyMatrices(m, this);
2208
+ // }
2209
+ // multiplyMatrices(a, b) {
2210
+ // const ae = a.elements;
2211
+ // const be = b.elements;
2212
+ // const te = this.elements;
2213
+ // const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
2214
+ // const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
2215
+ // const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
2216
+ // const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
2217
+ // const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
2218
+ // const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
2219
+ // const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
2220
+ // const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
2221
+ // te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
2222
+ // te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
2223
+ // te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
2224
+ // te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
2225
+ // te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
2226
+ // te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
2227
+ // te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
2228
+ // te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
2229
+ // te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
2230
+ // te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
2231
+ // te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
2232
+ // te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
2233
+ // te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
2234
+ // te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
2235
+ // te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
2236
+ // te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
2237
+ // return this;
2238
+ // }
2239
+ // multiplyScalar(s) {
2240
+ // const te = this.elements;
2241
+ // te[0] *= s; te[4] *= s; te[8] *= s; te[12] *= s;
2242
+ // te[1] *= s; te[5] *= s; te[9] *= s; te[13] *= s;
2243
+ // te[2] *= s; te[6] *= s; te[10] *= s; te[14] *= s;
2244
+ // te[3] *= s; te[7] *= s; te[11] *= s; te[15] *= s;
2245
+ // return this;
2246
+ // }
2247
+ // determinant() {
2248
+ // const te = this.elements;
2249
+ // const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
2250
+ // const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
2251
+ // const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
2252
+ // const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
2253
+ // //TODO: make this more efficient
2254
+ // //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
2255
+ // return (
2256
+ // n41 * (
2257
+ // + n14 * n23 * n32
2258
+ // - n13 * n24 * n32
2259
+ // - n14 * n22 * n33
2260
+ // + n12 * n24 * n33
2261
+ // + n13 * n22 * n34
2262
+ // - n12 * n23 * n34
2263
+ // ) +
2264
+ // n42 * (
2265
+ // + n11 * n23 * n34
2266
+ // - n11 * n24 * n33
2267
+ // + n14 * n21 * n33
2268
+ // - n13 * n21 * n34
2269
+ // + n13 * n24 * n31
2270
+ // - n14 * n23 * n31
2271
+ // ) +
2272
+ // n43 * (
2273
+ // + n11 * n24 * n32
2274
+ // - n11 * n22 * n34
2275
+ // - n14 * n21 * n32
2276
+ // + n12 * n21 * n34
2277
+ // + n14 * n22 * n31
2278
+ // - n12 * n24 * n31
2279
+ // ) +
2280
+ // n44 * (
2281
+ // - n13 * n22 * n31
2282
+ // - n11 * n23 * n32
2283
+ // + n11 * n22 * n33
2284
+ // + n13 * n21 * n32
2285
+ // - n12 * n21 * n33
2286
+ // + n12 * n23 * n31
2287
+ // )
2288
+ // );
2289
+ // }
2290
+ // transpose() {
2291
+ // const te = this.elements;
2292
+ // let tmp;
2293
+ // tmp = te[1]; te[1] = te[4]; te[4] = tmp;
2294
+ // tmp = te[2]; te[2] = te[8]; te[8] = tmp;
2295
+ // tmp = te[6]; te[6] = te[9]; te[9] = tmp;
2296
+ // tmp = te[3]; te[3] = te[12]; te[12] = tmp;
2297
+ // tmp = te[7]; te[7] = te[13]; te[13] = tmp;
2298
+ // tmp = te[11]; te[11] = te[14]; te[14] = tmp;
2299
+ // return this;
2300
+ // }
2301
+ // setPosition(x, y, z) {
2302
+ // const te = this.elements;
2303
+ // if (x.isVector3) {
2304
+ // te[12] = x.x;
2305
+ // te[13] = x.y;
2306
+ // te[14] = x.z;
2307
+ // } else {
2308
+ // te[12] = x;
2309
+ // te[13] = y;
2310
+ // te[14] = z;
2311
+ // }
2312
+ // return this;
2313
+ // }
2314
+ // invert() {
2315
+ // // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
2316
+ // const te = this.elements,
2317
+ // n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3],
2318
+ // n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7],
2319
+ // n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11],
2320
+ // n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15],
2321
+ // t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
2322
+ // t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
2323
+ // t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
2324
+ // t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
2325
+ // const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
2326
+ // if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2327
+ // const detInv = 1 / det;
2328
+ // te[0] = t11 * detInv;
2329
+ // te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
2330
+ // te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
2331
+ // te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
2332
+ // te[4] = t12 * detInv;
2333
+ // te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
2334
+ // te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
2335
+ // te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
2336
+ // te[8] = t13 * detInv;
2337
+ // te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
2338
+ // te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
2339
+ // te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
2340
+ // te[12] = t14 * detInv;
2341
+ // te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
2342
+ // te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
2343
+ // te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
2344
+ // return this;
2345
+ // }
2346
+ // scale(v) {
2347
+ // const te = this.elements;
2348
+ // const x = v.x, y = v.y, z = v.z;
2349
+ // te[0] *= x; te[4] *= y; te[8] *= z;
2350
+ // te[1] *= x; te[5] *= y; te[9] *= z;
2351
+ // te[2] *= x; te[6] *= y; te[10] *= z;
2352
+ // te[3] *= x; te[7] *= y; te[11] *= z;
2353
+ // return this;
2354
+ // }
2355
+ // getMaxScaleOnAxis() {
2356
+ // const te = this.elements;
2357
+ // const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
2358
+ // const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
2359
+ // const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
2360
+ // return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
2361
+ // }
2362
+ // makeTranslation(x, y, z) {
2363
+ // if (x.isVector3) {
2364
+ // this.set(
2365
+ // 1, 0, 0, x.x,
2366
+ // 0, 1, 0, x.y,
2367
+ // 0, 0, 1, x.z,
2368
+ // 0, 0, 0, 1
2369
+ // );
2370
+ // } else {
2371
+ // this.set(
2372
+ // 1, 0, 0, x,
2373
+ // 0, 1, 0, y,
2374
+ // 0, 0, 1, z,
2375
+ // 0, 0, 0, 1
2376
+ // );
2377
+ // }
2378
+ // return this;
2379
+ // }
2380
+ // makeRotationX(theta) {
2381
+ // const c = Math.cos(theta), s = Math.sin(theta);
2382
+ // this.set(
2383
+ // 1, 0, 0, 0,
2384
+ // 0, c, -s, 0,
2385
+ // 0, s, c, 0,
2386
+ // 0, 0, 0, 1
2387
+ // );
2388
+ // return this;
2389
+ // }
2390
+ // makeRotationY(theta) {
2391
+ // const c = Math.cos(theta), s = Math.sin(theta);
2392
+ // this.set(
2393
+ // c, 0, s, 0,
2394
+ // 0, 1, 0, 0,
2395
+ // -s, 0, c, 0,
2396
+ // 0, 0, 0, 1
2397
+ // );
2398
+ // return this;
2399
+ // }
2400
+ // makeRotationZ(theta) {
2401
+ // const c = Math.cos(theta), s = Math.sin(theta);
2402
+ // this.set(
2403
+ // c, -s, 0, 0,
2404
+ // s, c, 0, 0,
2405
+ // 0, 0, 1, 0,
2406
+ // 0, 0, 0, 1
2407
+ // );
2408
+ // return this;
2409
+ // }
2410
+ ;
2411
+
2412
+ _proto.makeRotationAxis = function makeRotationAxis(axis, angle) {
2413
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
2414
+ var c = Math.cos(angle);
2415
+ var s = Math.sin(angle);
2416
+ var t = 1 - c;
2417
+ var x = axis.x,
2418
+ y = axis.y,
2419
+ z = axis.z;
2420
+ var tx = t * x,
2421
+ ty = t * y;
2422
+ this.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);
2423
+ return this;
2424
+ } // makeScale(x, y, z) {
2425
+ // this.set(
2426
+ // x, 0, 0, 0,
2427
+ // 0, y, 0, 0,
2428
+ // 0, 0, z, 0,
2429
+ // 0, 0, 0, 1
2430
+ // );
2431
+ // return this;
2432
+ // }
2433
+ // makeShear(xy, xz, yx, yz, zx, zy) {
2434
+ // this.set(
2435
+ // 1, yx, zx, 0,
2436
+ // xy, 1, zy, 0,
2437
+ // xz, yz, 1, 0,
2438
+ // 0, 0, 0, 1
2439
+ // );
2440
+ // return this;
2441
+ // }
2442
+ // compose(position, quaternion, scale) {
2443
+ // const te = this.elements;
2444
+ // const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
2445
+ // const x2 = x + x, y2 = y + y, z2 = z + z;
2446
+ // const xx = x * x2, xy = x * y2, xz = x * z2;
2447
+ // const yy = y * y2, yz = y * z2, zz = z * z2;
2448
+ // const wx = w * x2, wy = w * y2, wz = w * z2;
2449
+ // const sx = scale.x, sy = scale.y, sz = scale.z;
2450
+ // te[0] = (1 - (yy + zz)) * sx;
2451
+ // te[1] = (xy + wz) * sx;
2452
+ // te[2] = (xz - wy) * sx;
2453
+ // te[3] = 0;
2454
+ // te[4] = (xy - wz) * sy;
2455
+ // te[5] = (1 - (xx + zz)) * sy;
2456
+ // te[6] = (yz + wx) * sy;
2457
+ // te[7] = 0;
2458
+ // te[8] = (xz + wy) * sz;
2459
+ // te[9] = (yz - wx) * sz;
2460
+ // te[10] = (1 - (xx + yy)) * sz;
2461
+ // te[11] = 0;
2462
+ // te[12] = position.x;
2463
+ // te[13] = position.y;
2464
+ // te[14] = position.z;
2465
+ // te[15] = 1;
2466
+ // return this;
2467
+ // }
2468
+ // decompose(position, quaternion, scale) {
2469
+ // const te = this.elements;
2470
+ // let sx = _v1.set(te[0], te[1], te[2]).length();
2471
+ // const sy = _v1.set(te[4], te[5], te[6]).length();
2472
+ // const sz = _v1.set(te[8], te[9], te[10]).length();
2473
+ // // if determine is negative, we need to invert one scale
2474
+ // const det = this.determinant();
2475
+ // if (det < 0) sx = -sx;
2476
+ // position.x = te[12];
2477
+ // position.y = te[13];
2478
+ // position.z = te[14];
2479
+ // // scale the rotation part
2480
+ // _m1.copy(this);
2481
+ // const invSX = 1 / sx;
2482
+ // const invSY = 1 / sy;
2483
+ // const invSZ = 1 / sz;
2484
+ // _m1.elements[0] *= invSX;
2485
+ // _m1.elements[1] *= invSX;
2486
+ // _m1.elements[2] *= invSX;
2487
+ // _m1.elements[4] *= invSY;
2488
+ // _m1.elements[5] *= invSY;
2489
+ // _m1.elements[6] *= invSY;
2490
+ // _m1.elements[8] *= invSZ;
2491
+ // _m1.elements[9] *= invSZ;
2492
+ // _m1.elements[10] *= invSZ;
2493
+ // quaternion.setFromRotationMatrix(_m1);
2494
+ // scale.x = sx;
2495
+ // scale.y = sy;
2496
+ // scale.z = sz;
2497
+ // return this;
2498
+ // }
2499
+ // makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
2500
+ // const te = this.elements;
2501
+ // const x = 2 * near / (right - left);
2502
+ // const y = 2 * near / (top - bottom);
2503
+ // const a = (right + left) / (right - left);
2504
+ // const b = (top + bottom) / (top - bottom);
2505
+ // let c, d;
2506
+ // if (coordinateSystem === WebGLCoordinateSystem) {
2507
+ // c = - (far + near) / (far - near);
2508
+ // d = (- 2 * far * near) / (far - near);
2509
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
2510
+ // c = - far / (far - near);
2511
+ // d = (- far * near) / (far - near);
2512
+ // } else {
2513
+ // throw new Error('THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem);
2514
+ // }
2515
+ // te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
2516
+ // te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
2517
+ // te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
2518
+ // te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
2519
+ // return this;
2520
+ // }
2521
+ // makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
2522
+ // const te = this.elements;
2523
+ // const w = 1.0 / (right - left);
2524
+ // const h = 1.0 / (top - bottom);
2525
+ // const p = 1.0 / (far - near);
2526
+ // const x = (right + left) * w;
2527
+ // const y = (top + bottom) * h;
2528
+ // let z, zInv;
2529
+ // if (coordinateSystem === WebGLCoordinateSystem) {
2530
+ // z = (far + near) * p;
2531
+ // zInv = - 2 * p;
2532
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
2533
+ // z = near * p;
2534
+ // zInv = - 1 * p;
2535
+ // } else {
2536
+ // throw new Error('THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem);
2537
+ // }
2538
+ // te[0] = 2 * w; te[4] = 0; te[8] = 0; te[12] = - x;
2539
+ // te[1] = 0; te[5] = 2 * h; te[9] = 0; te[13] = - y;
2540
+ // te[2] = 0; te[6] = 0; te[10] = zInv; te[14] = - z;
2541
+ // te[3] = 0; te[7] = 0; te[11] = 0; te[15] = 1;
2542
+ // return this;
2543
+ // }
2544
+ ;
2545
+
2546
+ _proto.equals = function equals(matrix) {
2547
+ var te = this.elements;
2548
+ var me = matrix.elements;
2549
+
2550
+ for (var i = 0; i < 16; i++) {
2551
+ if (te[i] !== me[i]) return false;
2552
+ }
2553
+
2554
+ return true;
2555
+ } // fromArray(array, offset = 0) {
2556
+ // for (let i = 0; i < 16; i++) {
2557
+ // this.elements[i] = array[i + offset];
2558
+ // }
2559
+ // return this;
2560
+ // }
2561
+ // toArray(array = [], offset = 0) {
2562
+ // const te = this.elements;
2563
+ // array[offset] = te[0];
2564
+ // array[offset + 1] = te[1];
2565
+ // array[offset + 2] = te[2];
2566
+ // array[offset + 3] = te[3];
2567
+ // array[offset + 4] = te[4];
2568
+ // array[offset + 5] = te[5];
2569
+ // array[offset + 6] = te[6];
2570
+ // array[offset + 7] = te[7];
2571
+ // array[offset + 8] = te[8];
2572
+ // array[offset + 9] = te[9];
2573
+ // array[offset + 10] = te[10];
2574
+ // array[offset + 11] = te[11];
2575
+ // array[offset + 12] = te[12];
2576
+ // array[offset + 13] = te[13];
2577
+ // array[offset + 14] = te[14];
2578
+ // array[offset + 15] = te[15];
2579
+ // return array;
2580
+ // }
2581
+ ;
2582
+
2583
+ return Matrix4;
2584
+ }(); // const _v1 = new Vector3();
2585
+
2586
+ function _inheritsLoose(subClass, superClass) {
2587
+ subClass.prototype = Object.create(superClass.prototype);
2588
+ subClass.prototype.constructor = subClass;
2589
+
2590
+ _setPrototypeOf(subClass, superClass);
2591
+ }
2592
+
2593
+ function _setPrototypeOf(o, p) {
2594
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2595
+ o.__proto__ = p;
2596
+ return o;
2597
+ };
2598
+ return _setPrototypeOf(o, p);
2599
+ }
2600
+
2601
+ // code copy from https://github.com/mrdoob/three.js/blob/dev/src/extras/core/Curve.js
2602
+ // import * as MathUtils from '../../math/MathUtils.js';
2603
+ // import { Vector2 } from '../../math/Vector2.js';
2604
+ // import { Vector3 } from '../../math/Vector3.js';
2605
+ // import { Matrix4 } from '../../math/Matrix4.js';
2606
+
2607
+ /**
2608
+ * Extensible curve object.
2609
+ *
2610
+ * Some common of curve methods:
2611
+ * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget )
2612
+ * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget )
2613
+ * .getPoints(), .getSpacedPoints()
2614
+ * .getLength()
2615
+ * .updateArcLengths()
2616
+ *
2617
+ * This following curves inherit from THREE.Curve:
2618
+ *
2619
+ * -- 2D curves --
2620
+ * THREE.ArcCurve
2621
+ * THREE.CubicBezierCurve
2622
+ * THREE.EllipseCurve
2623
+ * THREE.LineCurve
2624
+ * THREE.QuadraticBezierCurve
2625
+ * THREE.SplineCurve
2626
+ *
2627
+ * -- 3D curves --
2628
+ * THREE.CatmullRomCurve3
2629
+ * THREE.CubicBezierCurve3
2630
+ * THREE.LineCurve3
2631
+ * THREE.QuadraticBezierCurve3
2632
+ *
2633
+ * A series of curves can be represented as a THREE.CurvePath.
2634
+ *
2635
+ **/
2636
+ var Curve = /*#__PURE__*/function () {
2637
+ function Curve() {
2638
+ this.type = 'Curve';
2639
+ this.arcLengthDivisions = 200;
2640
+ } // Virtual base class method to overwrite and implement in subclasses
2641
+
2642
+
2643
+ var _proto = Curve.prototype;
2644
+
2645
+ _proto.getPoint = function getPoint() {
2646
+ console.warn('THREE.Curve: .getPoint() not implemented.');
2647
+ return null;
2648
+ } // Get point at relative position in curve according to arc length
2649
+ // - u [0 .. 1]
2650
+ ;
2651
+
2652
+ _proto.getPointAt = function getPointAt(u, optionalTarget) {
2653
+ var t = this.getUtoTmapping(u);
2654
+ return this.getPoint(t, optionalTarget);
2655
+ } // Get sequence of points using getPoint( t )
2656
+ ;
2657
+
2658
+ _proto.getPoints = function getPoints(divisions) {
2659
+ if (divisions === void 0) {
2660
+ divisions = 5;
2661
+ }
2662
+
2663
+ var points = [];
2664
+
2665
+ for (var d = 0; d <= divisions; d++) {
2666
+ points.push(this.getPoint(d / divisions));
2667
+ }
2668
+
2669
+ return points;
2670
+ } // // Get sequence of points using getPointAt( u )
2671
+ // getSpacedPoints(divisions = 5) {
2672
+ // const points = [];
2673
+ // for (let d = 0; d <= divisions; d++) {
2674
+ // points.push(this.getPointAt(d / divisions));
2675
+ // }
2676
+ // return points;
2677
+ // }
2678
+ // Get total curve arc length
2679
+ ;
2680
+
2681
+ _proto.getLength = function getLength() {
2682
+ var lengths = this.getLengths();
2683
+ return lengths[lengths.length - 1];
2684
+ } // Get list of cumulative segment lengths
2685
+ ;
2686
+
2687
+ _proto.getLengths = function getLengths(divisions) {
2688
+ if (divisions === void 0) {
2689
+ divisions = this.arcLengthDivisions;
2690
+ }
2691
+
2692
+ if (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {
2693
+ return this.cacheArcLengths;
2694
+ }
2695
+
2696
+ this.needsUpdate = false;
2697
+ var cache = [];
2698
+ var current,
2699
+ last = this.getPoint(0);
2700
+ var sum = 0;
2701
+ cache.push(0);
2702
+
2703
+ for (var p = 1; p <= divisions; p++) {
2704
+ current = this.getPoint(p / divisions);
2705
+ sum += current.distanceTo(last);
2706
+ cache.push(sum);
2707
+ last = current;
2708
+ }
2709
+
2710
+ this.cacheArcLengths = cache;
2711
+ return cache; // { sums: cache, sum: sum }; Sum is in the last element.
2712
+ } // updateArcLengths() {
2713
+ // this.needsUpdate = true;
2714
+ // this.getLengths();
2715
+ // }
2716
+ // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
2717
+ ;
2718
+
2719
+ _proto.getUtoTmapping = function getUtoTmapping(u, distance) {
2720
+ var arcLengths = this.getLengths();
2721
+ var i = 0;
2722
+ var il = arcLengths.length;
2723
+ var targetArcLength; // The targeted u distance value to get
2724
+
2725
+ if (distance) {
2726
+ targetArcLength = distance;
2727
+ } else {
2728
+ targetArcLength = u * arcLengths[il - 1];
2729
+ } // binary search for the index with largest value smaller than target u distance
2730
+
2731
+
2732
+ var low = 0,
2733
+ high = il - 1,
2734
+ comparison;
2735
+
2736
+ while (low <= high) {
2737
+ i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats
2738
+
2739
+ comparison = arcLengths[i] - targetArcLength;
2740
+
2741
+ if (comparison < 0) {
2742
+ low = i + 1;
2743
+ } else if (comparison > 0) {
2744
+ high = i - 1;
2745
+ } else {
2746
+ high = i;
2747
+ break; // DONE
2748
+ }
2749
+ }
2750
+
2751
+ i = high;
2752
+
2753
+ if (arcLengths[i] === targetArcLength) {
2754
+ return i / (il - 1);
2755
+ } // we could get finer grain at lengths, or use simple interpolation between two points
2756
+
2757
+
2758
+ var lengthBefore = arcLengths[i];
2759
+ var lengthAfter = arcLengths[i + 1];
2760
+ var segmentLength = lengthAfter - lengthBefore; // determine where we are between the 'before' and 'after' points
2761
+
2762
+ var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; // add that fractional amount to t
2763
+
2764
+ var t = (i + segmentFraction) / (il - 1);
2765
+ return t;
2766
+ } // Returns a unit vector tangent at t
2767
+ // In case any sub curve does not implement its tangent derivation,
2768
+ // 2 points a small delta apart will be used to find its gradient
2769
+ // which seems to give a reasonable approximation
2770
+ // getTangent(t, optionalTarget) {
2771
+ // const delta = 0.0001;
2772
+ // let t1 = t - delta;
2773
+ // let t2 = t + delta;
2774
+ // // Capping in case of danger
2775
+ // if (t1 < 0) t1 = 0;
2776
+ // if (t2 > 1) t2 = 1;
2777
+ // const pt1 = this.getPoint(t1);
2778
+ // const pt2 = this.getPoint(t2);
2779
+ // const tangent = optionalTarget || ((pt1.isVector2) ? new Vector2() : new Vector3());
2780
+ // tangent.copy(pt2).sub(pt1).normalize();
2781
+ // return tangent;
2782
+ // }
2783
+ // getTangentAt(u, optionalTarget) {
2784
+ // const t = this.getUtoTmapping(u);
2785
+ // return this.getTangent(t, optionalTarget);
2786
+ // }
2787
+ // computeFrenetFrames(segments, closed) {
2788
+ // // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf
2789
+ // const normal = new Vector3();
2790
+ // const tangents = [];
2791
+ // const normals = [];
2792
+ // const binormals = [];
2793
+ // const vec = new Vector3();
2794
+ // const mat = new Matrix4();
2795
+ // // compute the tangent vectors for each segment on the curve
2796
+ // for (let i = 0; i <= segments; i++) {
2797
+ // const u = i / segments;
2798
+ // tangents[i] = this.getTangentAt(u, new Vector3());
2799
+ // }
2800
+ // // select an initial normal vector perpendicular to the first tangent vector,
2801
+ // // and in the direction of the minimum tangent xyz component
2802
+ // normals[0] = new Vector3();
2803
+ // binormals[0] = new Vector3();
2804
+ // let min = Number.MAX_VALUE;
2805
+ // const tx = Math.abs(tangents[0].x);
2806
+ // const ty = Math.abs(tangents[0].y);
2807
+ // const tz = Math.abs(tangents[0].z);
2808
+ // if (tx <= min) {
2809
+ // min = tx;
2810
+ // normal.set(1, 0, 0);
2811
+ // }
2812
+ // if (ty <= min) {
2813
+ // min = ty;
2814
+ // normal.set(0, 1, 0);
2815
+ // }
2816
+ // if (tz <= min) {
2817
+ // normal.set(0, 0, 1);
2818
+ // }
2819
+ // vec.crossVectors(tangents[0], normal).normalize();
2820
+ // normals[0].crossVectors(tangents[0], vec);
2821
+ // binormals[0].crossVectors(tangents[0], normals[0]);
2822
+ // // compute the slowly-varying normal and binormal vectors for each segment on the curve
2823
+ // for (let i = 1; i <= segments; i++) {
2824
+ // normals[i] = normals[i - 1].clone();
2825
+ // binormals[i] = binormals[i - 1].clone();
2826
+ // vec.crossVectors(tangents[i - 1], tangents[i]);
2827
+ // if (vec.length() > Number.EPSILON) {
2828
+ // vec.normalize();
2829
+ // const theta = Math.acos(MathUtils.clamp(tangents[i - 1].dot(tangents[i]), - 1, 1)); // clamp for floating pt errors
2830
+ // normals[i].applyMatrix4(mat.makeRotationAxis(vec, theta));
2831
+ // }
2832
+ // binormals[i].crossVectors(tangents[i], normals[i]);
2833
+ // }
2834
+ // // if the curve is closed, postprocess the vectors so the first and last normal vectors are the same
2835
+ // if (closed === true) {
2836
+ // let theta = Math.acos(MathUtils.clamp(normals[0].dot(normals[segments]), - 1, 1));
2837
+ // theta /= segments;
2838
+ // if (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) {
2839
+ // theta = - theta;
2840
+ // }
2841
+ // for (let i = 1; i <= segments; i++) {
2842
+ // // twist a little...
2843
+ // normals[i].applyMatrix4(mat.makeRotationAxis(tangents[i], theta * i));
2844
+ // binormals[i].crossVectors(tangents[i], normals[i]);
2845
+ // }
2846
+ // }
2847
+ // return {
2848
+ // tangents: tangents,
2849
+ // normals: normals,
2850
+ // binormals: binormals
2851
+ // };
2852
+ // }
2853
+ // clone() {
2854
+ // return new this.constructor().copy(this);
2855
+ // }
2856
+ // copy(source) {
2857
+ // this.arcLengthDivisions = source.arcLengthDivisions;
2858
+ // return this;
2859
+ // }
2860
+ // toJSON() {
2861
+ // const data = {
2862
+ // metadata: {
2863
+ // version: 4.6,
2864
+ // type: 'Curve',
2865
+ // generator: 'Curve.toJSON'
2866
+ // }
2867
+ // };
2868
+ // data.arcLengthDivisions = this.arcLengthDivisions;
2869
+ // data.type = this.type;
2870
+ // return data;
2871
+ // }
2872
+ // fromJSON(json) {
2873
+ // this.arcLengthDivisions = json.arcLengthDivisions;
2874
+ // return this;
2875
+ // }
2876
+ ;
2877
+
2878
+ return Curve;
2879
+ }();
2880
+
2881
+ /**
2882
+ * // code copy from https://github.com/mrdoob/three.js/blob/dev/src/extras/core/Interpolations.js
2883
+ * Bezier Curves formulas obtained from
2884
+ * https://en.wikipedia.org/wiki/B%C3%A9zier_curve
2885
+ */
2886
+
2887
+
2888
+ function QuadraticBezierP0(t, p) {
2889
+ var k = 1 - t;
2890
+ return k * k * p;
2891
+ }
2892
+
2893
+ function QuadraticBezierP1(t, p) {
2894
+ return 2 * (1 - t) * t * p;
2895
+ }
2896
+
2897
+ function QuadraticBezierP2(t, p) {
2898
+ return t * t * p;
2899
+ }
2900
+
2901
+ function QuadraticBezier(t, p0, p1, p2) {
2902
+ return QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2);
2903
+ } //
2904
+
2905
+ var QuadraticBezierCurve3 = /*#__PURE__*/function (_Curve) {
2906
+ _inheritsLoose(QuadraticBezierCurve3, _Curve);
2907
+
2908
+ function QuadraticBezierCurve3(v0, v1, v2) {
2909
+ var _this;
2910
+
2911
+ if (v0 === void 0) {
2912
+ v0 = new Vector3();
2913
+ }
2914
+
2915
+ if (v1 === void 0) {
2916
+ v1 = new Vector3();
2917
+ }
2918
+
2919
+ if (v2 === void 0) {
2920
+ v2 = new Vector3();
2921
+ }
2922
+
2923
+ _this = _Curve.call(this) || this;
2924
+ _this.isQuadraticBezierCurve3 = true;
2925
+ _this.type = 'QuadraticBezierCurve3';
2926
+ _this.v0 = v0;
2927
+ _this.v1 = v1;
2928
+ _this.v2 = v2;
2929
+ return _this;
2930
+ }
2931
+
2932
+ var _proto = QuadraticBezierCurve3.prototype;
2933
+
2934
+ _proto.getPoint = function getPoint(t, optionalTarget) {
2935
+ if (optionalTarget === void 0) {
2936
+ optionalTarget = new Vector3();
2937
+ }
2938
+
2939
+ var point = optionalTarget;
2940
+ var v0 = this.v0,
2941
+ v1 = this.v1,
2942
+ v2 = this.v2;
2943
+ point.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y), QuadraticBezier(t, v0.z, v1.z, v2.z));
2944
+ return point;
2945
+ } // copy(source) {
2946
+ // super.copy(source);
2947
+ // this.v0.copy(source.v0);
2948
+ // this.v1.copy(source.v1);
2949
+ // this.v2.copy(source.v2);
2950
+ // return this;
2951
+ // }
2952
+ // toJSON() {
2953
+ // const data = super.toJSON();
2954
+ // data.v0 = this.v0.toArray();
2955
+ // data.v1 = this.v1.toArray();
2956
+ // data.v2 = this.v2.toArray();
2957
+ // return data;
2958
+ // }
2959
+ // fromJSON(json) {
2960
+ // super.fromJSON(json);
2961
+ // this.v0.fromArray(json.v0);
2962
+ // this.v1.fromArray(json.v1);
2963
+ // this.v2.fromArray(json.v2);
2964
+ // return this;
2965
+ // }
2966
+ ;
2967
+
2968
+ return QuadraticBezierCurve3;
2969
+ }(Curve);
2970
+
2971
+ /* eslint-disable no-tabs */
2972
+ var helpVec3_1 = new Vector3();
2973
+ var helpVec3_2 = new Vector3();
2974
+ var helpVec3_3 = new Vector3();
2975
+ var helpMat4 = new Matrix4();
2976
+ var helpCurve = new QuadraticBezierCurve3();
2977
+
2978
+ function _getCornerBezierCurve(last, current, next, cornerRadius, firstCorner, out) {
2979
+ var lastDir = helpVec3_1.subVectors(current, last);
2980
+ var nextDir = helpVec3_2.subVectors(next, current);
2981
+ var lastDirLength = lastDir.length();
2982
+ var nextDirLength = nextDir.length();
2983
+ lastDir.normalize();
2984
+ nextDir.normalize(); // cornerRadius can not bigger then lineDistance / 2, auto fix this
2985
+
2986
+ var v0Dist = Math.min((firstCorner ? lastDirLength / 2 : lastDirLength) * 0.999999, cornerRadius);
2987
+ out.v0.copy(current).sub(lastDir.multiplyScalar(v0Dist));
2988
+ out.v1.copy(current);
2989
+ var v2Dist = Math.min(nextDirLength / 2 * 0.999999, cornerRadius);
2990
+ out.v2.copy(current).add(nextDir.multiplyScalar(v2Dist));
2991
+ return out;
2992
+ }
2993
+ /**
2994
+ * PathPointList
2995
+ * input points to generate a PathPoint list
2996
+ */
2997
+
2998
+
2999
+ var PathPointList = /*#__PURE__*/function () {
3000
+ function PathPointList() {
3001
+ this.array = []; // path point array
3002
+
3003
+ this.count = 0;
3004
+ }
3005
+ /**
3006
+ * Set points
3007
+ * @param {THREE.Vector3[]} points key points array
3008
+ * @param {number} cornerRadius? the corner radius. set 0 to disable round corner. default is 0.1
3009
+ * @param {number} cornerSplit? the corner split. default is 10.
3010
+ * @param {number} up? force up. default is auto up (calculate by tangent).
3011
+ * @param {boolean} close? close path. default is false.
3012
+ */
3013
+
3014
+
3015
+ var _proto = PathPointList.prototype;
3016
+
3017
+ _proto.set = function set(points, cornerRadius, cornerSplit, up, close) {
3018
+ if (cornerRadius === void 0) {
3019
+ cornerRadius = 0.1;
3020
+ }
3021
+
3022
+ if (cornerSplit === void 0) {
3023
+ cornerSplit = 10;
3024
+ }
3025
+
3026
+ if (up === void 0) {
3027
+ up = null;
3028
+ }
3029
+
3030
+ if (close === void 0) {
3031
+ close = false;
3032
+ }
3033
+
3034
+ points = points.slice(0);
3035
+
3036
+ if (points.length < 2) {
3037
+ console.warn('PathPointList: points length less than 2.');
3038
+ this.count = 0;
3039
+ return;
3040
+ } // Auto close
3041
+
3042
+
3043
+ if (close && !points[0].equals(points[points.length - 1])) {
3044
+ points.push(new Vector3().copy(points[0]));
3045
+ } // Generate path point list
3046
+
3047
+
3048
+ for (var i = 0, l = points.length; i < l; i++) {
3049
+ if (i === 0) {
3050
+ this._start(points[i], points[i + 1], up);
3051
+ } else if (i === l - 1) {
3052
+ if (close) {
3053
+ // Connect end point and start point
3054
+ this._corner(points[i], points[1], cornerRadius, cornerSplit, up); // Fix start point
3055
+
3056
+
3057
+ var dist = this.array[0].dist; // should not copy dist
3058
+
3059
+ this.array[0].copy(this.array[this.count - 1]);
3060
+ this.array[0].dist = dist;
3061
+ } else {
3062
+ this._end(points[i]);
3063
+ }
3064
+ } else {
3065
+ this._corner(points[i], points[i + 1], cornerRadius, cornerSplit, up);
3066
+ }
3067
+ }
3068
+ }
3069
+ /**
3070
+ * Get distance of this path
3071
+ * @return {number}
3072
+ */
3073
+ ;
3074
+
3075
+ _proto.distance = function distance() {
3076
+ if (this.count > 0) {
3077
+ return this.array[this.count - 1].dist;
3078
+ }
3079
+
3080
+ return 0;
3081
+ };
3082
+
3083
+ _proto._getByIndex = function _getByIndex(index) {
3084
+ if (!this.array[index]) {
3085
+ this.array[index] = new PathPoint();
3086
+ }
3087
+
3088
+ return this.array[index];
3089
+ };
3090
+
3091
+ _proto._start = function _start(current, next, up) {
3092
+ this.count = 0;
3093
+
3094
+ var point = this._getByIndex(this.count);
3095
+
3096
+ point.pos.copy(current);
3097
+ point.dir.subVectors(next, current); // init start up dir
3098
+
3099
+ if (up) {
3100
+ point.up.copy(up);
3101
+ } else {
3102
+ // select an initial normal vector perpendicular to the first tangent vector
3103
+ var min = Number.MAX_VALUE;
3104
+ var tx = Math.abs(point.dir.x);
3105
+ var ty = Math.abs(point.dir.y);
3106
+ var tz = Math.abs(point.dir.z);
3107
+
3108
+ if (tx < min) {
3109
+ min = tx;
3110
+ point.up.set(1, 0, 0);
3111
+ }
3112
+
3113
+ if (ty < min) {
3114
+ min = ty;
3115
+ point.up.set(0, 1, 0);
3116
+ }
3117
+
3118
+ if (tz < min) {
3119
+ point.up.set(0, 0, 1);
3120
+ }
3121
+ }
3122
+
3123
+ point.right.crossVectors(point.dir, point.up).normalize();
3124
+ point.up.crossVectors(point.right, point.dir).normalize();
3125
+ point.dist = 0;
3126
+ point.widthScale = 1;
3127
+ point.sharp = false;
3128
+ point.dir.normalize();
3129
+ this.count++;
3130
+ };
3131
+
3132
+ _proto._end = function _end(current) {
3133
+ var lastPoint = this.array[this.count - 1];
3134
+
3135
+ var point = this._getByIndex(this.count);
3136
+
3137
+ point.pos.copy(current);
3138
+ point.dir.subVectors(current, lastPoint.pos);
3139
+ var dist = point.dir.length();
3140
+ point.dir.normalize();
3141
+ point.up.copy(lastPoint.up); // copy last up
3142
+
3143
+ var vec = helpVec3_1.crossVectors(lastPoint.dir, point.dir);
3144
+
3145
+ if (vec.length() > Number.EPSILON) {
3146
+ vec.normalize();
3147
+ var theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
3148
+
3149
+ point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
3150
+ }
3151
+
3152
+ point.right.crossVectors(point.dir, point.up).normalize();
3153
+ point.dist = lastPoint.dist + dist;
3154
+ point.widthScale = 1;
3155
+ point.sharp = false;
3156
+ this.count++;
3157
+ };
3158
+
3159
+ _proto._corner = function _corner(current, next, cornerRadius, cornerSplit, up) {
3160
+ if (cornerRadius > 0 && cornerSplit > 0) {
3161
+ var lastPoint = this.array[this.count - 1];
3162
+
3163
+ var curve = _getCornerBezierCurve(lastPoint.pos, current, next, cornerRadius, this.count - 1 === 0, helpCurve);
3164
+
3165
+ var samplerPoints = curve.getPoints(cornerSplit); // TODO optimize
3166
+
3167
+ for (var f = 0; f < cornerSplit; f++) {
3168
+ this._sharpCorner(samplerPoints[f], samplerPoints[f + 1], up, f === 0 ? 1 : 0);
3169
+ }
3170
+
3171
+ if (!samplerPoints[cornerSplit].equals(next)) {
3172
+ this._sharpCorner(samplerPoints[cornerSplit], next, up, 2);
3173
+ }
3174
+ } else {
3175
+ this._sharpCorner(current, next, up, 0, true);
3176
+ }
3177
+ } // dirType: 0 - use middle dir / 1 - use last dir / 2- use next dir
3178
+ ;
3179
+
3180
+ _proto._sharpCorner = function _sharpCorner(current, next, up, dirType, sharp) {
3181
+ if (dirType === void 0) {
3182
+ dirType = 0;
3183
+ }
3184
+
3185
+ if (sharp === void 0) {
3186
+ sharp = false;
3187
+ }
3188
+
3189
+ var lastPoint = this.array[this.count - 1];
3190
+
3191
+ var point = this._getByIndex(this.count);
3192
+
3193
+ var lastDir = helpVec3_1.subVectors(current, lastPoint.pos);
3194
+ var nextDir = helpVec3_2.subVectors(next, current);
3195
+ var lastDirLength = lastDir.length();
3196
+ lastDir.normalize();
3197
+ nextDir.normalize();
3198
+ point.pos.copy(current);
3199
+
3200
+ if (dirType === 1) {
3201
+ point.dir.copy(lastDir);
3202
+ } else if (dirType === 2) {
3203
+ point.dir.copy(nextDir);
3204
+ } else {
3205
+ point.dir.addVectors(lastDir, nextDir);
3206
+ point.dir.normalize();
3207
+ }
3208
+
3209
+ if (up) {
3210
+ if (point.dir.dot(up) === 1) {
3211
+ point.right.crossVectors(nextDir, up).normalize();
3212
+ } else {
3213
+ point.right.crossVectors(point.dir, up).normalize();
3214
+ }
3215
+
3216
+ point.up.crossVectors(point.right, point.dir).normalize();
3217
+ } else {
3218
+ point.up.copy(lastPoint.up);
3219
+ var vec = helpVec3_3.crossVectors(lastPoint.dir, point.dir);
3220
+
3221
+ if (vec.length() > Number.EPSILON) {
3222
+ vec.normalize();
3223
+ var theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
3224
+
3225
+ point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
3226
+ }
3227
+
3228
+ point.right.crossVectors(point.dir, point.up).normalize();
3229
+ }
3230
+
3231
+ point.dist = lastPoint.dist + lastDirLength;
3232
+
3233
+ var _cos = lastDir.dot(nextDir);
3234
+
3235
+ point.widthScale = Math.min(1 / Math.sqrt((1 + _cos) / 2), 1.415) || 1;
3236
+ point.sharp = Math.abs(_cos - 1) > 0.05 && sharp;
3237
+ this.count++;
3238
+ };
3239
+
3240
+ return PathPointList;
3241
+ }();
3242
+
3243
+ var UP = new Vector3(0, 0, 1);
3244
+ function expandPaths(lines, options) {
3245
+ options = Object.assign({}, {
3246
+ lineWidth: 1,
3247
+ cornerRadius: 0,
3248
+ cornerSplit: 10
3249
+ }, options);
3250
+ var results = lines.map(function (line) {
3251
+ var points = line.map(function (p) {
3252
+ var x = p[0],
3253
+ y = p[1],
3254
+ z = p[2];
3255
+ return new Vector3(x, y, z || 0);
3256
+ });
3257
+ var pathPointList = new PathPointList();
3258
+ pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
3259
+ var result = generatePathVertexData(pathPointList, options);
3260
+ result.line = line;
3261
+ result.position = new Float32Array(result.points);
3262
+ result.indices = new Uint32Array(result.index);
3263
+ result.uv = new Float32Array(result.uvs);
3264
+ result.normal = new Float32Array(result.normal);
3265
+ return result;
3266
+ });
3267
+ var result = merge(results);
3268
+ result.lines = lines;
3269
+ return result;
3270
+ } // Vertex Data Generate Functions
3271
+ // code copy from https://github.com/shawn0326/three.path/blob/master/src/PathGeometry.js
3272
+
3273
+ function generatePathVertexData(pathPointList, options) {
3274
+ var width = options.lineWidth || 0.1;
3275
+ var progress = 1;
3276
+ var halfWidth = width / 2;
3277
+ var sideWidth = width;
3278
+ var totalDistance = pathPointList.distance();
3279
+ var progressDistance = progress * totalDistance;
3280
+
3281
+ if (totalDistance === 0) {
3282
+ return null;
3283
+ }
3284
+
3285
+ var sharpUvOffset = halfWidth / sideWidth; // const sharpUvOffset2 = halfWidth / totalDistance;
3286
+
3287
+ var count = 0; // modify data
3288
+
3289
+ var position = [];
3290
+ var normal = [];
3291
+ var uv = [];
3292
+ var indices = [];
3293
+ var verticesCount = 0;
3294
+ var right = new Vector3();
3295
+ var left = new Vector3(); // for sharp corners
3296
+
3297
+ var leftOffset = new Vector3();
3298
+ var rightOffset = new Vector3();
3299
+ var tempPoint1 = new Vector3();
3300
+ var tempPoint2 = new Vector3();
3301
+
3302
+ function addVertices(pathPoint) {
3303
+ var first = position.length === 0;
3304
+ var sharpCorner = pathPoint.sharp && !first;
3305
+ var uvDist = pathPoint.dist / sideWidth; // const uvDist2 = pathPoint.dist / totalDistance;
3306
+
3307
+ var dir = pathPoint.dir;
3308
+ var up = pathPoint.up;
3309
+ var _right = pathPoint.right;
3310
+
3311
+ {
3312
+ right.copy(_right).multiplyScalar(halfWidth * pathPoint.widthScale);
3313
+ }
3314
+
3315
+ {
3316
+ left.copy(_right).multiplyScalar(-halfWidth * pathPoint.widthScale);
3317
+ }
3318
+
3319
+ right.add(pathPoint.pos);
3320
+ left.add(pathPoint.pos);
3321
+
3322
+ if (sharpCorner) {
3323
+ leftOffset.fromArray(position, position.length - 6).sub(left);
3324
+ rightOffset.fromArray(position, position.length - 3).sub(right);
3325
+ var leftDist = leftOffset.length();
3326
+ var rightDist = rightOffset.length();
3327
+ var sideOffset = leftDist - rightDist;
3328
+ var longerOffset, longEdge;
3329
+
3330
+ if (sideOffset > 0) {
3331
+ longerOffset = leftOffset;
3332
+ longEdge = left;
3333
+ } else {
3334
+ longerOffset = rightOffset;
3335
+ longEdge = right;
3336
+ }
3337
+
3338
+ tempPoint1.copy(longerOffset).setLength(Math.abs(sideOffset)).add(longEdge); // eslint-disable-next-line prefer-const
3339
+
3340
+ var _cos = tempPoint2.copy(longEdge).sub(tempPoint1).normalize().dot(dir); // eslint-disable-next-line prefer-const
3341
+
3342
+
3343
+ var _len = tempPoint2.copy(longEdge).sub(tempPoint1).length(); // eslint-disable-next-line prefer-const
3344
+
3345
+
3346
+ var _dist = _cos * _len * 2;
3347
+
3348
+ tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
3349
+
3350
+ if (sideOffset > 0) {
3351
+ position.push(tempPoint1.x, tempPoint1.y, tempPoint1.z, // 6
3352
+ right.x, right.y, right.z, // 5
3353
+ left.x, left.y, left.z, // 4
3354
+ right.x, right.y, right.z, // 3
3355
+ tempPoint2.x, tempPoint2.y, tempPoint2.z, // 2
3356
+ right.x, right.y, right.z // 1
3357
+ );
3358
+ verticesCount += 6;
3359
+ indices.push(verticesCount - 6, verticesCount - 8, verticesCount - 7, verticesCount - 6, verticesCount - 7, verticesCount - 5, verticesCount - 4, verticesCount - 6, verticesCount - 5, verticesCount - 2, verticesCount - 4, verticesCount - 1);
3360
+ count += 12;
3361
+ } else {
3362
+ position.push(left.x, left.y, left.z, // 6
3363
+ tempPoint1.x, tempPoint1.y, tempPoint1.z, // 5
3364
+ left.x, left.y, left.z, // 4
3365
+ right.x, right.y, right.z, // 3
3366
+ left.x, left.y, left.z, // 2
3367
+ tempPoint2.x, tempPoint2.y, tempPoint2.z // 1
3368
+ );
3369
+ verticesCount += 6;
3370
+ indices.push(verticesCount - 6, verticesCount - 8, verticesCount - 7, verticesCount - 6, verticesCount - 7, verticesCount - 5, verticesCount - 6, verticesCount - 5, verticesCount - 3, verticesCount - 2, verticesCount - 3, verticesCount - 1);
3371
+ count += 12;
3372
+ }
3373
+
3374
+ normal.push(up.x, up.y, up.z, up.x, up.y, up.z, up.x, up.y, up.z, up.x, up.y, up.z, up.x, up.y, up.z, up.x, up.y, up.z);
3375
+ uv.push(uvDist - sharpUvOffset, 0, uvDist - sharpUvOffset, 1, uvDist, 0, uvDist, 1, uvDist + sharpUvOffset, 0, uvDist + sharpUvOffset, 1); // if (generateUv2) {
3376
+ // uv2.push(
3377
+ // uvDist2 - sharpUvOffset2, 0,
3378
+ // uvDist2 - sharpUvOffset2, 1,
3379
+ // uvDist2, 0,
3380
+ // uvDist2, 1,
3381
+ // uvDist2 + sharpUvOffset2, 0,
3382
+ // uvDist2 + sharpUvOffset2, 1
3383
+ // );
3384
+ // }
3385
+ } else {
3386
+ position.push(left.x, left.y, left.z, right.x, right.y, right.z);
3387
+ normal.push(up.x, up.y, up.z, up.x, up.y, up.z);
3388
+ uv.push(uvDist, 0, uvDist, 1); // if (generateUv2) {
3389
+ // uv2.push(
3390
+ // uvDist2, 0,
3391
+ // uvDist2, 1
3392
+ // );
3393
+ // }
3394
+
3395
+ verticesCount += 2;
3396
+
3397
+ if (!first) {
3398
+ indices.push(verticesCount - 2, verticesCount - 4, verticesCount - 3, verticesCount - 2, verticesCount - 3, verticesCount - 1);
3399
+ count += 6;
3400
+ }
3401
+ }
3402
+ }
3403
+
3404
+ var lastPoint;
3405
+
3406
+ if (progressDistance > 0) {
3407
+ for (var i = 0; i < pathPointList.count; i++) {
3408
+ var pathPoint = pathPointList.array[i];
3409
+
3410
+ if (pathPoint.dist > progressDistance) {
3411
+ var prevPoint = pathPointList.array[i - 1];
3412
+ lastPoint = new PathPoint(); // linear lerp for progress
3413
+
3414
+ var alpha = (progressDistance - prevPoint.dist) / (pathPoint.dist - prevPoint.dist);
3415
+ lastPoint.lerpPathPoints(prevPoint, pathPoint, alpha);
3416
+ addVertices(lastPoint);
3417
+ break;
3418
+ } else {
3419
+ addVertices(pathPoint);
3420
+ }
3421
+ }
3422
+ } else {
3423
+ lastPoint = pathPointList.array[0];
3424
+ }
3425
+
3426
+ return {
3427
+ points: position,
3428
+ normal: normal,
3429
+ uvs: uv,
3430
+ index: indices,
3431
+ count: count
3432
+ };
3433
+ }
3434
+
1463
3435
  exports.cylinder = cylinder;
1464
3436
  exports.expandLine = expandLine;
3437
+ exports.expandPaths = expandPaths;
1465
3438
  exports.extrudePolygons = extrudePolygons;
1466
3439
  exports.extrudePolylines = extrudePolylines;
1467
3440