poly-extrude 0.6.0 → 0.8.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.6.0
2
+ * poly-extrude v0.8.0
3
3
  */
4
4
  var earcut$2 = {exports: {}};
5
5
 
@@ -944,7 +944,9 @@ function generateSides$1(result, options) {
944
944
  index = result.index,
945
945
  polygon = result.polygon,
946
946
  uvs = result.uvs;
947
- var z = options.depth;
947
+ var depth = options.depth;
948
+ var pIndex = points.length - 1;
949
+ var iIndex = index.length - 1;
948
950
 
949
951
  for (var i = 0, len = polygon.length; i < len; i++) {
950
952
  var ring = polygon[i];
@@ -962,15 +964,35 @@ function generateSides$1(result, options) {
962
964
  var idx = points.length / 3;
963
965
  var x1 = v1[0],
964
966
  y1 = v1[1],
967
+ z1 = v1[2] || 0,
965
968
  x2 = v2[0],
966
- y2 = v2[1];
967
- points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
969
+ y2 = v2[1],
970
+ z2 = v2[2] || 0;
971
+ points[++pIndex] = x1;
972
+ points[++pIndex] = y1;
973
+ points[++pIndex] = z1 + depth;
974
+ points[++pIndex] = x2;
975
+ points[++pIndex] = y2;
976
+ points[++pIndex] = z2 + depth;
977
+ points[++pIndex] = x1;
978
+ points[++pIndex] = y1;
979
+ points[++pIndex] = z1;
980
+ points[++pIndex] = x2;
981
+ points[++pIndex] = y2;
982
+ points[++pIndex] = z2; // points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
983
+
968
984
  var a = idx + 2,
969
985
  b = idx + 3,
970
986
  c = idx,
971
987
  d = idx + 1; // points.push(p3, p4, p1, p2);
988
+ // index.push(a, c, b, c, d, b);
972
989
 
973
- index.push(a, c, b, c, d, b); // index.push(c, d, b);
990
+ index[++iIndex] = a;
991
+ index[++iIndex] = c;
992
+ index[++iIndex] = b;
993
+ index[++iIndex] = c;
994
+ index[++iIndex] = d;
995
+ index[++iIndex] = b; // index.push(c, d, b);
974
996
 
975
997
  generateSideWallUV(uvs, points, a, b, c, d);
976
998
  j++;
@@ -1000,7 +1022,7 @@ function flatVertices(polygon, options) {
1000
1022
  uvs = [];
1001
1023
  var pOffset = count * 3,
1002
1024
  uOffset = count * 2;
1003
- var z = options.depth;
1025
+ var depth = options.depth;
1004
1026
  var idx0 = 0,
1005
1027
  idx1 = 0,
1006
1028
  idx2 = 0;
@@ -1018,17 +1040,18 @@ function flatVertices(polygon, options) {
1018
1040
  while (j < len1) {
1019
1041
  var c = ring[j];
1020
1042
  var x = c[0],
1021
- y = c[1];
1043
+ y = c[1],
1044
+ z = c[2] || 0;
1022
1045
  flatVertices[idx0++] = x;
1023
1046
  flatVertices[idx0++] = y; // top vertices
1024
1047
 
1025
1048
  points[idx1] = x;
1026
1049
  points[idx1 + 1] = y;
1027
- points[idx1 + 2] = z; // bottom vertices
1050
+ points[idx1 + 2] = depth + z; // bottom vertices
1028
1051
 
1029
1052
  points[pOffset + idx1] = x;
1030
1053
  points[pOffset + idx1 + 1] = y;
1031
- points[pOffset + idx1 + 2] = 0;
1054
+ points[pOffset + idx1 + 2] = z;
1032
1055
  uvs[idx2] = x;
1033
1056
  uvs[idx2 + 1] = y;
1034
1057
  uvs[uOffset + idx2] = x;
@@ -1633,8 +1656,980 @@ function cylinder(point, options) {
1633
1656
  };
1634
1657
  }
1635
1658
 
1659
+ function _regeneratorRuntime() {
1660
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1661
+
1662
+ _regeneratorRuntime = function () {
1663
+ return exports;
1664
+ };
1665
+
1666
+ var exports = {},
1667
+ Op = Object.prototype,
1668
+ hasOwn = Op.hasOwnProperty,
1669
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
1670
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
1671
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
1672
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1673
+
1674
+ function define(obj, key, value) {
1675
+ return Object.defineProperty(obj, key, {
1676
+ value: value,
1677
+ enumerable: !0,
1678
+ configurable: !0,
1679
+ writable: !0
1680
+ }), obj[key];
1681
+ }
1682
+
1683
+ try {
1684
+ define({}, "");
1685
+ } catch (err) {
1686
+ define = function (obj, key, value) {
1687
+ return obj[key] = value;
1688
+ };
1689
+ }
1690
+
1691
+ function wrap(innerFn, outerFn, self, tryLocsList) {
1692
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
1693
+ generator = Object.create(protoGenerator.prototype),
1694
+ context = new Context(tryLocsList || []);
1695
+ return generator._invoke = function (innerFn, self, context) {
1696
+ var state = "suspendedStart";
1697
+ return function (method, arg) {
1698
+ if ("executing" === state) throw new Error("Generator is already running");
1699
+
1700
+ if ("completed" === state) {
1701
+ if ("throw" === method) throw arg;
1702
+ return doneResult();
1703
+ }
1704
+
1705
+ for (context.method = method, context.arg = arg;;) {
1706
+ var delegate = context.delegate;
1707
+
1708
+ if (delegate) {
1709
+ var delegateResult = maybeInvokeDelegate(delegate, context);
1710
+
1711
+ if (delegateResult) {
1712
+ if (delegateResult === ContinueSentinel) continue;
1713
+ return delegateResult;
1714
+ }
1715
+ }
1716
+
1717
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
1718
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
1719
+ context.dispatchException(context.arg);
1720
+ } else "return" === context.method && context.abrupt("return", context.arg);
1721
+ state = "executing";
1722
+ var record = tryCatch(innerFn, self, context);
1723
+
1724
+ if ("normal" === record.type) {
1725
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
1726
+ return {
1727
+ value: record.arg,
1728
+ done: context.done
1729
+ };
1730
+ }
1731
+
1732
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
1733
+ }
1734
+ };
1735
+ }(innerFn, self, context), generator;
1736
+ }
1737
+
1738
+ function tryCatch(fn, obj, arg) {
1739
+ try {
1740
+ return {
1741
+ type: "normal",
1742
+ arg: fn.call(obj, arg)
1743
+ };
1744
+ } catch (err) {
1745
+ return {
1746
+ type: "throw",
1747
+ arg: err
1748
+ };
1749
+ }
1750
+ }
1751
+
1752
+ exports.wrap = wrap;
1753
+ var ContinueSentinel = {};
1754
+
1755
+ function Generator() {}
1756
+
1757
+ function GeneratorFunction() {}
1758
+
1759
+ function GeneratorFunctionPrototype() {}
1760
+
1761
+ var IteratorPrototype = {};
1762
+ define(IteratorPrototype, iteratorSymbol, function () {
1763
+ return this;
1764
+ });
1765
+ var getProto = Object.getPrototypeOf,
1766
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1767
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
1768
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1769
+
1770
+ function defineIteratorMethods(prototype) {
1771
+ ["next", "throw", "return"].forEach(function (method) {
1772
+ define(prototype, method, function (arg) {
1773
+ return this._invoke(method, arg);
1774
+ });
1775
+ });
1776
+ }
1777
+
1778
+ function AsyncIterator(generator, PromiseImpl) {
1779
+ function invoke(method, arg, resolve, reject) {
1780
+ var record = tryCatch(generator[method], generator, arg);
1781
+
1782
+ if ("throw" !== record.type) {
1783
+ var result = record.arg,
1784
+ value = result.value;
1785
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1786
+ invoke("next", value, resolve, reject);
1787
+ }, function (err) {
1788
+ invoke("throw", err, resolve, reject);
1789
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
1790
+ result.value = unwrapped, resolve(result);
1791
+ }, function (error) {
1792
+ return invoke("throw", error, resolve, reject);
1793
+ });
1794
+ }
1795
+
1796
+ reject(record.arg);
1797
+ }
1798
+
1799
+ var previousPromise;
1800
+
1801
+ this._invoke = function (method, arg) {
1802
+ function callInvokeWithMethodAndArg() {
1803
+ return new PromiseImpl(function (resolve, reject) {
1804
+ invoke(method, arg, resolve, reject);
1805
+ });
1806
+ }
1807
+
1808
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1809
+ };
1810
+ }
1811
+
1812
+ function maybeInvokeDelegate(delegate, context) {
1813
+ var method = delegate.iterator[context.method];
1814
+
1815
+ if (undefined === method) {
1816
+ if (context.delegate = null, "throw" === context.method) {
1817
+ if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
1818
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
1819
+ }
1820
+
1821
+ return ContinueSentinel;
1822
+ }
1823
+
1824
+ var record = tryCatch(method, delegate.iterator, context.arg);
1825
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
1826
+ var info = record.arg;
1827
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
1828
+ }
1829
+
1830
+ function pushTryEntry(locs) {
1831
+ var entry = {
1832
+ tryLoc: locs[0]
1833
+ };
1834
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
1835
+ }
1836
+
1837
+ function resetTryEntry(entry) {
1838
+ var record = entry.completion || {};
1839
+ record.type = "normal", delete record.arg, entry.completion = record;
1840
+ }
1841
+
1842
+ function Context(tryLocsList) {
1843
+ this.tryEntries = [{
1844
+ tryLoc: "root"
1845
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
1846
+ }
1847
+
1848
+ function values(iterable) {
1849
+ if (iterable) {
1850
+ var iteratorMethod = iterable[iteratorSymbol];
1851
+ if (iteratorMethod) return iteratorMethod.call(iterable);
1852
+ if ("function" == typeof iterable.next) return iterable;
1853
+
1854
+ if (!isNaN(iterable.length)) {
1855
+ var i = -1,
1856
+ next = function next() {
1857
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1858
+
1859
+ return next.value = undefined, next.done = !0, next;
1860
+ };
1861
+
1862
+ return next.next = next;
1863
+ }
1864
+ }
1865
+
1866
+ return {
1867
+ next: doneResult
1868
+ };
1869
+ }
1870
+
1871
+ function doneResult() {
1872
+ return {
1873
+ value: undefined,
1874
+ done: !0
1875
+ };
1876
+ }
1877
+
1878
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
1879
+ var ctor = "function" == typeof genFun && genFun.constructor;
1880
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
1881
+ }, exports.mark = function (genFun) {
1882
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
1883
+ }, exports.awrap = function (arg) {
1884
+ return {
1885
+ __await: arg
1886
+ };
1887
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1888
+ return this;
1889
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1890
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
1891
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1892
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
1893
+ return result.done ? result.value : iter.next();
1894
+ });
1895
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
1896
+ return this;
1897
+ }), define(Gp, "toString", function () {
1898
+ return "[object Generator]";
1899
+ }), exports.keys = function (object) {
1900
+ var keys = [];
1901
+
1902
+ for (var key in object) keys.push(key);
1903
+
1904
+ return keys.reverse(), function next() {
1905
+ for (; keys.length;) {
1906
+ var key = keys.pop();
1907
+ if (key in object) return next.value = key, next.done = !1, next;
1908
+ }
1909
+
1910
+ return next.done = !0, next;
1911
+ };
1912
+ }, exports.values = values, Context.prototype = {
1913
+ constructor: Context,
1914
+ reset: function (skipTempReset) {
1915
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1916
+ },
1917
+ stop: function () {
1918
+ this.done = !0;
1919
+ var rootRecord = this.tryEntries[0].completion;
1920
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
1921
+ return this.rval;
1922
+ },
1923
+ dispatchException: function (exception) {
1924
+ if (this.done) throw exception;
1925
+ var context = this;
1926
+
1927
+ function handle(loc, caught) {
1928
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
1929
+ }
1930
+
1931
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1932
+ var entry = this.tryEntries[i],
1933
+ record = entry.completion;
1934
+ if ("root" === entry.tryLoc) return handle("end");
1935
+
1936
+ if (entry.tryLoc <= this.prev) {
1937
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
1938
+ hasFinally = hasOwn.call(entry, "finallyLoc");
1939
+
1940
+ if (hasCatch && hasFinally) {
1941
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1942
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1943
+ } else if (hasCatch) {
1944
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1945
+ } else {
1946
+ if (!hasFinally) throw new Error("try statement without catch or finally");
1947
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1948
+ }
1949
+ }
1950
+ }
1951
+ },
1952
+ abrupt: function (type, arg) {
1953
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1954
+ var entry = this.tryEntries[i];
1955
+
1956
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1957
+ var finallyEntry = entry;
1958
+ break;
1959
+ }
1960
+ }
1961
+
1962
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
1963
+ var record = finallyEntry ? finallyEntry.completion : {};
1964
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
1965
+ },
1966
+ complete: function (record, afterLoc) {
1967
+ if ("throw" === record.type) throw record.arg;
1968
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
1969
+ },
1970
+ finish: function (finallyLoc) {
1971
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1972
+ var entry = this.tryEntries[i];
1973
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
1974
+ }
1975
+ },
1976
+ catch: function (tryLoc) {
1977
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1978
+ var entry = this.tryEntries[i];
1979
+
1980
+ if (entry.tryLoc === tryLoc) {
1981
+ var record = entry.completion;
1982
+
1983
+ if ("throw" === record.type) {
1984
+ var thrown = record.arg;
1985
+ resetTryEntry(entry);
1986
+ }
1987
+
1988
+ return thrown;
1989
+ }
1990
+ }
1991
+
1992
+ throw new Error("illegal catch attempt");
1993
+ },
1994
+ delegateYield: function (iterable, resultName, nextLoc) {
1995
+ return this.delegate = {
1996
+ iterator: values(iterable),
1997
+ resultName: resultName,
1998
+ nextLoc: nextLoc
1999
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
2000
+ }
2001
+ }, exports;
2002
+ }
2003
+
2004
+ function _defineProperties(target, props) {
2005
+ for (var i = 0; i < props.length; i++) {
2006
+ var descriptor = props[i];
2007
+ descriptor.enumerable = descriptor.enumerable || false;
2008
+ descriptor.configurable = true;
2009
+ if ("value" in descriptor) descriptor.writable = true;
2010
+ Object.defineProperty(target, descriptor.key, descriptor);
2011
+ }
2012
+ }
2013
+
2014
+ function _createClass(Constructor, protoProps, staticProps) {
2015
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
2016
+ if (staticProps) _defineProperties(Constructor, staticProps);
2017
+ Object.defineProperty(Constructor, "prototype", {
2018
+ writable: false
2019
+ });
2020
+ return Constructor;
2021
+ }
2022
+
2023
+ function _inheritsLoose(subClass, superClass) {
2024
+ subClass.prototype = Object.create(superClass.prototype);
2025
+ subClass.prototype.constructor = subClass;
2026
+
2027
+ _setPrototypeOf(subClass, superClass);
2028
+ }
2029
+
2030
+ function _setPrototypeOf(o, p) {
2031
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2032
+ o.__proto__ = p;
2033
+ return o;
2034
+ };
2035
+ return _setPrototypeOf(o, p);
2036
+ }
2037
+
2038
+ // code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js
2039
+ // import { clamp } from './MathUtils.js';
2040
+ var Quaternion = /*#__PURE__*/function (_Symbol$iterator) {
2041
+ function Quaternion(x, y, z, w) {
2042
+ if (x === void 0) {
2043
+ x = 0;
2044
+ }
2045
+
2046
+ if (y === void 0) {
2047
+ y = 0;
2048
+ }
2049
+
2050
+ if (z === void 0) {
2051
+ z = 0;
2052
+ }
2053
+
2054
+ if (w === void 0) {
2055
+ w = 1;
2056
+ }
2057
+
2058
+ this.isQuaternion = true;
2059
+ this._x = x;
2060
+ this._y = y;
2061
+ this._z = z;
2062
+ this._w = w;
2063
+ }
2064
+
2065
+ Quaternion.slerpFlat = function slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
2066
+ // fuzz-free, array-based Quaternion SLERP operation
2067
+ var x0 = src0[srcOffset0 + 0],
2068
+ y0 = src0[srcOffset0 + 1],
2069
+ z0 = src0[srcOffset0 + 2],
2070
+ w0 = src0[srcOffset0 + 3];
2071
+ var x1 = src1[srcOffset1 + 0],
2072
+ y1 = src1[srcOffset1 + 1],
2073
+ z1 = src1[srcOffset1 + 2],
2074
+ w1 = src1[srcOffset1 + 3];
2075
+
2076
+ if (t === 0) {
2077
+ dst[dstOffset + 0] = x0;
2078
+ dst[dstOffset + 1] = y0;
2079
+ dst[dstOffset + 2] = z0;
2080
+ dst[dstOffset + 3] = w0;
2081
+ return;
2082
+ }
2083
+
2084
+ if (t === 1) {
2085
+ dst[dstOffset + 0] = x1;
2086
+ dst[dstOffset + 1] = y1;
2087
+ dst[dstOffset + 2] = z1;
2088
+ dst[dstOffset + 3] = w1;
2089
+ return;
2090
+ }
2091
+
2092
+ if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
2093
+ var s = 1 - t;
2094
+ var cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
2095
+ dir = cos >= 0 ? 1 : -1,
2096
+ sqrSin = 1 - cos * cos; // Skip the Slerp for tiny steps to avoid numeric problems:
2097
+
2098
+ if (sqrSin > Number.EPSILON) {
2099
+ var sin = Math.sqrt(sqrSin),
2100
+ len = Math.atan2(sin, cos * dir);
2101
+ s = Math.sin(s * len) / sin;
2102
+ t = Math.sin(t * len) / sin;
2103
+ }
2104
+
2105
+ var tDir = t * dir;
2106
+ x0 = x0 * s + x1 * tDir;
2107
+ y0 = y0 * s + y1 * tDir;
2108
+ z0 = z0 * s + z1 * tDir;
2109
+ w0 = w0 * s + w1 * tDir; // Normalize in case we just did a lerp:
2110
+
2111
+ if (s === 1 - t) {
2112
+ var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
2113
+ x0 *= f;
2114
+ y0 *= f;
2115
+ z0 *= f;
2116
+ w0 *= f;
2117
+ }
2118
+ }
2119
+
2120
+ dst[dstOffset] = x0;
2121
+ dst[dstOffset + 1] = y0;
2122
+ dst[dstOffset + 2] = z0;
2123
+ dst[dstOffset + 3] = w0;
2124
+ };
2125
+
2126
+ Quaternion.multiplyQuaternionsFlat = function multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
2127
+ var x0 = src0[srcOffset0];
2128
+ var y0 = src0[srcOffset0 + 1];
2129
+ var z0 = src0[srcOffset0 + 2];
2130
+ var w0 = src0[srcOffset0 + 3];
2131
+ var x1 = src1[srcOffset1];
2132
+ var y1 = src1[srcOffset1 + 1];
2133
+ var z1 = src1[srcOffset1 + 2];
2134
+ var w1 = src1[srcOffset1 + 3];
2135
+ dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
2136
+ dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
2137
+ dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
2138
+ dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
2139
+ return dst;
2140
+ };
2141
+
2142
+ var _proto = Quaternion.prototype;
2143
+
2144
+ _proto.set = function set(x, y, z, w) {
2145
+ this._x = x;
2146
+ this._y = y;
2147
+ this._z = z;
2148
+ this._w = w;
2149
+
2150
+ this._onChangeCallback();
2151
+
2152
+ return this;
2153
+ };
2154
+
2155
+ _proto.clone = function clone() {
2156
+ return new this.constructor(this._x, this._y, this._z, this._w);
2157
+ };
2158
+
2159
+ _proto.copy = function copy(quaternion) {
2160
+ this._x = quaternion.x;
2161
+ this._y = quaternion.y;
2162
+ this._z = quaternion.z;
2163
+ this._w = quaternion.w;
2164
+
2165
+ this._onChangeCallback();
2166
+
2167
+ return this;
2168
+ };
2169
+
2170
+ _proto.setFromEuler = function setFromEuler(euler, update) {
2171
+ if (update === void 0) {
2172
+ update = true;
2173
+ }
2174
+
2175
+ var x = euler._x,
2176
+ y = euler._y,
2177
+ z = euler._z,
2178
+ order = euler._order; // http://www.mathworks.com/matlabcentral/fileexchange/
2179
+ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
2180
+ // content/SpinCalc.m
2181
+
2182
+ var cos = Math.cos;
2183
+ var sin = Math.sin;
2184
+ var c1 = cos(x / 2);
2185
+ var c2 = cos(y / 2);
2186
+ var c3 = cos(z / 2);
2187
+ var s1 = sin(x / 2);
2188
+ var s2 = sin(y / 2);
2189
+ var s3 = sin(z / 2);
2190
+
2191
+ switch (order) {
2192
+ case 'XYZ':
2193
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
2194
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
2195
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
2196
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
2197
+ break;
2198
+
2199
+ case 'YXZ':
2200
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
2201
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
2202
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
2203
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
2204
+ break;
2205
+
2206
+ case 'ZXY':
2207
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
2208
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
2209
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
2210
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
2211
+ break;
2212
+
2213
+ case 'ZYX':
2214
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
2215
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
2216
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
2217
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
2218
+ break;
2219
+
2220
+ case 'YZX':
2221
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
2222
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
2223
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
2224
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
2225
+ break;
2226
+
2227
+ case 'XZY':
2228
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
2229
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
2230
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
2231
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
2232
+ break;
2233
+
2234
+ default:
2235
+ console.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order);
2236
+ }
2237
+
2238
+ if (update === true) this._onChangeCallback();
2239
+ return this;
2240
+ };
2241
+
2242
+ _proto.setFromAxisAngle = function setFromAxisAngle(axis, angle) {
2243
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
2244
+ // assumes axis is normalized
2245
+ var halfAngle = angle / 2,
2246
+ s = Math.sin(halfAngle);
2247
+ this._x = axis.x * s;
2248
+ this._y = axis.y * s;
2249
+ this._z = axis.z * s;
2250
+ this._w = Math.cos(halfAngle);
2251
+
2252
+ this._onChangeCallback();
2253
+
2254
+ return this;
2255
+ };
2256
+
2257
+ _proto.setFromRotationMatrix = function setFromRotationMatrix(m) {
2258
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
2259
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
2260
+ var te = m.elements,
2261
+ m11 = te[0],
2262
+ m12 = te[4],
2263
+ m13 = te[8],
2264
+ m21 = te[1],
2265
+ m22 = te[5],
2266
+ m23 = te[9],
2267
+ m31 = te[2],
2268
+ m32 = te[6],
2269
+ m33 = te[10],
2270
+ trace = m11 + m22 + m33;
2271
+
2272
+ if (trace > 0) {
2273
+ var s = 0.5 / Math.sqrt(trace + 1.0);
2274
+ this._w = 0.25 / s;
2275
+ this._x = (m32 - m23) * s;
2276
+ this._y = (m13 - m31) * s;
2277
+ this._z = (m21 - m12) * s;
2278
+ } else if (m11 > m22 && m11 > m33) {
2279
+ var _s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
2280
+
2281
+ this._w = (m32 - m23) / _s;
2282
+ this._x = 0.25 * _s;
2283
+ this._y = (m12 + m21) / _s;
2284
+ this._z = (m13 + m31) / _s;
2285
+ } else if (m22 > m33) {
2286
+ var _s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
2287
+
2288
+ this._w = (m13 - m31) / _s2;
2289
+ this._x = (m12 + m21) / _s2;
2290
+ this._y = 0.25 * _s2;
2291
+ this._z = (m23 + m32) / _s2;
2292
+ } else {
2293
+ var _s3 = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
2294
+
2295
+ this._w = (m21 - m12) / _s3;
2296
+ this._x = (m13 + m31) / _s3;
2297
+ this._y = (m23 + m32) / _s3;
2298
+ this._z = 0.25 * _s3;
2299
+ }
2300
+
2301
+ this._onChangeCallback();
2302
+
2303
+ return this;
2304
+ };
2305
+
2306
+ _proto.setFromUnitVectors = function setFromUnitVectors(vFrom, vTo) {
2307
+ // assumes direction vectors vFrom and vTo are normalized
2308
+ var r = vFrom.dot(vTo) + 1;
2309
+
2310
+ if (r < Number.EPSILON) {
2311
+ // vFrom and vTo point in opposite directions
2312
+ r = 0;
2313
+
2314
+ if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
2315
+ this._x = -vFrom.y;
2316
+ this._y = vFrom.x;
2317
+ this._z = 0;
2318
+ this._w = r;
2319
+ } else {
2320
+ this._x = 0;
2321
+ this._y = -vFrom.z;
2322
+ this._z = vFrom.y;
2323
+ this._w = r;
2324
+ }
2325
+ } else {
2326
+ // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
2327
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
2328
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
2329
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
2330
+ this._w = r;
2331
+ }
2332
+
2333
+ return this.normalize();
2334
+ } // angleTo(q) {
2335
+ // return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
2336
+ // }
2337
+ ;
2338
+
2339
+ _proto.rotateTowards = function rotateTowards(q, step) {
2340
+ var angle = this.angleTo(q);
2341
+ if (angle === 0) return this;
2342
+ var t = Math.min(1, step / angle);
2343
+ this.slerp(q, t);
2344
+ return this;
2345
+ };
2346
+
2347
+ _proto.identity = function identity() {
2348
+ return this.set(0, 0, 0, 1);
2349
+ };
2350
+
2351
+ _proto.invert = function invert() {
2352
+ // quaternion is assumed to have unit length
2353
+ return this.conjugate();
2354
+ };
2355
+
2356
+ _proto.conjugate = function conjugate() {
2357
+ this._x *= -1;
2358
+ this._y *= -1;
2359
+ this._z *= -1;
2360
+
2361
+ this._onChangeCallback();
2362
+
2363
+ return this;
2364
+ };
2365
+
2366
+ _proto.dot = function dot(v) {
2367
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
2368
+ };
2369
+
2370
+ _proto.lengthSq = function lengthSq() {
2371
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
2372
+ };
2373
+
2374
+ _proto.length = function length() {
2375
+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
2376
+ };
2377
+
2378
+ _proto.normalize = function normalize() {
2379
+ var l = this.length();
2380
+
2381
+ if (l === 0) {
2382
+ this._x = 0;
2383
+ this._y = 0;
2384
+ this._z = 0;
2385
+ this._w = 1;
2386
+ } else {
2387
+ l = 1 / l;
2388
+ this._x = this._x * l;
2389
+ this._y = this._y * l;
2390
+ this._z = this._z * l;
2391
+ this._w = this._w * l;
2392
+ }
2393
+
2394
+ this._onChangeCallback();
2395
+
2396
+ return this;
2397
+ };
2398
+
2399
+ _proto.multiply = function multiply(q) {
2400
+ return this.multiplyQuaternions(this, q);
2401
+ };
2402
+
2403
+ _proto.premultiply = function premultiply(q) {
2404
+ return this.multiplyQuaternions(q, this);
2405
+ };
2406
+
2407
+ _proto.multiplyQuaternions = function multiplyQuaternions(a, b) {
2408
+ // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
2409
+ var qax = a._x,
2410
+ qay = a._y,
2411
+ qaz = a._z,
2412
+ qaw = a._w;
2413
+ var qbx = b._x,
2414
+ qby = b._y,
2415
+ qbz = b._z,
2416
+ qbw = b._w;
2417
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
2418
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
2419
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
2420
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
2421
+
2422
+ this._onChangeCallback();
2423
+
2424
+ return this;
2425
+ };
2426
+
2427
+ _proto.slerp = function slerp(qb, t) {
2428
+ if (t === 0) return this;
2429
+ if (t === 1) return this.copy(qb);
2430
+ var x = this._x,
2431
+ y = this._y,
2432
+ z = this._z,
2433
+ w = this._w; // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
2434
+
2435
+ var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
2436
+
2437
+ if (cosHalfTheta < 0) {
2438
+ this._w = -qb._w;
2439
+ this._x = -qb._x;
2440
+ this._y = -qb._y;
2441
+ this._z = -qb._z;
2442
+ cosHalfTheta = -cosHalfTheta;
2443
+ } else {
2444
+ this.copy(qb);
2445
+ }
2446
+
2447
+ if (cosHalfTheta >= 1.0) {
2448
+ this._w = w;
2449
+ this._x = x;
2450
+ this._y = y;
2451
+ this._z = z;
2452
+ return this;
2453
+ }
2454
+
2455
+ var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
2456
+
2457
+ if (sqrSinHalfTheta <= Number.EPSILON) {
2458
+ var s = 1 - t;
2459
+ this._w = s * w + t * this._w;
2460
+ this._x = s * x + t * this._x;
2461
+ this._y = s * y + t * this._y;
2462
+ this._z = s * z + t * this._z;
2463
+ this.normalize(); // normalize calls _onChangeCallback()
2464
+
2465
+ return this;
2466
+ }
2467
+
2468
+ var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
2469
+ var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
2470
+ var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta,
2471
+ ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
2472
+ this._w = w * ratioA + this._w * ratioB;
2473
+ this._x = x * ratioA + this._x * ratioB;
2474
+ this._y = y * ratioA + this._y * ratioB;
2475
+ this._z = z * ratioA + this._z * ratioB;
2476
+
2477
+ this._onChangeCallback();
2478
+
2479
+ return this;
2480
+ };
2481
+
2482
+ _proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
2483
+ return this.copy(qa).slerp(qb, t);
2484
+ };
2485
+
2486
+ _proto.random = function random() {
2487
+ // sets this quaternion to a uniform random unit quaternnion
2488
+ // Ken Shoemake
2489
+ // Uniform random rotations
2490
+ // D. Kirk, editor, Graphics Gems III, pages 124-132. Academic Press, New York, 1992.
2491
+ var theta1 = 2 * Math.PI * Math.random();
2492
+ var theta2 = 2 * Math.PI * Math.random();
2493
+ var x0 = Math.random();
2494
+ var r1 = Math.sqrt(1 - x0);
2495
+ var r2 = Math.sqrt(x0);
2496
+ return this.set(r1 * Math.sin(theta1), r1 * Math.cos(theta1), r2 * Math.sin(theta2), r2 * Math.cos(theta2));
2497
+ };
2498
+
2499
+ _proto.equals = function equals(quaternion) {
2500
+ return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
2501
+ };
2502
+
2503
+ _proto.fromArray = function fromArray(array, offset) {
2504
+ if (offset === void 0) {
2505
+ offset = 0;
2506
+ }
2507
+
2508
+ this._x = array[offset];
2509
+ this._y = array[offset + 1];
2510
+ this._z = array[offset + 2];
2511
+ this._w = array[offset + 3];
2512
+
2513
+ this._onChangeCallback();
2514
+
2515
+ return this;
2516
+ };
2517
+
2518
+ _proto.toArray = function toArray(array, offset) {
2519
+ if (array === void 0) {
2520
+ array = [];
2521
+ }
2522
+
2523
+ if (offset === void 0) {
2524
+ offset = 0;
2525
+ }
2526
+
2527
+ array[offset] = this._x;
2528
+ array[offset + 1] = this._y;
2529
+ array[offset + 2] = this._z;
2530
+ array[offset + 3] = this._w;
2531
+ return array;
2532
+ };
2533
+
2534
+ _proto.fromBufferAttribute = function fromBufferAttribute(attribute, index) {
2535
+ this._x = attribute.getX(index);
2536
+ this._y = attribute.getY(index);
2537
+ this._z = attribute.getZ(index);
2538
+ this._w = attribute.getW(index);
2539
+
2540
+ this._onChangeCallback();
2541
+
2542
+ return this;
2543
+ };
2544
+
2545
+ _proto.toJSON = function toJSON() {
2546
+ return this.toArray();
2547
+ };
2548
+
2549
+ _proto._onChange = function _onChange(callback) {
2550
+ this._onChangeCallback = callback;
2551
+ return this;
2552
+ };
2553
+
2554
+ _proto._onChangeCallback = function _onChangeCallback() {};
2555
+
2556
+ _proto[_Symbol$iterator] = /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
2557
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2558
+ while (1) {
2559
+ switch (_context.prev = _context.next) {
2560
+ case 0:
2561
+ _context.next = 2;
2562
+ return this._x;
2563
+
2564
+ case 2:
2565
+ _context.next = 4;
2566
+ return this._y;
2567
+
2568
+ case 4:
2569
+ _context.next = 6;
2570
+ return this._z;
2571
+
2572
+ case 6:
2573
+ _context.next = 8;
2574
+ return this._w;
2575
+
2576
+ case 8:
2577
+ case "end":
2578
+ return _context.stop();
2579
+ }
2580
+ }
2581
+ }, _callee, this);
2582
+ });
2583
+
2584
+ _createClass(Quaternion, [{
2585
+ key: "x",
2586
+ get: function get() {
2587
+ return this._x;
2588
+ },
2589
+ set: function set(value) {
2590
+ this._x = value;
2591
+
2592
+ this._onChangeCallback();
2593
+ }
2594
+ }, {
2595
+ key: "y",
2596
+ get: function get() {
2597
+ return this._y;
2598
+ },
2599
+ set: function set(value) {
2600
+ this._y = value;
2601
+
2602
+ this._onChangeCallback();
2603
+ }
2604
+ }, {
2605
+ key: "z",
2606
+ get: function get() {
2607
+ return this._z;
2608
+ },
2609
+ set: function set(value) {
2610
+ this._z = value;
2611
+
2612
+ this._onChangeCallback();
2613
+ }
2614
+ }, {
2615
+ key: "w",
2616
+ get: function get() {
2617
+ return this._w;
2618
+ },
2619
+ set: function set(value) {
2620
+ this._w = value;
2621
+
2622
+ this._onChangeCallback();
2623
+ }
2624
+ }]);
2625
+
2626
+ return Quaternion;
2627
+ }(Symbol.iterator);
2628
+
1636
2629
  // import * as MathUtils from './MathUtils.js';
