@jwc/jscad-utils 4.8.1 → 4.8.3
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/compat.js +41 -27
- package/dist/examples/bisect.jscad +153 -139
- package/dist/examples/boxes.jscad +153 -139
- package/dist/examples/chamfer.jscad +153 -139
- package/dist/examples/fillet.jscad +153 -139
- package/dist/examples/fit.jscad +153 -139
- package/dist/examples/groups.jscad +153 -139
- package/dist/examples/midlineTo.jscad +153 -139
- package/dist/examples/parts-hexagon.jscad +153 -139
- package/dist/examples/rabett-tb.jscad +153 -139
- package/dist/examples/rabett.jscad +153 -139
- package/dist/examples/rabett2.jscad +2231 -0
- package/dist/examples/retraction-test.jscad +153 -139
- package/dist/examples/size.jscad +153 -139
- package/dist/examples/snap.jscad +153 -139
- package/dist/examples/text.jscad +153 -139
- package/dist/examples/wedge.jscad +153 -139
- package/dist/index.js +41 -27
- package/package.json +32 -32
- package/src/boxes.js +26 -14
- package/src/group.js +17 -18
- package/src/util.js +15 -10
- package/dist/.DS_Store +0 -0
package/dist/compat.js
CHANGED
|
@@ -43,8 +43,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
43
43
|
var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
44
44
|
'use strict';
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
47
|
+
|
|
48
|
+
var jsCadCSG__default = /*#__PURE__*/_interopDefaultLegacy(jsCadCSG);
|
|
49
|
+
var scadApi__default = /*#__PURE__*/_interopDefaultLegacy(scadApi);
|
|
48
50
|
|
|
49
51
|
var util = /*#__PURE__*/Object.freeze({
|
|
50
52
|
__proto__: null,
|
|
@@ -1013,13 +1015,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
1013
1015
|
'default': init
|
|
1014
1016
|
});
|
|
1015
1017
|
|
|
1016
|
-
var CSG =
|
|
1017
|
-
CAG =
|
|
1018
|
-
var rectangular_extrude =
|
|
1019
|
-
var _scadApi$text =
|
|
1018
|
+
var CSG = jsCadCSG__default['default'].CSG,
|
|
1019
|
+
CAG = jsCadCSG__default['default'].CAG;
|
|
1020
|
+
var rectangular_extrude = scadApi__default['default'].extrusions.rectangular_extrude;
|
|
1021
|
+
var _scadApi$text = scadApi__default['default'].text,
|
|
1020
1022
|
vector_text = _scadApi$text.vector_text,
|
|
1021
1023
|
vector_char = _scadApi$text.vector_char;
|
|
1022
|
-
var union =
|
|
1024
|
+
var union = scadApi__default['default'].booleanOps.union;
|
|
1023
1025
|
init(CSG);
|
|
1024
1026
|
|
|
1025
1027
|
var debug = Debug('jscadUtils:group');
|
|
@@ -1632,8 +1634,8 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
1632
1634
|
* has been depricated and what to use instead.
|
|
1633
1635
|
* @function depreciated
|
|
1634
1636
|
* @param {string} method The name of the method being depricated.
|
|
1635
|
-
* @param {boolean} error Throws an error if called when true.
|
|
1636
|
-
* @param {string} message Instructions on what to use instead of the depricated method.
|
|
1637
|
+
* @param {boolean} [error] Throws an error if called when true.
|
|
1638
|
+
* @param {string} [message] Instructions on what to use instead of the depricated method.
|
|
1637
1639
|
*/
|
|
1638
1640
|
|
|
1639
1641
|
function depreciated(method, error, message) {
|
|
@@ -2335,12 +2337,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
2335
2337
|
return object.stretchAtPlane(normal[axis], cutDelta, distance);
|
|
2336
2338
|
}
|
|
2337
2339
|
/**
|
|
2338
|
-
* Takes two CSG polygons and
|
|
2339
|
-
* Similar to `CSG.extrude`,
|
|
2340
|
+
* Takes two CSG polygons and creates a solid of `height`.
|
|
2341
|
+
* Similar to `CSG.extrude`, except you can resize either
|
|
2340
2342
|
* polygon.
|
|
2341
2343
|
* @param {CAG} top Top polygon
|
|
2342
2344
|
* @param {CAG} bottom Bottom polygon
|
|
2343
|
-
* @param {number} height
|
|
2345
|
+
* @param {number} height height of solid
|
|
2344
2346
|
* @return {CSG} generated solid
|
|
2345
2347
|
*/
|
|
2346
2348
|
|
|
@@ -2377,6 +2379,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
2377
2379
|
return CSG.fromPolygons(polygons);
|
|
2378
2380
|
}
|
|
2379
2381
|
function slices2poly(slices, options, axis) {
|
|
2382
|
+
debug$1('slices2poly', slices, options, axis);
|
|
2383
|
+
options = Object.assign({
|
|
2384
|
+
twistangle: 0,
|
|
2385
|
+
twiststeps: 0
|
|
2386
|
+
}, options);
|
|
2380
2387
|
var twistangle = options && parseFloat(options.twistangle) || 0;
|
|
2381
2388
|
var twiststeps = options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
|
|
2382
2389
|
|
|
@@ -2389,6 +2396,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
2389
2396
|
|
|
2390
2397
|
var first$1 = first(slices);
|
|
2391
2398
|
var last$1 = last(slices);
|
|
2399
|
+
debug$1('slices2poly first', first$1, first$1.offset, 'last', last$1);
|
|
2392
2400
|
var up = first$1.offset[axis] > last$1.offset[axis]; // _toPlanePolygons only works in the 'z' axis. It's hard coded
|
|
2393
2401
|
// to create the poly using 'x' and 'y'.
|
|
2394
2402
|
|
|
@@ -2487,19 +2495,21 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
2487
2495
|
function reShape(object, radius, orientation, options, slicer) {
|
|
2488
2496
|
options = options || {};
|
|
2489
2497
|
var b = object.getBounds();
|
|
2490
|
-
var
|
|
2498
|
+
var absoluteRadius = Math.abs(radius);
|
|
2491
2499
|
var si = sliceParams(orientation, radius, b);
|
|
2500
|
+
debug$1('reShape', absoluteRadius, si);
|
|
2492
2501
|
if (si.axis !== 'z') throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
|
|
2493
2502
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
|
|
2494
2503
|
var slice = object.sectionCut(cutplane);
|
|
2495
2504
|
var first = axisApply(si.axis, function () {
|
|
2496
|
-
return si.positive ? 0 :
|
|
2505
|
+
return si.positive ? 0 : absoluteRadius;
|
|
2497
2506
|
});
|
|
2498
2507
|
var last = axisApply(si.axis, function () {
|
|
2499
|
-
return si.positive ?
|
|
2508
|
+
return si.positive ? absoluteRadius : 0;
|
|
2500
2509
|
});
|
|
2501
2510
|
var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
|
|
2502
|
-
|
|
2511
|
+
debug$1('reShape first/last', first, last);
|
|
2512
|
+
var slices = slicer(first, last, slice, radius);
|
|
2503
2513
|
var delta = slices2poly(slices, Object.assign(options, {
|
|
2504
2514
|
si: si
|
|
2505
2515
|
}), si.axis).color(options.color);
|
|
@@ -2975,23 +2985,27 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
2975
2985
|
debug$3('Rabett', 'thickness', thickness, 'gap', gap, 'height', height, 'face', face);
|
|
2976
2986
|
gap = gap || 0.25;
|
|
2977
2987
|
var inside = thickness - gap;
|
|
2978
|
-
var outside = -thickness + gap;
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
debug
|
|
2988
|
+
var outside = -thickness + gap; // options.color = true;
|
|
2989
|
+
|
|
2990
|
+
debug$3('inside', inside, 'outside', outside);
|
|
2991
|
+
var group = Group(); // debug('Rabbet top height:', height, 'options:', options);
|
|
2992
|
+
|
|
2982
2993
|
var _box$bisect$parts = box.bisect('z', height, options).parts,
|
|
2983
2994
|
top = _box$bisect$parts.positive,
|
|
2984
|
-
lower2_3rd = _box$bisect$parts.negative;
|
|
2985
|
-
|
|
2986
|
-
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
2987
|
-
|
|
2995
|
+
lower2_3rd = _box$bisect$parts.negative; // debug('face', face, 'height', height);
|
|
2996
|
+
|
|
2997
|
+
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face; // debug('Rabbet bottom height:', lowerBisectHeight, 'options:', options);
|
|
2998
|
+
|
|
2988
2999
|
var _lower2_3rd$bisect$pa = lower2_3rd.bisect('z', lowerBisectHeight, options).parts,
|
|
2989
3000
|
middle = _lower2_3rd$bisect$pa.positive,
|
|
2990
3001
|
bottom = _lower2_3rd$bisect$pa.negative;
|
|
3002
|
+
var middleTop = middle.color('yellow').subtract(middle.color('darkred').enlarge([outside, outside, 0]));
|
|
2991
3003
|
group.add(top // .color('blue')
|
|
2992
|
-
.union(
|
|
2993
|
-
|
|
2994
|
-
group.add(
|
|
3004
|
+
.union(middleTop), 'top');
|
|
3005
|
+
var bottomOutline = middle.color('yellow').subtract(middle.color('orange').enlarge([outside, outside, 0])).enlarge([outside, outside, 0]);
|
|
3006
|
+
group.add(bottomOutline, 'middle-top', true);
|
|
3007
|
+
group.add(middle.color('green').subtract(middle.color('pink').enlarge([inside, inside, 0])), 'middle-bottom', true);
|
|
3008
|
+
group.add(bottom.color('orange').union(middle.color('green').subtract(middle.color('red').enlarge([inside, inside, 0])).subtract(middleTop)), 'bottom');
|
|
2995
3009
|
return group;
|
|
2996
3010
|
}
|
|
2997
3011
|
/**
|