poly-extrude 0.22.1 → 0.22.2
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 +21 -12
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +21 -12
- package/dist/poly-extrude.mjs.map +1 -1
- package/dist/polylinehelper.js +15 -9
- package/dist/polylinehelper.js.map +1 -1
- package/dist/polylineoffset.d.ts +11 -0
- package/dist/polylineoffset.js +241 -0
- package/dist/polylineoffset.js.map +1 -0
- package/dist/util.d.ts +2 -2
- package/dist/util.js +9 -3
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
- package/src/polylinehelper.ts +15 -9
- package/src/util.ts +9 -3
package/dist/poly-extrude.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* poly-extrude v0.22.
|
|
2
|
+
* poly-extrude v0.22.2
|
|
3
3
|
*/
|
|
4
4
|
(function (global, factory) {
|
|
5
5
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -2017,11 +2017,14 @@
|
|
|
2017
2017
|
}
|
|
2018
2018
|
return distance;
|
|
2019
2019
|
}
|
|
2020
|
-
function pointEqual(p1, p2) {
|
|
2020
|
+
function pointEqual(p1, p2, considerZ) {
|
|
2021
|
+
if (considerZ) {
|
|
2022
|
+
return p1[0] === p2[0] && p1[1] === p2[1] && (p1[2] || 0) === (p2[2] || 0);
|
|
2023
|
+
}
|
|
2021
2024
|
return p1[0] === p2[0] && p1[1] === p2[1];
|
|
2022
2025
|
}
|
|
2023
|
-
function pointDistance(p1, p2) {
|
|
2024
|
-
const dx = p2[0] - p1[0], dy = p2[1] - p1[1];
|
|
2026
|
+
function pointDistance(p1, p2, considerZ) {
|
|
2027
|
+
const dx = p2[0] - p1[0], dy = p2[1] - p1[1]; (p2[2] || 0) - (p1[2] || 0);
|
|
2025
2028
|
return Math.sqrt(dx * dx + dy * dy);
|
|
2026
2029
|
}
|
|
2027
2030
|
|
|
@@ -7077,7 +7080,7 @@
|
|
|
7077
7080
|
if (!p3 || !p1 || !p2) {
|
|
7078
7081
|
continue;
|
|
7079
7082
|
}
|
|
7080
|
-
if (pointEqual(pre, p2)) {
|
|
7083
|
+
if (pointEqual(pre, p2, true)) {
|
|
7081
7084
|
continue;
|
|
7082
7085
|
}
|
|
7083
7086
|
const d1 = pointDistance(p2, p1), d2 = pointDistance(p2, p3);
|
|
@@ -7086,33 +7089,39 @@
|
|
|
7086
7089
|
points[++idx] = p2;
|
|
7087
7090
|
continue;
|
|
7088
7091
|
}
|
|
7089
|
-
const dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1];
|
|
7090
|
-
const dx2 = p3[0] - p2[0], dy2 = p3[1] - p2[1];
|
|
7092
|
+
const dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1], dz1 = (p2[2] || 0) - (p1[2] || 0);
|
|
7093
|
+
const dx2 = p3[0] - p2[0], dy2 = p3[1] - p2[1], dz2 = (p3[2] || 0) - (p2[2] || 0);
|
|
7091
7094
|
const percent1 = (d1 - roundSize) / d1;
|
|
7092
7095
|
const percent2 = roundSize / d2;
|
|
7093
7096
|
const c1 = {
|
|
7094
7097
|
x: p1[0] + percent1 * dx1,
|
|
7095
|
-
y: p1[1] + percent1 * dy1
|
|
7098
|
+
y: p1[1] + percent1 * dy1,
|
|
7099
|
+
z: (p1[2] || 0) + percent1 * dz1
|
|
7096
7100
|
};
|
|
7097
7101
|
const c2 = {
|
|
7098
7102
|
x: p2[0] + percent2 * dx2,
|
|
7099
|
-
y: p2[1] + percent2 * dy2
|
|
7103
|
+
y: p2[1] + percent2 * dy2,
|
|
7104
|
+
z: (p2[2] || 0) + percent2 * dz2
|
|
7100
7105
|
};
|
|
7101
|
-
const d3 = pointDistance([c1.x, c1.y], [c2.x, c2.y]);
|
|
7106
|
+
const d3 = pointDistance([c1.x, c1.y, c1.z], [c2.x, c2.y, c2.z]);
|
|
7102
7107
|
if (d3 < roundSize / 10) {
|
|
7103
7108
|
pre = p2;
|
|
7104
7109
|
points[++idx] = p2;
|
|
7105
7110
|
continue;
|
|
7106
7111
|
}
|
|
7107
|
-
const be = new bezier.Bezier([c1, { x: p2[0], y: p2[1] }, c2]);
|
|
7112
|
+
const be = new bezier.Bezier([c1, { x: p2[0], y: p2[1], z: p2[2] || 0 }, c2]);
|
|
7108
7113
|
const path = be.getLUT(steps);
|
|
7109
7114
|
for (let j = 0, len1 = path.length; j < len1; j++) {
|
|
7110
7115
|
const p = path[j];
|
|
7111
|
-
points[++idx] = [p.x, p.y];
|
|
7116
|
+
points[++idx] = [p.x, p.y, p.z];
|
|
7112
7117
|
}
|
|
7113
7118
|
pre = p2;
|
|
7114
7119
|
}
|
|
7115
7120
|
points.push(line[len - 1]);
|
|
7121
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
7122
|
+
const p = points[i];
|
|
7123
|
+
p[2] = p[2] || 0;
|
|
7124
|
+
}
|
|
7116
7125
|
return points;
|
|
7117
7126
|
}
|
|
7118
7127
|
|