@jwc/jscad-utils 4.8.4 → 5.0.0

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,335 +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$1;
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 _typeof(obj) {
291
- "@babel/helpers - typeof";
292
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
293
- _typeof = function(obj) {
294
- return typeof obj;
295
- };
296
- } else {
297
- _typeof = function(obj) {
298
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
299
- };
300
- }
301
- return _typeof(obj);
302
- }
303
- function _defineProperty(obj, key, value) {
304
- if (key in obj) {
305
- Object.defineProperty(obj, key, {
306
- value,
307
- enumerable: true,
308
- configurable: true,
309
- writable: true
310
- });
311
- } else {
312
- obj[key] = value;
313
- }
314
- return obj;
315
- }
316
- function ownKeys(object, enumerableOnly) {
317
- var keys = Object.keys(object);
318
- if (Object.getOwnPropertySymbols) {
319
- var symbols = Object.getOwnPropertySymbols(object);
320
- if (enumerableOnly) symbols = symbols.filter((function(sym) {
321
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
322
- }));
323
- keys.push.apply(keys, symbols);
324
- }
325
- return keys;
326
- }
327
- function _objectSpread2(target) {
328
- for (var i = 1; i < arguments.length; i++) {
329
- var source = arguments[i] != null ? arguments[i] : {};
330
- if (i % 2) {
331
- ownKeys(Object(source), true).forEach((function(key) {
332
- _defineProperty(target, key, source[key]);
333
- }));
334
- } else if (Object.getOwnPropertyDescriptors) {
335
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
336
- } else {
337
- ownKeys(Object(source)).forEach((function(key) {
338
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
339
- }));
340
- }
341
- }
342
- return target;
343
- }
344
- function _slicedToArray(arr, i) {
345
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
346
- }
347
- function _arrayWithHoles(arr) {
348
- if (Array.isArray(arr)) return arr;
349
- }
350
- function _iterableToArrayLimit(arr, i) {
351
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
352
- var _arr = [];
353
- var _n = true;
354
- var _d = false;
355
- var _e = undefined;
356
- try {
357
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
358
- _arr.push(_s.value);
359
- if (i && _arr.length === i) break;
360
- }
361
- } catch (err) {
362
- _d = true;
363
- _e = err;
364
- } finally {
365
- try {
366
- if (!_n && _i["return"] != null) _i["return"]();
367
- } finally {
368
- if (_d) throw _e;
369
- }
370
- }
371
- return _arr;
372
- }
373
- function _unsupportedIterableToArray(o, minLen) {
374
- if (!o) return;
375
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
376
- var n = Object.prototype.toString.call(o).slice(8, -1);
377
- if (n === "Object" && o.constructor) n = o.constructor.name;
378
- if (n === "Map" || n === "Set") return Array.from(o);
379
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
380
- }
381
- function _arrayLikeToArray(arr, len) {
382
- if (len == null || len > arr.length) len = arr.length;
383
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
384
- return arr2;
385
- }
386
- function _nonIterableRest() {
387
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
388
- }
389
- var toRadians = function toRadians(deg) {
67
+ const toRadians = function toRadians(deg) {
390
68
  return deg / 180 * Math.PI;
391
69
  };
392
- var toDegrees = function toDegrees(rad) {
70
+ const toDegrees = function toDegrees(rad) {
393
71
  return rad * (180 / Math.PI);
394
72
  };
395
- var solve = function solve(p1, p2) {
73
+ const solve = function(p1, p2) {
396
74
  var r = {
397
75
  c: 90,
398
76
  A: Math.abs(p2.x - p1.x),
@@ -404,7 +82,7 @@ function initJscadutils(_CSG, options = {}) {
404
82
  r.a = 90 - r.b;
405
83
  return r;
406
84
  };
407
- var solve90SA = function solve90SA(r) {
85
+ const solve90SA = function(r) {
408
86
  r = Object.assign(r, {
409
87
  C: 90
410
88
  });
@@ -416,7 +94,7 @@ function initJscadutils(_CSG, options = {}) {
416
94
  r.b = r.b || r.a / Math.tan(arad);
417
95
  return r;
418
96
  };
419
- var solve90ac = function solve90ac(r) {
97
+ const solve90ac = function(r) {
420
98
  r = Object.assign(r, {
421
99
  C: 90
422
100
  });
@@ -437,60 +115,60 @@ function initJscadutils(_CSG, options = {}) {
437
115
  }
438
116
  var triUtils = Object.freeze({
439
117
  __proto__: null,
440
- toRadians,
441
- toDegrees,
442
118
  solve,
443
119
  solve90SA,
444
120
  solve90ac,
445
- solveab
121
+ solveab,
122
+ toDegrees,
123
+ toRadians
446
124
  });
447
- var div = function div(a, f) {
448
- return a.map((function(e) {
125
+ const div$1 = function(a, f) {
126
+ return a.map(function(e) {
449
127
  return e / f;
450
- }));
128
+ });
451
129
  };
452
- var addValue = function addValue(a, f) {
453
- return a.map((function(e) {
130
+ const addValue = function(a, f) {
131
+ return a.map(function(e) {
454
132
  return e + f;
455
- }));
133
+ });
456
134
  };
457
- var addArray = function addArray(a, f) {
458
- return a.map((function(e, i) {
135
+ const addArray = function(a, f) {
136
+ return a.map(function(e, i) {
459
137
  return e + f[i];
460
- }));
138
+ });
461
139
  };
462
- var add = function add(a) {
463
- return Array.prototype.slice.call(arguments, 1).reduce((function(result, arg) {
140
+ const add = function(a) {
141
+ return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
464
142
  if (Array.isArray(arg)) {
465
143
  result = addArray(result, arg);
466
144
  } else {
467
145
  result = addValue(result, arg);
468
146
  }
469
147
  return result;
470
- }), a);
148
+ }, a);
471
149
  };
472
- var fromxyz = function fromxyz(object) {
150
+ const fromxyz = function(object) {
473
151
  return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
474
152
  };
475
- var toxyz = function toxyz(a) {
153
+ const toxyz = function(a) {
476
154
  return {
477
155
  x: a[0],
478
156
  y: a[1],
479
157
  z: a[2]
480
158
  };
481
159
  };
482
- var first = function first(a) {
160
+ const first = function(a) {
483
161
  return a ? a[0] : undefined;
484
162
  };
485
- var last = function last(a) {
163
+ const last = function(a) {
486
164
  return a && a.length > 0 ? a[a.length - 1] : undefined;
487
165
  };
488
- var min = function min(a) {
489
- return a.reduce((function(result, value) {
166
+ const min = function(a) {
167
+ return a.reduce(function(result, value) {
490
168
  return value < result ? value : result;
491
- }), Number.MAX_VALUE);
169
+ }, Number.MAX_VALUE);
492
170
  };
493
- var range = function range(a, b) {
171
+ const range = function(a, b) {
494
172
  var result = [];
495
173
  for (var i = a; i < b; i++) {
496
174
  result.push(i);
@@ -499,21 +177,21 @@ function initJscadutils(_CSG, options = {}) {
499
177
  };
500
178
  var array = Object.freeze({
501
179
  __proto__: null,
502
- div,
503
- addValue,
504
- addArray,
505
180
  add,
506
- fromxyz,
507
- toxyz,
181
+ addArray,
182
+ addValue,
183
+ div: div$1,
508
184
  first,
185
+ fromxyz,
509
186
  last,
510
187
  min,
511
- range
188
+ range,
189
+ toxyz
512
190
  });
513
- var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
514
- 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" ];
515
193
  var debugCount = 0;
516
- var Debug = function Debug(name) {
194
+ const Debug = function(name) {
517
195
  var checks = Object.assign({
518
196
  enabled: [],
519
197
  disabled: [],
@@ -521,31 +199,21 @@ function initJscadutils(_CSG, options = {}) {
521
199
  browser: true
522
200
  }
523
201
  }, jscadUtilsDebug || {});
524
- var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
525
- var enabled = checks.enabled.some((function checkEnabled(check) {
202
+ var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
203
+ var enabled = checks.enabled.some(function checkEnabled(check) {
526
204
  return check.test(name);
527
- })) && !checks.disabled.some((function checkEnabled(check) {
205
+ }) && !checks.disabled.some(function checkEnabled(check) {
528
206
  return check.test(name);
529
- }));
530
- var logger = enabled ? checks.options.browser ? function() {
531
- var _console;
532
- for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
533
- msg[_key] = arguments[_key];
534
- }
535
- (_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
536
- } : function() {
537
- var _console2;
538
- for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
539
- msg[_key2] = arguments[_key2];
540
- }
541
- (_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
542
- } : function() {
543
- return undefined;
544
- };
207
+ });
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;
545
213
  logger.enabled = enabled;
546
214
  return logger;
547
215
  };
548
- var nameArray = {
216
+ const nameArray = {
549
217
  aliceblue: "#f0f8ff",
550
218
  antiquewhite: "#faebd7",
551
219
  aqua: "#00ffff",
@@ -703,9 +371,11 @@ function initJscadutils(_CSG, options = {}) {
703
371
  h = h.replace(/^\#/, "");
704
372
  if (h.length === 6) {
705
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 ];
706
376
  }
707
377
  }
708
- var _name2rgb = {};
378
+ const _name2rgb = {};
709
379
  function name2rgb(n) {
710
380
  if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
711
381
  return _name2rgb[n];
@@ -713,9 +383,9 @@ function initJscadutils(_CSG, options = {}) {
713
383
  function color(o, r, g, b, a) {
714
384
  if (typeof r !== "string") return o.setColor(r, g, b, a);
715
385
  if (r === "") return o;
716
- var c = name2rgb(r).map((function(x) {
386
+ var c = name2rgb(r).map(function(x) {
717
387
  return x / 255;
718
- }));
388
+ });
719
389
  c[3] = g || 1;
720
390
  return o.setColor(c);
721
391
  }
@@ -785,23 +455,14 @@ function initJscadutils(_CSG, options = {}) {
785
455
  proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
786
456
  return chamfer(this, radius, orientation, options);
787
457
  };
788
- proto.prototype.bisect = function bisect$1() {
789
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
790
- args[_key] = arguments[_key];
791
- }
792
- return bisect.apply(util, [ this ].concat(args));
458
+ proto.prototype.bisect = function bisect$1(...args) {
459
+ return bisect(this, ...args);
793
460
  };
794
- proto.prototype.slice = function slice$1() {
795
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
796
- args[_key2] = arguments[_key2];
797
- }
798
- return slice.apply(util, [ this ].concat(args));
461
+ proto.prototype.slice = function slice$1(...args) {
462
+ return slice(this, ...args);
799
463
  };
800
- proto.prototype.wedge = function wedge$1() {
801
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
802
- args[_key3] = arguments[_key3];
803
- }
804
- return wedge.apply(util, [ this ].concat(args));
464
+ proto.prototype.wedge = function wedge$1(...args) {
465
+ return wedge(this, ...args);
805
466
  };
806
467
  proto.prototype.stretch = function stretch$1(axis, distance, offset) {
807
468
  return stretch(this, axis, distance, offset);
@@ -817,24 +478,20 @@ function initJscadutils(_CSG, options = {}) {
817
478
  if (arguments.length === 1) {
818
479
  return this._translate(arguments[0]);
819
480
  } else {
820
- var t = Array.prototype.slice.call(arguments, 0).reduce((function(result, arg) {
821
- result = undefined(result, arg);
481
+ var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
482
+ result = undefined.addArray(result, arg);
822
483
  return result;
823
- }), [ 0, 0, 0 ]);
484
+ }, [ 0, 0, 0 ]);
824
485
  return this._translate(t);
825
486
  }
826
487
  };
827
488
  proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
828
489
  return addConnector(this, name, point, axis, normal);
829
490
  };
830
- proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
831
- var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
832
- var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
833
- var myConnector = myConnectorName.split(".").reduce((function(a, v) {
834
- return a[v];
835
- }), 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);
836
493
  if (!myConnector) {
837
- 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");
838
495
  }
839
496
  return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
840
497
  };
@@ -844,32 +501,29 @@ function initJscadutils(_CSG, options = {}) {
844
501
  __proto__: null,
845
502
  default: init
846
503
  });
847
- var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
848
- var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
849
- var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
850
- 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;
851
508
  init(CSG);
852
- var debug = Debug("jscadUtils:group");
853
- function JsCadUtilsGroup() {
854
- var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
855
- var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
856
- var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
509
+ const debug$3 = Debug("jscadUtils:group");
510
+ function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
857
511
  this.name = "";
858
512
  this.names = names;
859
513
  this.parts = parts;
860
514
  this.holes = holes;
861
515
  }
862
516
  JsCadUtilsGroup.prototype.add = function(object, name, hidden, subparts, parts) {
863
- debug("add", object, name, hidden, subparts, parts);
517
+ debug$3("add", object, name, hidden, subparts, parts);
864
518
  var self = this;
865
519
  if (object.parts) {
866
520
  if (name) {
867
521
  if (!hidden) self.names.push(name);
868
522
  self.parts[name] = object.combine(parts);
869
523
  if (subparts) {
870
- Object.keys(object.parts).forEach((function(key) {
524
+ Object.keys(object.parts).forEach(function(key) {
871
525
  self.parts[subparts + key] = object.parts[key];
872
- }));
526
+ });
873
527
  }
874
528
  } else {
875
529
  Object.assign(self.parts, object.parts);
@@ -881,11 +535,7 @@ function initJscadutils(_CSG, options = {}) {
881
535
  }
882
536
  return self;
883
537
  };
884
- JsCadUtilsGroup.prototype.combine = function(pieces) {
885
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
886
- var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
887
- return x;
888
- };
538
+ JsCadUtilsGroup.prototype.combine = function(pieces, options = {}, map = x => x) {
889
539
  try {
890
540
  var self = this;
891
541
  options = Object.assign({
@@ -893,31 +543,30 @@ function initJscadutils(_CSG, options = {}) {
893
543
  }, options);
894
544
  pieces = pieces ? pieces.split(",") : self.names;
895
545
  if (pieces.length === 0) {
896
- 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}`);
897
547
  }
898
- debug("combine", self.names, self.parts);
899
- var g = union(mapPick(self.parts, pieces, (function(value, key, index, object) {
548
+ debug$3("combine", self.names, self.parts);
549
+ var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
550
+ debug$3("combine mapPick", value, key, object);
900
551
  return map ? map(value, key, index, object) : identity(value);
901
- }), self.name));
552
+ }, self.name));
902
553
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
903
554
  } catch (err) {
904
- debug("combine error", this, pieces, options, err);
905
- 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");
555
+ debug$3("combine error", this, pieces, options, err);
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");
906
557
  }
907
558
  };
908
559
  JsCadUtilsGroup.prototype.map = function(cb) {
909
560
  var self = this;
910
- self.parts = Object.keys(self.parts).filter((function(k) {
911
- return k !== "holes";
912
- })).reduce((function(result, key) {
561
+ self.parts = Object.keys(self.parts).filter(k => k !== "holes").reduce(function(result, key) {
913
562
  result[key] = cb(self.parts[key], key);
914
563
  return result;
915
- }), {});
564
+ }, {});
916
565
  if (self.holes) {
917
566
  if (Array.isArray(self.holes)) {
918
- self.holes = self.holes.map((function(hole, idx) {
567
+ self.holes = self.holes.map(function(hole, idx) {
919
568
  return cb(hole, idx);
920
- }));
569
+ });
921
570
  } else {
922
571
  self.holes = cb(self.holes, "holes");
923
572
  }
@@ -925,7 +574,7 @@ function initJscadutils(_CSG, options = {}) {
925
574
  return self;
926
575
  };
927
576
  JsCadUtilsGroup.prototype.clone = function(name, map) {
928
- debug("clone", name, _typeof(name), map);
577
+ debug$3("clone", name, typeof name, map);
929
578
  var self = this;
930
579
  if (typeof name == "function") {
931
580
  map = name;
@@ -933,15 +582,15 @@ function initJscadutils(_CSG, options = {}) {
933
582
  }
934
583
  if (!map) map = identity;
935
584
  var group = Group(name);
936
- Object.keys(self.parts).forEach((function(key) {
585
+ Object.keys(self.parts).forEach(function(key) {
937
586
  var part = self.parts[key];
938
587
  var hidden = self.names.indexOf(key) == -1;
939
588
  group.add(map(clone(part)), key, hidden);
940
- }));
589
+ });
941
590
  if (self.holes) {
942
- group.holes = toArray(self.holes).map((function(part) {
591
+ group.holes = toArray(self.holes).map(function(part) {
943
592
  return map(CSG.fromPolygons(part.toPolygons()), "holes");
944
- }));
593
+ });
945
594
  }
946
595
  return group;
947
596
  };
@@ -958,9 +607,9 @@ function initJscadutils(_CSG, options = {}) {
958
607
  }
959
608
  var rotationCenter = solid.centroid();
960
609
  var rotationAxis = axes[axis];
961
- self.map((function(part) {
610
+ self.map(function(part) {
962
611
  return part.rotate(rotationCenter, rotationAxis, angle);
963
- }));
612
+ });
964
613
  return self;
965
614
  };
966
615
  JsCadUtilsGroup.prototype.combineAll = function(options, map) {
@@ -971,13 +620,13 @@ function initJscadutils(_CSG, options = {}) {
971
620
  try {
972
621
  var self = this;
973
622
  var t = calcSnap(self.combine(part), to, axis, orientation, delta);
974
- self.map((function(part) {
623
+ self.map(function(part) {
975
624
  return part.translate(t);
976
- }));
625
+ });
977
626
  return self;
978
627
  } catch (err) {
979
- debug("snap error", this, part, to, axis, delta, err);
980
- 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");
628
+ debug$3("snap error", this, part, to, axis, delta, err);
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");
981
630
  }
982
631
  };
983
632
  JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
@@ -986,13 +635,13 @@ function initJscadutils(_CSG, options = {}) {
986
635
  var t = calcCenterWith(self.combine(part, {
987
636
  noholes: true
988
637
  }), axis, to, delta);
989
- self.map((function(part) {
638
+ self.map(function(part) {
990
639
  return part.translate(t);
991
- }));
640
+ });
992
641
  return self;
993
642
  } catch (err) {
994
- debug("align error", this, part, to, axis, delta, err);
995
- 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");
643
+ debug$3("align error", this, part, to, axis, delta, err);
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");
996
645
  }
997
646
  };
998
647
  JsCadUtilsGroup.prototype.center = function center(part) {
@@ -1004,10 +653,8 @@ function initJscadutils(_CSG, options = {}) {
1004
653
  var bounds = self.parts[part].getBounds();
1005
654
  return self.translate([ 0, 0, -bounds[0].z ]);
1006
655
  };
1007
- JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
1008
- var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1009
- var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
1010
- debug("connectTo", {
656
+ JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
657
+ debug$3("connectTo", {
1011
658
  partName,
1012
659
  connectorName,
1013
660
  to,
@@ -1016,38 +663,34 @@ function initJscadutils(_CSG, options = {}) {
1016
663
  normalrotation
1017
664
  });
1018
665
  var self = this;
1019
- var myConnector = connectorName.split(".").reduce((function(a, v) {
1020
- return a[v];
1021
- }), self.parts[partName].properties);
1022
- debug("toConnector", to instanceof CSG.Connector);
1023
- var toConnector = toConnectorName.split(".").reduce((function(a, v) {
1024
- return a[v];
1025
- }), to.properties);
666
+ var myConnector = connectorName.split(".").reduce((a, v) => a[v], self.parts[partName].properties);
667
+ debug$3("toConnector", to instanceof CSG.Connector);
668
+ var toConnector = toConnectorName.split(".").reduce((a, v) => a[v], to.properties);
1026
669
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
1027
- debug("connectTo", matrix);
1028
- self.map((function(part) {
670
+ debug$3("connectTo", matrix);
671
+ self.map(function(part) {
1029
672
  return part.transform(matrix);
1030
- }));
673
+ });
1031
674
  return self;
1032
675
  };
1033
676
  JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
1034
677
  var self = this;
1035
678
  var size = self.combine(part).size();
1036
- var t = axisApply(axis, (function(i, a) {
679
+ var t = axisApply(axis, function(i, a) {
1037
680
  return to - size[a] / 2;
1038
- }));
1039
- self.map((function(part) {
681
+ });
682
+ self.map(function(part) {
1040
683
  return part.translate(t);
1041
- }));
684
+ });
1042
685
  return self;
1043
686
  };
1044
687
  JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
1045
688
  var self = this;
1046
689
  var t = Array.isArray(x) ? x : [ x, y, z ];
1047
- debug("translate", t);
1048
- self.map((function(part) {
690
+ debug$3("translate", t);
691
+ self.map(function(part) {
1049
692
  return part.translate(t);
1050
- }));
693
+ });
1051
694
  return self;
1052
695
  };
1053
696
  JsCadUtilsGroup.prototype.pick = function(parts, map) {
@@ -1055,43 +698,42 @@ function initJscadutils(_CSG, options = {}) {
1055
698
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1056
699
  if (!map) map = identity;
1057
700
  var g = Group();
1058
- p.forEach((function(name) {
701
+ p.forEach(function(name) {
1059
702
  g.add(map(CSG.fromPolygons(self.parts[name].toPolygons()), name), name);
1060
- }));
703
+ });
1061
704
  return g;
1062
705
  };
1063
706
  JsCadUtilsGroup.prototype.array = function(parts, map) {
1064
- var _this = this;
1065
707
  var self = this;
1066
708
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1067
709
  if (!map) map = identity;
1068
710
  var a = [];
1069
- p.forEach((function(name) {
711
+ p.forEach(name => {
1070
712
  if (!self.parts[name]) {
1071
- debug("array error", _this, parts);
1072
- 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");
1073
715
  }
1074
716
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1075
- }));
717
+ });
1076
718
  return a;
1077
719
  };
1078
720
  JsCadUtilsGroup.prototype.toArray = function(pieces) {
1079
721
  var self = this;
1080
722
  var piecesArray = pieces ? pieces.split(",") : self.names;
1081
- return piecesArray.map((function(piece) {
1082
- if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
723
+ return piecesArray.map(function(piece) {
724
+ if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
1083
725
  return self.parts[piece];
1084
- }));
726
+ });
1085
727
  };
1086
728
  JsCadUtilsGroup.prototype.toString = function() {
1087
- return '{\n name: "'.concat(this.name, '",\n names: "').concat(this.names.join(","), '", \n parts: "').concat(Object.keys(this.parts), '",\n holes: "').concat(this.holes, '"\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}`;
1088
730
  };
1089
731
  JsCadUtilsGroup.prototype.setName = function(name) {
1090
732
  this.name = name;
1091
733
  return this;
1092
734
  };
1093
735
  function Group(objectNames, addObjects) {
1094
- debug("Group", objectNames, addObjects);
736
+ debug$3("Group", objectNames, addObjects);
1095
737
  var self = {
1096
738
  name: "",
1097
739
  names: [],
@@ -1114,9 +756,7 @@ function initJscadutils(_CSG, options = {}) {
1114
756
  self.name = objectNames;
1115
757
  } else {
1116
758
  var objects = objectNames;
1117
- self.names = Object.keys(objects).filter((function(k) {
1118
- return k !== "holes";
1119
- }));
759
+ self.names = Object.keys(objects).filter(k => k !== "holes");
1120
760
  self.parts = Object.assign({}, objects);
1121
761
  self.holes = objects.holes;
1122
762
  }
@@ -1124,17 +764,13 @@ function initJscadutils(_CSG, options = {}) {
1124
764
  }
1125
765
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1126
766
  }
1127
- var debug$1 = Debug("jscadUtils:util");
767
+ const debug$2 = Debug("jscadUtils:util");
1128
768
  var NOZZEL_SIZE = .4;
1129
- var nearest = {
1130
- under: function under(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;
769
+ const nearest = {
770
+ under: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1133
771
  return (Math.floor(desired / nozzel) + nozzie) * nozzel;
1134
772
  },
1135
- over: function over(desired) {
1136
- var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
1137
- var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
773
+ over: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
1138
774
  return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
1139
775
  }
1140
776
  };
@@ -1159,12 +795,12 @@ function initJscadutils(_CSG, options = {}) {
1159
795
  return ((n = +n) || 1 / n) < 0;
1160
796
  }
1161
797
  function print(msg, o) {
1162
- debug$1(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
798
+ debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1163
799
  }
1164
800
  function jscadToString(o) {
1165
- if (_typeof(o) == "object") {
801
+ if (typeof o == "object") {
1166
802
  if (o.polygons) {
1167
- 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`;
1168
804
  }
1169
805
  } else {
1170
806
  return o.toString();
@@ -1195,22 +831,22 @@ function initJscadutils(_CSG, options = {}) {
1195
831
  function label(text, x, y, width, height) {
1196
832
  var l = vector_text(x || 0, y || 0, text);
1197
833
  var o = [];
1198
- l.forEach((function(pl) {
834
+ l.forEach(function(pl) {
1199
835
  o.push(rectangular_extrude(pl, {
1200
836
  w: width || 2,
1201
837
  h: height || 2
1202
838
  }));
1203
- }));
839
+ });
1204
840
  return center(union(o));
1205
841
  }
1206
842
  function text(text) {
1207
843
  var l = vector_char(0, 0, text);
1208
- var _char = l.segments.reduce((function(result, segment) {
844
+ var char = l.segments.reduce(function(result, segment) {
1209
845
  var path = new CSG.Path2D(segment);
1210
846
  var cag = path.expandToCAG(2);
1211
847
  return result ? result.union(cag) : cag;
1212
- }), undefined);
1213
- return _char;
848
+ }, undefined);
849
+ return char;
1214
850
  }
1215
851
  function unitCube(length, radius) {
1216
852
  radius = radius || .5;
@@ -1220,7 +856,7 @@ function initJscadutils(_CSG, options = {}) {
1220
856
  });
1221
857
  }
1222
858
  function unitAxis(length, radius, centroid) {
1223
- debug$1("unitAxis", length, radius, centroid);
859
+ debug$2("unitAxis", length, radius, centroid);
1224
860
  centroid = centroid || [ 0, 0, 0 ];
1225
861
  var unitaxis = unitCube(length, radius).setColor(1, 0, 0).union([ unitCube(length, radius).rotateY(90).setColor(0, 1, 0), unitCube(length, radius).rotateX(90).setColor(0, 0, 1) ]);
1226
862
  unitaxis.properties.origin = new CSG.Connector([ 0, 0, 0 ], [ 1, 0, 0 ], [ 0, 1, 0 ]);
@@ -1242,38 +878,38 @@ function initJscadutils(_CSG, options = {}) {
1242
878
  return result;
1243
879
  }
1244
880
  function zipObject(names, values) {
1245
- return names.reduce((function(result, value, idx) {
881
+ return names.reduce(function(result, value, idx) {
1246
882
  result[value] = values[idx];
1247
883
  return result;
1248
- }), {});
884
+ }, {});
1249
885
  }
1250
886
  function map(o, f) {
1251
- return Object.keys(o).map((function(key) {
887
+ return Object.keys(o).map(function(key) {
1252
888
  return f(o[key], key, o);
1253
- }));
889
+ });
1254
890
  }
1255
891
  function mapValues(o, f) {
1256
- return Object.keys(o).map((function(key) {
892
+ return Object.keys(o).map(function(key) {
1257
893
  return f(o[key], key);
1258
- }));
894
+ });
1259
895
  }
1260
896
  function pick(o, names) {
1261
- return names.reduce((function(result, name) {
897
+ return names.reduce(function(result, name) {
1262
898
  result[name] = o[name];
1263
899
  return result;
1264
- }), {});
900
+ }, {});
1265
901
  }
1266
902
  function mapPick(o, names, f, options) {
1267
- return names.reduce((function(result, name, index) {
903
+ return names.reduce(function(result, name, index) {
1268
904
  if (!o[name]) {
1269
- 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(",")}`);
1270
906
  }
1271
907
  result.push(f ? f(o[name], name, index, o) : o[name]);
1272
908
  return result;
1273
- }), []);
909
+ }, []);
1274
910
  }
1275
911
  function divA(a, f) {
1276
- return div(a, f);
912
+ return div$1(a, f);
1277
913
  }
1278
914
  function divxyz(size, x, y, z) {
1279
915
  return {
@@ -1282,7 +918,7 @@ function initJscadutils(_CSG, options = {}) {
1282
918
  z: size.z / z
1283
919
  };
1284
920
  }
1285
- function div$1(size, d) {
921
+ function div(size, d) {
1286
922
  return this.divxyz(size, d, d, d);
1287
923
  }
1288
924
  function mulxyz(size, x, y, z) {
@@ -1298,7 +934,7 @@ function initJscadutils(_CSG, options = {}) {
1298
934
  function xyz2array(size) {
1299
935
  return [ size.x, size.y, size.z ];
1300
936
  }
1301
- var rotationAxes = {
937
+ const rotationAxes = {
1302
938
  x: [ 1, 0, 0 ],
1303
939
  y: [ 0, 1, 0 ],
1304
940
  z: [ 0, 0, 1 ]
@@ -1334,9 +970,9 @@ function initJscadutils(_CSG, options = {}) {
1334
970
  var objectSize = size(object);
1335
971
  var objectCentroid = centroid(object, objectSize);
1336
972
  var idx = 0;
1337
- var t = map(objectSize, (function(i) {
973
+ var t = map(objectSize, function(i) {
1338
974
  return scale(i, a[idx++]);
1339
- }));
975
+ });
1340
976
  var new_object = object.scale(t);
1341
977
  var new_centroid = centroid(new_object);
1342
978
  var delta = new_centroid.minus(objectCentroid).times(-1);
@@ -1360,10 +996,10 @@ function initJscadutils(_CSG, options = {}) {
1360
996
  }
1361
997
  var s = [ scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z) ];
1362
998
  var min$1 = min(s);
1363
- return centerWith(object.scale(s.map((function(d, i) {
999
+ return centerWith(object.scale(s.map(function(d, i) {
1364
1000
  if (a[i] === 0) return 1;
1365
1001
  return keep_aspect_ratio ? min$1 : d;
1366
- }))), "xyz", object);
1002
+ })), "xyz", object);
1367
1003
  }
1368
1004
  function shift(object, x, y, z) {
1369
1005
  var hsize = this.div(this.size(object.getBounds()), 2);
@@ -1376,7 +1012,7 @@ function initJscadutils(_CSG, options = {}) {
1376
1012
  function mirrored4(x) {
1377
1013
  return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
1378
1014
  }
1379
- var flushSide = {
1015
+ const flushSide = {
1380
1016
  "above-outside": [ 1, 0 ],
1381
1017
  "above-inside": [ 1, 1 ],
1382
1018
  "below-outside": [ 0, 1 ],
@@ -1402,12 +1038,11 @@ function initJscadutils(_CSG, options = {}) {
1402
1038
  if (side[0] === -1) {
1403
1039
  w[-1] = toxyz(withobj.centroid());
1404
1040
  }
1405
- return this.axisApply(axes, (function(i, axis) {
1041
+ return this.axisApply(axes, function(i, axis) {
1406
1042
  return w[side[0]][axis] - m[side[1]][axis];
1407
- }));
1043
+ });
1408
1044
  }
1409
- function calcSnap(moveobj, withobj, axes, orientation) {
1410
- var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1045
+ function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
1411
1046
  var side = flushSide[orientation];
1412
1047
  if (!side) {
1413
1048
  var fix = {
@@ -1425,15 +1060,15 @@ function initJscadutils(_CSG, options = {}) {
1425
1060
  if (side[0] === -1) {
1426
1061
  w[-1] = withobj.centroid();
1427
1062
  }
1428
- var t = axisApply(axes, (function(i, axis) {
1063
+ var t = axisApply(axes, function(i, axis) {
1429
1064
  return w[side[0]][axis] - m[side[1]][axis];
1430
- }));
1431
- return delta ? axisApply(axes, (function(i) {
1065
+ });
1066
+ return delta ? axisApply(axes, function(i) {
1432
1067
  return t[i] + delta;
1433
- })) : t;
1068
+ }) : t;
1434
1069
  }
1435
1070
  function snap(moveobj, withobj, axis, orientation, delta) {
1436
- debug$1("snap", moveobj, withobj, axis, orientation, delta);
1071
+ debug$2("snap", moveobj, withobj, axis, orientation, delta);
1437
1072
  var t = calcSnap(moveobj, withobj, axis, orientation, delta);
1438
1073
  return moveobj.translate(t);
1439
1074
  }
@@ -1441,16 +1076,16 @@ function initJscadutils(_CSG, options = {}) {
1441
1076
  return moveobj.translate(calcFlush(moveobj, withobj, axis, mside, wside));
1442
1077
  }
1443
1078
  function axisApply(axes, valfun, a) {
1444
- debug$1("axisApply", axes, valfun, a);
1079
+ debug$2("axisApply", axes, valfun, a);
1445
1080
  var retval = a || [ 0, 0, 0 ];
1446
1081
  var lookup = {
1447
1082
  x: 0,
1448
1083
  y: 1,
1449
1084
  z: 2
1450
1085
  };
1451
- axes.split("").forEach((function(axis) {
1086
+ axes.split("").forEach(function(axis) {
1452
1087
  retval[lookup[axis]] = valfun(lookup[axis], axis);
1453
- }));
1088
+ });
1454
1089
  return retval;
1455
1090
  }
1456
1091
  function axis2array(axes, valfun) {
@@ -1461,10 +1096,10 @@ function initJscadutils(_CSG, options = {}) {
1461
1096
  y: 1,
1462
1097
  z: 2
1463
1098
  };
1464
- axes.split("").forEach((function(axis) {
1099
+ axes.split("").forEach(function(axis) {
1465
1100
  var i = lookup[axis];
1466
1101
  a[i] = valfun(i, axis);
1467
- }));
1102
+ });
1468
1103
  return a;
1469
1104
  }
1470
1105
  function centroid(o, objectSize) {
@@ -1473,15 +1108,15 @@ function initJscadutils(_CSG, options = {}) {
1473
1108
  objectSize = objectSize || size(bounds);
1474
1109
  return bounds[0].plus(objectSize.dividedBy(2));
1475
1110
  } catch (err) {
1476
- error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
1111
+ error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
1477
1112
  }
1478
1113
  }
1479
1114
  function calcmidlineTo(o, axis, to) {
1480
1115
  var bounds = o.getBounds();
1481
1116
  var objectSize = size(bounds);
1482
- return axisApply(axis, (function(i, a) {
1117
+ return axisApply(axis, function(i, a) {
1483
1118
  return to - objectSize[a] / 2;
1484
- }));
1119
+ });
1485
1120
  }
1486
1121
  function midlineTo(o, axis, to) {
1487
1122
  return o.translate(calcmidlineTo(o, axis, to));
@@ -1489,18 +1124,17 @@ function initJscadutils(_CSG, options = {}) {
1489
1124
  function translator(o, axis, withObj) {
1490
1125
  var objectCentroid = centroid(o);
1491
1126
  var withCentroid = centroid(withObj);
1492
- var t = axisApply(axis, (function(i) {
1127
+ var t = axisApply(axis, function(i) {
1493
1128
  return withCentroid[i] - objectCentroid[i];
1494
- }));
1129
+ });
1495
1130
  return t;
1496
1131
  }
1497
- function calcCenterWith(o, axes, withObj) {
1498
- var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1132
+ function calcCenterWith(o, axes, withObj, delta = 0) {
1499
1133
  var objectCentroid = centroid(o);
1500
1134
  var withCentroid = centroid(withObj);
1501
- var t = axisApply(axes, (function(i, axis) {
1135
+ var t = axisApply(axes, function(i, axis) {
1502
1136
  return withCentroid[axis] - objectCentroid[axis];
1503
- }));
1137
+ });
1504
1138
  return delta ? add(t, delta) : t;
1505
1139
  }
1506
1140
  function centerWith(o, axis, withObj) {
@@ -1513,16 +1147,13 @@ function initJscadutils(_CSG, options = {}) {
1513
1147
  }
1514
1148
  }
1515
1149
  var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
1516
- return axisApply(axis, (function(i, a) {
1150
+ return axisApply(axis, function(i, a) {
1517
1151
  return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
1518
- }));
1152
+ });
1519
1153
  }
1520
- function bisect() {
1521
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1522
- args[_key] = arguments[_key];
1523
- }
1154
+ function bisect(...args) {
1524
1155
  if (args.length < 2) {
1525
- 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");
1526
1157
  }
1527
1158
  var object = args[0];
1528
1159
  var axis = args[1];
@@ -1578,14 +1209,14 @@ function initJscadutils(_CSG, options = {}) {
1578
1209
  }[[ axis, rotateaxis ].sort().join("")];
1579
1210
  var centroid = object.centroid();
1580
1211
  var rotateDelta = getDelta(objectSize, bounds, rotateOffsetAxis, rotateoffset);
1581
- var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", (function(i, a) {
1212
+ var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", function(i, a) {
1582
1213
  if (a == axis) return cutDelta[i];
1583
1214
  if (a == rotateOffsetAxis) return rotateDelta[i];
1584
1215
  return centroid[a];
1585
- })));
1216
+ }));
1586
1217
  var theRotationAxis = rotationAxes[rotateaxis];
1587
1218
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
1588
- debug$1("bisect", debug$1.enabled && {
1219
+ debug$2("bisect", debug$2.enabled && {
1589
1220
  axis,
1590
1221
  offset,
1591
1222
  angle,
@@ -1601,14 +1232,10 @@ function initJscadutils(_CSG, options = {}) {
1601
1232
  if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
1602
1233
  return g;
1603
1234
  }
1604
- function slice(object) {
1605
- var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
1606
- var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
1607
- var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
1608
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
1609
- color: true,
1610
- addRotationCenter: true
1611
- };
1235
+ function slice(object, angle = 15, axis = "x", rotateaxis = "z", options = {
1236
+ color: true,
1237
+ addRotationCenter: true
1238
+ }) {
1612
1239
  var info = normalVector(axis);
1613
1240
  var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
1614
1241
  var theRotationAxis = rotationAxes[rotateaxis];
@@ -1666,21 +1293,18 @@ function initJscadutils(_CSG, options = {}) {
1666
1293
  return CSG.fromPolygons(polygons);
1667
1294
  }
1668
1295
  function slices2poly(slices, options, axis) {
1669
- debug$1("slices2poly", slices, options, axis);
1296
+ debug$2("slices2poly", slices, options, axis);
1670
1297
  options = Object.assign({
1671
1298
  twistangle: 0,
1672
1299
  twiststeps: 0
1673
1300
  }, options);
1674
1301
  var twistangle = options && parseFloat(options.twistangle) || 0;
1675
- var twiststeps = options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
1676
- if (twistangle == 0 || twiststeps < 1) {
1677
- twiststeps = 1;
1678
- }
1302
+ options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
1679
1303
  var normalVector = options.si.normalVector;
1680
1304
  var polygons = [];
1681
1305
  var first$1 = first(slices);
1682
1306
  var last$1 = last(slices);
1683
- debug$1("slices2poly first", first$1, first$1.offset, "last", last$1);
1307
+ debug$2("slices2poly first", first$1, first$1.offset, "last", last$1);
1684
1308
  var up = first$1.offset[axis] > last$1.offset[axis];
1685
1309
  polygons = polygons.concat(first$1.poly._toPlanePolygons({
1686
1310
  translation: first$1.offset,
@@ -1699,7 +1323,7 @@ function initJscadutils(_CSG, options = {}) {
1699
1323
  return v[rotateAxis](angle * percent);
1700
1324
  };
1701
1325
  var connectorAxis = last$1.offset.minus(first$1.offset).abs();
1702
- slices.forEach((function(slice, idx) {
1326
+ slices.forEach(function(slice, idx) {
1703
1327
  if (idx < slices.length - 1) {
1704
1328
  var nextidx = idx + 1;
1705
1329
  var top = !up ? slices[nextidx] : slice;
@@ -1712,7 +1336,7 @@ function initJscadutils(_CSG, options = {}) {
1712
1336
  toConnector2: c2
1713
1337
  }));
1714
1338
  }
1715
- }));
1339
+ });
1716
1340
  return CSG.fromPolygons(polygons);
1717
1341
  }
1718
1342
  function normalVector(axis) {
@@ -1753,12 +1377,12 @@ function initJscadutils(_CSG, options = {}) {
1753
1377
  var info = dirInfo["dir" + direction];
1754
1378
  return Object.assign({
1755
1379
  axis,
1756
- cutDelta: axisApply(axis, (function(i, a) {
1380
+ cutDelta: axisApply(axis, function(i, a) {
1757
1381
  return bounds[info.sizeIdx][a] + Math.abs(radius) * info.sizeDir;
1758
- })),
1759
- moveDelta: axisApply(axis, (function(i, a) {
1382
+ }),
1383
+ moveDelta: axisApply(axis, function(i, a) {
1760
1384
  return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
1761
- }))
1385
+ })
1762
1386
  }, info, normalVector(axis));
1763
1387
  }
1764
1388
  function reShape(object, radius, orientation, options, slicer) {
@@ -1766,18 +1390,18 @@ function initJscadutils(_CSG, options = {}) {
1766
1390
  var b = object.getBounds();
1767
1391
  var absoluteRadius = Math.abs(radius);
1768
1392
  var si = sliceParams(orientation, radius, b);
1769
- debug$1("reShape", absoluteRadius, si);
1770
- if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
1393
+ debug$2("reShape", absoluteRadius, si);
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.');
1771
1395
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
1772
1396
  var slice = object.sectionCut(cutplane);
1773
- var first = axisApply(si.axis, (function() {
1397
+ var first = axisApply(si.axis, function() {
1774
1398
  return si.positive ? 0 : absoluteRadius;
1775
- }));
1776
- var last = axisApply(si.axis, (function() {
1399
+ });
1400
+ var last = axisApply(si.axis, function() {
1777
1401
  return si.positive ? absoluteRadius : 0;
1778
- }));
1402
+ });
1779
1403
  var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
1780
- debug$1("reShape first/last", first, last);
1404
+ debug$2("reShape first/last", first, last);
1781
1405
  var slices = slicer(first, last, slice, radius);
1782
1406
  var delta = slices2poly(slices, Object.assign(options, {
1783
1407
  si
@@ -1786,7 +1410,7 @@ function initJscadutils(_CSG, options = {}) {
1786
1410
  return union([ options.unionOriginal ? object : remainder, delta.translate(si.moveDelta) ]);
1787
1411
  }
1788
1412
  function chamfer(object, radius, orientation, options) {
1789
- return reShape(object, radius, orientation, options, (function(first, last, slice) {
1413
+ return reShape(object, radius, orientation, options, function(first, last, slice) {
1790
1414
  return [ {
1791
1415
  poly: slice,
1792
1416
  offset: new CSG.Vector3D(first)
@@ -1794,15 +1418,15 @@ function initJscadutils(_CSG, options = {}) {
1794
1418
  poly: enlarge(slice, [ -radius * 2, -radius * 2 ]),
1795
1419
  offset: new CSG.Vector3D(last)
1796
1420
  } ];
1797
- }));
1421
+ });
1798
1422
  }
1799
1423
  function fillet(object, radius, orientation, options) {
1800
1424
  options = options || {};
1801
- return reShape(object, radius, orientation, options, (function(first, last, slice) {
1425
+ return reShape(object, radius, orientation, options, function(first, last, slice) {
1802
1426
  var v1 = new CSG.Vector3D(first);
1803
1427
  var v2 = new CSG.Vector3D(last);
1804
1428
  var res = options.resolution || CSG.defaultResolution3D;
1805
- var slices = range(0, res).map((function(i) {
1429
+ var slices = range(0, res).map(function(i) {
1806
1430
  var p = i > 0 ? i / (res - 1) : 0;
1807
1431
  var v = v1.lerp(v2, p);
1808
1432
  var size = -radius * 2 - Math.cos(Math.asin(p)) * (-radius * 2);
@@ -1810,9 +1434,9 @@ function initJscadutils(_CSG, options = {}) {
1810
1434
  poly: enlarge(slice, [ size, size ]),
1811
1435
  offset: v
1812
1436
  };
1813
- }));
1437
+ });
1814
1438
  return slices;
1815
- }));
1439
+ });
1816
1440
  }
1817
1441
  function calcRotate(part, solid, axis) {
1818
1442
  var axes = {
@@ -1828,54 +1452,121 @@ function initJscadutils(_CSG, options = {}) {
1828
1452
  };
1829
1453
  }
1830
1454
  function rotateAround(part, solid, axis, angle) {
1831
- var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
1455
+ var {rotationCenter, rotationAxis} = calcRotate(part, solid, axis);
1832
1456
  return part.rotate(rotationCenter, rotationAxis, angle);
1833
1457
  }
1834
- function cloneProperties(from, to) {
1835
- return Object.entries(from).reduce((function(props, _ref) {
1836
- 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]) => {
1837
1460
  props[key] = value;
1838
1461
  return props;
1839
- }), to);
1462
+ }, to);
1840
1463
  }
1841
1464
  function clone(o) {
1842
1465
  var c = CSG.fromPolygons(o.toPolygons());
1843
1466
  cloneProperties(o, c);
1844
- debug$1("clone", o, c, CSG);
1467
+ debug$2("clone", o, c, CSG);
1845
1468
  return c;
1846
1469
  }
1847
- function addConnector(object, name) {
1848
- var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
1849
- var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
1850
- 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 ]) {
1851
1471
  object.properties[name] = new CSG.Connector(point, axis, normal);
1852
1472
  return object;
1853
1473
  }
1854
- var debug$2 = 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");
1855
1549
  var parts = {
1856
- BBox,
1550
+ BBox: BBox$1,
1857
1551
  Cube,
1858
1552
  RoundedCube,
1859
1553
  Cylinder,
1860
1554
  Cone
1861
1555
  };
1862
- function BBox() {
1556
+ function BBox$1(...objects) {
1863
1557
  function box(object) {
1864
1558
  return CSG.cube({
1865
1559
  center: object.centroid(),
1866
1560
  radius: object.size().dividedBy(2)
1867
1561
  });
1868
1562
  }
1869
- for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
1870
- objects[_key] = arguments[_key];
1871
- }
1872
- return objects.reduce((function(bbox, part) {
1563
+ return objects.reduce(function(bbox, part) {
1873
1564
  var object = bbox ? union([ bbox, box(part) ]) : part;
1874
1565
  return box(object);
1875
- }), undefined);
1566
+ }, undefined);
1876
1567
  }
1877
1568
  function Cube(width) {
1878
- var r = div(fromxyz(width), 2);
1569
+ var r = div$1(fromxyz(width), 2);
1879
1570
  return CSG.cube({
1880
1571
  center: r,
1881
1572
  radius: r
@@ -1890,7 +1581,7 @@ function initJscadutils(_CSG, options = {}) {
1890
1581
  } else {
1891
1582
  var r = [ x / 2, y / 2 ];
1892
1583
  }
1893
- debug$2("RoundedCube", size$1, r, thickness, corner_radius);
1584
+ debug$1("RoundedCube", size$1, r, thickness, corner_radius);
1894
1585
  var roundedcube = CAG.roundedRectangle({
1895
1586
  center: [ r[0], r[1], 0 ],
1896
1587
  radius: r,
@@ -1901,9 +1592,8 @@ function initJscadutils(_CSG, options = {}) {
1901
1592
  });
1902
1593
  return roundedcube;
1903
1594
  }
1904
- function Cylinder(diameter, height) {
1905
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1906
- debug$2("parts.Cylinder", diameter, height, options);
1595
+ function Cylinder(diameter, height, options = {}) {
1596
+ debug$1("parts.Cylinder", diameter, height, options);
1907
1597
  options = Object.assign({
1908
1598
  start: [ 0, 0, 0 ],
1909
1599
  end: [ 0, 0, height ],
@@ -1912,9 +1602,8 @@ function initJscadutils(_CSG, options = {}) {
1912
1602
  }, options);
1913
1603
  return CSG.cylinder(options);
1914
1604
  }
1915
- function Cone(diameter1, diameter2, height) {
1916
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1917
- debug$2("parts.Cone", diameter1, diameter2, height, options);
1605
+ function Cone(diameter1, diameter2, height, options = {}) {
1606
+ debug$1("parts.Cone", diameter1, diameter2, height, options);
1918
1607
  return CSG.cylinder(Object.assign({
1919
1608
  start: [ 0, 0, 0 ],
1920
1609
  end: [ 0, 0, height ],
@@ -1924,7 +1613,7 @@ function initJscadutils(_CSG, options = {}) {
1924
1613
  }, options));
1925
1614
  }
1926
1615
  function Hexagon(diameter, height) {
1927
- debug$2("hexagon", diameter, height);
1616
+ debug$1("hexagon", diameter, height);
1928
1617
  var radius = diameter / 2;
1929
1618
  var sqrt3 = Math.sqrt(3) / 2;
1930
1619
  var hex = CAG.fromPoints([ [ radius, 0 ], [ radius / 2, radius * sqrt3 ], [ -radius / 2, radius * sqrt3 ], [ -radius, 0 ], [ -radius / 2, -radius * sqrt3 ], [ radius / 2, -radius * sqrt3 ] ]);
@@ -1942,9 +1631,7 @@ function initJscadutils(_CSG, options = {}) {
1942
1631
  function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
1943
1632
  return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
1944
1633
  }
1945
- function Anchor() {
1946
- var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
1947
- var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
1634
+ function Anchor(width = 10, height = 10) {
1948
1635
  var hole = Cylinder(width, height).Center().color("red");
1949
1636
  var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
1950
1637
  return Group({
@@ -1964,7 +1651,7 @@ function initJscadutils(_CSG, options = {}) {
1964
1651
  });
1965
1652
  return board;
1966
1653
  }
1967
- var Hardware = {
1654
+ const Hardware = {
1968
1655
  Orientation: {
1969
1656
  up: {
1970
1657
  head: "outside-",
@@ -1975,7 +1662,7 @@ function initJscadutils(_CSG, options = {}) {
1975
1662
  clear: "inside-"
1976
1663
  }
1977
1664
  },
1978
- Screw: function Screw(head, thread, headClearSpace, options) {
1665
+ Screw: function(head, thread, headClearSpace, options) {
1979
1666
  depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
1980
1667
  options = Object.assign(options, {
1981
1668
  orientation: "up",
@@ -1991,7 +1678,7 @@ function initJscadutils(_CSG, options = {}) {
1991
1678
  }
1992
1679
  return group;
1993
1680
  },
1994
- PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1681
+ PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
1995
1682
  depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
1996
1683
  var head = Cylinder(headDiameter, headLength);
1997
1684
  var thread = Cylinder(diameter, length);
@@ -2000,7 +1687,7 @@ function initJscadutils(_CSG, options = {}) {
2000
1687
  }
2001
1688
  return Hardware.Screw(head, thread, headClearSpace, options);
2002
1689
  },
2003
- HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1690
+ HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
2004
1691
  depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
2005
1692
  var head = Hexagon(headDiameter, headLength);
2006
1693
  var thread = Cylinder(diameter, length);
@@ -2009,7 +1696,7 @@ function initJscadutils(_CSG, options = {}) {
2009
1696
  }
2010
1697
  return Hardware.Screw(head, thread, headClearSpace, options);
2011
1698
  },
2012
- FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
1699
+ FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
2013
1700
  depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
2014
1701
  var head = Cone(headDiameter, diameter, headLength);
2015
1702
  var thread = Cylinder(diameter, length);
@@ -2021,43 +1708,42 @@ function initJscadutils(_CSG, options = {}) {
2021
1708
  };
2022
1709
  var parts$1 = Object.freeze({
2023
1710
  __proto__: null,
2024
- default: parts,
2025
- BBox,
1711
+ Anchor,
1712
+ BBox: BBox$1,
1713
+ Board,
1714
+ Cone,
2026
1715
  Cube,
2027
- RoundedCube,
2028
1716
  Cylinder,
2029
- Cone,
1717
+ Hardware,
2030
1718
  Hexagon,
1719
+ RoundedCube,
2031
1720
  Triangle,
2032
1721
  Tube,
2033
- Anchor,
2034
- Board,
2035
- Hardware
1722
+ default: parts
2036
1723
  });
2037
- var debug$3 = Debug("jscadUtils:boxes");
1724
+ const debug = Debug("jscadUtils:boxes");
2038
1725
  function RabbetJoin(box, thickness, cutHeight) {
2039
1726
  depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
2040
1727
  return rabbetJoin(box, thickness, cutHeight);
2041
1728
  }
2042
1729
  function topMiddleBottom(box, thickness) {
2043
- debug$3("TopMiddleBottom", box, thickness);
1730
+ debug("TopMiddleBottom", box, thickness);
2044
1731
  var bottom = box.bisect("z", thickness, {
2045
1732
  color: true
2046
1733
  });
2047
1734
  var top = bottom.parts.positive.bisect("z", -thickness);
2048
1735
  return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
2049
1736
  }
2050
- function Rabett(box, thickness, gap, height, face) {
2051
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2052
- debug$3("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
1737
+ function Rabett(box, thickness, gap, height, face, options = {}) {
1738
+ debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
2053
1739
  gap = gap || .25;
2054
1740
  var inside = thickness - gap;
2055
1741
  var outside = -thickness + gap;
2056
- debug$3("inside", inside, "outside", outside);
1742
+ debug("inside", inside, "outside", outside);
2057
1743
  var group = Group();
2058
- 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;
2059
1745
  var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
2060
- 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;
2061
1747
  var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
2062
1748
  group.add(top.union(middleTop), "top");
2063
1749
  var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
@@ -2066,16 +1752,14 @@ function initJscadutils(_CSG, options = {}) {
2066
1752
  group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
2067
1753
  return group;
2068
1754
  }
2069
- var RabettTopBottom = function rabbetTMB(box, thickness) {
2070
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
2071
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1755
+ const RabettTopBottom = function rabbetTMB(box, thickness, gap = .25, options = {}) {
2072
1756
  options = Object.assign({
2073
1757
  removableTop: true,
2074
1758
  removableBottom: true,
2075
1759
  topWidth: -thickness,
2076
1760
  bottomWidth: thickness
2077
1761
  }, options);
2078
- debug$3("RabettTopBottom", box, thickness, gap, options);
1762
+ debug("RabettTopBottom", box, thickness, gap, options);
2079
1763
  var group = Group("", {
2080
1764
  box
2081
1765
  });
@@ -2101,7 +1785,7 @@ function initJscadutils(_CSG, options = {}) {
2101
1785
  }
2102
1786
  return group;
2103
1787
  };
2104
- var CutOut = function cutOut(o, h, box, plug, gap) {
1788
+ const CutOut = function cutOut(o, h, box, plug, gap) {
2105
1789
  gap = gap || .25;
2106
1790
  var s = o.size();
2107
1791
  var cutout = o.intersect(box);
@@ -2119,9 +1803,9 @@ function initJscadutils(_CSG, options = {}) {
2119
1803
  insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
2120
1804
  });
2121
1805
  };
2122
- var Rectangle = function Rectangle(size, thickness, cb) {
1806
+ const Rectangle = function(size, thickness, cb) {
2123
1807
  thickness = thickness || 2;
2124
- var s = div(xyz2array(size), 2);
1808
+ var s = div$1(xyz2array(size), 2);
2125
1809
  var r = add(s, thickness);
2126
1810
  var box = CSG.cube({
2127
1811
  center: r,
@@ -2133,7 +1817,7 @@ function initJscadutils(_CSG, options = {}) {
2133
1817
  if (cb) box = cb(box);
2134
1818
  return box;
2135
1819
  };
2136
- var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
1820
+ const Hollow = function(object, thickness, interiorcb, exteriorcb) {
2137
1821
  thickness = thickness || 2;
2138
1822
  var size = -thickness * 2;
2139
1823
  interiorcb = interiorcb || identity;
@@ -2141,19 +1825,18 @@ function initJscadutils(_CSG, options = {}) {
2141
1825
  if (exteriorcb) box = exteriorcb(box);
2142
1826
  return box;
2143
1827
  };
2144
- var BBox$1 = function BBox(o) {
1828
+ const BBox = function(o) {
2145
1829
  depreciated("BBox", true, "Use 'parts.BBox' instead");
2146
- var s = div(xyz2array(o.size()), 2);
1830
+ var s = div$1(xyz2array(o.size()), 2);
2147
1831
  return CSG.cube({
2148
1832
  center: s,
2149
1833
  radius: s
2150
1834
  }).align(o, "xyz");
2151
1835
  };
2152
1836
  function getRadius(o) {
2153
- return div(xyz2array(o.size()), 2);
1837
+ return div$1(xyz2array(o.size()), 2);
2154
1838
  }
2155
- function rabbetJoin(box, thickness) {
2156
- var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
1839
+ function rabbetJoin(box, thickness, gap = .25) {
2157
1840
  var r = add(getRadius(box), -thickness / 2);
2158
1841
  r[2] = thickness / 2;
2159
1842
  var cutter = CSG.cube({
@@ -2171,16 +1854,17 @@ function initJscadutils(_CSG, options = {}) {
2171
1854
  }
2172
1855
  var Boxes = Object.freeze({
2173
1856
  __proto__: null,
1857
+ BBox,
1858
+ CutOut,
1859
+ Hollow,
2174
1860
  RabbetJoin,
2175
- topMiddleBottom,
2176
1861
  Rabett,
2177
1862
  RabettTopBottom,
2178
- CutOut,
2179
1863
  Rectangle,
2180
- Hollow,
2181
- BBox: BBox$1
1864
+ topMiddleBottom
2182
1865
  });
2183
- var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
1866
+ const compatV1 = {
1867
+ ...util,
2184
1868
  group: Group,
2185
1869
  init: init$1,
2186
1870
  triangle: triUtils,
@@ -2188,7 +1872,7 @@ function initJscadutils(_CSG, options = {}) {
2188
1872
  parts: parts$1,
2189
1873
  Boxes,
2190
1874
  Debug
2191
- });
1875
+ };
2192
1876
  exports.Boxes = Boxes;
2193
1877
  exports.Debug = Debug;
2194
1878
  exports.Group = Group;