@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.
@@ -64,329 +64,13 @@ function initJscadutils(_CSG, options = {}) {
64
64
  });
65
65
  var jscadUtils = function(exports, jsCadCSG, scadApi) {
66
66
  "use strict";
67
- function _interopDefaultLegacy(e) {
68
- return e && typeof e === "object" && "default" in e ? e : {
69
- default: e
70
- };
71
- }
72
- var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
73
- var scadApi__default = _interopDefaultLegacy(scadApi);
74
- var util = Object.freeze({
75
- __proto__: null,
76
- get NOZZEL_SIZE() {
77
- return NOZZEL_SIZE;
78
- },
79
- get nearest() {
80
- return nearest;
81
- },
82
- get identity() {
83
- return identity;
84
- },
85
- get result() {
86
- return result;
87
- },
88
- get defaults() {
89
- return defaults;
90
- },
91
- get isEmpty() {
92
- return isEmpty;
93
- },
94
- get isNegative() {
95
- return isNegative;
96
- },
97
- get print() {
98
- return print;
99
- },
100
- get jscadToString() {
101
- return jscadToString;
102
- },
103
- get error() {
104
- return error;
105
- },
106
- get depreciated() {
107
- return depreciated;
108
- },
109
- get inch() {
110
- return inch;
111
- },
112
- get cm() {
113
- return cm;
114
- },
115
- get label() {
116
- return label;
117
- },
118
- get text() {
119
- return text;
120
- },
121
- get unitCube() {
122
- return unitCube;
123
- },
124
- get unitAxis() {
125
- return unitAxis;
126
- },
127
- get toArray() {
128
- return toArray;
129
- },
130
- get ifArray() {
131
- return ifArray;
132
- },
133
- get segment() {
134
- return segment;
135
- },
136
- get zipObject() {
137
- return zipObject;
138
- },
139
- get map() {
140
- return map;
141
- },
142
- get mapValues() {
143
- return mapValues;
144
- },
145
- get pick() {
146
- return pick;
147
- },
148
- get mapPick() {
149
- return mapPick;
150
- },
151
- get divA() {
152
- return divA;
153
- },
154
- get divxyz() {
155
- return divxyz;
156
- },
157
- get div() {
158
- return div;
159
- },
160
- get mulxyz() {
161
- return mulxyz;
162
- },
163
- get mul() {
164
- return mul;
165
- },
166
- get xyz2array() {
167
- return xyz2array;
168
- },
169
- get rotationAxes() {
170
- return rotationAxes;
171
- },
172
- get size() {
173
- return size;
174
- },
175
- get scale() {
176
- return scale;
177
- },
178
- get center() {
179
- return center;
180
- },
181
- get centerY() {
182
- return centerY;
183
- },
184
- get centerX() {
185
- return centerX;
186
- },
187
- get enlarge() {
188
- return enlarge;
189
- },
190
- get fit() {
191
- return fit;
192
- },
193
- get shift() {
194
- return shift;
195
- },
196
- get zero() {
197
- return zero;
198
- },
199
- get mirrored4() {
200
- return mirrored4;
201
- },
202
- get flushSide() {
203
- return flushSide;
204
- },
205
- get calcFlush() {
206
- return calcFlush;
207
- },
208
- get calcSnap() {
209
- return calcSnap;
210
- },
211
- get snap() {
212
- return snap;
213
- },
214
- get flush() {
215
- return flush;
216
- },
217
- get axisApply() {
218
- return axisApply;
219
- },
220
- get axis2array() {
221
- return axis2array;
222
- },
223
- get centroid() {
224
- return centroid;
225
- },
226
- get calcmidlineTo() {
227
- return calcmidlineTo;
228
- },
229
- get midlineTo() {
230
- return midlineTo;
231
- },
232
- get translator() {
233
- return translator;
234
- },
235
- get calcCenterWith() {
236
- return calcCenterWith;
237
- },
238
- get centerWith() {
239
- return centerWith;
240
- },
241
- get getDelta() {
242
- return getDelta;
243
- },
244
- get bisect() {
245
- return bisect;
246
- },
247
- get slice() {
248
- return slice;
249
- },
250
- get wedge() {
251
- return wedge;
252
- },
253
- get stretch() {
254
- return stretch;
255
- },
256
- get poly2solid() {
257
- return poly2solid;
258
- },
259
- get slices2poly() {
260
- return slices2poly;
261
- },
262
- get normalVector() {
263
- return normalVector;
264
- },
265
- get sliceParams() {
266
- return sliceParams;
267
- },
268
- get reShape() {
269
- return reShape;
270
- },
271
- get chamfer() {
272
- return chamfer;
273
- },
274
- get fillet() {
275
- return fillet;
276
- },
277
- get calcRotate() {
278
- return calcRotate;
279
- },
280
- get rotateAround() {
281
- return rotateAround;
282
- },
283
- get clone() {
284
- return clone;
285
- },
286
- get addConnector() {
287
- return addConnector;
288
- }
289
- });
290
- function _arrayLikeToArray(r, a) {
291
- (null == a || a > r.length) && (a = r.length);
292
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
293
- return n;
294
- }
295
- function _arrayWithHoles(r) {
296
- if (Array.isArray(r)) return r;
297
- }
298
- function _defineProperty(e, r, t) {
299
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
300
- value: t,
301
- enumerable: !0,
302
- configurable: !0,
303
- writable: !0
304
- }) : e[r] = t, e;
305
- }
306
- function _iterableToArrayLimit(r, l) {
307
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
308
- if (null != t) {
309
- var e, n, i, u, a = [], f = !0, o = !1;
310
- try {
311
- if (i = (t = t.call(r)).next, 0 === l) {
312
- if (Object(t) !== t) return;
313
- f = !1;
314
- } else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
315
- } catch (r) {
316
- o = !0, n = r;
317
- } finally {
318
- try {
319
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
320
- } finally {
321
- if (o) throw n;
322
- }
323
- }
324
- return a;
325
- }
326
- }
327
- function _nonIterableRest() {
328
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
329
- }
330
- function ownKeys(e, r) {
331
- var t = Object.keys(e);
332
- if (Object.getOwnPropertySymbols) {
333
- var o = Object.getOwnPropertySymbols(e);
334
- r && (o = o.filter(function(r) {
335
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
336
- })), t.push.apply(t, o);
337
- }
338
- return t;
339
- }
340
- function _objectSpread2(e) {
341
- for (var r = 1; r < arguments.length; r++) {
342
- var t = null != arguments[r] ? arguments[r] : {};
343
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
344
- _defineProperty(e, r, t[r]);
345
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
346
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
347
- });
348
- }
349
- return e;
350
- }
351
- function _slicedToArray(r, e) {
352
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
353
- }
354
- function _toPrimitive(t, r) {
355
- if ("object" != typeof t || !t) return t;
356
- var e = t[Symbol.toPrimitive];
357
- if (void 0 !== e) {
358
- var i = e.call(t, r || "default");
359
- if ("object" != typeof i) return i;
360
- throw new TypeError("@@toPrimitive must return a primitive value.");
361
- }
362
- return ("string" === r ? String : Number)(t);
363
- }
364
- function _toPropertyKey(t) {
365
- var i = _toPrimitive(t, "string");
366
- return "symbol" == typeof i ? i : i + "";
367
- }
368
- function _typeof(o) {
369
- "@babel/helpers - typeof";
370
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
371
- return typeof o;
372
- } : function(o) {
373
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
374
- }, _typeof(o);
375
- }
376
- function _unsupportedIterableToArray(r, a) {
377
- if (r) {
378
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
379
- var t = {}.toString.call(r).slice(8, -1);
380
- 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;
381
- }
382
- }
383
- var toRadians = function toRadians(deg) {
67
+ const toRadians = function toRadians(deg) {
384
68
  return deg / 180 * Math.PI;
385
69
  };
386
- var toDegrees = function toDegrees(rad) {
70
+ const toDegrees = function toDegrees(rad) {
387
71
  return rad * (180 / Math.PI);
388
72
  };
389
- var solve = function solve(p1, p2) {
73
+ const solve = function(p1, p2) {
390
74
  var r = {
391
75
  c: 90,
392
76
  A: Math.abs(p2.x - p1.x),
@@ -398,7 +82,7 @@ function initJscadutils(_CSG, options = {}) {
398
82
  r.a = 90 - r.b;
399
83
  return r;
400
84
  };
401
- var solve90SA = function solve90SA(r) {
85
+ const solve90SA = function(r) {
402
86
  r = Object.assign(r, {
403
87
  C: 90
404
88
  });
@@ -410,7 +94,7 @@ function initJscadutils(_CSG, options = {}) {
410
94
  r.b = r.b || r.a / Math.tan(arad);
411
95
  return r;
412
96
  };
413
- var solve90ac = function solve90ac(r) {
97
+ const solve90ac = function(r) {
414
98
  r = Object.assign(r, {
415
99
  C: 90
416
100
  });
@@ -431,29 +115,29 @@ function initJscadutils(_CSG, options = {}) {
431
115
  }
432
116
  var triUtils = Object.freeze({
433
117
  __proto__: null,
434
- toRadians,
435
- toDegrees,
436
118
  solve,
437
119
  solve90SA,
438
120
  solve90ac,
439
- solveab
121
+ solveab,
122
+ toDegrees,
123
+ toRadians
440
124
  });
441
- var div$1 = function div(a, f) {
125
+ const div$1 = function(a, f) {
442
126
  return a.map(function(e) {
443
127
  return e / f;
444
128
  });
445
129
  };
446
- var addValue = function addValue(a, f) {
130
+ const addValue = function(a, f) {
447
131
  return a.map(function(e) {
448
132
  return e + f;
449
133
  });
450
134
  };
451
- var addArray = function addArray(a, f) {
135
+ const addArray = function(a, f) {
452
136
  return a.map(function(e, i) {
453
137
  return e + f[i];
454
138
  });
455
139
  };
456
- var add = function add(a) {
140
+ const add = function(a) {
457
141
  return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
458
142
  if (Array.isArray(arg)) {
459
143
  result = addArray(result, arg);
@@ -463,28 +147,28 @@ function initJscadutils(_CSG, options = {}) {
463
147
  return result;
464
148
  }, a);
465
149
  };
466
- var fromxyz = function fromxyz(object) {
150
+ const fromxyz = function(object) {
467
151
  return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
468
152
  };
469
- var toxyz = function toxyz(a) {
153
+ const toxyz = function(a) {
470
154
  return {
471
155
  x: a[0],
472
156
  y: a[1],
473
157
  z: a[2]
474
158
  };
475
159
  };
476
- var first = function first(a) {
160
+ const first = function(a) {
477
161
  return a ? a[0] : undefined;
478
162
  };
479
- var last = function last(a) {
163
+ const last = function(a) {
480
164
  return a && a.length > 0 ? a[a.length - 1] : undefined;
481
165
  };
482
- var min = function min(a) {
166
+ const min = function(a) {
483
167
  return a.reduce(function(result, value) {
484
168
  return value < result ? value : result;
485
169
  }, Number.MAX_VALUE);
486
170
  };
487
- var range = function range(a, b) {
171
+ const range = function(a, b) {
488
172
  var result = [];
489
173
  for (var i = a; i < b; i++) {
490
174
  result.push(i);
@@ -493,21 +177,21 @@ function initJscadutils(_CSG, options = {}) {
493
177
  };
494
178
  var array = Object.freeze({
495
179
  __proto__: null,
496
- div: div$1,
497
- addValue,
498
- addArray,
499
180
  add,
500
- fromxyz,
501
- toxyz,
181
+ addArray,
182
+ addValue,
183
+ div: div$1,
502
184
  first,
185
+ fromxyz,
503
186
  last,
504
187
  min,
505
- range
188
+ range,
189
+ toxyz
506
190
  });
507
- var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
508
- 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" ];
191
+ const debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
192
+ 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" ];
509
193
  var debugCount = 0;
510
- var Debug = function Debug(name) {
194
+ const Debug = function(name) {
511
195
  var checks = Object.assign({
512
196
  enabled: [],
513
197
  disabled: [],
@@ -515,31 +199,21 @@ function initJscadutils(_CSG, options = {}) {
515
199
  browser: true
516
200
  }
517
201
  }, jscadUtilsDebug || {});
518
- var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
202
+ var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
519
203
  var enabled = checks.enabled.some(function checkEnabled(check) {
520
204
  return check.test(name);
521
205
  }) && !checks.disabled.some(function checkEnabled(check) {
522
206
  return check.test(name);
523
207
  });
524
- var logger = enabled ? checks.options.browser ? function() {
525
- var _console;
526
- for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
527
- msg[_key] = arguments[_key];
528
- }
529
- (_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
530
- } : function() {
531
- var _console2;
532
- for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
533
- msg[_key2] = arguments[_key2];
534
- }
535
- (_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
536
- } : function() {
537
- return undefined;
538
- };
208
+ var logger = enabled ? checks.options.browser ? (...msg) => {
209
+ console.log("%c%s", style, name, ...msg);
210
+ } : (...msg) => {
211
+ console.log(`${name}`, ...msg);
212
+ } : () => undefined;
539
213
  logger.enabled = enabled;
540
214
  return logger;
541
215
  };
542
- var nameArray = {
216
+ const nameArray = {
543
217
  aliceblue: "#f0f8ff",
544
218
  antiquewhite: "#faebd7",
545
219
  aqua: "#00ffff",
@@ -697,9 +371,11 @@ function initJscadutils(_CSG, options = {}) {
697
371
  h = h.replace(/^\#/, "");
698
372
  if (h.length === 6) {
699
373
  return [ parseInt(h.substr(0, 2), 16), parseInt(h.substr(2, 2), 16), parseInt(h.substr(4, 2), 16) ];
374
+ } else {
375
+ return [ 0, 0, 0 ];
700
376
  }
701
377
  }
702
- var _name2rgb = {};
378
+ const _name2rgb = {};
703
379
  function name2rgb(n) {
704
380
  if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
705
381
  return _name2rgb[n];
@@ -779,23 +455,14 @@ function initJscadutils(_CSG, options = {}) {
779
455
  proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
780
456
  return chamfer(this, radius, orientation, options);
781
457
  };
782
- proto.prototype.bisect = function bisect$1() {
783
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
784
- args[_key] = arguments[_key];
785
- }
786
- return bisect.apply(util, [ this ].concat(args));
458
+ proto.prototype.bisect = function bisect$1(...args) {
459
+ return bisect(this, ...args);
787
460
  };
788
- proto.prototype.slice = function slice$1() {
789
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
790
- args[_key2] = arguments[_key2];
791
- }
792
- return slice.apply(util, [ this ].concat(args));
461
+ proto.prototype.slice = function slice$1(...args) {
462
+ return slice(this, ...args);
793
463
  };
794
- proto.prototype.wedge = function wedge$1() {
795
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
796
- args[_key3] = arguments[_key3];
797
- }
798
- return wedge.apply(util, [ this ].concat(args));
464
+ proto.prototype.wedge = function wedge$1(...args) {
465
+ return wedge(this, ...args);
799
466
  };
800
467
  proto.prototype.stretch = function stretch$1(axis, distance, offset) {
801
468
  return stretch(this, axis, distance, offset);
@@ -812,7 +479,7 @@ function initJscadutils(_CSG, options = {}) {
812
479
  return this._translate(arguments[0]);
813
480
  } else {
814
481
  var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
815
- result = undefined(result, arg);
482
+ result = undefined.addArray(result, arg);
816
483
  return result;
817
484
  }, [ 0, 0, 0 ]);
818
485
  return this._translate(t);
@@ -821,14 +488,10 @@ function initJscadutils(_CSG, options = {}) {
821
488
  proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
822
489
  return addConnector(this, name, point, axis, normal);
823
490
  };
824
- proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
825
- var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
826
- var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
827
- var myConnector = myConnectorName.split(".").reduce(function(a, v) {
828
- return a[v];
829
- }, this.properties);
491
+ proto.prototype.connect = function connectTo(myConnectorName, otherConnector, mirror = false, normalrotation = 0) {
492
+ var myConnector = myConnectorName.split(".").reduce((a, v) => a[v], this.properties);
830
493
  if (!myConnector) {
831
- error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
494
+ error(`The connector '${myConnectorName}' does not exist on the object [${Object.keys(this.properties).join(",")}]`, "Missing connector property");
832
495
  }
833
496
  return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
834
497
  };
@@ -838,16 +501,13 @@ function initJscadutils(_CSG, options = {}) {
838
501
  __proto__: null,
839
502
  default: init
840
503
  });
841
- var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
842
- var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
843
- var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
844
- var union = scadApi__default["default"].booleanOps.union;
504
+ const {CSG, CAG} = jsCadCSG;
505
+ const {rectangular_extrude} = scadApi.extrusions;
506
+ const {vector_text, vector_char} = scadApi.text;
507
+ const {union} = scadApi.booleanOps;
845
508
  init(CSG);
846
- var debug$3 = Debug("jscadUtils:group");
847
- function JsCadUtilsGroup() {
848
- var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
849
- var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
850
- var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
509
+ const debug$3 = Debug("jscadUtils:group");
510
+ function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
851
511
  this.name = "";
852
512
  this.names = names;
853
513
  this.parts = parts;
@@ -875,11 +535,7 @@ function initJscadutils(_CSG, options = {}) {
875
535
  }
876
536
  return self;
877
537
  };
878
- JsCadUtilsGroup.prototype.combine = function(pieces) {
879
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
880
- var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
881
- return x;
882
- };
538
+ JsCadUtilsGroup.prototype.combine = function(pieces, options = {}, map = x => x) {
883
539
  try {
884
540
  var self = this;
885
541
  options = Object.assign({
@@ -887,7 +543,7 @@ function initJscadutils(_CSG, options = {}) {
887
543
  }, options);
888
544
  pieces = pieces ? pieces.split(",") : self.names;
889
545
  if (pieces.length === 0) {
890
- throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
546
+ throw new Error(`no pieces found in ${self.name} pieces: ${pieces} parts: ${Object.keys(self.parts)} names: ${self.names}`);
891
547
  }
892
548
  debug$3("combine", self.names, self.parts);
893
549
  var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
@@ -897,14 +553,12 @@ function initJscadutils(_CSG, options = {}) {
897
553
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
898
554
  } catch (err) {
899
555
  debug$3("combine error", this, pieces, options, err);
900
- 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");
556
+ 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");
901
557
  }
902
558
  };
903
559
  JsCadUtilsGroup.prototype.map = function(cb) {
904
560
  var self = this;
905
- self.parts = Object.keys(self.parts).filter(function(k) {
906
- return k !== "holes";
907
- }).reduce(function(result, key) {
561
+ self.parts = Object.keys(self.parts).filter(k => k !== "holes").reduce(function(result, key) {
908
562
  result[key] = cb(self.parts[key], key);
909
563
  return result;
910
564
  }, {});
@@ -920,7 +574,7 @@ function initJscadutils(_CSG, options = {}) {
920
574
  return self;
921
575
  };
922
576
  JsCadUtilsGroup.prototype.clone = function(name, map) {
923
- debug$3("clone", name, _typeof(name), map);
577
+ debug$3("clone", name, typeof name, map);
924
578
  var self = this;
925
579
  if (typeof name == "function") {
926
580
  map = name;
@@ -972,7 +626,7 @@ function initJscadutils(_CSG, options = {}) {
972
626
  return self;
973
627
  } catch (err) {
974
628
  debug$3("snap error", this, part, to, axis, delta, err);
975
- 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");
629
+ 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");
976
630
  }
977
631
  };
978
632
  JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
@@ -987,7 +641,7 @@ function initJscadutils(_CSG, options = {}) {
987
641
  return self;
988
642
  } catch (err) {
989
643
  debug$3("align error", this, part, to, axis, delta, err);
990
- 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");
644
+ 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");
991
645
  }
992
646
  };
993
647
  JsCadUtilsGroup.prototype.center = function center(part) {
@@ -999,9 +653,7 @@ function initJscadutils(_CSG, options = {}) {
999
653
  var bounds = self.parts[part].getBounds();
1000
654
  return self.translate([ 0, 0, -bounds[0].z ]);
1001
655
  };
1002
- JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
1003
- var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1004
- var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
656
+ JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
1005
657
  debug$3("connectTo", {
1006
658
  partName,
1007
659
  connectorName,
@@ -1011,13 +663,9 @@ function initJscadutils(_CSG, options = {}) {
1011
663
  normalrotation
1012
664
  });
1013
665
  var self = this;
1014
- var myConnector = connectorName.split(".").reduce(function(a, v) {
1015
- return a[v];
1016
- }, self.parts[partName].properties);
666
+ var myConnector = connectorName.split(".").reduce((a, v) => a[v], self.parts[partName].properties);
1017
667
  debug$3("toConnector", to instanceof CSG.Connector);
1018
- var toConnector = toConnectorName.split(".").reduce(function(a, v) {
1019
- return a[v];
1020
- }, to.properties);
668
+ var toConnector = toConnectorName.split(".").reduce((a, v) => a[v], to.properties);
1021
669
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
1022
670
  debug$3("connectTo", matrix);
1023
671
  self.map(function(part) {
@@ -1056,15 +704,14 @@ function initJscadutils(_CSG, options = {}) {
1056
704
  return g;
1057
705
  };
1058
706
  JsCadUtilsGroup.prototype.array = function(parts, map) {
1059
- var _this = this;
1060
707
  var self = this;
1061
708
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1062
709
  if (!map) map = identity;
1063
710
  var a = [];
1064
- p.forEach(function(name) {
711
+ p.forEach(name => {
1065
712
  if (!self.parts[name]) {
1066
- debug$3("array error", _this, parts);
1067
- throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
713
+ debug$3("array error", this, parts);
714
+ throw error(`group::array error "${name}" not found.\nthis: ${this}\nparts: "${parts}"\n`, "JSCAD_UTILS_GROUP_ERROR");
1068
715
  }
1069
716
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1070
717
  });
@@ -1074,12 +721,12 @@ function initJscadutils(_CSG, options = {}) {
1074
721
  var self = this;
1075
722
  var piecesArray = pieces ? pieces.split(",") : self.names;
1076
723
  return piecesArray.map(function(piece) {
1077
- if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
724
+ if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
1078
725
  return self.parts[piece];
1079
726
  });
1080
727
  };
1081
728
  JsCadUtilsGroup.prototype.toString = function() {
1082
- 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}");
729
+ 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}`;
1083
730
  };
1084
731
  JsCadUtilsGroup.prototype.setName = function(name) {
1085
732
  this.name = name;
@@ -1109,9 +756,7 @@ function initJscadutils(_CSG, options = {}) {
1109
756
  self.name = objectNames;
1110
757
  } else {
1111
758
  var objects = objectNames;
1112
- self.names = Object.keys(objects).filter(function(k) {
1113
- return k !== "holes";
1114
- });
759
+ self.names = Object.keys(objects).filter(k => k !== "holes");
1115
760
  self.parts = Object.assign({}, objects);
1116
761
  self.holes = objects.holes;
1117
762
  }
@@ -1119,17 +764,13 @@ function initJscadutils(_CSG, options = {}) {
1119
764
  }
1120
765
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1121
766
  }
1122
- var debug$2 = Debug("jscadUtils:util");
767
+ const debug$2 = Debug("jscadUtils:util");
1123
768
  var NOZZEL_SIZE = .4;
1124
- var nearest = {
1125
- under: function under(desired) {
1126
- var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1127
- var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
769
+ const nearest = {
770
+ under: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1128
771
  return (Math.floor(desired / nozzel) + nozzie) * nozzel;
1129
772
  },
1130
- over: function over(desired) {
1131
- var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1132
- var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
773
+ over: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1133
774
  return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
1134
775
  }
1135
776
  };
@@ -1157,9 +798,9 @@ function initJscadutils(_CSG, options = {}) {
1157
798
  debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1158
799
  }
1159
800
  function jscadToString(o) {
1160
- if (_typeof(o) == "object") {
801
+ if (typeof o == "object") {
1161
802
  if (o.polygons) {
1162
- return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
803
+ return `{\npolygons: ${o.polygons.length},\nproperties: "${Object.keys(o.properties)}"\n}\n`;
1163
804
  }
1164
805
  } else {
1165
806
  return o.toString();
@@ -1200,12 +841,12 @@ function initJscadutils(_CSG, options = {}) {
1200
841
  }
1201
842
  function text(text) {
1202
843
  var l = vector_char(0, 0, text);
1203
- var _char = l.segments.reduce(function(result, segment) {
844
+ var char = l.segments.reduce(function(result, segment) {
1204
845
  var path = new CSG.Path2D(segment);
1205
846
  var cag = path.expandToCAG(2);
1206
847
  return result ? result.union(cag) : cag;
1207
848
  }, undefined);
1208
- return _char;
849
+ return char;
1209
850
  }
1210
851
  function unitCube(length, radius) {
1211
852
  radius = radius || .5;
@@ -1261,7 +902,7 @@ function initJscadutils(_CSG, options = {}) {
1261
902
  function mapPick(o, names, f, options) {
1262
903
  return names.reduce(function(result, name, index) {
1263
904
  if (!o[name]) {
1264
- throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
905
+ throw new Error(`${name} not found in ${options.name}: ${Object.keys(o).join(",")}`);
1265
906
  }
1266
907
  result.push(f ? f(o[name], name, index, o) : o[name]);
1267
908
  return result;
@@ -1293,7 +934,7 @@ function initJscadutils(_CSG, options = {}) {
1293
934
  function xyz2array(size) {
1294
935
  return [ size.x, size.y, size.z ];
1295
936
  }
1296
- var rotationAxes = {
937
+ const rotationAxes = {
1297
938
  x: [ 1, 0, 0 ],
1298
939
  y: [ 0, 1, 0 ],
1299
940
  z: [ 0, 0, 1 ]
@@ -1371,7 +1012,7 @@ function initJscadutils(_CSG, options = {}) {
1371
1012
  function mirrored4(x) {
1372
1013
  return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
1373
1014
  }
1374
- var flushSide = {
1015
+ const flushSide = {
1375
1016
  "above-outside": [ 1, 0 ],
1376
1017
  "above-inside": [ 1, 1 ],
1377
1018
  "below-outside": [ 0, 1 ],
@@ -1401,8 +1042,7 @@ function initJscadutils(_CSG, options = {}) {
1401
1042
  return w[side[0]][axis] - m[side[1]][axis];
1402
1043
  });
1403
1044
  }
1404
- function calcSnap(moveobj, withobj, axes, orientation) {
1405
- var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1045
+ function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
1406
1046
  var side = flushSide[orientation];
1407
1047
  if (!side) {
1408
1048
  var fix = {
@@ -1468,7 +1108,7 @@ function initJscadutils(_CSG, options = {}) {
1468
1108
  objectSize = objectSize || size(bounds);
1469
1109
  return bounds[0].plus(objectSize.dividedBy(2));
1470
1110
  } catch (err) {
1471
- error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
1111
+ error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
1472
1112
  }
1473
1113
  }
1474
1114
  function calcmidlineTo(o, axis, to) {
@@ -1489,8 +1129,7 @@ function initJscadutils(_CSG, options = {}) {
1489
1129
  });
1490
1130
  return t;
1491
1131
  }
1492
- function calcCenterWith(o, axes, withObj) {
1493
- var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1132
+ function calcCenterWith(o, axes, withObj, delta = 0) {
1494
1133
  var objectCentroid = centroid(o);
1495
1134
  var withCentroid = centroid(withObj);
1496
1135
  var t = axisApply(axes, function(i, axis) {
@@ -1512,12 +1151,9 @@ function initJscadutils(_CSG, options = {}) {
1512
1151
  return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
1513
1152
  });
1514
1153
  }
1515
- function bisect() {
1516
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1517
- args[_key] = arguments[_key];
1518
- }
1154
+ function bisect(...args) {
1519
1155
  if (args.length < 2) {
1520
- error("bisect requries an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
1156
+ error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
1521
1157
  }
1522
1158
  var object = args[0];
1523
1159
  var axis = args[1];
@@ -1596,14 +1232,10 @@ function initJscadutils(_CSG, options = {}) {
1596
1232
  if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
1597
1233
  return g;
1598
1234
  }
1599
- function slice(object) {
1600
- var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
1601
- var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
1602
- var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
1603
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
1604
- color: true,
1605
- addRotationCenter: true
1606
- };
1235
+ function slice(object, angle = 15, axis = "x", rotateaxis = "z", options = {
1236
+ color: true,
1237
+ addRotationCenter: true
1238
+ }) {
1607
1239
  var info = normalVector(axis);
1608
1240
  var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
1609
1241
  var theRotationAxis = rotationAxes[rotateaxis];
@@ -1759,7 +1391,7 @@ function initJscadutils(_CSG, options = {}) {
1759
1391
  var absoluteRadius = Math.abs(radius);
1760
1392
  var si = sliceParams(orientation, radius, b);
1761
1393
  debug$2("reShape", absoluteRadius, si);
1762
- if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
1394
+ if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolygons only uses the "z" axis. You must use the "z" axis for now.');
1763
1395
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
1764
1396
  var slice = object.sectionCut(cutplane);
1765
1397
  var first = axisApply(si.axis, function() {
@@ -1820,12 +1452,11 @@ function initJscadutils(_CSG, options = {}) {
1820
1452
  };
1821
1453
  }
1822
1454
  function rotateAround(part, solid, axis, angle) {
1823
- var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
1455
+ var {rotationCenter, rotationAxis} = calcRotate(part, solid, axis);
1824
1456
  return part.rotate(rotationCenter, rotationAxis, angle);
1825
1457
  }
1826
- function cloneProperties(from, to) {
1827
- return Object.entries(from).reduce(function(props, _ref) {
1828
- var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
1458
+ function cloneProperties(from, to, depth = 0) {
1459
+ return Object.entries(from).reduce((props, [key, value]) => {
1829
1460
  props[key] = value;
1830
1461
  return props;
1831
1462
  }, to);
@@ -1836,14 +1467,85 @@ function initJscadutils(_CSG, options = {}) {
1836
1467
  debug$2("clone", o, c, CSG);
1837
1468
  return c;
1838
1469
  }
1839
- function addConnector(object, name) {
1840
- var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
1841
- var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
1842
- var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
1470
+ function addConnector(object, name, point = [ 0, 0, 0 ], axis = [ 1, 0, 0 ], normal = [ 0, 0, 1 ]) {
1843
1471
  object.properties[name] = new CSG.Connector(point, axis, normal);
1844
1472
  return object;
1845
1473
  }
1846
- var debug$1 = Debug("jscadUtils:parts");
1474
+ var util = Object.freeze({
1475
+ __proto__: null,
1476
+ NOZZEL_SIZE,
1477
+ addConnector,
1478
+ axis2array,
1479
+ axisApply,
1480
+ bisect,
1481
+ calcCenterWith,
1482
+ calcFlush,
1483
+ calcRotate,
1484
+ calcSnap,
1485
+ calcmidlineTo,
1486
+ center,
1487
+ centerWith,
1488
+ centerX,
1489
+ centerY,
1490
+ centroid,
1491
+ chamfer,
1492
+ clone,
1493
+ cm,
1494
+ defaults,
1495
+ depreciated,
1496
+ div,
1497
+ divA,
1498
+ divxyz,
1499
+ enlarge,
1500
+ error,
1501
+ fillet,
1502
+ fit,
1503
+ flush,
1504
+ flushSide,
1505
+ getDelta,
1506
+ identity,
1507
+ ifArray,
1508
+ inch,
1509
+ isEmpty,
1510
+ isNegative,
1511
+ jscadToString,
1512
+ label,
1513
+ map,
1514
+ mapPick,
1515
+ mapValues,
1516
+ midlineTo,
1517
+ mirrored4,
1518
+ mul,
1519
+ mulxyz,
1520
+ nearest,
1521
+ normalVector,
1522
+ pick,
1523
+ poly2solid,
1524
+ print,
1525
+ reShape,
1526
+ result,
1527
+ rotateAround,
1528
+ rotationAxes,
1529
+ scale,
1530
+ segment,
1531
+ shift,
1532
+ size,
1533
+ slice,
1534
+ sliceParams,
1535
+ slices2poly,
1536
+ snap,
1537
+ stretch,
1538
+ text,
1539
+ toArray,
1540
+ translator,
1541
+ unitAxis,
1542
+ unitCube,
1543
+ wedge,
1544
+ xyz2array,
1545
+ zero,
1546
+ zipObject
1547
+ });
1548
+ const debug$1 = Debug("jscadUtils:parts");
1847
1549
  var parts = {
1848
1550
  BBox: BBox$1,
1849
1551
  Cube,
@@ -1851,16 +1553,13 @@ function initJscadutils(_CSG, options = {}) {
1851
1553
  Cylinder,
1852
1554
  Cone
1853
1555
  };
1854
- function BBox$1() {
1556
+ function BBox$1(...objects) {
1855
1557
  function box(object) {
1856
1558
  return CSG.cube({
1857
1559
  center: object.centroid(),
1858
1560
  radius: object.size().dividedBy(2)
1859
1561
  });
1860
1562
  }
1861
- for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
1862
- objects[_key] = arguments[_key];
1863
- }
1864
1563
  return objects.reduce(function(bbox, part) {
1865
1564
  var object = bbox ? union([ bbox, box(part) ]) : part;
1866
1565
  return box(object);
@@ -1893,8 +1592,7 @@ function initJscadutils(_CSG, options = {}) {
1893
1592
  });
1894
1593
  return roundedcube;
1895
1594
  }
1896
- function Cylinder(diameter, height) {
1897
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1595
+ function Cylinder(diameter, height, options = {}) {
1898
1596
  debug$1("parts.Cylinder", diameter, height, options);
1899
1597
  options = Object.assign({
1900
1598
  start: [ 0, 0, 0 ],
@@ -1904,8 +1602,7 @@ function initJscadutils(_CSG, options = {}) {
1904
1602
  }, options);
1905
1603
  return CSG.cylinder(options);
1906
1604
  }
1907
- function Cone(diameter1, diameter2, height) {
1908
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1605
+ function Cone(diameter1, diameter2, height, options = {}) {
1909
1606
  debug$1("parts.Cone", diameter1, diameter2, height, options);
1910
1607
  return CSG.cylinder(Object.assign({
1911
1608
  start: [ 0, 0, 0 ],
@@ -1934,9 +1631,7 @@ function initJscadutils(_CSG, options = {}) {
1934
1631
  function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
1935
1632
  return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
1936
1633
  }
1937
- function Anchor() {
1938
- var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
1939
- var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
1634
+ function Anchor(width = 10, height = 10) {
1940
1635
  var hole = Cylinder(width, height).Center().color("red");
1941
1636
  var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
1942
1637
  return Group({
@@ -1956,7 +1651,7 @@ function initJscadutils(_CSG, options = {}) {
1956
1651
  });
1957
1652
  return board;
1958
1653
  }
1959
- var Hardware = {
1654
+ const Hardware = {
1960
1655
  Orientation: {
1961
1656
  up: {
1962
1657
  head: "outside-",
@@ -1967,7 +1662,7 @@ function initJscadutils(_CSG, options = {}) {
1967
1662
  clear: "inside-"
1968
1663
  }
1969
1664
  },
1970
- Screw: function Screw(head, thread, headClearSpace, options) {
1665
+ Screw: function(head, thread, headClearSpace, options) {
1971
1666
  depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
1972
1667
  options = Object.assign(options, {
1973
1668
  orientation: "up",
@@ -1983,7 +1678,7 @@ function initJscadutils(_CSG, options = {}) {
1983
1678
  }
1984
1679
  return group;
1985
1680
  },
1986
- PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1681
+ PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1987
1682
  depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
1988
1683
  var head = Cylinder(headDiameter, headLength);
1989
1684
  var thread = Cylinder(diameter, length);
@@ -1992,7 +1687,7 @@ function initJscadutils(_CSG, options = {}) {
1992
1687
  }
1993
1688
  return Hardware.Screw(head, thread, headClearSpace, options);
1994
1689
  },
1995
- HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1690
+ HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1996
1691
  depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
1997
1692
  var head = Hexagon(headDiameter, headLength);
1998
1693
  var thread = Cylinder(diameter, length);
@@ -2001,7 +1696,7 @@ function initJscadutils(_CSG, options = {}) {
2001
1696
  }
2002
1697
  return Hardware.Screw(head, thread, headClearSpace, options);
2003
1698
  },
2004
- FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1699
+ FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
2005
1700
  depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
2006
1701
  var head = Cone(headDiameter, diameter, headLength);
2007
1702
  var thread = Cylinder(diameter, length);
@@ -2013,20 +1708,20 @@ function initJscadutils(_CSG, options = {}) {
2013
1708
  };
2014
1709
  var parts$1 = Object.freeze({
2015
1710
  __proto__: null,
2016
- default: parts,
1711
+ Anchor,
2017
1712
  BBox: BBox$1,
1713
+ Board,
1714
+ Cone,
2018
1715
  Cube,
2019
- RoundedCube,
2020
1716
  Cylinder,
2021
- Cone,
1717
+ Hardware,
2022
1718
  Hexagon,
1719
+ RoundedCube,
2023
1720
  Triangle,
2024
1721
  Tube,
2025
- Anchor,
2026
- Board,
2027
- Hardware
1722
+ default: parts
2028
1723
  });
2029
- var debug = Debug("jscadUtils:boxes");
1724
+ const debug = Debug("jscadUtils:boxes");
2030
1725
  function RabbetJoin(box, thickness, cutHeight) {
2031
1726
  depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
2032
1727
  return rabbetJoin(box, thickness, cutHeight);
@@ -2039,17 +1734,16 @@ function initJscadutils(_CSG, options = {}) {
2039
1734
  var top = bottom.parts.positive.bisect("z", -thickness);
2040
1735
  return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
2041
1736
  }
2042
- function Rabett(box, thickness, gap, height, face) {
2043
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1737
+ function Rabett(box, thickness, gap, height, face, options = {}) {
2044
1738
  debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
2045
1739
  gap = gap || .25;
2046
1740
  var inside = thickness - gap;
2047
1741
  var outside = -thickness + gap;
2048
1742
  debug("inside", inside, "outside", outside);
2049
1743
  var group = Group();
2050
- var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
1744
+ var {positive: top, negative: lower2_3rd} = box.bisect("z", height, options).parts;
2051
1745
  var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
2052
- var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
1746
+ var {positive: middle, negative: bottom} = lower2_3rd.bisect("z", lowerBisectHeight, options).parts;
2053
1747
  var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
2054
1748
  group.add(top.union(middleTop), "top");
2055
1749
  var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
@@ -2058,9 +1752,7 @@ function initJscadutils(_CSG, options = {}) {
2058
1752
  group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
2059
1753
  return group;
2060
1754
  }
2061
- var RabettTopBottom = function rabbetTMB(box, thickness) {
2062
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
2063
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1755
+ const RabettTopBottom = function rabbetTMB(box, thickness, gap = .25, options = {}) {
2064
1756
  options = Object.assign({
2065
1757
  removableTop: true,
2066
1758
  removableBottom: true,
@@ -2093,7 +1785,7 @@ function initJscadutils(_CSG, options = {}) {
2093
1785
  }
2094
1786
  return group;
2095
1787
  };
2096
- var CutOut = function cutOut(o, h, box, plug, gap) {
1788
+ const CutOut = function cutOut(o, h, box, plug, gap) {
2097
1789
  gap = gap || .25;
2098
1790
  var s = o.size();
2099
1791
  var cutout = o.intersect(box);
@@ -2111,7 +1803,7 @@ function initJscadutils(_CSG, options = {}) {
2111
1803
  insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
2112
1804
  });
2113
1805
  };
2114
- var Rectangle = function Rectangle(size, thickness, cb) {
1806
+ const Rectangle = function(size, thickness, cb) {
2115
1807
  thickness = thickness || 2;
2116
1808
  var s = div$1(xyz2array(size), 2);
2117
1809
  var r = add(s, thickness);
@@ -2125,7 +1817,7 @@ function initJscadutils(_CSG, options = {}) {
2125
1817
  if (cb) box = cb(box);
2126
1818
  return box;
2127
1819
  };
2128
- var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
1820
+ const Hollow = function(object, thickness, interiorcb, exteriorcb) {
2129
1821
  thickness = thickness || 2;
2130
1822
  var size = -thickness * 2;
2131
1823
  interiorcb = interiorcb || identity;
@@ -2133,7 +1825,7 @@ function initJscadutils(_CSG, options = {}) {
2133
1825
  if (exteriorcb) box = exteriorcb(box);
2134
1826
  return box;
2135
1827
  };
2136
- var BBox = function BBox(o) {
1828
+ const BBox = function(o) {
2137
1829
  depreciated("BBox", true, "Use 'parts.BBox' instead");
2138
1830
  var s = div$1(xyz2array(o.size()), 2);
2139
1831
  return CSG.cube({
@@ -2144,8 +1836,7 @@ function initJscadutils(_CSG, options = {}) {
2144
1836
  function getRadius(o) {
2145
1837
  return div$1(xyz2array(o.size()), 2);
2146
1838
  }
2147
- function rabbetJoin(box, thickness) {
2148
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
1839
+ function rabbetJoin(box, thickness, gap = .25) {
2149
1840
  var r = add(getRadius(box), -thickness / 2);
2150
1841
  r[2] = thickness / 2;
2151
1842
  var cutter = CSG.cube({
@@ -2163,16 +1854,17 @@ function initJscadutils(_CSG, options = {}) {
2163
1854
  }
2164
1855
  var Boxes = Object.freeze({
2165
1856
  __proto__: null,
1857
+ BBox,
1858
+ CutOut,
1859
+ Hollow,
2166
1860
  RabbetJoin,
2167
- topMiddleBottom,
2168
1861
  Rabett,
2169
1862
  RabettTopBottom,
2170
- CutOut,
2171
1863
  Rectangle,
2172
- Hollow,
2173
- BBox
1864
+ topMiddleBottom
2174
1865
  });
2175
- var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
1866
+ const compatV1 = {
1867
+ ...util,
2176
1868
  group: Group,
2177
1869
  init: init$1,
2178
1870
  triangle: triUtils,
@@ -2180,7 +1872,7 @@ function initJscadutils(_CSG, options = {}) {
2180
1872
  parts: parts$1,
2181
1873
  Boxes,
2182
1874
  Debug
2183
- });
1875
+ };
2184
1876
  exports.Boxes = Boxes;
2185
1877
  exports.Debug = Debug;
2186
1878
  exports.Group = Group;
@@ -2190,9 +1882,6 @@ function initJscadutils(_CSG, options = {}) {
2190
1882
  exports.parts = parts$1;
2191
1883
  exports.triUtils = triUtils;
2192
1884
  exports.util = util;
2193
- Object.defineProperty(exports, "__esModule", {
2194
- value: true
2195
- });
2196
1885
  return exports;
2197
1886
  }({}, jsCadCSG, scadApi);
2198
1887
  const debug = jscadUtils.Debug("jscadUtils:initJscadutils");