makerjs 0.17.3 → 0.17.4
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/browser.maker.js +49 -30
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -29
- package/package.json +1 -1
package/dist/browser.maker.js
CHANGED
|
@@ -39,7 +39,7 @@ and limitations under the License.
|
|
|
39
39
|
* author: Dan Marshall / Microsoft Corporation
|
|
40
40
|
* maintainers: Dan Marshall <danmar@microsoft.com>
|
|
41
41
|
* homepage: https://maker.js.org
|
|
42
|
-
* version: 0.17.
|
|
42
|
+
* version: 0.17.4
|
|
43
43
|
*
|
|
44
44
|
* browserify:
|
|
45
45
|
* license: MIT (http://opensource.org/licenses/MIT)
|
|
@@ -8384,10 +8384,12 @@ var MakerJs;
|
|
|
8384
8384
|
cpa.sort(function (a, b) { return a.xRatio - b.xRatio; });
|
|
8385
8385
|
var first = cpa[0];
|
|
8386
8386
|
var last = cpa[cpa.length - 1];
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8387
|
+
if (cpa.length > 1) {
|
|
8388
|
+
var min = first.xRatio;
|
|
8389
|
+
var max = last.xRatio;
|
|
8390
|
+
var span = max - min;
|
|
8391
|
+
cpa.forEach(function (cp) { return cp.xRatio = (cp.xRatio - min) / span; });
|
|
8392
|
+
}
|
|
8391
8393
|
return {
|
|
8392
8394
|
cpa: cpa,
|
|
8393
8395
|
firstX: xMap[first.childId],
|
|
@@ -8440,7 +8442,7 @@ var MakerJs;
|
|
|
8440
8442
|
var result = getChildPlacement(parentModel, baseline);
|
|
8441
8443
|
var cpa = result.cpa;
|
|
8442
8444
|
var chosenPath = onPath;
|
|
8443
|
-
if (contain) {
|
|
8445
|
+
if (contain && cpa.length > 1) {
|
|
8444
8446
|
//see if we need to clip
|
|
8445
8447
|
var onPathLength = MakerJs.measure.pathLength(onPath);
|
|
8446
8448
|
if (result.firstX + result.lastX < onPathLength) {
|
|
@@ -8502,35 +8504,52 @@ var MakerJs;
|
|
|
8502
8504
|
var result = getChildPlacement(parentModel, baseline);
|
|
8503
8505
|
var cpa = result.cpa;
|
|
8504
8506
|
var chainLength = onChain.pathLength;
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
relatives
|
|
8507
|
+
var points;
|
|
8508
|
+
if (cpa.length > 1) {
|
|
8509
|
+
if (contain)
|
|
8510
|
+
chainLength -= result.firstX + result.lastX;
|
|
8511
|
+
var absolutes = cpa.map(function (cp) { return (reversed ? 1 - cp.xRatio : cp.xRatio) * chainLength; });
|
|
8512
|
+
var relatives;
|
|
8513
|
+
if (reversed)
|
|
8514
|
+
absolutes.reverse();
|
|
8515
|
+
relatives = absolutes.map(function (ab, i) { return Math.abs(ab - (i == 0 ? 0 : absolutes[i - 1])); });
|
|
8516
|
+
if (contain) {
|
|
8517
|
+
relatives[0] += reversed ? result.lastX : result.firstX;
|
|
8518
|
+
}
|
|
8519
|
+
else {
|
|
8520
|
+
relatives.shift();
|
|
8521
|
+
}
|
|
8522
|
+
//chain.toPoints always follows the chain in its order, from beginning to end. This is why we needed to contort the points input
|
|
8523
|
+
points = MakerJs.chain.toPoints(onChain, relatives);
|
|
8524
|
+
if (points.length < cpa.length) {
|
|
8525
|
+
//add last point of chain, since our distances exceeded the chain
|
|
8526
|
+
var endLink = onChain.links[onChain.links.length - 1];
|
|
8527
|
+
points.push(endLink.endPoints[endLink.reversed ? 0 : 1]);
|
|
8528
|
+
}
|
|
8529
|
+
if (contain)
|
|
8530
|
+
points.shift(); //delete the first point which is the beginning of the chain
|
|
8514
8531
|
}
|
|
8515
8532
|
else {
|
|
8516
|
-
|
|
8533
|
+
//get the first point and the middle point of the chain
|
|
8534
|
+
points = MakerJs.chain.toPoints(onChain, 0.5 * chainLength);
|
|
8535
|
+
points.length = 2;
|
|
8536
|
+
//add the last point of the chain
|
|
8537
|
+
points.push(onChain.links[onChain.links.length - 1].endPoints[onChain.links[onChain.links.length - 1].reversed ? 0 : 1]);
|
|
8517
8538
|
}
|
|
8518
|
-
//chain.toPoints always follows the chain in its order, from beginning to end. This is why we needed to contort the points input
|
|
8519
|
-
var points = MakerJs.chain.toPoints(onChain, relatives);
|
|
8520
|
-
if (points.length < cpa.length) {
|
|
8521
|
-
//add last point of chain, since our distances exceeded the chain
|
|
8522
|
-
var endLink = onChain.links[onChain.links.length - 1];
|
|
8523
|
-
points.push(endLink.endPoints[endLink.reversed ? 0 : 1]);
|
|
8524
|
-
}
|
|
8525
|
-
if (contain)
|
|
8526
|
-
points.shift(); //delete the first point which is the beginning of the chain
|
|
8527
8539
|
if (reversed)
|
|
8528
8540
|
points.reverse();
|
|
8529
8541
|
var angles = miterAngles(points, -90);
|
|
8530
|
-
cpa.
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8542
|
+
if (cpa.length > 1) {
|
|
8543
|
+
cpa.forEach(function (cp, i) {
|
|
8544
|
+
cp.angle = angles[i];
|
|
8545
|
+
cp.origin = points[i];
|
|
8546
|
+
});
|
|
8547
|
+
}
|
|
8548
|
+
else {
|
|
8549
|
+
//use the middle point
|
|
8550
|
+
cpa[0].angle = angles[1];
|
|
8551
|
+
cpa[0].origin = points[1];
|
|
8552
|
+
}
|
|
8534
8553
|
moveAndRotate(parentModel, cpa, rotated);
|
|
8535
8554
|
return parentModel;
|
|
8536
8555
|
}
|
|
@@ -10286,6 +10305,6 @@ var MakerJs;
|
|
|
10286
10305
|
];
|
|
10287
10306
|
})(models = MakerJs.models || (MakerJs.models = {}));
|
|
10288
10307
|
})(MakerJs || (MakerJs = {}));
|
|
10289
|
-
MakerJs.version = "0.17.
|
|
10308
|
+
MakerJs.version = "0.17.4";
|
|
10290
10309
|
|
|
10291
10310
|
},{"clone":2,"graham_scan":3,"kdbush":4}]},{},[]);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7967,10 +7967,12 @@ var MakerJs;
|
|
|
7967
7967
|
cpa.sort(function (a, b) { return a.xRatio - b.xRatio; });
|
|
7968
7968
|
var first = cpa[0];
|
|
7969
7969
|
var last = cpa[cpa.length - 1];
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7970
|
+
if (cpa.length > 1) {
|
|
7971
|
+
var min = first.xRatio;
|
|
7972
|
+
var max = last.xRatio;
|
|
7973
|
+
var span = max - min;
|
|
7974
|
+
cpa.forEach(function (cp) { return cp.xRatio = (cp.xRatio - min) / span; });
|
|
7975
|
+
}
|
|
7974
7976
|
return {
|
|
7975
7977
|
cpa: cpa,
|
|
7976
7978
|
firstX: xMap[first.childId],
|
|
@@ -8023,7 +8025,7 @@ var MakerJs;
|
|
|
8023
8025
|
var result = getChildPlacement(parentModel, baseline);
|
|
8024
8026
|
var cpa = result.cpa;
|
|
8025
8027
|
var chosenPath = onPath;
|
|
8026
|
-
if (contain) {
|
|
8028
|
+
if (contain && cpa.length > 1) {
|
|
8027
8029
|
//see if we need to clip
|
|
8028
8030
|
var onPathLength = MakerJs.measure.pathLength(onPath);
|
|
8029
8031
|
if (result.firstX + result.lastX < onPathLength) {
|
|
@@ -8085,35 +8087,52 @@ var MakerJs;
|
|
|
8085
8087
|
var result = getChildPlacement(parentModel, baseline);
|
|
8086
8088
|
var cpa = result.cpa;
|
|
8087
8089
|
var chainLength = onChain.pathLength;
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
relatives
|
|
8090
|
+
var points;
|
|
8091
|
+
if (cpa.length > 1) {
|
|
8092
|
+
if (contain)
|
|
8093
|
+
chainLength -= result.firstX + result.lastX;
|
|
8094
|
+
var absolutes = cpa.map(function (cp) { return (reversed ? 1 - cp.xRatio : cp.xRatio) * chainLength; });
|
|
8095
|
+
var relatives;
|
|
8096
|
+
if (reversed)
|
|
8097
|
+
absolutes.reverse();
|
|
8098
|
+
relatives = absolutes.map(function (ab, i) { return Math.abs(ab - (i == 0 ? 0 : absolutes[i - 1])); });
|
|
8099
|
+
if (contain) {
|
|
8100
|
+
relatives[0] += reversed ? result.lastX : result.firstX;
|
|
8101
|
+
}
|
|
8102
|
+
else {
|
|
8103
|
+
relatives.shift();
|
|
8104
|
+
}
|
|
8105
|
+
//chain.toPoints always follows the chain in its order, from beginning to end. This is why we needed to contort the points input
|
|
8106
|
+
points = MakerJs.chain.toPoints(onChain, relatives);
|
|
8107
|
+
if (points.length < cpa.length) {
|
|
8108
|
+
//add last point of chain, since our distances exceeded the chain
|
|
8109
|
+
var endLink = onChain.links[onChain.links.length - 1];
|
|
8110
|
+
points.push(endLink.endPoints[endLink.reversed ? 0 : 1]);
|
|
8111
|
+
}
|
|
8112
|
+
if (contain)
|
|
8113
|
+
points.shift(); //delete the first point which is the beginning of the chain
|
|
8097
8114
|
}
|
|
8098
8115
|
else {
|
|
8099
|
-
|
|
8116
|
+
//get the first point and the middle point of the chain
|
|
8117
|
+
points = MakerJs.chain.toPoints(onChain, 0.5 * chainLength);
|
|
8118
|
+
points.length = 2;
|
|
8119
|
+
//add the last point of the chain
|
|
8120
|
+
points.push(onChain.links[onChain.links.length - 1].endPoints[onChain.links[onChain.links.length - 1].reversed ? 0 : 1]);
|
|
8100
8121
|
}
|
|
8101
|
-
//chain.toPoints always follows the chain in its order, from beginning to end. This is why we needed to contort the points input
|
|
8102
|
-
var points = MakerJs.chain.toPoints(onChain, relatives);
|
|
8103
|
-
if (points.length < cpa.length) {
|
|
8104
|
-
//add last point of chain, since our distances exceeded the chain
|
|
8105
|
-
var endLink = onChain.links[onChain.links.length - 1];
|
|
8106
|
-
points.push(endLink.endPoints[endLink.reversed ? 0 : 1]);
|
|
8107
|
-
}
|
|
8108
|
-
if (contain)
|
|
8109
|
-
points.shift(); //delete the first point which is the beginning of the chain
|
|
8110
8122
|
if (reversed)
|
|
8111
8123
|
points.reverse();
|
|
8112
8124
|
var angles = miterAngles(points, -90);
|
|
8113
|
-
cpa.
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8125
|
+
if (cpa.length > 1) {
|
|
8126
|
+
cpa.forEach(function (cp, i) {
|
|
8127
|
+
cp.angle = angles[i];
|
|
8128
|
+
cp.origin = points[i];
|
|
8129
|
+
});
|
|
8130
|
+
}
|
|
8131
|
+
else {
|
|
8132
|
+
//use the middle point
|
|
8133
|
+
cpa[0].angle = angles[1];
|
|
8134
|
+
cpa[0].origin = points[1];
|
|
8135
|
+
}
|
|
8117
8136
|
moveAndRotate(parentModel, cpa, rotated);
|
|
8118
8137
|
return parentModel;
|
|
8119
8138
|
}
|
|
@@ -9869,5 +9888,5 @@ var MakerJs;
|
|
|
9869
9888
|
];
|
|
9870
9889
|
})(models = MakerJs.models || (MakerJs.models = {}));
|
|
9871
9890
|
})(MakerJs || (MakerJs = {}));
|
|
9872
|
-
MakerJs.version = "0.17.
|
|
9891
|
+
MakerJs.version = "0.17.4";
|
|
9873
9892
|
var Bezier = require('bezier-js');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makerjs",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
4
4
|
"description": "Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|