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