1637
- // code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Vector3.js
2630
+
2631
+ var _quaternion = new Quaternion();
2632
+
1638
2633
  var Vector3 = /*#__PURE__*/function () {
1639
2634
  function Vector3(x, y, z) {
1640
2635
  if (x === void 0) {
@@ -1782,10 +2777,11 @@ var Vector3 = /*#__PURE__*/function () {
1782
2777
  } // applyEuler(euler) {
1783
2778
  // return this.applyQuaternion(_quaternion.setFromEuler(euler));
1784
2779
  // }
1785
- // applyAxisAngle(axis, angle) {
1786
- // return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
1787
- // }
1788
- // applyMatrix3(m) {
2780
+ ;
2781
+
2782
+ _proto.applyAxisAngle = function applyAxisAngle(axis, angle) {
2783
+ return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
2784
+ } // applyMatrix3(m) {
1789
2785
  // const x = this.x, y = this.y, z = this.z;
1790
2786
  // const e = m.elements;
1791
2787
  // this.x = e[0] * x + e[3] * y + e[6] * z;
@@ -1808,21 +2804,27 @@ var Vector3 = /*#__PURE__*/function () {
1808
2804
  this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
1809
2805
  this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
1810
2806
  return this;
1811
- } // applyQuaternion(q) {
1812
- // const x = this.x, y = this.y, z = this.z;
1813
- // const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
1814
- // // calculate quat * vector
1815
- // const ix = qw * x + qy * z - qz * y;
1816
- // const iy = qw * y + qz * x - qx * z;
1817
- // const iz = qw * z + qx * y - qy * x;
1818
- // const iw = - qx * x - qy * y - qz * z;
1819
- // // calculate result * inverse quat
1820
- // this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
1821
- // this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
1822
- // this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
1823
- // return this;
1824
- // }
1825
- // project(camera) {
2807
+ };
2808
+
2809
+ _proto.applyQuaternion = function applyQuaternion(q) {
2810
+ var x = this.x,
2811
+ y = this.y,
2812
+ z = this.z;
2813
+ var qx = q.x,
2814
+ qy = q.y,
2815
+ qz = q.z,
2816
+ qw = q.w; // calculate quat * vector
2817
+
2818
+ var ix = qw * x + qy * z - qz * y;
2819
+ var iy = qw * y + qz * x - qx * z;
2820
+ var iz = qw * z + qx * y - qy * x;
2821
+ var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat
2822
+
2823
+ this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
2824
+ this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
2825
+ this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
2826
+ return this;
2827
+ } // project(camera) {
1826
2828
  // return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
1827
2829
  // }
1828
2830
  // unproject(camera) {
@@ -2753,21 +3755,6 @@ var Matrix4 = /*#__PURE__*/function () {
2753
3755
  return Matrix4;
2754
3756
  }(); // const _v1 = new Vector3();
2755
3757
 
2756
- function _inheritsLoose(subClass, superClass) {
2757
- subClass.prototype = Object.create(superClass.prototype);
2758
- subClass.prototype.constructor = subClass;
2759
-
2760
- _setPrototypeOf(subClass, superClass);
2761
- }
2762
-
2763
- function _setPrototypeOf(o, p) {
2764
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2765
- o.__proto__ = p;
2766
- return o;
2767
- };
2768
- return _setPrototypeOf(o, p);
2769
- }
2770
-
2771
3758
  // code copy from https://github.com/mrdoob/three.js/blob/dev/src/extras/core/Curve.js
2772
3759
  // import * as MathUtils from '../../math/MathUtils.js';
2773
3760
  // import { Vector2 } from '../../math/Vector2.js';
@@ -3410,7 +4397,7 @@ var PathPointList = /*#__PURE__*/function () {
3410
4397
  return PathPointList;
3411
4398
  }();
3412
4399
 
3413
- var UP = new Vector3(0, 0, 1);
4400
+ var UP$1 = new Vector3(0, 0, 1);
3414
4401
  function expandPaths(lines, options) {
3415
4402
  options = Object.assign({}, {
3416
4403
  lineWidth: 1,
@@ -3425,7 +4412,7 @@ function expandPaths(lines, options) {
3425
4412
  return new Vector3(x, y, z || 0);
3426
4413
  });
3427
4414
  var pathPointList = new PathPointList();
3428
- pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
4415
+ pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP$1);
3429
4416
  var result = generatePathVertexData(pathPointList, options);
3430
4417
  result.line = line;
3431
4418
  result.position = new Float32Array(result.points);
@@ -3602,4 +4589,142 @@ function generatePathVertexData(pathPointList, options) {
3602
4589
  };
3603
4590
  }
3604
4591
 
3605
- export { cylinder, expandLine, expandPaths, extrudePolygons, extrudePolylines, extrudeSlopes, leftOnLine };
4592
+ var UP = new Vector3(0, 0, 1);
4593
+ function expandTubes(lines, options) {
4594
+ options = Object.assign({}, {
4595
+ radius: 1,
4596
+ cornerSplit: 0,
4597
+ radialSegments: 8,
4598
+ startRad: -Math.PI / 4
4599
+ }, options);
4600
+ var results = lines.map(function (line) {
4601
+ var points = line.map(function (p) {
4602
+ var x = p[0],
4603
+ y = p[1],
4604
+ z = p[2];
4605
+ return new Vector3(x, y, z || 0);
4606
+ });
4607
+ var pathPointList = new PathPointList();
4608
+ pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
4609
+ var result = generateTubeVertexData(pathPointList, options);
4610
+ result.line = line;
4611
+ result.position = new Float32Array(result.points);
4612
+ result.indices = new Uint32Array(result.index);
4613
+ result.uv = new Float32Array(result.uvs);
4614
+ result.normal = new Float32Array(result.normal);
4615
+ return result;
4616
+ });
4617
+ var result = merge(results);
4618
+ result.lines = lines;
4619
+ return result;
4620
+ } // Vertex Data Generate Functions
4621
+ // code copy from https://github.com/shawn0326/three.path/blob/master/src/PathGeometry.js
4622
+
4623
+ function generateTubeVertexData(pathPointList, options) {
4624
+ var radius = Math.max(options.radius || 1, 0.00000001);
4625
+ var progress = options.progress !== undefined ? options.progress : 1;
4626
+ var radialSegments = Math.max(3, options.radialSegments || 8);
4627
+ var startRad = options.startRad || 0;
4628
+ var circum = radius * 2 * Math.PI;
4629
+ var totalDistance = pathPointList.distance();
4630
+ var progressDistance = progress * totalDistance;
4631
+
4632
+ if (progressDistance === 0) {
4633
+ return null;
4634
+ }
4635
+
4636
+ var count = 0; // modify data
4637
+
4638
+ var points = [];
4639
+ var normal = [];
4640
+ var uvs = []; // const uv2 = [];
4641
+
4642
+ var index = [];
4643
+ var verticesCount = 0;
4644
+ var normalDir = new Vector3();
4645
+ var pIndex = -1;
4646
+ var nIndex = -1;
4647
+ var uIndex = -1;
4648
+ var iIndex = -1;
4649
+
4650
+ function addVertices(pathPoint, radius, radialSegments) {
4651
+ var first = points.length === 0;
4652
+ var uvDist = pathPoint.dist / circum; // const uvDist2 = pathPoint.dist / totalDistance;
4653
+
4654
+ for (var i = 0; i <= radialSegments; i++) {
4655
+ var r = i;
4656
+
4657
+ if (r === radialSegments) {
4658
+ r = 0;
4659
+ }
4660
+
4661
+ normalDir.copy(pathPoint.up).applyAxisAngle(pathPoint.dir, startRad + Math.PI * 2 * r / radialSegments).normalize();
4662
+ var scale = radius * pathPoint.widthScale;
4663
+ points[++pIndex] = pathPoint.pos.x + normalDir.x * scale;
4664
+ points[++pIndex] = pathPoint.pos.y + normalDir.y * scale;
4665
+ points[++pIndex] = pathPoint.pos.z + normalDir.z * scale;
4666
+ normal[++nIndex] = normalDir.x;
4667
+ normal[++nIndex] = normalDir.y;
4668
+ normal[++nIndex] = normalDir.z;
4669
+ uvs[++uIndex] = uvDist;
4670
+ uvs[++uIndex] = i / radialSegments; // uvs.push(uvDist, r / radialSegments);
4671
+ // if (generateUv2) {
4672
+ // uv2.push(uvDist2, r / radialSegments);
4673
+ // }
4674
+
4675
+ verticesCount++;
4676
+ }
4677
+
4678
+ if (!first) {
4679
+ var begin1 = verticesCount - (radialSegments + 1) * 2;
4680
+ var begin2 = verticesCount - (radialSegments + 1);
4681
+
4682
+ for (var _i = 0; _i < radialSegments; _i++) {
4683
+ index[++iIndex] = begin2 + _i;
4684
+ index[++iIndex] = begin1 + _i;
4685
+ index[++iIndex] = begin1 + _i + 1;
4686
+ index[++iIndex] = begin2 + _i;
4687
+ index[++iIndex] = begin1 + _i + 1;
4688
+ index[++iIndex] = begin2 + _i + 1; // index.push(
4689
+ // begin2 + i,
4690
+ // begin1 + i,
4691
+ // begin1 + i + 1,
4692
+ // begin2 + i,
4693
+ // begin1 + i + 1,
4694
+ // begin2 + i + 1
4695
+ // );
4696
+
4697
+ count += 6;
4698
+ }
4699
+ }
4700
+ }
4701
+
4702
+ if (progressDistance > 0) {
4703
+ for (var i = 0; i < pathPointList.count; i++) {
4704
+ var pathPoint = pathPointList.array[i];
4705
+
4706
+ if (pathPoint.dist > progressDistance) {
4707
+ var prevPoint = pathPointList.array[i - 1];
4708
+ var lastPoint = new PathPoint(); // linear lerp for progress
4709
+
4710
+ var alpha = (progressDistance - prevPoint.dist) / (pathPoint.dist - prevPoint.dist);
4711
+ lastPoint.lerpPathPoints(prevPoint, pathPoint, alpha);
4712
+ addVertices(lastPoint, radius, radialSegments);
4713
+ break;
4714
+ } else {
4715
+ addVertices(pathPoint, radius, radialSegments);
4716
+ }
4717
+ }
4718
+ }
4719
+
4720
+ return {
4721
+ points: points,
4722
+ normal: normal,
4723
+ uvs: uvs,
4724
+ // uv2,
4725
+ index: index,
4726
+ count: count
4727
+ };
4728
+ }
4729
+
4730
+ export { cylinder, expandLine, expandPaths, expandTubes, extrudePolygons, extrudePolylines, extrudeSlopes, leftOnLine };