poly-extrude 0.22.0 → 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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/poly-extrude.js +32 -16
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +32 -16
- package/dist/poly-extrude.mjs.map +1 -1
- package/dist/polylinehelper.d.ts +11 -0
- package/dist/polylinehelper.js +254 -0
- package/dist/polylinehelper.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 +53 -53
- package/src/index.ts +1 -1
- package/src/{polylineoffset.ts → polylinehelper.ts} +26 -13
- package/src/util.ts +9 -3
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { expandPaths } from './path';
|
|
|
5
5
|
import { expandTubes } from './tube';
|
|
6
6
|
import { plane } from './plane';
|
|
7
7
|
import { extrudePolygonsOnPath } from './polygonpath';
|
|
8
|
-
import { polylineOffset, polylineRound } from './
|
|
8
|
+
import { polylineOffset, polylineRound } from './polylinehelper';
|
|
9
9
|
import { isClockwise, merge } from './util';
|
|
10
10
|
export { isClockwise, merge, extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes, plane, extrudePolygonsOnPath, polygons, polylineOffset, polylineRound };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { expandPaths } from './path';
|
|
|
5
5
|
import { expandTubes } from './tube';
|
|
6
6
|
import { plane } from './plane';
|
|
7
7
|
import { extrudePolygonsOnPath } from './polygonpath';
|
|
8
|
-
import { polylineOffset, polylineRound } from './
|
|
8
|
+
import { polylineOffset, polylineRound } from './polylinehelper';
|
|
9
9
|
import { isClockwise, merge } from './util';
|
|
10
10
|
export { isClockwise, merge, extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes, plane, extrudePolygonsOnPath, polygons, polylineOffset, polylineRound };
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
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
|
|
|
@@ -7069,44 +7072,57 @@
|
|
|
7069
7072
|
}
|
|
7070
7073
|
const len = line.length;
|
|
7071
7074
|
const { roundSize, steps } = options;
|
|
7072
|
-
const
|
|
7075
|
+
const points = [line[0]];
|
|
7073
7076
|
let pre = line[0];
|
|
7077
|
+
let idx = 0;
|
|
7074
7078
|
for (let i = 1; i < len; i++) {
|
|
7075
7079
|
const p1 = line[i - 1], p2 = line[i], p3 = line[i + 1];
|
|
7076
|
-
if (
|
|
7080
|
+
if (!p3 || !p1 || !p2) {
|
|
7077
7081
|
continue;
|
|
7078
7082
|
}
|
|
7079
|
-
if (
|
|
7083
|
+
if (pointEqual(pre, p2, true)) {
|
|
7080
7084
|
continue;
|
|
7081
7085
|
}
|
|
7082
7086
|
const d1 = pointDistance(p2, p1), d2 = pointDistance(p2, p3);
|
|
7083
7087
|
if (d1 < roundSize || d2 < roundSize) {
|
|
7084
7088
|
pre = p2;
|
|
7085
|
-
|
|
7089
|
+
points[++idx] = p2;
|
|
7086
7090
|
continue;
|
|
7087
7091
|
}
|
|
7088
|
-
const dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1];
|
|
7089
|
-
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);
|
|
7090
7094
|
const percent1 = (d1 - roundSize) / d1;
|
|
7091
7095
|
const percent2 = roundSize / d2;
|
|
7092
7096
|
const c1 = {
|
|
7093
7097
|
x: p1[0] + percent1 * dx1,
|
|
7094
|
-
y: p1[1] + percent1 * dy1
|
|
7098
|
+
y: p1[1] + percent1 * dy1,
|
|
7099
|
+
z: (p1[2] || 0) + percent1 * dz1
|
|
7095
7100
|
};
|
|
7096
7101
|
const c2 = {
|
|
7097
7102
|
x: p2[0] + percent2 * dx2,
|
|
7098
|
-
y: p2[1] + percent2 * dy2
|
|
7103
|
+
y: p2[1] + percent2 * dy2,
|
|
7104
|
+
z: (p2[2] || 0) + percent2 * dz2
|
|
7099
7105
|
};
|
|
7100
|
-
const
|
|
7106
|
+
const d3 = pointDistance([c1.x, c1.y, c1.z], [c2.x, c2.y, c2.z]);
|
|
7107
|
+
if (d3 < roundSize / 10) {
|
|
7108
|
+
pre = p2;
|
|
7109
|
+
points[++idx] = p2;
|
|
7110
|
+
continue;
|
|
7111
|
+
}
|
|
7112
|
+
const be = new bezier.Bezier([c1, { x: p2[0], y: p2[1], z: p2[2] || 0 }, c2]);
|
|
7101
7113
|
const path = be.getLUT(steps);
|
|
7102
7114
|
for (let j = 0, len1 = path.length; j < len1; j++) {
|
|
7103
7115
|
const p = path[j];
|
|
7104
|
-
|
|
7116
|
+
points[++idx] = [p.x, p.y, p.z];
|
|
7105
7117
|
}
|
|
7106
7118
|
pre = p2;
|
|
7107
7119
|
}
|
|
7108
|
-
|
|
7109
|
-
|
|
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
|
+
}
|
|
7125
|
+
return points;
|
|
7110
7126
|
}
|
|
7111
7127
|
|
|
7112
7128
|
exports.cylinder = cylinder;
|