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