@jwc/jscad-utils 5.0.2 → 5.1.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/compat.js CHANGED
@@ -43,6 +43,187 @@ function initJscadutils(_CSG, options = {}) {
43
43
  var jscadUtils = (function (exports, jsCadCSG, scadApi) {
44
44
  'use strict';
45
45
 
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);
50
+
51
+ var util = /*#__PURE__*/Object.freeze({
52
+ __proto__: null,
53
+ get NOZZEL_SIZE () { return NOZZEL_SIZE; },
54
+ get nearest () { return nearest; },
55
+ get identity () { return identity; },
56
+ get result () { return result; },
57
+ get defaults () { return defaults; },
58
+ get isEmpty () { return isEmpty; },
59
+ get isNegative () { return isNegative; },
60
+ get print () { return print; },
61
+ get jscadToString () { return jscadToString; },
62
+ get error () { return error; },
63
+ get depreciated () { return depreciated; },
64
+ get inch () { return inch; },
65
+ get cm () { return cm; },
66
+ get label () { return label; },
67
+ get text () { return text; },
68
+ get unitCube () { return unitCube; },
69
+ get unitAxis () { return unitAxis; },
70
+ get toArray () { return toArray; },
71
+ get ifArray () { return ifArray; },
72
+ get segment () { return segment; },
73
+ get zipObject () { return zipObject; },
74
+ get map () { return map; },
75
+ get mapValues () { return mapValues; },
76
+ get pick () { return pick; },
77
+ get mapPick () { return mapPick; },
78
+ get divA () { return divA; },
79
+ get divxyz () { return divxyz; },
80
+ get div () { return div; },
81
+ get mulxyz () { return mulxyz; },
82
+ get mul () { return mul; },
83
+ get xyz2array () { return xyz2array; },
84
+ get rotationAxes () { return rotationAxes; },
85
+ get size () { return size; },
86
+ get scale () { return scale; },
87
+ get center () { return center; },
88
+ get centerY () { return centerY; },
89
+ get centerX () { return centerX; },
90
+ get enlarge () { return enlarge; },
91
+ get fit () { return fit; },
92
+ get shift () { return shift; },
93
+ get zero () { return zero; },
94
+ get mirrored4 () { return mirrored4; },
95
+ get flushSide () { return flushSide; },
96
+ get calcFlush () { return calcFlush; },
97
+ get calcSnap () { return calcSnap; },
98
+ get snap () { return snap; },
99
+ get flush () { return flush; },
100
+ get axisApply () { return axisApply; },
101
+ get axis2array () { return axis2array; },
102
+ get centroid () { return centroid; },
103
+ get calcmidlineTo () { return calcmidlineTo; },
104
+ get midlineTo () { return midlineTo; },
105
+ get translator () { return translator; },
106
+ get calcCenterWith () { return calcCenterWith; },
107
+ get centerWith () { return centerWith; },
108
+ get getDelta () { return getDelta; },
109
+ get bisect () { return bisect; },
110
+ get slice () { return slice; },
111
+ get wedge () { return wedge; },
112
+ get stretch () { return stretch; },
113
+ get poly2solid () { return poly2solid; },
114
+ get slices2poly () { return slices2poly; },
115
+ get normalVector () { return normalVector; },
116
+ get sliceParams () { return sliceParams; },
117
+ get reShape () { return reShape; },
118
+ get chamfer () { return chamfer; },
119
+ get fillet () { return fillet; },
120
+ get calcRotate () { return calcRotate; },
121
+ get rotateAround () { return rotateAround; },
122
+ get clone () { return clone; },
123
+ get addConnector () { return addConnector; }
124
+ });
125
+
126
+ function _arrayLikeToArray(r, a) {
127
+ (null == a || a > r.length) && (a = r.length);
128
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
129
+ return n;
130
+ }
131
+ function _arrayWithHoles(r) {
132
+ if (Array.isArray(r)) return r;
133
+ }
134
+ function _defineProperty(e, r, t) {
135
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
136
+ value: t,
137
+ enumerable: !0,
138
+ configurable: !0,
139
+ writable: !0
140
+ }) : e[r] = t, e;
141
+ }
142
+ function _iterableToArrayLimit(r, l) {
143
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
144
+ if (null != t) {
145
+ var e,
146
+ n,
147
+ i,
148
+ u,
149
+ a = [],
150
+ f = !0,
151
+ o = !1;
152
+ try {
153
+ if (i = (t = t.call(r)).next, 0 === l) {
154
+ if (Object(t) !== t) return;
155
+ f = !1;
156
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
157
+ } catch (r) {
158
+ o = !0, n = r;
159
+ } finally {
160
+ try {
161
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
162
+ } finally {
163
+ if (o) throw n;
164
+ }
165
+ }
166
+ return a;
167
+ }
168
+ }
169
+ function _nonIterableRest() {
170
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
171
+ }
172
+ function ownKeys(e, r) {
173
+ var t = Object.keys(e);
174
+ if (Object.getOwnPropertySymbols) {
175
+ var o = Object.getOwnPropertySymbols(e);
176
+ r && (o = o.filter(function (r) {
177
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
178
+ })), t.push.apply(t, o);
179
+ }
180
+ return t;
181
+ }
182
+ function _objectSpread2(e) {
183
+ for (var r = 1; r < arguments.length; r++) {
184
+ var t = null != arguments[r] ? arguments[r] : {};
185
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
186
+ _defineProperty(e, r, t[r]);
187
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
188
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
189
+ });
190
+ }
191
+ return e;
192
+ }
193
+ function _slicedToArray(r, e) {
194
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
195
+ }
196
+ function _toPrimitive(t, r) {
197
+ if ("object" != typeof t || !t) return t;
198
+ var e = t[Symbol.toPrimitive];
199
+ if (void 0 !== e) {
200
+ var i = e.call(t, r || "default");
201
+ if ("object" != typeof i) return i;
202
+ throw new TypeError("@@toPrimitive must return a primitive value.");
203
+ }
204
+ return ("string" === r ? String : Number)(t);
205
+ }
206
+ function _toPropertyKey(t) {
207
+ var i = _toPrimitive(t, "string");
208
+ return "symbol" == typeof i ? i : i + "";
209
+ }
210
+ function _typeof(o) {
211
+ "@babel/helpers - typeof";
212
+
213
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
214
+ return typeof o;
215
+ } : function (o) {
216
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
217
+ }, _typeof(o);
218
+ }
219
+ function _unsupportedIterableToArray(r, a) {
220
+ if (r) {
221
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
222
+ var t = {}.toString.call(r).slice(8, -1);
223
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
224
+ }
225
+ }
226
+
46
227
  /** @module triangle */
47
228
 
48
229
  /**
@@ -50,7 +231,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
50
231
  * @param {Number} deg value in degrees
51
232
  * @return {Number} value in radians
52
233
  */
