@jwc/jscad-utils 4.9.0 → 5.0.1

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.
@@ -54,329 +54,13 @@ function initJscadutils(_CSG, options = {}) {
54
54
  });
55
55
  var jscadUtils = function(exports, jsCadCSG, scadApi) {
56
56
  "use strict";
57
- function _interopDefaultLegacy(e) {
58
- return e && typeof e === "object" && "default" in e ? e : {
59
- default: e
60
- };
61
- }
62
- var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
63
- var scadApi__default = _interopDefaultLegacy(scadApi);
64
- var util = Object.freeze({
65
- __proto__: null,
66
- get NOZZEL_SIZE() {
67
- return NOZZEL_SIZE;
68
- },
69
- get nearest() {
70
- return nearest;
71
- },
72
- get identity() {
73
- return identity;
74
- },
75
- get result() {
76
- return result;
77
- },
78
- get defaults() {
79
- return defaults;
80
- },
81
- get isEmpty() {
82
- return isEmpty;
83
- },
84
- get isNegative() {
85
- return isNegative;
86
- },
87
- get print() {
88
- return print;
89
- },
90
- get jscadToString() {
91
- return jscadToString;
92
- },
93
- get error() {
94
- return error;
95
- },
96
- get depreciated() {
97
- return depreciated;
98
- },
99
- get inch() {
100
- return inch;
101
- },
102
- get cm() {
103
- return cm;
104
- },
105
- get label() {
106
- return label;
107
- },
108
- get text() {
109
- return text;
110
- },
111
- get unitCube() {
112
- return unitCube;
113
- },
114
- get unitAxis() {
115
- return unitAxis;
116
- },
117
- get toArray() {
118
- return toArray;
119
- },
120
- get ifArray() {
121
- return ifArray;
122
- },
123
- get segment() {
124
- return segment;
125
- },
126
- get zipObject() {
127
- return zipObject;
128
- },
129
- get map() {
130
- return map;
131
- },
132
- get mapValues() {
133
- return mapValues;
134
- },
135
- get pick() {
136
- return pick;
137
- },
138
- get mapPick() {
139
- return mapPick;
140
- },
141
- get divA() {
142
- return divA;
143
- },
144
- get divxyz() {
145
- return divxyz;
146
- },
147
- get div() {
148
- return div;
149
- },
150
- get mulxyz() {
151
- return mulxyz;
152
- },
153
- get mul() {
154
- return mul;
155
- },
156
- get xyz2array() {
157
- return xyz2array;
158
- },
159
- get rotationAxes() {
160
- return rotationAxes;
161
- },
162
- get size() {
163
- return size;
164
- },
165
- get scale() {
166
- return scale;
167
- },
168
- get center() {
169
- return center;
170
- },
171
- get centerY() {
172
- return centerY;
173
- },
174
- get centerX() {
175
- return centerX;
176
- },
177
- get enlarge() {
178
- return enlarge;
179
- },
180
- get fit() {
181
- return fit;
182
- },
183
- get shift() {
184
- return shift;
185
- },
186
- get zero() {
187
- return zero;
188
- },
189
- get mirrored4() {
190
- return mirrored4;
191
- },
192
- get flushSide() {
193
- return flushSide;
194
- },
195
- get calcFlush() {
196
- return calcFlush;
197
- },
198
- get calcSnap() {
199
- return calcSnap;
200
- },
201
- get snap() {
202
- return snap;
203
- },
204
- get flush() {
205
- return flush;
206
- },
207
- get axisApply() {
208
- return axisApply;
209
- },
210
- get axis2array() {
211
- return axis2array;
212
- },
213
- get centroid() {
214
- return centroid;
215
- },
216
- get calcmidlineTo() {
217
- return calcmidlineTo;
218
- },
219
- get midlineTo() {
220
- return midlineTo;
221
- },
222
- get translator() {
223
- return translator;
224
- },
225
- get calcCenterWith() {
226
- return calcCenterWith;
227
- },
228
- get centerWith() {
229
- return centerWith;
230
- },
231
- get getDelta() {
232
- return getDelta;
233
- },
234
- get bisect() {
235
- return bisect;
236
- },
237
- get slice() {
238
- return slice;
239
- },
240
- get wedge() {
241
- return wedge;
242
- },
243
- get stretch() {
244
- return stretch;
245
- },
246
- get poly2solid() {
247
- return poly2solid;
248
- },
249
- get slices2poly() {
250
- return slices2poly;
251
- },
252
- get normalVector() {
253
- return normalVector;
254
- },
255
- get sliceParams() {
256
- return sliceParams;
257
- },
258
- get reShape() {
259
- return reShape;
260
- },
261
- get chamfer() {
262
- return chamfer;
263
- },
264
- get fillet() {
265
- return fillet;
266
- },
267
- get calcRotate() {
268
- return calcRotate;
269
- },
270
- get rotateAround() {
271
- return rotateAround;
272
- },
273
- get clone() {
274
- return clone;
275
- },
276
- get addConnector() {
277
- return addConnector;
278
- }
279
- });
280
- function _arrayLikeToArray(r, a) {
281
- (null == a || a > r.length) && (a = r.length);
282
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
283
- return n;
284
- }
285
- function _arrayWithHoles(r) {
286
- if (Array.isArray(r)) return r;
287
- }
288
- function _defineProperty(e, r, t) {
289
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
290
- value: t,
291
- enumerable: !0,
292
- configurable: !0,
293
- writable: !0
294
- }) : e[r] = t, e;
295
- }
296
- function _iterableToArrayLimit(r, l) {
297
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
298
- if (null != t) {
299
- var e, n, i, u, a = [], f = !0, o = !1;
300
- try {
301
- if (i = (t = t.call(r)).next, 0 === l) {
302
- if (Object(t) !== t) return;
303
- f = !1;
304
- } else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
305
- } catch (r) {
306
- o = !0, n = r;
307
- } finally {
308
- try {
309
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
310
- } finally {
311
- if (o) throw n;
312
- }
313
- }
314
- return a;
315
- }
316
- }
317
- function _nonIterableRest() {
318
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
319
- }
320
- function ownKeys(e, r) {
321
- var t = Object.keys(e);
322
- if (Object.getOwnPropertySymbols) {
323
- var o = Object.getOwnPropertySymbols(e);
324
- r && (o = o.filter(function(r) {
325
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
326
- })), t.push.apply(t, o);
327
- }
328
- return t;
329
- }
330
- function _objectSpread2(e) {
331
- for (var r = 1; r < arguments.length; r++) {
332
- var t = null != arguments[r] ? arguments[r] : {};
333
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
334
- _defineProperty(e, r, t[r]);
335
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
336
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
337
- });
338
- }
339
- return e;
340
- }
341
- function _slicedToArray(r, e) {
342
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
343
- }
344
- function _toPrimitive(t, r) {
345
- if ("object" != typeof t || !t) return t;
346
- var e = t[Symbol.toPrimitive];
347
- if (void 0 !== e) {
348
- var i = e.call(t, r || "default");
349
- if ("object" != typeof i) return i;
350
- throw new TypeError("@@toPrimitive must return a primitive value.");
351
- }
352
- return ("string" === r ? String : Number)(t);
353
- }
354
- function _toPropertyKey(t) {
355
- var i = _toPrimitive(t, "string");
356
- return "symbol" == typeof i ? i : i + "";
357
- }
358
- function _typeof(o) {
359
- "@babel/helpers - typeof";
360
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
361
- return typeof o;
362
- } : function(o) {
363
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
364
- }, _typeof(o);
365
- }
366
- function _unsupportedIterableToArray(r, a) {
367
- if (r) {
368
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
369
- var t = {}.toString.call(r).slice(8, -1);
370
- 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;
371
- }
372
- }
373
- var toRadians = function toRadians(deg) {
57
+ const toRadians = function toRadians(deg) {
374
58
  return deg / 180 * Math.PI;
375
59
  };
376
- var toDegrees = function toDegrees(rad) {
60
+ const toDegrees = function toDegrees(rad) {
377
61
  return rad * (180 / Math.PI);
378
62
  };
379
- var solve = function solve(p1, p2) {
63
+ const solve = function(p1, p2) {
380
64
  var r = {
381
65
  c: 90,
382
66
  A: Math.abs(p2.x - p1.x),
@@ -388,7 +72,7 @@ function initJscadutils(_CSG, options = {}) {
388
72
  r.a = 90 - r.b;
389
73
  return r;
390
74
  };
391
- var solve90SA = function solve90SA(r) {
75
+ const solve90SA = function(r) {
392
76
  r = Object.assign(r, {
393
77
  C: 90
394
78
  });
@@ -400,7 +84,7 @@ function initJscadutils(_CSG, options = {}) {
400
84
  r.b = r.b || r.a / Math.tan(arad);
401
85
  return r;
402
86
  };
403
- var solve90ac = function solve90ac(r) {
87
+ const solve90ac = function(r) {
404
88
  r = Object.assign(r, {
405
89
  C: 90
406
90
  });
@@ -421,29 +105,29 @@ function initJscadutils(_CSG, options = {}) {
421
105
  }
422
106
  var triUtils = Object.freeze({
423
107
  __proto__: null,
424
- toRadians,
425
- toDegrees,
426
108
  solve,
427
109
  solve90SA,
428
110
  solve90ac,
429
- solveab
111
+ solveab,
112
+ toDegrees,
113
+ toRadians
430
114
  });
431
- var div$1 = function div(a, f) {
115
+ const div$1 = function(a, f) {
432
116
  return a.map(function(e) {
433
117
  return e / f;
434
118
  });
435
119
  };
436
- var addValue = function addValue(a, f) {
120
+ const addValue = function(a, f) {
437
121
  return a.map(function(e) {
438
122
  return e + f;
439
123
  });
440
124
  };
441
- var addArray = function addArray(a, f) {
125
+ const addArray = function(a, f) {
442
126
  return a.map(function(e, i) {
443
127
  return e + f[i];
444
128
  });
445
129
  };
446
- var add = function add(a) {
130
+ const add = function(a) {
447
131
  return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
448
132
  if (Array.isArray(arg)) {
449
133
  result = addArray(result, arg);
@@ -453,28 +137,28 @@ function initJscadutils(_CSG, options = {}) {
453
137
  return result;
454
138
  }, a);
455
139
  };
456
- var fromxyz = function fromxyz(object) {
140
+ const fromxyz = function(object) {
457
141
  return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
458
142
  };
459
- var toxyz = function toxyz(a) {
143
+ const toxyz = function(a) {
460
144
  return {
461
145
  x: a[0],
462
146
  y: a[1],
463
147
  z: a[2]
464
148
  };
465
149
  };
466
- var first = function first(a) {
150
+ const first = function(a) {
467
151
  return a ? a[0] : undefined;
468
152
  };
469
- var last = function last(a) {
153
+ const last = function(a) {
470
154
  return a && a.length > 0 ? a[a.length - 1] : undefined;
471
155
  };
472
- var min = function min(a) {
156
+ const min = function(a) {
473
157
  return a.reduce(function(result, value) {
474
158
  return value < result ? value : result;
475
159
  }, Number.MAX_VALUE);
476
160
  };
477
- var range = function range(a, b) {
161
+ const range = function(a, b) {
478
162
  var result = [];
479
163
  for (var i = a; i < b; i++) {
480
164
  result.push(i);
@@ -483,21 +167,21 @@ function initJscadutils(_CSG, options = {}) {
483
167
  };
484
168
  var array = Object.freeze({
485
169
  __proto__: null,
486
- div: div$1,
487
- addValue,
488
- addArray,
489
170
  add,
490
- fromxyz,
491
- toxyz,
171
+ addArray,
172
+ addValue,
173
+ div: div$1,
492
174
  first,
175
+ fromxyz,
493
176
  last,
494
177
  min,
495
- range
178
+ range,
179
+ toxyz
496
180
  });
497
- var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
498
- 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" ];
181
+ const debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
182
+ 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" ];
499
183
  var debugCount = 0;
500
- var Debug = function Debug(name) {
184
+ const Debug = function(name) {
501
185
  var checks = Object.assign({
502
186
  enabled: [],
503
187
  disabled: [],
@@ -505,31 +189,21 @@ function initJscadutils(_CSG, options = {}) {
505
189
  browser: true
506
190
  }
507
191
  }, jscadUtilsDebug || {});
508
- var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
192
+ var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
509
193
  var enabled = checks.enabled.some(function checkEnabled(check) {
510
194
  return check.test(name);
511
195
  }) && !checks.disabled.some(function checkEnabled(check) {
512
196
  return check.test(name);
513
197
  });
514
- var logger = enabled ? checks.options.browser ? function() {
515
- var _console;
516
- for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
517
- msg[_key] = arguments[_key];
518
- }
519
- (_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
520
- } : function() {
521
- var _console2;
522
- for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
523
- msg[_key2] = arguments[_key2];
524
- }
525
- (_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
526
- } : function() {
527
- return undefined;
528
- };
198
+ var logger = enabled ? checks.options.browser ? (...msg) => {
199
+ console.log("%c%s", style, name, ...msg);
200
+ } : (...msg) => {
201
+ console.log(`${name}`, ...msg);
202
+ } : () => undefined;
529
203
  logger.enabled = enabled;
530
204
  return logger;
531
205
  };
532
- var nameArray = {
206
+ const nameArray = {
533
207
  aliceblue: "#f0f8ff",
534
208
  antiquewhite: "#faebd7",
535
209
  aqua: "#00ffff",
@@ -687,9 +361,11 @@ function initJscadutils(_CSG, options = {}) {
687
361
  h = h.replace(/^\#/, "");
688
362
  if (h.length === 6) {
689
363
  return [ parseInt(h.substr(0, 2), 16), parseInt(h.substr(2, 2), 16), parseInt(h.substr(4, 2), 16) ];
364
+ } else {
365
+ return [ 0, 0, 0 ];
690
366
  }
691
367
  }
692
- var _name2rgb = {};
368
+ const _name2rgb = {};
693
369
  function name2rgb(n) {
694
370
  if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
695
371
  return _name2rgb[n];
@@ -769,23 +445,14 @@ function initJscadutils(_CSG, options = {}) {
769
445
  proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
770
446
  return chamfer(this, radius, orientation, options);
771
447
  };
772
- proto.prototype.bisect = function bisect$1() {
773
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
774
- args[_key] = arguments[_key];
775
- }
776
- return bisect.apply(util, [ this ].concat(args));
448
+ proto.prototype.bisect = function bisect$1(...args) {
449
+ return bisect(this, ...args);
777
450
  };
778
- proto.prototype.slice = function slice$1() {
779
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
780
- args[_key2] = arguments[_key2];
781
- }
782
- return slice.apply(util, [ this ].concat(args));
451
+ proto.prototype.slice = function slice$1(...args) {
452
+ return slice(this, ...args);
783
453
  };
784
- proto.prototype.wedge = function wedge$1() {
785
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
786
- args[_key3] = arguments[_key3];
787
- }
788
- return wedge.apply(util, [ this ].concat(args));
454
+ proto.prototype.wedge = function wedge$1(...args) {
455
+ return wedge(this, ...args);
789
456
  };
790
457
  proto.prototype.stretch = function stretch$1(axis, distance, offset) {
791
458
  return stretch(this, axis, distance, offset);
@@ -802,7 +469,7 @@ function initJscadutils(_CSG, options = {}) {
802
469
  return this._translate(arguments[0]);
803
470
  } else {
804
471
  var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
805
- result = undefined(result, arg);
472
+ result = undefined.addArray(result, arg);
806
473
  return result;
807
474
  }, [ 0, 0, 0 ]);
808
475
  return this._translate(t);
@@ -811,14 +478,10 @@ function initJscadutils(_CSG, options = {}) {
811
478
  proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
812
479
  return addConnector(this, name, point, axis, normal);
813
480
  };
814
- proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
815
- var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
816
- var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
817
- var myConnector = myConnectorName.split(".").reduce(function(a, v) {
818
- return a[v];
819
- }, this.properties);
481
+ proto.prototype.connect = function connectTo(myConnectorName, otherConnector, mirror = false, normalrotation = 0) {
482
+ var myConnector = myConnectorName.split(".").reduce((a, v) => a[v], this.properties);
820
483
  if (!myConnector) {
821
- error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
484
+ error(`The connector '${myConnectorName}' does not exist on the object [${Object.keys(this.properties).join(",")}]`, "Missing connector property");
822
485
  }
823
486
  return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
824
487
  };
@@ -828,16 +491,13 @@ function initJscadutils(_CSG, options = {}) {
828
491
  __proto__: null,
829
492
  default: init
830
493
  });
831
- var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
832
- var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
833
- var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
834
- var union = scadApi__default["default"].booleanOps.union;
494
+ const {CSG, CAG} = jsCadCSG;
495
+ const {rectangular_extrude} = scadApi.extrusions;
496
+ const {vector_text, vector_char} = scadApi.text;
497
+ const {union} = scadApi.booleanOps;
835
498
  init(CSG);
836
- var debug$3 = Debug("jscadUtils:group");
837
- function JsCadUtilsGroup() {
838
- var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
839
- var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
840
- var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
499
+ const debug$3 = Debug("jscadUtils:group");
500
+ function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
841
501
  this.name = "";
842
502
  this.names = names;
843
503
  this.parts = parts;
@@ -865,11 +525,7 @@ function initJscadutils(_CSG, options = {}) {
865
525
  }
866
526
  return self;
867
527
  };
868
- JsCadUtilsGroup.prototype.combine = function(pieces) {
869
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
870
- var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
871
- return x;
872
- };
528
+ JsCadUtilsGroup.prototype.combine = function(pieces, options = {}, map = x => x) {
873
529
  try {
874
530
  var self = this;
875
531
  options = Object.assign({
@@ -877,7 +533,7 @@ function initJscadutils(_CSG, options = {}) {
877
533
  }, options);
878
534
  pieces = pieces ? pieces.split(",") : self.names;
879
535
  if (pieces.length === 0) {
880
- throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
536
+ throw new Error(`no pieces found in ${self.name} pieces: ${pieces} parts: ${Object.keys(self.parts)} names: ${self.names}`);
881
537
  }
882
538
  debug$3("combine", self.names, self.parts);
883
539
  var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
@@ -887,14 +543,12 @@ function initJscadutils(_CSG, options = {}) {
887
543
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
888
544
  } catch (err) {
889
545
  debug$3("combine error", this, pieces, options, err);
890
- 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");
546
+ throw error(`group::combine error "${err.message || err.toString()}"\nthis: ${this}\npieces: "${pieces}"\noptions: ${JSON.stringify(options, null, 2)}\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
891
547
  }
892
548
  };
893
549
  JsCadUtilsGroup.prototype.map = function(cb) {
894
550
  var self = this;
895
- self.parts = Object.keys(self.parts).filter(function(k) {
896
- return k !== "holes";
897
- }).reduce(function(result, key) {
551
+ self.parts = Object.keys(self.parts).filter(k => k !== "holes").reduce(function(result, key) {
898
552
  result[key] = cb(self.parts[key], key);
899
553
  return result;
900
554
  }, {});
@@ -910,7 +564,7 @@ function initJscadutils(_CSG, options = {}) {
910
564
  return self;
911
565
  };
912
566
  JsCadUtilsGroup.prototype.clone = function(name, map) {
913
- debug$3("clone", name, _typeof(name), map);
567
+ debug$3("clone", name, typeof name, map);
914
568
  var self = this;
915
569
  if (typeof name == "function") {
916
570
  map = name;
@@ -962,7 +616,7 @@ function initJscadutils(_CSG, options = {}) {
962
616
  return self;
963
617
  } catch (err) {
964
618
  debug$3("snap error", this, part, to, axis, delta, err);
965
- 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");
619
+ throw error(`group::snap error "${err.message || err.toString()}"\nthis: ${this}\npart: "${part}"\nto: ${to}\naxis: "${axis}"\norientation: "${orientation}"\ndelta: "${delta}"\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
966
620
  }
967
621
  };
968
622
  JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
@@ -977,7 +631,7 @@ function initJscadutils(_CSG, options = {}) {
977
631
  return self;
978
632
  } catch (err) {
979
633
  debug$3("align error", this, part, to, axis, delta, err);
980
- 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");
634
+ throw error(`group::align error "${err.message || err.toString()}"\nthis: ${this}\npart: "${part}"\nto: ${to}\naxis: "${axis}"\ndelta: "${delta}"\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
981
635
  }
982
636
  };
983
637
  JsCadUtilsGroup.prototype.center = function center(part) {
@@ -989,9 +643,7 @@ function initJscadutils(_CSG, options = {}) {
989
643
  var bounds = self.parts[part].getBounds();
990
644
  return self.translate([ 0, 0, -bounds[0].z ]);
991
645
  };
992
- JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
993
- var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
994
- var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
646
+ JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
995
647
  debug$3("connectTo", {
996
648
  partName,
997
649
  connectorName,
@@ -1001,13 +653,9 @@ function initJscadutils(_CSG, options = {}) {
1001
653
  normalrotation
1002
654
  });
1003
655
  var self = this;
1004
- var myConnector = connectorName.split(".").reduce(function(a, v) {
1005
- return a[v];
1006
- }, self.parts[partName].properties);
656
+ var myConnector = connectorName.split(".").reduce((a, v) => a[v], self.parts[partName].properties);
1007
657
  debug$3("toConnector", to instanceof CSG.Connector);
1008
- var toConnector = toConnectorName.split(".").reduce(function(a, v) {
1009
- return a[v];
1010
- }, to.properties);
658
+ var toConnector = toConnectorName.split(".").reduce((a, v) => a[v], to.properties);
1011
659
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
1012
660
  debug$3("connectTo", matrix);
1013
661
  self.map(function(part) {
@@ -1046,15 +694,14 @@ function initJscadutils(_CSG, options = {}) {
1046
694
  return g;
1047
695
  };
1048
696
  JsCadUtilsGroup.prototype.array = function(parts, map) {
1049
- var _this = this;
1050
697
  var self = this;
1051
698
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1052
699
  if (!map) map = identity;
1053
700
  var a = [];
1054
- p.forEach(function(name) {
701
+ p.forEach(name => {
1055
702
  if (!self.parts[name]) {
1056
- debug$3("array error", _this, parts);
1057
- throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
703
+ debug$3("array error", this, parts);
704
+ throw error(`group::array error "${name}" not found.\nthis: ${this}\nparts: "${parts}"\n`, "JSCAD_UTILS_GROUP_ERROR");
1058
705
  }
1059
706
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1060
707
  });
@@ -1064,12 +711,12 @@ function initJscadutils(_CSG, options = {}) {
1064
711
  var self = this;
1065
712
  var piecesArray = pieces ? pieces.split(",") : self.names;
1066
713
  return piecesArray.map(function(piece) {
1067
- if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
714
+ if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
1068
715
  return self.parts[piece];
1069
716
  });
1070
717
  };
1071
718
  JsCadUtilsGroup.prototype.toString = function() {
1072
- 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}");
719
+ return `{\n name: "${this.name}",\n names: "${this.names.join(",")}", \n parts: "${Object.keys(this.parts)}",\n holes: ${Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0}\n}`;
1073
720
  };
1074
721
  JsCadUtilsGroup.prototype.setName = function(name) {
1075
722
  this.name = name;
@@ -1099,9 +746,7 @@ function initJscadutils(_CSG, options = {}) {
1099
746
  self.name = objectNames;
1100
747
  } else {
1101
748
  var objects = objectNames;
1102
- self.names = Object.keys(objects).filter(function(k) {
1103
- return k !== "holes";
1104
- });
749
+ self.names = Object.keys(objects).filter(k => k !== "holes");
1105
750
  self.parts = Object.assign({}, objects);
1106
751
  self.holes = objects.holes;
1107
752
  }
@@ -1109,17 +754,13 @@ function initJscadutils(_CSG, options = {}) {
1109
754
  }
1110
755
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1111
756
  }
1112
- var debug$2 = Debug("jscadUtils:util");
757
+ const debug$2 = Debug("jscadUtils:util");
1113
758
  var NOZZEL_SIZE = .4;
1114
- var nearest = {
1115
- under: function under(desired) {
1116
- var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1117
- var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
759
+ const nearest = {
760
+ under: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1118
761
  return (Math.floor(desired / nozzel) + nozzie) * nozzel;
1119
762
  },
1120
- over: function over(desired) {
1121
- var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1122
- var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
763
+ over: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1123
764
  return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
1124
765
  }
1125
766
  };
@@ -1147,9 +788,9 @@ function initJscadutils(_CSG, options = {}) {
1147
788
  debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1148
789
  }
1149
790
  function jscadToString(o) {
1150
- if (_typeof(o) == "object") {
791
+ if (typeof o == "object") {
1151
792
  if (o.polygons) {
1152
- return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
793
+ return `{\npolygons: ${o.polygons.length},\nproperties: "${Object.keys(o.properties)}"\n}\n`;
1153
794
  }
1154
795
  } else {
1155
796
  return o.toString();
@@ -1190,12 +831,12 @@ function initJscadutils(_CSG, options = {}) {
1190
831
  }
1191
832
  function text(text) {
1192
833
  var l = vector_char(0, 0, text);
1193
- var _char = l.segments.reduce(function(result, segment) {
834
+ var char = l.segments.reduce(function(result, segment) {
1194
835
  var path = new CSG.Path2D(segment);
1195
836
  var cag = path.expandToCAG(2);
1196
837
  return result ? result.union(cag) : cag;
1197
838
  }, undefined);
1198
- return _char;
839
+ return char;
1199
840
  }
1200
841
  function unitCube(length, radius) {
1201
842
  radius = radius || .5;
@@ -1251,7 +892,7 @@ function initJscadutils(_CSG, options = {}) {
1251
892
  function mapPick(o, names, f, options) {
1252
893
  return names.reduce(function(result, name, index) {
1253
894
  if (!o[name]) {
1254
- throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
895
+ throw new Error(`${name} not found in ${options.name}: ${Object.keys(o).join(",")}`);
1255
896
  }
1256
897
  result.push(f ? f(o[name], name, index, o) : o[name]);
1257
898
  return result;
@@ -1283,7 +924,7 @@ function initJscadutils(_CSG, options = {}) {
1283
924
  function xyz2array(size) {
1284
925
  return [ size.x, size.y, size.z ];
1285
926
  }
1286
- var rotationAxes = {
927
+ const rotationAxes = {
1287
928
  x: [ 1, 0, 0 ],
1288
929
  y: [ 0, 1, 0 ],
1289
930
  z: [ 0, 0, 1 ]
@@ -1361,7 +1002,7 @@ function initJscadutils(_CSG, options = {}) {
1361
1002
  function mirrored4(x) {
1362
1003
  return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
1363
1004
  }
1364
- var flushSide = {
1005
+ const flushSide = {
1365
1006
  "above-outside": [ 1, 0 ],
1366
1007
  "above-inside": [ 1, 1 ],
1367
1008
  "below-outside": [ 0, 1 ],
@@ -1391,8 +1032,7 @@ function initJscadutils(_CSG, options = {}) {
1391
1032
  return w[side[0]][axis] - m[side[1]][axis];
1392
1033
  });
1393
1034
  }
1394
- function calcSnap(moveobj, withobj, axes, orientation) {
1395
- var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1035
+ function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
1396
1036
  var side = flushSide[orientation];
1397
1037
  if (!side) {
1398
1038
  var fix = {
@@ -1458,7 +1098,7 @@ function initJscadutils(_CSG, options = {}) {
1458
1098
  objectSize = objectSize || size(bounds);
1459
1099
  return bounds[0].plus(objectSize.dividedBy(2));
1460
1100
  } catch (err) {
1461
- error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
1101
+ error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
1462
1102
  }
1463
1103
  }
1464
1104
  function calcmidlineTo(o, axis, to) {
@@ -1479,8 +1119,7 @@ function initJscadutils(_CSG, options = {}) {
1479
1119
  });
1480
1120
  return t;
1481
1121
  }
1482
- function calcCenterWith(o, axes, withObj) {
1483
- var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1122
+ function calcCenterWith(o, axes, withObj, delta = 0) {
1484
1123
  var objectCentroid = centroid(o);
1485
1124
  var withCentroid = centroid(withObj);
1486
1125
  var t = axisApply(axes, function(i, axis) {
@@ -1502,12 +1141,9 @@ function initJscadutils(_CSG, options = {}) {
1502
1141
  return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
1503
1142
  });
1504
1143
  }
1505
- function bisect() {
1506
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1507
- args[_key] = arguments[_key];
1508
- }
1144
+ function bisect(...args) {
1509
1145
  if (args.length < 2) {
1510
- error("bisect requries an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
1146
+ error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
1511
1147
  }
1512
1148
  var object = args[0];
1513
1149
  var axis = args[1];
@@ -1586,14 +1222,10 @@ function initJscadutils(_CSG, options = {}) {
1586
1222
  if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
1587
1223
  return g;
1588
1224
  }
1589
- function slice(object) {
1590
- var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
1591
- var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
1592
- var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
1593
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
1594
- color: true,
1595
- addRotationCenter: true
1596
- };
1225
+ function slice(object, angle = 15, axis = "x", rotateaxis = "z", options = {
1226
+ color: true,
1227
+ addRotationCenter: true
1228
+ }) {
1597
1229
  var info = normalVector(axis);
1598
1230
  var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
1599
1231
  var theRotationAxis = rotationAxes[rotateaxis];
@@ -1749,7 +1381,7 @@ function initJscadutils(_CSG, options = {}) {
1749
1381
  var absoluteRadius = Math.abs(radius);
1750
1382
  var si = sliceParams(orientation, radius, b);
1751
1383
  debug$2("reShape", absoluteRadius, si);
1752
- if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
1384
+ if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolygons only uses the "z" axis. You must use the "z" axis for now.');
1753
1385
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
1754
1386
  var slice = object.sectionCut(cutplane);
1755
1387
  var first = axisApply(si.axis, function() {
@@ -1810,12 +1442,11 @@ function initJscadutils(_CSG, options = {}) {
1810
1442
  };
1811
1443
  }
1812
1444
  function rotateAround(part, solid, axis, angle) {
1813
- var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
1445
+ var {rotationCenter, rotationAxis} = calcRotate(part, solid, axis);
1814
1446
  return part.rotate(rotationCenter, rotationAxis, angle);
1815
1447
  }
1816
- function cloneProperties(from, to) {
1817
- return Object.entries(from).reduce(function(props, _ref) {
1818
- var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
1448
+ function cloneProperties(from, to, depth = 0) {
1449
+ return Object.entries(from).reduce((props, [key, value]) => {
1819
1450
  props[key] = value;
1820
1451
  return props;
1821
1452
  }, to);
@@ -1826,14 +1457,85 @@ function initJscadutils(_CSG, options = {}) {
1826
1457
  debug$2("clone", o, c, CSG);
1827
1458
  return c;
1828
1459
  }
1829
- function addConnector(object, name) {
1830
- var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
1831
- var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
1832
- var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
1460
+ function addConnector(object, name, point = [ 0, 0, 0 ], axis = [ 1, 0, 0 ], normal = [ 0, 0, 1 ]) {
1833
1461
  object.properties[name] = new CSG.Connector(point, axis, normal);
1834
1462
  return object;
1835
1463
  }
1836
- var debug$1 = Debug("jscadUtils:parts");
1464
+ var util = Object.freeze({
1465
+ __proto__: null,
1466
+ NOZZEL_SIZE,
1467
+ addConnector,
1468
+ axis2array,
1469
+ axisApply,
1470
+ bisect,
1471
+ calcCenterWith,
1472
+ calcFlush,
1473
+ calcRotate,
1474
+ calcSnap,
1475
+ calcmidlineTo,
1476
+ center,
1477
+ centerWith,
1478
+ centerX,
1479
+ centerY,
1480
+ centroid,
1481
+ chamfer,
1482
+ clone,
1483
+ cm,
1484
+ defaults,
1485
+ depreciated,
1486
+ div,
1487
+ divA,
1488
+ divxyz,
1489
+ enlarge,
1490
+ error,
1491
+ fillet,
1492
+ fit,
1493
+ flush,
1494
+ flushSide,
1495
+ getDelta,
1496
+ identity,
1497
+ ifArray,
1498
+ inch,
1499
+ isEmpty,
1500
+ isNegative,
1501
+ jscadToString,
1502
+ label,
1503
+ map,
1504
+ mapPick,
1505
+ mapValues,
1506
+ midlineTo,
1507
+ mirrored4,
1508
+ mul,
1509
+ mulxyz,
1510
+ nearest,
1511
+ normalVector,
1512
+ pick,
1513
+ poly2solid,
1514
+ print,
1515
+ reShape,
1516
+ result,
1517
+ rotateAround,
1518
+ rotationAxes,
1519
+ scale,
1520
+ segment,
1521
+ shift,
1522
+ size,
1523
+ slice,
1524
+ sliceParams,
1525
+ slices2poly,
1526
+ snap,
1527
+ stretch,
1528
+ text,
1529
+ toArray,
1530
+ translator,
1531
+ unitAxis,
1532
+ unitCube,
1533
+ wedge,
1534
+ xyz2array,
1535
+ zero,
1536
+ zipObject
1537
+ });
1538
+ const debug$1 = Debug("jscadUtils:parts");
1837
1539
  var parts = {
1838
1540
  BBox: BBox$1,
1839
1541
  Cube,
@@ -1841,16 +1543,13 @@ function initJscadutils(_CSG, options = {}) {
1841
1543
  Cylinder,
1842
1544
  Cone
1843
1545
  };
1844
- function BBox$1() {
1546
+ function BBox$1(...objects) {
1845
1547
  function box(object) {
1846
1548
  return CSG.cube({
1847
1549
  center: object.centroid(),
1848
1550
  radius: object.size().dividedBy(2)
1849
1551
  });
1850
1552
  }
1851
- for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
1852
- objects[_key] = arguments[_key];
1853
- }
1854
1553
  return objects.reduce(function(bbox, part) {
1855
1554
  var object = bbox ? union([ bbox, box(part) ]) : part;
1856
1555
  return box(object);
@@ -1883,8 +1582,7 @@ function initJscadutils(_CSG, options = {}) {
1883
1582
  });
1884
1583
  return roundedcube;
1885
1584
  }
1886
- function Cylinder(diameter, height) {
1887
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1585
+ function Cylinder(diameter, height, options = {}) {
1888
1586
  debug$1("parts.Cylinder", diameter, height, options);
1889
1587
  options = Object.assign({
1890
1588
  start: [ 0, 0, 0 ],
@@ -1894,8 +1592,7 @@ function initJscadutils(_CSG, options = {}) {
1894
1592
  }, options);
1895
1593
  return CSG.cylinder(options);
1896
1594
  }
1897
- function Cone(diameter1, diameter2, height) {
1898
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1595
+ function Cone(diameter1, diameter2, height, options = {}) {
1899
1596
  debug$1("parts.Cone", diameter1, diameter2, height, options);
1900
1597
  return CSG.cylinder(Object.assign({
1901
1598
  start: [ 0, 0, 0 ],
@@ -1924,9 +1621,7 @@ function initJscadutils(_CSG, options = {}) {
1924
1621
  function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
1925
1622
  return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
1926
1623
  }
1927
- function Anchor() {
1928
- var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
1929
- var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
1624
+ function Anchor(width = 10, height = 10) {
1930
1625
  var hole = Cylinder(width, height).Center().color("red");
1931
1626
  var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
1932
1627
  return Group({
@@ -1946,7 +1641,7 @@ function initJscadutils(_CSG, options = {}) {
1946
1641
  });
1947
1642
  return board;
1948
1643
  }
1949
- var Hardware = {
1644
+ const Hardware = {
1950
1645
  Orientation: {
1951
1646
  up: {
1952
1647
  head: "outside-",
@@ -1957,7 +1652,7 @@ function initJscadutils(_CSG, options = {}) {
1957
1652
  clear: "inside-"
1958
1653
  }
1959
1654
  },
1960
- Screw: function Screw(head, thread, headClearSpace, options) {
1655
+ Screw: function(head, thread, headClearSpace, options) {
1961
1656
  depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
1962
1657
  options = Object.assign(options, {
1963
1658
  orientation: "up",
@@ -1973,7 +1668,7 @@ function initJscadutils(_CSG, options = {}) {
1973
1668
  }
1974
1669
  return group;
1975
1670
  },
1976
- PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1671
+ PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1977
1672
  depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
1978
1673
  var head = Cylinder(headDiameter, headLength);
1979
1674
  var thread = Cylinder(diameter, length);
@@ -1982,7 +1677,7 @@ function initJscadutils(_CSG, options = {}) {
1982
1677
  }
1983
1678
  return Hardware.Screw(head, thread, headClearSpace, options);
1984
1679
  },
1985
- HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1680
+ HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1986
1681
  depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
1987
1682
  var head = Hexagon(headDiameter, headLength);
1988
1683
  var thread = Cylinder(diameter, length);
@@ -1991,7 +1686,7 @@ function initJscadutils(_CSG, options = {}) {
1991
1686
  }
1992
1687
  return Hardware.Screw(head, thread, headClearSpace, options);
1993
1688
  },
1994
- FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1689
+ FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1995
1690
  depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
1996
1691
  var head = Cone(headDiameter, diameter, headLength);
1997
1692
  var thread = Cylinder(diameter, length);
@@ -2003,20 +1698,20 @@ function initJscadutils(_CSG, options = {}) {
2003
1698
  };
2004
1699
  var parts$1 = Object.freeze({
2005
1700
  __proto__: null,
2006
- default: parts,
1701
+ Anchor,
2007
1702
  BBox: BBox$1,
1703
+ Board,
1704
+ Cone,
2008
1705
  Cube,
2009
- RoundedCube,
2010
1706
  Cylinder,
2011
- Cone,
1707
+ Hardware,
2012
1708
  Hexagon,
1709
+ RoundedCube,
2013
1710
  Triangle,
2014
1711
  Tube,
2015
- Anchor,
2016
- Board,
2017
- Hardware
1712
+ default: parts
2018
1713
  });
2019
- var debug = Debug("jscadUtils:boxes");
1714
+ const debug = Debug("jscadUtils:boxes");
2020
1715
  function RabbetJoin(box, thickness, cutHeight) {
2021
1716
  depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
2022
1717
  return rabbetJoin(box, thickness, cutHeight);
@@ -2029,17 +1724,16 @@ function initJscadutils(_CSG, options = {}) {
2029
1724
  var top = bottom.parts.positive.bisect("z", -thickness);
2030
1725
  return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
2031
1726
  }
2032
- function Rabett(box, thickness, gap, height, face) {
2033
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1727
+ function Rabett(box, thickness, gap, height, face, options = {}) {
2034
1728
  debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
2035
1729
  gap = gap || .25;
2036
1730
  var inside = thickness - gap;
2037
1731
  var outside = -thickness + gap;
2038
1732
  debug("inside", inside, "outside", outside);
2039
1733
  var group = Group();
2040
- var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
1734
+ var {positive: top, negative: lower2_3rd} = box.bisect("z", height, options).parts;
2041
1735
  var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
2042
- var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
1736
+ var {positive: middle, negative: bottom} = lower2_3rd.bisect("z", lowerBisectHeight, options).parts;
2043
1737
  var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
2044
1738
  group.add(top.union(middleTop), "top");
2045
1739
  var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
@@ -2048,9 +1742,7 @@ function initJscadutils(_CSG, options = {}) {
2048
1742
  group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
2049
1743
  return group;
2050
1744
  }
2051
- var RabettTopBottom = function rabbetTMB(box, thickness) {
2052
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
2053
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1745
+ const RabettTopBottom = function rabbetTMB(box, thickness, gap = .25, options = {}) {
2054
1746
  options = Object.assign({
2055
1747
  removableTop: true,
2056
1748
  removableBottom: true,
@@ -2083,7 +1775,7 @@ function initJscadutils(_CSG, options = {}) {
2083
1775
  }
2084
1776
  return group;
2085
1777
  };
2086
- var CutOut = function cutOut(o, h, box, plug, gap) {
1778
+ const CutOut = function cutOut(o, h, box, plug, gap) {
2087
1779
  gap = gap || .25;
2088
1780
  var s = o.size();
2089
1781
  var cutout = o.intersect(box);
@@ -2101,7 +1793,7 @@ function initJscadutils(_CSG, options = {}) {
2101
1793
  insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
2102
1794
  });
2103
1795
  };
2104
- var Rectangle = function Rectangle(size, thickness, cb) {
1796
+ const Rectangle = function(size, thickness, cb) {
2105
1797
  thickness = thickness || 2;
2106
1798
  var s = div$1(xyz2array(size), 2);
2107
1799
  var r = add(s, thickness);
@@ -2115,7 +1807,7 @@ function initJscadutils(_CSG, options = {}) {
2115
1807
  if (cb) box = cb(box);
2116
1808
  return box;
2117
1809
  };
2118
- var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
1810
+ const Hollow = function(object, thickness, interiorcb, exteriorcb) {
2119
1811
  thickness = thickness || 2;
2120
1812
  var size = -thickness * 2;
2121
1813
  interiorcb = interiorcb || identity;
@@ -2123,7 +1815,7 @@ function initJscadutils(_CSG, options = {}) {
2123
1815
  if (exteriorcb) box = exteriorcb(box);
2124
1816
  return box;
2125
1817
  };
2126
- var BBox = function BBox(o) {
1818
+ const BBox = function(o) {
2127
1819
  depreciated("BBox", true, "Use 'parts.BBox' instead");
2128
1820
  var s = div$1(xyz2array(o.size()), 2);
2129
1821
  return CSG.cube({
@@ -2134,8 +1826,7 @@ function initJscadutils(_CSG, options = {}) {
2134
1826
  function getRadius(o) {
2135
1827
  return div$1(xyz2array(o.size()), 2);
2136
1828
  }
2137
- function rabbetJoin(box, thickness) {
2138
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
1829
+ function rabbetJoin(box, thickness, gap = .25) {
2139
1830
  var r = add(getRadius(box), -thickness / 2);
2140
1831
  r[2] = thickness / 2;
2141
1832
  var cutter = CSG.cube({
@@ -2153,16 +1844,17 @@ function initJscadutils(_CSG, options = {}) {
2153
1844
  }
2154
1845
  var Boxes = Object.freeze({
2155
1846
  __proto__: null,
1847
+ BBox,
1848
+ CutOut,
1849
+ Hollow,
2156
1850
  RabbetJoin,
2157
- topMiddleBottom,
2158
1851
  Rabett,
2159
1852
  RabettTopBottom,
2160
- CutOut,
2161
1853
  Rectangle,
2162
- Hollow,
2163
- BBox
1854
+ topMiddleBottom
2164
1855
  });
2165
- var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
1856
+ const compatV1 = {
1857
+ ...util,
2166
1858
  group: Group,
2167
1859
  init: init$1,
2168
1860
  triangle: triUtils,
@@ -2170,7 +1862,7 @@ function initJscadutils(_CSG, options = {}) {
2170
1862
  parts: parts$1,
2171
1863
  Boxes,
2172
1864
  Debug
2173
- });
1865
+ };
2174
1866
  exports.Boxes = Boxes;
2175
1867
  exports.Debug = Debug;
2176
1868
  exports.Group = Group;
@@ -2180,9 +1872,6 @@ function initJscadutils(_CSG, options = {}) {
2180
1872
  exports.parts = parts$1;
2181
1873
  exports.triUtils = triUtils;
2182
1874
  exports.util = util;
2183
- Object.defineProperty(exports, "__esModule", {
2184
- value: true
2185
- });
2186
1875
  return exports;
2187
1876
  }({}, jsCadCSG, scadApi);
2188
1877
  const debug = jscadUtils.Debug("jscadUtils:initJscadutils");