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