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