53
- const toRadians = function toRadians(deg) {
234
+ var toRadians = function toRadians(deg) {
54
235
  return deg / 180 * Math.PI;
55
236
  };
56
237
 
@@ -59,7 +240,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
59
240
  * @param {Number} rad value in radians
60
241
  * @return {Number} value in degrees
61
242
  */
62
- const toDegrees = function toDegrees(rad) {
243
+ var toDegrees = function toDegrees(rad) {
63
244
  return rad * (180 / Math.PI);
64
245
  };
65
246
 
@@ -71,7 +252,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
71
252
  * @param {Number} p2.y Point 2 y coordinate
72
253
  * @return {Object} A triangle object {A,B,C,a,b,c}
73
254
  */
74
- const solve = function (p1, p2) {
255
+ var solve = function solve(p1, p2) {
75
256
  var r = {
76
257
  c: 90,
77
258
  A: Math.abs(p2.x - p1.x),
@@ -113,7 +294,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
113
294
  * @param {Number} r.c Length of side `c`
114
295
  * @return {Object} A solved triangle object {A,B,C,a,b,c}
115
296
  */
116
- const solve90SA = function (r) {
297
+ var solve90SA = function solve90SA(r) {
117
298
  r = Object.assign(r, {
118
299
  C: 90
119
300
  });
@@ -134,7 +315,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
134
315
  r.b = r.b || r.a / Math.tan(arad);
135
316
  return r;
136
317
  };
137
- const solve90ac = function (r) {
318
+ var solve90ac = function solve90ac(r) {
138
319
  r = Object.assign(r, {
139
320
  C: 90
140
321
  });
@@ -191,12 +372,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
191
372
 
192
373
  var triUtils = /*#__PURE__*/Object.freeze({
193
374
  __proto__: null,
375
+ toRadians: toRadians,
376
+ toDegrees: toDegrees,
194
377
  solve: solve,
195
378
  solve90SA: solve90SA,
196
379
  solve90ac: solve90ac,
197
- solveab: solveab,
198
- toDegrees: toDegrees,
199
- toRadians: toRadians
380
+ solveab: solveab
200
381
  });
201
382
 
202
383
  /**
@@ -211,7 +392,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
211
392
  * @param {Number} f
212
393
  * @memberof! array
213
394
  */
214
- const div$1 = function (a, f) {
395
+ var div$1 = function div(a, f) {
215
396
  return a.map(function (e) {
216
397
  return e / f;
217
398
  });
@@ -224,7 +405,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
224
405
  * @param {Number} f A value to add to each element of the original array.
225
406
  * @return {Array} A new array with the values added together.
226
407
  */
227
- const addValue = function (a, f) {
408
+ var addValue = function addValue(a, f) {
228
409
  return a.map(function (e) {
229
410
  return e + f;
230
411
  });
@@ -238,7 +419,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
238
419
  * @param {Array} f Another array of numbers, if
239
420
  * @return {Array} A new array with the two values added together.
240
421
  */
241
- const addArray = function (a, f) {
422
+ var addArray = function addArray(a, f) {
242
423
  return a.map(function (e, i) {
243
424
  return e + f[i];
244
425
  });
@@ -250,7 +431,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
250
431
  * @param {Array} a An array of numbers .
251
432
  * @return {Array} A new array with the two values added together.
252
433
  */
253
- const add = function (a) {
434
+ var add = function add(a) {
254
435
  return Array.prototype.slice.call(arguments, 1).reduce(function (result, arg) {
255
436
  if (Array.isArray(arg)) {
256
437
  result = addArray(result, arg);
@@ -267,10 +448,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
267
448
  * @function fromxyz
268
449
  * @param {Object|Array} object
269
450
  */
270
- const fromxyz = function (object) {
451
+ var fromxyz = function fromxyz(object) {
271
452
  return Array.isArray(object) ? object : [object.x, object.y, object.z];
272
453
  };
273
- const toxyz = function (a) {
454
+ var toxyz = function toxyz(a) {
274
455
  return {
275
456
  x: a[0],
276
457
  y: a[1],
@@ -284,7 +465,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
284
465
  * @param {Array} a An array of numbers.
285
466
  * @return {Number} The value of the first element of the array or undefined.
286
467
  */
287
- const first = function (a) {
468
+ var first = function first(a) {
288
469
  return a ? a[0] : undefined;
289
470
  };
290
471
 
@@ -293,7 +474,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
293
474
  * @param {Array} a An array of numbers.
294
475
  * @return {Number} The value of the last element of the array or undefined.
295
476
  */
296
- const last = function (a) {
477
+ var last = function last(a) {
297
478
  return a && a.length > 0 ? a[a.length - 1] : undefined;
298
479
  };
299
480
 
@@ -303,7 +484,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
303
484
  * @param {Array} a An array of numbers.
304
485
  * @return {Number} The minimum value in an array of numbers.
305
486
  */
306
- const min = function (a) {
487
+ var min = function min(a) {
307
488
  return a.reduce(function (result, value) {
308
489
  return value < result ? value : result;
309
490
  }, Number.MAX_VALUE);
@@ -316,7 +497,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
316
497
  * @param {Number} b The ending value.
317
498
  * @return {Array} An array of values from `a` to `b`.
318
499
  */
319
- const range = function (a, b) {
500
+ var range = function range(a, b) {
320
501
  var result = [];
321
502
  for (var i = a; i < b; i++) {
322
503
  result.push(i);
@@ -326,22 +507,22 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
326
507
 
327
508
  var array = /*#__PURE__*/Object.freeze({
328
509
  __proto__: null,
329
- add: add,
330
- addArray: addArray,
331
- addValue: addValue,
332
510
  div: div$1,
333
- first: first,
511
+ addValue: addValue,
512
+ addArray: addArray,
513
+ add: add,
334
514
  fromxyz: fromxyz,
515
+ toxyz: toxyz,
516
+ first: first,
335
517
  last: last,
336
518
  min: min,
337
- range: range,
338
- toxyz: toxyz
519
+ range: range
339
520
  });
340
521
 
341
522
  /* globals jscadUtilsDebug */
342
523
 
343
- const debugColors = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'];
344
- const termColors = ['\\033[0;34m', '\\033[0;32m', '\\033[0;36m', '\\033[0;31m', '\\033[0;35m', '\\033[0;33m', '\\033[1;33m', '\\033[0;30m', '\\033[1;34m'];
524
+ var debugColors = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'];
525
+ var termColors = ['\\033[0;34m', '\\033[0;32m', '\\033[0;36m', '\\033[0;31m', '\\033[0;35m', '\\033[0;33m', '\\033[1;33m', '\\033[0;30m', '\\033[1;34m'];
345
526
  var debugCount = 0;
346
527
 
347
528
  /**
@@ -362,7 +543,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
362
543
  * @param {String} name The name of the debug function.
363
544
  * @return {Function} A debug function if enabled otherwise an empty function.
364
545
  */
365
- const Debug = function (name) {
546
+ var Debug = function Debug(name) {
366
547
  var checks = Object.assign({
367
548
  enabled: [],
368
549
  disabled: [],
@@ -370,17 +551,27 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
370
551
  browser: true
371
552
  }
372
553
  }, jscadUtilsDebug || {});
373
- var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
554
+ var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
374
555
  var enabled = checks.enabled.some(function checkEnabled(check) {
375
556
  return check.test(name);
376
557
  }) && !checks.disabled.some(function checkEnabled(check) {
377
558
  return check.test(name);
378
559
  });
379
- var logger = enabled ? checks.options.browser ? (...msg) => {
380
- console.log('%c%s', style, name, ...msg);
381
- } : (...msg) => {
382
- console.log(`${name}`, ...msg);
383
- } : () => undefined;
560
+ var logger = enabled ? checks.options.browser ? function () {
561
+ var _console;
562
+ for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
563
+ msg[_key] = arguments[_key];
564
+ }
565
+ (_console = console).log.apply(_console, ['%c%s', style, name].concat(msg));
566
+ } : function () {
567
+ var _console2;
568
+ for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
569
+ msg[_key2] = arguments[_key2];
570
+ }
571
+ (_console2 = console).log.apply(_console2, ["".concat(name)].concat(msg));
572
+ } : function () {
573
+ return undefined;
574
+ };
384
575
  logger.enabled = enabled;
385
576
  return logger;
386
577
  };
@@ -403,7 +594,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
403
594
  *}
404
595
  * @type {Record<ColorName, string>}
405
596
  */
406
- const nameArray = {
597
+ var nameArray = {
407
598
  aliceblue: '#f0f8ff',
408
599
  antiquewhite: '#faebd7',
409
600
  aqua: '#00ffff',
@@ -581,7 +772,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
581
772
  /**
582
773
  * @type {Record<ColorName, number[]>}
583
774
  */
584
- const _name2rgb = {};
775
+ var _name2rgb = {};
585
776
 
586
777
  /**
587
778
  * Converts a css color name to an rgb array.
@@ -685,7 +876,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
685
876
  * @property {function} getConnector
686
877
  */
687
878
 
688
-
689
879
  /**
690
880
  * Initialize `jscad-utils` and add utilities to the `proto` object.
691
881
  * @param {CSG} proto The global `proto` object
@@ -768,14 +958,23 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
768
958
  proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
769
959
  return chamfer(this, radius, orientation, options);
770
960
  };
771
- proto.prototype.bisect = function bisect$1(...args) {
772
- return bisect(this, ...args);
961
+ proto.prototype.bisect = function bisect$1() {
962
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
963
+ args[_key] = arguments[_key];
964
+ }
965
+ return bisect.apply(util, [this].concat(args));
773
966
  };
774
- proto.prototype.slice = function slice$1(...args) {
775
- return slice(this, ...args);
967
+ proto.prototype.slice = function slice$1() {
968
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
969
+ args[_key2] = arguments[_key2];
970
+ }
971
+ return slice.apply(util, [this].concat(args));
776
972
  };
777
- proto.prototype.wedge = function wedge$1(...args) {
778
- return wedge(this, ...args);
973
+ proto.prototype.wedge = function wedge$1() {
974
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
975
+ args[_key3] = arguments[_key3];
976
+ }
977
+ return wedge.apply(util, [this].concat(args));
779
978
  };
780
979
  proto.prototype.stretch = function stretch$1(axis, distance, offset) {
781
980
  return stretch(this, axis, distance, offset);
@@ -801,7 +1000,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
801
1000
  } else {
802
1001
  var t = Array.prototype.slice.call(arguments, 0).reduce(function (result, arg) {
803
1002
  // console.log('arg', arg);
804
- result = undefined.addArray(result, arg);
1003
+ result = undefined(result, arg);
805
1004
  return result;
806
1005
  }, [0, 0, 0]);
807
1006
 
@@ -812,8 +1011,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
812
1011
  proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
813
1012
  return addConnector(this, name, point, axis, normal);
814
1013
  };
815
- proto.prototype.connect = function connectTo(myConnectorName, otherConnector, mirror = false, normalrotation = 0) {
816
- var myConnector = myConnectorName.split('.').reduce((a, v) => {
1014
+ proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
1015
+ var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1016
+ var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1017
+ var myConnector = myConnectorName.split('.').reduce(function (a, v) {
817
1018
  return a[v];
818
1019
  }, this.properties);
819
1020
 
@@ -821,7 +1022,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
821
1022
  * Check for missing property.
822
1023
  */
823
1024
  if (!myConnector) {
824
- error(`The connector '${myConnectorName}' does not exist on the object [${Object.keys(this.properties).join(',')}]`, 'Missing connector property');
1025
+ error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(','), "]"), 'Missing connector property');
825
1026
  }
826
1027
  return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
827
1028
  };
@@ -832,26 +1033,19 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
832
1033
 
833
1034
  var init$1 = /*#__PURE__*/Object.freeze({
834
1035
  __proto__: null,
835
- default: init
1036
+ 'default': init
836
1037
  });
837
1038
 
838
- const {
839
- CSG,
840
- CAG
841
- } = jsCadCSG;
842
- const {
843
- rectangular_extrude
844
- } = scadApi.extrusions;
845
- const {
846
- vector_text,
847
- vector_char
848
- } = scadApi.text;
849
- const {
850
- union
851
- } = scadApi.booleanOps;
1039
+ var CSG = jsCadCSG__default["default"].CSG,
1040
+ CAG = jsCadCSG__default["default"].CAG;
1041
+ var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
1042
+ var _scadApi$text = scadApi__default["default"].text,
1043
+ vector_text = _scadApi$text.vector_text,
1044
+ vector_char = _scadApi$text.vector_char;
1045
+ var union = scadApi__default["default"].booleanOps.union;
852
1046
  init(CSG);
853
1047
 
854
- const debug$3 = Debug('jscadUtils:group');
1048
+ var debug$3 = Debug('jscadUtils:group');
855
1049
 
856
1050
  /**
857
1051
  * @function JsCadUtilsGroup
@@ -860,7 +1054,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
860
1054
  * @param {CSG[]} holes An array of CSG objects that will be subtracted after combination.
861
1055
  * @namespace JsCadUtilsGroup
862
1056
  */
863
- function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
1057
+ function JsCadUtilsGroup() {
1058
+ var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1059
+ var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1060
+ var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
864
1061
  this.name = '';
865
1062
  this.names = names;
866
1063
  this.parts = parts;
@@ -908,7 +1105,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
908
1105
  * @param {Function} map A function that is run before unioning the parts together.
909
1106
  * @return {CSG} A single `CSG` object of the unioned parts.
910
1107
  */
911
- JsCadUtilsGroup.prototype.combine = function (pieces, options = {}, map = x => x) {
1108
+ JsCadUtilsGroup.prototype.combine = function (pieces) {
1109
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1110
+ var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) {
1111
+ return x;
1112
+ };
912
1113
  try {
913
1114
  var self = this;
914
1115
  options = Object.assign({
@@ -916,7 +1117,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
916
1117
  }, options);
917
1118
  pieces = pieces ? pieces.split(',') : self.names;
918
1119
  if (pieces.length === 0) {
919
- throw new Error(`no pieces found in ${self.name} pieces: ${pieces} parts: ${Object.keys(self.parts)} names: ${self.names}`);
1120
+ throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
920
1121
  }
921
1122
  debug$3('combine', self.names, self.parts);
922
1123
  var g = union(mapPick(self.parts, pieces, function (value, key, index, object) {
@@ -926,12 +1127,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
926
1127
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
927
1128
  } catch (err) {
928
1129
  debug$3('combine error', this, pieces, options, err);
929
- throw error(`group::combine error "${err.message || err.toString()}"
930
- this: ${this}
931
- pieces: "${pieces}"
932
- options: ${JSON.stringify(options, null, 2)}
933
- stack: ${err.stack}
934
- `, 'JSCAD_UTILS_GROUP_ERROR');
1130
+ throw error("group::combine error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npieces: \"").concat(pieces, "\"\noptions: ").concat(JSON.stringify(options, null, 2), "\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
935
1131
  }
936
1132
  };
937
1133
 
@@ -944,7 +1140,9 @@ stack: ${err.stack}
944
1140
  */
945
1141
  JsCadUtilsGroup.prototype.map = function (cb) {
946
1142
  var self = this;
947
- self.parts = Object.keys(self.parts).filter(k => k !== 'holes').reduce(function (result, key) {
1143
+ self.parts = Object.keys(self.parts).filter(function (k) {
1144
+ return k !== 'holes';
1145
+ }).reduce(function (result, key) {
948
1146
  result[key] = cb(self.parts[key], key);
949
1147
  return result;
950
1148
  }, {});
@@ -968,7 +1166,7 @@ stack: ${err.stack}
968
1166
  * @return {JsCadUtilsGroup} The new group.
969
1167
  */
970
1168
  JsCadUtilsGroup.prototype.clone = function (name, map) {
971
- debug$3('clone', name, typeof name, map);
1169
+ debug$3('clone', name, _typeof(name), map);
972
1170
  var self = this;
973
1171
  /**
974
1172
  * For backwards compatibility
@@ -1055,15 +1253,7 @@ stack: ${err.stack}
1055
1253
  return self;
1056
1254
  } catch (err) {
1057
1255
  debug$3('snap error', this, part, to, axis, delta, err);
1058
- throw error(`group::snap error "${err.message || err.toString()}"
1059
- this: ${this}
1060
- part: "${part}"
1061
- to: ${to}
1062
- axis: "${axis}"
1063
- orientation: "${orientation}"
1064
- delta: "${delta}"
1065
- stack: ${err.stack}
1066
- `, 'JSCAD_UTILS_GROUP_ERROR');
1256
+ throw error("group::snap error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npart: \"").concat(part, "\"\nto: ").concat(to, "\naxis: \"").concat(axis, "\"\norientation: \"").concat(orientation, "\"\ndelta: \"").concat(delta, "\"\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
1067
1257
  }
1068
1258
  };
1069
1259
 
@@ -1095,14 +1285,7 @@ stack: ${err.stack}
1095
1285
  return self;
1096
1286
  } catch (err) {
1097
1287
  debug$3('align error', this, part, to, axis, delta, err);
1098
- throw error(`group::align error "${err.message || err.toString()}"
1099
- this: ${this}
1100
- part: "${part}"
1101
- to: ${to}
1102
- axis: "${axis}"
1103
- delta: "${delta}"
1104
- stack: ${err.stack}
1105
- `, 'JSCAD_UTILS_GROUP_ERROR');
1288
+ throw error("group::align error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npart: \"").concat(part, "\"\nto: ").concat(to, "\naxis: \"").concat(axis, "\"\ndelta: \"").concat(delta, "\"\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
1106
1289
  }
1107
1290
  };
1108
1291
  JsCadUtilsGroup.prototype.center = function center(part) {
@@ -1114,21 +1297,23 @@ stack: ${err.stack}
1114
1297
  var bounds = self.parts[part].getBounds();
1115
1298
  return self.translate([0, 0, -bounds[0].z]);
1116
1299
  };
1117
- JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
1300
+ JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
1301
+ var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1302
+ var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
1118
1303
  debug$3('connectTo', {
1119
- partName,
1120
- connectorName,
1121
- to,
1122
- toConnectorName,
1123
- mirror,
1124
- normalrotation
1304
+ partName: partName,
1305
+ connectorName: connectorName,
1306
+ to: to,
1307
+ toConnectorName: toConnectorName,
1308
+ mirror: mirror,
1309
+ normalrotation: normalrotation
1125
1310
  });
1126
1311
  var self = this;
1127
- var myConnector = connectorName.split('.').reduce((a, v) => {
1312
+ var myConnector = connectorName.split('.').reduce(function (a, v) {
1128
1313
  return a[v];
1129
1314
  }, self.parts[partName].properties);
1130
1315
  debug$3('toConnector', to instanceof CSG.Connector);
1131
- var toConnector = toConnectorName.split('.').reduce((a, v) => {
1316
+ var toConnector = toConnectorName.split('.').reduce(function (a, v) {
1132
1317
  return a[v];
1133
1318
  }, to.properties);
1134
1319
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
@@ -1216,18 +1401,16 @@ stack: ${err.stack}
1216
1401
  * @return {Array} An array of `CSG` objects
1217
1402
  */
1218
1403
  JsCadUtilsGroup.prototype.array = function (parts, map) {
1404
+ var _this = this;
1219
1405
  var self = this;
1220
1406
  // try {
1221
1407
  var p = parts && parts.length > 0 && parts.split(',') || self.names;
1222
1408
  if (!map) map = identity;
1223
1409
  var a = [];
1224
- p.forEach(name => {
1410
+ p.forEach(function (name) {
1225
1411
  if (!self.parts[name]) {
1226
- debug$3('array error', this, parts);
1227
- throw error(`group::array error "${name}" not found.
1228
- this: ${this}
1229
- parts: "${parts}"
1230
- `, 'JSCAD_UTILS_GROUP_ERROR');
1412
+ debug$3('array error', _this, parts);
1413
+ throw error("group::array error \"".concat(name, "\" not found.\nthis: ").concat(_this, "\nparts: \"").concat(parts, "\"\n"), 'JSCAD_UTILS_GROUP_ERROR');
1231
1414
  }
1232
1415
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1233
1416
  });
@@ -1257,17 +1440,12 @@ parts: "${parts}"
1257
1440
  var self = this;
1258
1441
  var piecesArray = pieces ? pieces.split(',') : self.names;
1259
1442
  return piecesArray.map(function (piece) {
1260
- if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
1443
+ if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
1261
1444
  return self.parts[piece];
1262
1445
  });
1263
1446
  };
1264
1447
  JsCadUtilsGroup.prototype.toString = function () {
1265
- return `{
1266
- name: "${this.name}",
1267
- names: "${this.names.join(',')}",
1268
- parts: "${Object.keys(this.parts)}",
1269
- holes: ${Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0}
1270
- }`;
1448
+ return "{\n name: \"".concat(this.name, "\",\n names: \"").concat(this.names.join(','), "\", \n parts: \"").concat(Object.keys(this.parts), "\",\n holes: ").concat(Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0, "\n}");
1271
1449
  };
1272
1450
  JsCadUtilsGroup.prototype.setName = function (name) {
1273
1451
  this.name = name;
@@ -1316,7 +1494,9 @@ parts: "${parts}"
1316
1494
  self.name = objectNames;
1317
1495
  } else {
1318
1496
  var objects = objectNames; // eslint-disable-line no-redeclare
1319
- self.names = Object.keys(objects).filter(k => k !== 'holes');
1497
+ self.names = Object.keys(objects).filter(function (k) {
1498
+ return k !== 'holes';
1499
+ });
1320
1500
  self.parts = Object.assign({}, objects);
1321
1501
  self.holes = objects.holes;
1322
1502
  }
@@ -1325,15 +1505,13 @@ parts: "${parts}"
1325
1505
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1326
1506
  }
1327
1507
 
1328
- /** @typedef { import('@jscad/csg').CSG } CSG */
1329
-
1330
- const debug$2 = Debug('jscadUtils:util');
1508
+ var debug$2 = Debug('jscadUtils:util');
1331
1509
  // import utilInit from '../src/add-prototype';
1332
1510
  // utilInit(CSG);
1333
1511
  // console.trace('CSG', CSG.prototype);
1334
1512
 
1335
1513
  var NOZZEL_SIZE = 0.4;
1336
- const nearest = {
1514
+ var nearest = {
1337
1515
  /**
1338
1516
  * Return the largest number that is a multiple of the
1339
1517
  * nozzel size.
@@ -1342,7 +1520,9 @@ parts: "${parts}"
1342
1520
  * @param {Number} [nozzie=0] Number of nozzel sizes to add to the value
1343
1521
  * @return {Number} Multiple of nozzel size
1344
1522
  */
1345
- under: function (desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1523
+ under: function under(desired) {
1524
+ var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1525
+ var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1346
1526
  return (Math.floor(desired / nozzel) + nozzie) * nozzel;
1347
1527
  },
1348
1528
  /**
@@ -1353,7 +1533,9 @@ parts: "${parts}"
1353
1533
  * @param {Number} [nozzie=0] Number of nozzel sizes to add to the value
1354
1534
  * @return {Number} Multiple of nozzel size
1355
1535
  */
1356
- over: function (desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1536
+ over: function over(desired) {
1537
+ var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1538
+ var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1357
1539
  return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
1358
1540
  }
1359
1541
  };
@@ -1419,14 +1601,10 @@ parts: "${parts}"
1419
1601
  debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1420
1602
  }
1421
1603
  function jscadToString(o) {
1422
- if (typeof o == 'object') {
1604
+ if (_typeof(o) == 'object') {
1423
1605
  if (o.polygons) {
1424
1606
  // is this CSG like?
1425
- return `{
1426
- polygons: ${o.polygons.length},
1427
- properties: "${Object.keys(o.properties)}"
1428
- }
1429
- `;
1607
+ return "{\npolygons: ".concat(o.polygons.length, ",\nproperties: \"").concat(Object.keys(o.properties), "\"\n}\n");
1430
1608
  }
1431
1609
  } else {
1432
1610
  return o.toString();
@@ -1495,13 +1673,13 @@ properties: "${Object.keys(o.properties)}"
1495
1673
  }
1496
1674
  function text(text) {
1497
1675
  var l = vector_char(0, 0, text); // l contains a list of polylines to draw
1498
- var char = l.segments.reduce(function (result, segment) {
1676
+ var _char = l.segments.reduce(function (result, segment) {
1499
1677
  var path = new CSG.Path2D(segment);
1500
1678
  var cag = path.expandToCAG(2);
1501
1679
  // debug('reduce', result, segment, path, cag);
1502
1680
  return result ? result.union(cag) : cag;
1503
1681
  }, undefined);
1504
- return char;
1682
+ return _char;
1505
1683
  }
1506
1684
  function unitCube(length, radius) {
1507
1685
  radius = radius || 0.5;
@@ -1574,7 +1752,7 @@ properties: "${Object.keys(o.properties)}"
1574
1752
  function mapPick(o, names, f, options) {
1575
1753
  return names.reduce(function (result, name, index) {
1576
1754
  if (!o[name]) {
1577
- throw new Error(`${name} not found in ${options.name}: ${Object.keys(o).join(',')}`);
1755
+ throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(',')));
1578
1756
  }
1579
1757
  result.push(f ? f(o[name], name, index, o) : o[name]);
1580
1758
  return result;
@@ -1606,7 +1784,7 @@ properties: "${Object.keys(o.properties)}"
1606
1784
  function xyz2array(size) {
1607
1785
  return [size.x, size.y, size.z];
1608
1786
  }
1609
- const rotationAxes = {
1787
+ var rotationAxes = {
1610
1788
  x: [1, 0, 0],
1611
1789
  y: [0, 1, 0],
1612
1790
  z: [0, 0, 1]
@@ -1727,7 +1905,7 @@ properties: "${Object.keys(o.properties)}"
1727
1905
  function mirrored4(x) {
1728
1906
  return x.union([x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90)]);
1729
1907
  }
1730
- const flushSide = {
1908
+ var flushSide = {
1731
1909
  'above-outside': [1, 0],
1732
1910
  'above-inside': [1, 1],
1733
1911
  'below-outside': [0, 1],
@@ -1760,7 +1938,8 @@ properties: "${Object.keys(o.properties)}"
1760
1938
  return w[side[0]][axis] - m[side[1]][axis];
1761
1939
  });
1762
1940
  }
1763
- function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
1941
+ function calcSnap(moveobj, withobj, axes, orientation) {
1942
+ var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1764
1943
  var side = flushSide[orientation];
1765
1944
  if (!side) {
1766
1945
  var fix = {
@@ -1838,7 +2017,7 @@ properties: "${Object.keys(o.properties)}"
1838
2017
  objectSize = objectSize || size(bounds);
1839
2018
  return bounds[0].plus(objectSize.dividedBy(2));
1840
2019
  } catch (err) {
1841
- error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
2020
+ error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
1842
2021
  }
1843
2022
  }
1844
2023
 
@@ -1871,7 +2050,8 @@ properties: "${Object.keys(o.properties)}"
1871
2050
  });
1872
2051
  return t;
1873
2052
  }
1874
- function calcCenterWith(o, axes, withObj, delta = 0) {
2053
+ function calcCenterWith(o, axes, withObj) {
2054
+ var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1875
2055
  var objectCentroid = centroid(o);
1876
2056
  var withCentroid = centroid(withObj);
1877
2057
  var t = axisApply(axes, function (i, axis) {
@@ -1933,7 +2113,10 @@ properties: "${Object.keys(o.properties)}"
1933
2113
  * @param {CSG.Vector3D} [options.rotationCenter]
1934
2114
  * @return {JsCadUtilsGroup} Returns a group object with a parts object.
1935
2115
  */
1936
- function bisect(...args) {
2116
+ function bisect() {
2117
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2118
+ args[_key] = arguments[_key];
2119
+ }
1937
2120
  if (args.length < 2) {
1938
2121
  error('bisect requires an object and an axis', 'JSCAD_UTILS_INVALID_ARGS');
1939
2122
  }
@@ -2003,16 +2186,16 @@ properties: "${Object.keys(o.properties)}"
2003
2186
  var theRotationAxis = rotationAxes[rotateaxis];
2004
2187
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
2005
2188
  debug$2('bisect', debug$2.enabled && {
2006
- axis,
2007
- offset,
2008
- angle,
2009
- rotateaxis,
2010
- cutDelta,
2011
- rotateOffsetAxis,
2012
- rotationCenter,
2013
- theRotationAxis,
2014
- cutplane,
2015
- options
2189
+ axis: axis,
2190
+ offset: offset,
2191
+ angle: angle,
2192
+ rotateaxis: rotateaxis,
2193
+ cutDelta: cutDelta,
2194
+ rotateOffsetAxis: rotateOffsetAxis,
2195
+ rotationCenter: rotationCenter,
2196
+ theRotationAxis: theRotationAxis,
2197
+ cutplane: cutplane,
2198
+ options: options
2016
2199
  });
2017
2200
  var g = Group('negative,positive', [object.cutByPlane(cutplane.plane).color(options.color && 'red'), object.cutByPlane(cutplane.plane.flipped()).color(options.color && 'blue')]);
2018
2201
  if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, 0.1, rotationCenter), 'rotationCenter');
@@ -2030,10 +2213,14 @@ properties: "${Object.keys(o.properties)}"
2030
2213
  * @param {CSG.Vector3D} [options.rotationCenter] The location of the rotation center, defaults to [0,0,0].
2031
2214
  * @return {JsCadUtilsGroup} A group with a positive and negative CSG object.
2032
2215
  */
2033
- function slice(object, angle = 15, axis = 'x', rotateaxis = 'z', options = {
2034
- color: true,
2035
- addRotationCenter: true
2036
- }) {
2216
+ function slice(object) {
2217
+ var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
2218
+ var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'x';
2219
+ var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'z';
2220
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
2221
+ color: true,
2222
+ addRotationCenter: true
2223
+ };
2037
2224
  var info = normalVector(axis);
2038
2225
  var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
2039
2226
  var theRotationAxis = rotationAxes[rotateaxis];
@@ -2330,19 +2517,21 @@ properties: "${Object.keys(o.properties)}"
2330
2517
  var rotationCenter = solid.centroid();
2331
2518
  var rotationAxis = axes[axis];
2332
2519
  return {
2333
- rotationCenter,
2334
- rotationAxis
2520
+ rotationCenter: rotationCenter,
2521
+ rotationAxis: rotationAxis
2335
2522
  };
2336
2523
  }
2337
2524
  function rotateAround(part, solid, axis, angle) {
2338
- var {
2339
- rotationCenter,
2340
- rotationAxis
2341
- } = calcRotate(part, solid, axis);
2525
+ var _calcRotate = calcRotate(part, solid, axis),
2526
+ rotationCenter = _calcRotate.rotationCenter,
2527
+ rotationAxis = _calcRotate.rotationAxis;
2342
2528
  return part.rotate(rotationCenter, rotationAxis, angle);
2343
2529
  }
2344
- function cloneProperties(from, to, depth = 0) {
2345
- return Object.entries(from).reduce((props, [key, value]) => {
2530
+ function cloneProperties(from, to) {
2531
+ return Object.entries(from).reduce(function (props, _ref) {
2532
+ var _ref2 = _slicedToArray(_ref, 2),
2533
+ key = _ref2[0],
2534
+ value = _ref2[1];
2346
2535
  props[key] = value;
2347
2536
  return props;
2348
2537
  }, to);
@@ -2363,93 +2552,21 @@ properties: "${Object.keys(o.properties)}"
2363
2552
  * @param {Array} point=[0,0,0] a 3 axis array direction vector somewhat perpendicular to axis; this defines the “12 o'clock” orientation of the connection.
2364
2553
  * @return {CSG} The CSG object with the new connector added.
2365
2554
  */
2366
- function addConnector(object, name, point = [0, 0, 0], axis = [1, 0, 0], normal = [0, 0, 1]) {
2555
+ function addConnector(object, name) {
2556
+ var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0];
2557
+ var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [1, 0, 0];
2558
+ var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [0, 0, 1];
2367
2559
  object.properties[name] = new CSG.Connector(point, axis, normal);
2368
2560
  return object;
2369
2561
  }
2370
2562
 
2371
- var util = /*#__PURE__*/Object.freeze({
2372
- __proto__: null,
2373
- NOZZEL_SIZE: NOZZEL_SIZE,
2374
- addConnector: addConnector,
2375
- axis2array: axis2array,
2376
- axisApply: axisApply,
2377
- bisect: bisect,
2378
- calcCenterWith: calcCenterWith,
2379
- calcFlush: calcFlush,
2380
- calcRotate: calcRotate,
2381
- calcSnap: calcSnap,
2382
- calcmidlineTo: calcmidlineTo,
2383
- center: center,
2384
- centerWith: centerWith,
2385
- centerX: centerX,
2386
- centerY: centerY,
2387
- centroid: centroid,
2388
- chamfer: chamfer,
2389
- clone: clone,
2390
- cm: cm,
2391
- defaults: defaults,
2392
- depreciated: depreciated,
2393
- div: div,
2394
- divA: divA,
2395
- divxyz: divxyz,
2396
- enlarge: enlarge,
2397
- error: error,
2398
- fillet: fillet,
2399
- fit: fit,
2400
- flush: flush,
2401
- flushSide: flushSide,
2402
- getDelta: getDelta,
2403
- identity: identity,
2404
- ifArray: ifArray,
2405
- inch: inch,
2406
- isEmpty: isEmpty,
2407
- isNegative: isNegative,
2408
- jscadToString: jscadToString,
2409
- label: label,
2410
- map: map,
2411
- mapPick: mapPick,
2412
- mapValues: mapValues,
2413
- midlineTo: midlineTo,
2414
- mirrored4: mirrored4,
2415
- mul: mul,
2416
- mulxyz: mulxyz,
2417
- nearest: nearest,
2418
- normalVector: normalVector,
2419
- pick: pick,
2420
- poly2solid: poly2solid,
2421
- print: print,
2422
- reShape: reShape,
2423
- result: result,
2424
- rotateAround: rotateAround,
2425
- rotationAxes: rotationAxes,
2426
- scale: scale,
2427
- segment: segment,
2428
- shift: shift,
2429
- size: size,
2430
- slice: slice,
2431
- sliceParams: sliceParams,
2432
- slices2poly: slices2poly,
2433
- snap: snap,
2434
- stretch: stretch,
2435
- text: text,
2436
- toArray: toArray,
2437
- translator: translator,
2438
- unitAxis: unitAxis,
2439
- unitCube: unitCube,
2440
- wedge: wedge,
2441
- xyz2array: xyz2array,
2442
- zero: zero,
2443
- zipObject: zipObject
2444
- });
2445
-
2446
- const debug$1 = Debug('jscadUtils:parts');
2563
+ var debug$1 = Debug('jscadUtils:parts');
2447
2564
  var parts = {
2448
2565
  BBox: BBox$1,
2449
- Cube,
2450
- RoundedCube,
2451
- Cylinder,
2452
- Cone
2566
+ Cube: Cube,
2567
+ RoundedCube: RoundedCube,
2568
+ Cylinder: Cylinder,
2569
+ Cone: Cone
2453
2570
  };
2454
2571
 
2455
2572
  /**
@@ -2459,13 +2576,16 @@ properties: "${Object.keys(o.properties)}"
2459
2576
  * @param {CSG} ...objects Any number of CSG objects to create a bounding box for.
2460
2577
  * @return {CSG} A box with the size of the extents of all of the passed in objects
2461
2578
  */
2462
- function BBox$1(...objects) {
2579
+ function BBox$1() {
2463
2580
  function box(object) {
2464
2581
  return CSG.cube({
2465
2582
  center: object.centroid(),
2466
2583
  radius: object.size().dividedBy(2)
2467
2584
  });
2468
2585
  }
2586
+ for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
2587
+ objects[_key] = arguments[_key];
2588
+ }
2469
2589
  return objects.reduce(function (bbox, part) {
2470
2590
  var object = bbox ? union([bbox, box(part)]) : part;
2471
2591
  return box(object);
@@ -2525,7 +2645,8 @@ properties: "${Object.keys(o.properties)}"
2525
2645
  * @param {number} [options.resolution] The number of segments to create in 360 degrees of rotation.
2526
2646
  * @return {CSG} A CSG Cylinder
2527
2647
  */
2528
- function Cylinder(diameter, height, options = {}) {
2648
+ function Cylinder(diameter, height) {
2649
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2529
2650
  debug$1('parts.Cylinder', diameter, height, options);
2530
2651
  options = Object.assign({
2531
2652
  start: [0, 0, 0],
@@ -2545,7 +2666,8 @@ properties: "${Object.keys(o.properties)}"
2545
2666
  * @param {Object} options Additional options passed to `CSG.cylinder`.
2546
2667
  * @return {CSG} A CSG cone object.
2547
2668
  */
2548
- function Cone(diameter1, diameter2, height, options = {}) {
2669
+ function Cone(diameter1, diameter2, height) {
2670
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2549
2671
  debug$1('parts.Cone', diameter1, diameter2, height, options);
2550
2672
  return CSG.cylinder(Object.assign({
2551
2673
  start: [0, 0, 0],
@@ -2606,12 +2728,14 @@ properties: "${Object.keys(o.properties)}"
2606
2728
  * @param {Number} width
2607
2729
  * @param {Number} height
2608
2730
  */
2609
- function Anchor(width = 10, height = 10) {
2731
+ function Anchor() {
2732
+ var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
2733
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
2610
2734
  var hole = Cylinder(width, height).Center().color('red');
2611
2735
  var post = Cylinder(height / 2, width * 0.66).rotateX(90).align(hole, 'xz').snap(hole, 'y', 'inside-').translate([0, 0, -height / 6]).color('purple');
2612
2736
  return Group({
2613
- post,
2614
- hole
2737
+ post: post,
2738
+ hole: hole
2615
2739
  });
2616
2740
  }
2617
2741
  function Board(width, height, corner_radius, thickness) {
@@ -2626,7 +2750,7 @@ properties: "${Object.keys(o.properties)}"
2626
2750
  });
2627
2751
  return board;
2628
2752
  }
2629
- const Hardware = {
2753
+ var Hardware = {
2630
2754
  Orientation: {
2631
2755
  up: {
2632
2756
  head: 'outside-',
@@ -2637,7 +2761,7 @@ properties: "${Object.keys(o.properties)}"
2637
2761
  clear: 'inside-'
2638
2762
  }
2639
2763
  },
2640
- Screw: function (head, thread, headClearSpace, options) {
2764
+ Screw: function Screw(head, thread, headClearSpace, options) {
2641
2765
  depreciated('Screw', false, 'Use the jscad-hardware screw methods instead');
2642
2766
  options = Object.assign(options, {
2643
2767
  orientation: 'up',
@@ -2662,7 +2786,7 @@ properties: "${Object.keys(o.properties)}"
2662
2786
  * @param {number} clearLength Length of the clearance section of the head.
2663
2787
  * @param {object} options Screw options include orientation and clerance scale.
2664
2788
  */
2665
- PanHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
2789
+ PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
2666
2790
  depreciated('PanHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2667
2791
  var head = Cylinder(headDiameter, headLength);
2668
2792
  var thread = Cylinder(diameter, length);
@@ -2680,7 +2804,7 @@ properties: "${Object.keys(o.properties)}"
2680
2804
  * @param {number} clearLength Length of the clearance section of the head.
2681
2805
  * @param {object} options Screw options include orientation and clerance scale.
2682
2806
  */
2683
- HexHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
2807
+ HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
2684
2808
  depreciated('HexHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2685
2809
  var head = Hexagon(headDiameter, headLength);
2686
2810
  var thread = Cylinder(diameter, length);
@@ -2698,7 +2822,7 @@ properties: "${Object.keys(o.properties)}"
2698
2822
  * @param {number} clearLength clearance length
2699
2823
  * @param {object} options options
2700
2824
  */
2701
- FlatHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
2825
+ FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
2702
2826
  depreciated('FlatHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2703
2827
  var head = Cone(headDiameter, diameter, headLength);
2704
2828
  // var head = Cylinder(headDiameter, headLength);
@@ -2712,21 +2836,21 @@ properties: "${Object.keys(o.properties)}"
2712
2836
 
2713
2837
  var parts$1 = /*#__PURE__*/Object.freeze({
2714
2838
  __proto__: null,
2715
- Anchor: Anchor,
2839
+ 'default': parts,
2716
2840
  BBox: BBox$1,
2717
- Board: Board,
2718
- Cone: Cone,
2719
2841
  Cube: Cube,
2842
+ RoundedCube: RoundedCube,
2720
2843
  Cylinder: Cylinder,
2721
- Hardware: Hardware,
2844
+ Cone: Cone,
2722
2845
  Hexagon: Hexagon,
2723
- RoundedCube: RoundedCube,
2724
2846
  Triangle: Triangle,
2725
2847
  Tube: Tube,
2726
- default: parts
2848
+ Anchor: Anchor,
2849
+ Board: Board,
2850
+ Hardware: Hardware
2727
2851
  });
2728
2852
 
2729
- const debug = Debug('jscadUtils:boxes');
2853
+ var debug = Debug('jscadUtils:boxes');
2730
2854
 
2731
2855
  /** @typedef {import("./group").JsCadUtilsGroup} JsCadUtilsGroup */
2732
2856
 
@@ -2798,7 +2922,8 @@ properties: "${Object.keys(o.properties)}"
2798
2922
  * @param {Number} face Size of the join face.
2799
2923
  * @return {JsCadUtilsGroup} A group object with `positive`, `negative` parts.
2800
2924
  */
2801
- function Rabett(box, thickness, gap, height, face, options = {}) {
2925
+ function Rabett(box, thickness, gap, height, face) {
2926
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2802
2927
  debug('Rabett', 'thickness', thickness, 'gap', gap, 'height', height, 'face', face);
2803
2928
  gap = gap || 0.25;
2804
2929
  var inside = thickness - gap;
@@ -2807,18 +2932,16 @@ properties: "${Object.keys(o.properties)}"
2807
2932
  debug('inside', inside, 'outside', outside);
2808
2933
  var group = Group();
2809
2934
  // debug('Rabbet top height:', height, 'options:', options);
2810
- var {
2811
- positive: top,
2812
- negative: lower2_3rd
2813
- } = box.bisect('z', height, options).parts;
2935
+ var _box$bisect$parts = box.bisect('z', height, options).parts,
2936
+ top = _box$bisect$parts.positive,
2937
+ lower2_3rd = _box$bisect$parts.negative;
2814
2938
 
2815
2939
  // debug('face', face, 'height', height);
2816
2940
  var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
2817
2941
  // debug('Rabbet bottom height:', lowerBisectHeight, 'options:', options);
2818
- var {
2819
- positive: middle,
2820
- negative: bottom
2821
- } = lower2_3rd.bisect('z', lowerBisectHeight, options).parts;
2942
+ var _lower2_3rd$bisect$pa = lower2_3rd.bisect('z', lowerBisectHeight, options).parts,
2943
+ middle = _lower2_3rd$bisect$pa.positive,
2944
+ bottom = _lower2_3rd$bisect$pa.negative;
2822
2945
  var middleTop = middle.color('yellow').subtract(middle.color('darkred').enlarge([outside, outside, 0]));
2823
2946
  group.add(top
2824
2947
  // .color('blue')
@@ -2862,7 +2985,9 @@ properties: "${Object.keys(o.properties)}"
2862
2985
  * @return {JsCadUtilsGroup} An A hollow version of the original object..
2863
2986
  * @memberof module:Boxes
2864
2987
  */
2865
- const RabettTopBottom = function rabbetTMB(box, thickness, gap = 0.25, options = {}) {
2988
+ var RabettTopBottom = function rabbetTMB(box, thickness) {
2989
+ var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
2990
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2866
2991
  options = Object.assign({
2867
2992
  removableTop: true,
2868
2993
  removableBottom: true,
@@ -2895,7 +3020,7 @@ properties: "${Object.keys(o.properties)}"
2895
3020
  }
2896
3021
  return group;
2897
3022
  };
2898
- const CutOut = function cutOut(o, h, box, plug, gap) {
3023
+ var CutOut = function cutOut(o, h, box, plug, gap) {
2899
3024
  gap = gap || 0.25;
2900
3025
  // console.log('cutOut', o.size(), h, b.size());
2901
3026
  // var r = getRadius(o);
@@ -2915,7 +3040,7 @@ properties: "${Object.keys(o.properties)}"
2915
3040
  insert: union([o, top]).intersect(box).subtract(o).enlarge([-gap, 0, 0]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color('blue')
2916
3041
  });
2917
3042
  };
2918
- const Rectangle = function (size, thickness, cb) {
3043
+ var Rectangle = function Rectangle(size, thickness, cb) {
2919
3044
  thickness = thickness || 2;
2920
3045
  var s = div$1(xyz2array(size), 2);
2921
3046
  var r = add(s, thickness);
@@ -2946,7 +3071,7 @@ properties: "${Object.keys(o.properties)}"
2946
3071
  * @return {CSG} An A hollow version of the original object..
2947
3072
  * @memberof module:Boxes
2948
3073
  */
2949
- const Hollow = function (object, thickness, interiorcb, exteriorcb) {
3074
+ var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
2950
3075
  thickness = thickness || 2;
2951
3076
  var size = -thickness * 2;
2952
3077
  interiorcb = interiorcb || identity;
@@ -2962,7 +3087,7 @@ properties: "${Object.keys(o.properties)}"
2962
3087
  * @deprecated use parts.BBox
2963
3088
  * @memberof module:Boxes
2964
3089
  */
2965
- const BBox = function (o) {
3090
+ var BBox = function BBox(o) {
2966
3091
  depreciated('BBox', true, "Use 'parts.BBox' instead");
2967
3092
  var s = div$1(xyz2array(o.size()), 2);
2968
3093
  return CSG.cube({
@@ -2973,7 +3098,8 @@ properties: "${Object.keys(o.properties)}"
2973
3098
  function getRadius(o) {
2974
3099
  return div$1(xyz2array(o.size()), 2);
2975
3100
  }
2976
- function rabbetJoin(box, thickness, gap = 0.25) {
3101
+ function rabbetJoin(box, thickness) {
3102
+ var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
2977
3103
  var r = add(getRadius(box), -thickness / 2);
2978
3104
  r[2] = thickness / 2;
2979
3105
  var cutter = CSG.cube({
@@ -2992,30 +3118,25 @@ properties: "${Object.keys(o.properties)}"
2992
3118
 
2993
3119
  var Boxes = /*#__PURE__*/Object.freeze({
2994
3120
  __proto__: null,
2995
- BBox: BBox,
2996
- CutOut: CutOut,
2997
- Hollow: Hollow,
2998
3121
  RabbetJoin: RabbetJoin,
3122
+ topMiddleBottom: topMiddleBottom,
2999
3123
  Rabett: Rabett,
3000
3124
  RabettTopBottom: RabettTopBottom,
3125
+ CutOut: CutOut,
3001
3126
  Rectangle: Rectangle,
3002
- topMiddleBottom: topMiddleBottom
3127
+ Hollow: Hollow,
3128
+ BBox: BBox
3003
3129
  });
3004
3130
 
3005
- /**
3006
- * JsCad Utilities es6
3007
- */
3008
-
3009
- const compatV1 = {
3010
- ...util,
3131
+ var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
3011
3132
  group: Group,
3012
3133
  init: init$1,
3013
3134
  triangle: triUtils,
3014
- array,
3135
+ array: array,
3015
3136
  parts: parts$1,
3016
- Boxes,
3017
- Debug
3018
- };
3137
+ Boxes: Boxes,
3138
+ Debug: Debug
3139
+ });
3019
3140
 
3020
3141
  exports.Boxes = Boxes;
3021
3142
  exports.Debug = Debug;
@@ -3027,6 +3148,8 @@ properties: "${Object.keys(o.properties)}"
3027
3148
  exports.triUtils = triUtils;
3028
3149
  exports.util = util;
3029
3150
 
3151
+ Object.defineProperty(exports, '__esModule', { value: true });
3152
+
3030
3153
  return exports;
3031
3154
 
3032
3155
  })({}, jsCadCSG, scadApi);
@@ -3051,7 +3174,7 @@ properties: "${Object.keys(o.properties)}"
3051
3174
  }
3052
3175
 
3053
3176
  var jscadUtilsPluginInit = [];
3054
- util = {
3177
+ var util = {
3055
3178
  init: (...a) => {
3056
3179
  initJscadutils(...a);
3057
3180