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