@jwc/jscad-utils 4.8.4 → 4.9.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.
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
35
35
  get mapPick () { return mapPick; },
36
36
  get divA () { return divA; },
37
37
  get divxyz () { return divxyz; },
38
- get div () { return div$1; },
38
+ get div () { return div; },
39
39
  get mulxyz () { return mulxyz; },
40
40
  get mul () { return mul; },
41
41
  get xyz2array () { return xyz2array; },
@@ -81,125 +81,105 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
81
81
  get addConnector () { return addConnector; }
82
82
  });
83
83
 
84
- function _typeof(obj) {
85
- "@babel/helpers - typeof";
86
-
87
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
88
- _typeof = function (obj) {
89
- return typeof obj;
90
- };
91
- } else {
92
- _typeof = function (obj) {
93
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
94
- };
84
+ function _arrayLikeToArray(r, a) {
85
+ (null == a || a > r.length) && (a = r.length);
86
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
87
+ return n;
88
+ }
89
+ function _arrayWithHoles(r) {
90
+ if (Array.isArray(r)) return r;
91
+ }
92
+ function _defineProperty(e, r, t) {
93
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
94
+ value: t,
95
+ enumerable: !0,
96
+ configurable: !0,
97
+ writable: !0
98
+ }) : e[r] = t, e;
99
+ }
100
+ function _iterableToArrayLimit(r, l) {
101
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
102
+ if (null != t) {
103
+ var e,
104
+ n,
105
+ i,
106
+ u,
107
+ a = [],
108
+ f = !0,
109
+ o = !1;
110
+ try {
111
+ if (i = (t = t.call(r)).next, 0 === l) {
112
+ if (Object(t) !== t) return;
113
+ f = !1;
114
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
115
+ } catch (r) {
116
+ o = !0, n = r;
117
+ } finally {
118
+ try {
119
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
120
+ } finally {
121
+ if (o) throw n;
122
+ }
123
+ }
124
+ return a;
95
125
  }
96
-
97
- return _typeof(obj);
98
126
  }
99
-
100
- function _defineProperty(obj, key, value) {
101
- if (key in obj) {
102
- Object.defineProperty(obj, key, {
103
- value: value,
104
- enumerable: true,
105
- configurable: true,
106
- writable: true
107
- });
108
- } else {
109
- obj[key] = value;
110
- }
111
-
112
- return obj;
127
+ function _nonIterableRest() {
128
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
129
  }
114
-
115
- function ownKeys(object, enumerableOnly) {
116
- var keys = Object.keys(object);
117
-
130
+ function ownKeys(e, r) {
131
+ var t = Object.keys(e);
118
132
  if (Object.getOwnPropertySymbols) {
119
- var symbols = Object.getOwnPropertySymbols(object);
120
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
121
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
122
- });
123
- keys.push.apply(keys, symbols);
133
+ var o = Object.getOwnPropertySymbols(e);
134
+ r && (o = o.filter(function (r) {
135
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
136
+ })), t.push.apply(t, o);
124
137
  }
125
-
126
- return keys;
138
+ return t;
127
139
  }
128
-
129
- function _objectSpread2(target) {
130
- for (var i = 1; i < arguments.length; i++) {
131
- var source = arguments[i] != null ? arguments[i] : {};
132
-
133
- if (i % 2) {
134
- ownKeys(Object(source), true).forEach(function (key) {
135
- _defineProperty(target, key, source[key]);
136
- });
137
- } else if (Object.getOwnPropertyDescriptors) {
138
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
139
- } else {
140
- ownKeys(Object(source)).forEach(function (key) {
141
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
142
- });
143
- }
140
+ function _objectSpread2(e) {
141
+ for (var r = 1; r < arguments.length; r++) {
142
+ var t = null != arguments[r] ? arguments[r] : {};
143
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
144
+ _defineProperty(e, r, t[r]);
145
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
146
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
147
+ });
144
148
  }
145
-
146
- return target;
147
- }
148
-
149
- function _slicedToArray(arr, i) {
150
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
151
- }
152
-
153
- function _arrayWithHoles(arr) {
154
- if (Array.isArray(arr)) return arr;
155
- }
156
-
157
- function _iterableToArrayLimit(arr, i) {
158
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
159
- var _arr = [];
160
- var _n = true;
161
- var _d = false;
162
- var _e = undefined;
163
-
164
- try {
165
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
166
- _arr.push(_s.value);
167
-
168
- if (i && _arr.length === i) break;
169
- }
170
- } catch (err) {
171
- _d = true;
172
- _e = err;
173
- } finally {
174
- try {
175
- if (!_n && _i["return"] != null) _i["return"]();
176
- } finally {
177
- if (_d) throw _e;
178
- }
149
+ return e;
150
+ }
151
+ function _slicedToArray(r, e) {
152
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
153
+ }
154
+ function _toPrimitive(t, r) {
155
+ if ("object" != typeof t || !t) return t;
156
+ var e = t[Symbol.toPrimitive];
157
+ if (void 0 !== e) {
158
+ var i = e.call(t, r || "default");
159
+ if ("object" != typeof i) return i;
160
+ throw new TypeError("@@toPrimitive must return a primitive value.");
179
161
  }
180
-
181
- return _arr;
182
- }
183
-
184
- function _unsupportedIterableToArray(o, minLen) {
185
- if (!o) return;
186
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
187
- var n = Object.prototype.toString.call(o).slice(8, -1);
188
- if (n === "Object" && o.constructor) n = o.constructor.name;
189
- if (n === "Map" || n === "Set") return Array.from(o);
190
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
162
+ return ("string" === r ? String : Number)(t);
191
163
  }
192
-
193
- function _arrayLikeToArray(arr, len) {
194
- if (len == null || len > arr.length) len = arr.length;
195
-
196
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
197
-
198
- return arr2;
164
+ function _toPropertyKey(t) {
165
+ var i = _toPrimitive(t, "string");
166
+ return "symbol" == typeof i ? i : i + "";
199
167
  }
168
+ function _typeof(o) {
169
+ "@babel/helpers - typeof";
200
170
 
201
- function _nonIterableRest() {
202
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
171
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
172
+ return typeof o;
173
+ } : function (o) {
174
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
175
+ }, _typeof(o);
176
+ }
177
+ function _unsupportedIterableToArray(r, a) {
178
+ if (r) {
179
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
180
+ var t = {}.toString.call(r).slice(8, -1);
181
+ 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;
182
+ }
203
183
  }
204
184
 
205
185
  /** @module triangle */
@@ -212,15 +192,16 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
212
192
  var toRadians = function toRadians(deg) {
213
193
  return deg / 180 * Math.PI;
214
194
  };
195
+
215
196
  /**
216
197
  * Convert radians to degrees.
217
198
  * @param {Number} rad value in radians
218
199
  * @return {Number} value in degrees
219
200
  */
220
-
221
201
  var toDegrees = function toDegrees(rad) {
222
202
  return rad * (180 / Math.PI);
223
203
  };
204
+
224
205
  /**
225
206
  * Solve a 90 degree triangle from two points.
226
207
  * @param {Number} p1.x Point 1 x coordinate
@@ -229,7 +210,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
229
210
  * @param {Number} p2.y Point 2 y coordinate
230
211
  * @return {Object} A triangle object {A,B,C,a,b,c}
231
212
  */
232
-
233
213
  var solve = function solve(p1, p2) {
234
214
  var r = {
235
215
  c: 90,
@@ -237,12 +217,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
237
217
  B: Math.abs(p2.y - p1.y)
238
218
  };
239
219
  var brad = Math.atan2(r.B, r.A);
240
- r.b = this.toDegrees(brad); // r.C = Math.sqrt(Math.pow(r.B, 2) + Math.pow(r.A, 2));
241
-
220
+ r.b = this.toDegrees(brad);
221
+ // r.C = Math.sqrt(Math.pow(r.B, 2) + Math.pow(r.A, 2));
242
222
  r.C = r.B / Math.sin(brad);
243
223
  r.a = 90 - r.b;
244
224
  return r;
245
225
  };
226
+
246
227
  /**
247
228
  * Solve a partial triangle object. Angles are in degrees.
248
229
  * Angle `C` is set to 90 degrees. Requires a Side and an
@@ -271,43 +252,48 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
271
252
  * @param {Number} r.c Length of side `c`
272
253
  * @return {Object} A solved triangle object {A,B,C,a,b,c}
273
254
  */
274
-
275
255
  var solve90SA = function solve90SA(r) {
276
256
  r = Object.assign(r, {
277
257
  C: 90
278
258
  });
279
259
  r.A = r.A || 90 - r.B;
280
260
  r.B = r.B || 90 - r.A;
281
- var arad = toRadians(r.A); // sinA = a/c
261
+ var arad = toRadians(r.A);
262
+
263
+ // sinA = a/c
282
264
  // a = c * sinA
283
265
  // tanA = a/b
284
266
  // a = b * tanA
267
+ r.a = r.a || (r.c ? r.c * Math.sin(arad) : r.b * Math.tan(arad));
285
268
 
286
- r.a = r.a || (r.c ? r.c * Math.sin(arad) : r.b * Math.tan(arad)); // sinA = a/c
287
-
288
- r.c = r.c || r.a / Math.sin(arad); // tanA = a/b
269
+ // sinA = a/c
270
+ r.c = r.c || r.a / Math.sin(arad);
289
271
 
272
+ // tanA = a/b
290
273
  r.b = r.b || r.a / Math.tan(arad);
291
274
  return r;
292
275
  };
293
276
  var solve90ac = function solve90ac(r) {
294
277
  r = Object.assign(r, {
295
278
  C: 90
296
- }); // sinA = a/c
297
- // a = arcsin(a/c)
279
+ });
298
280
 
281
+ // sinA = a/c
282
+ // a = arcsin(a/c)
299
283
  var arad = Math.asin(r.a / r.c);
300
284
  r.A = toDegrees(arad);
301
- r.B = 90 - r.A; // tanA = a/b
285
+ r.B = 90 - r.A;
286
+
287
+ // tanA = a/b
302
288
  // r.b = r.a / Math.tan(arad);
303
289
  // or
304
290
  // a*a + b*b = c*c
305
291
  // b*b = c*c - a*a
306
292
  // b = sqr(c*c - a*a)
307
-
308
293
  r.b = Math.sqrt(Math.pow(r.c, 2) - Math.pow(r.a, 2));
309
294
  return r;
310
295
  };
296
+
311
297
  /**
312
298
  * @function solveab
313
299
  * Solve a partial right triangle object from two sides (a and b). Angles are in degrees.
@@ -326,16 +312,18 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
326
312
  * @param {Number} r.b Length of side `b`
327
313
  * @return {Object} A solved triangle object {A,B,C,a,b,c}
328
314
  */
329
-
330
315
  function solveab(r) {
331
316
  r = Object.assign(r, {
332
317
  C: 90
333
- }); // c = sqr(a*a + b*b)
318
+ });
334
319
 
335
- r.c = Math.sqrt(Math.pow(r.a, 2) + Math.pow(r.b, 2)); // A = arcsin(a/c)
320
+ // c = sqr(a*a + b*b)
321
+ r.c = Math.sqrt(Math.pow(r.a, 2) + Math.pow(r.b, 2));
336
322
 
337
- r.A = toDegrees(Math.asin(r.a / r.c)); // B = arcsin(b/c);
323
+ // A = arcsin(a/c)
324
+ r.A = toDegrees(Math.asin(r.a / r.c));
338
325
 
326
+ // B = arcsin(b/c);
339
327
  r.B = toDegrees(Math.asin(r.b / r.c));
340
328
  return r;
341
329
  }
@@ -362,11 +350,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
362
350
  * @param {Number} f
363
351
  * @memberof! array
364
352
  */
365
- var div = function div(a, f) {
353
+ var div$1 = function div(a, f) {
366
354
  return a.map(function (e) {
367
355
  return e / f;
368
356
  });
369
357
  };
358
+
370
359
  /**
371
360
  * Adds a value to each element of an array of numbers.
372
361
  * @function addValue
@@ -374,12 +363,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
374
363
  * @param {Number} f A value to add to each element of the original array.
375
364
  * @return {Array} A new array with the values added together.
376
365
  */
377
-
378
366
  var addValue = function addValue(a, f) {
379
367
  return a.map(function (e) {
380
368
  return e + f;
381
369
  });
382
370
  };
371
+
383
372
  /**
384
373
  * Adds two arrays together. The shorter array must be the first argument.
385
374
  *
@@ -388,19 +377,18 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
388
377
  * @param {Array} f Another array of numbers, if
389
378
  * @return {Array} A new array with the two values added together.
390
379
  */
391
-
392
380
  var addArray = function addArray(a, f) {
393
381
  return a.map(function (e, i) {
394
382
  return e + f[i];
395
383
  });
396
384
  };
385
+
397
386
  /**
398
387
  * Adds a value or array to another array.
399
388
  * @function add
400
389
  * @param {Array} a An array of numbers .
401
390
  * @return {Array} A new array with the two values added together.
402
391
  */
403
-
404
392
  var add = function add(a) {
405
393
  return Array.prototype.slice.call(arguments, 1).reduce(function (result, arg) {
406
394
  if (Array.isArray(arg)) {
@@ -408,17 +396,16 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
408
396
  } else {
409
397
  result = addValue(result, arg);
410
398
  }
411
-
412
399
  return result;
413
400
  }, a);
414
401
  };
402
+
415
403
  /**
416
404
  * Converts an object with x, y, and z properties into
417
405
  * an array, or an array if passed an array.
418
406
  * @function fromxyz
419
407
  * @param {Object|Array} object
420
408
  */
421
-
422
409
  var fromxyz = function fromxyz(object) {
423
410
  return Array.isArray(object) ? object : [object.x, object.y, object.z];
424
411
  };
@@ -429,37 +416,38 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
429
416
  z: a[2]
430
417
  };
431
418
  };
419
+
432
420
  /**
433
421
  * Returns the first value of an array.
434
422
  * @function first
435
423
  * @param {Array} a An array of numbers.
436
424
  * @return {Number} The value of the first element of the array or undefined.
437
425
  */
438
-
439
426
  var first = function first(a) {
440
427
  return a ? a[0] : undefined;
441
428
  };
429
+
442
430
  /**
443
431
  * @function last
444
432
  * @param {Array} a An array of numbers.
445
433
  * @return {Number} The value of the last element of the array or undefined.
446
434
  */
447
-
448
435
  var last = function last(a) {
449
436
  return a && a.length > 0 ? a[a.length - 1] : undefined;
450
437
  };
438
+
451
439
  /**
452
440
  * Finds the minimum value of an array.
453
441
  * @function min
454
442
  * @param {Array} a An array of numbers.
455
443
  * @return {Number} The minimum value in an array of numbers.
456
444
  */
457
-
458
445
  var min = function min(a) {
459
446
  return a.reduce(function (result, value) {
460
447
  return value < result ? value : result;
461
448
  }, Number.MAX_VALUE);
462
449
  };
450
+
463
451
  /**
464
452
  * Creates a array of numbers given the start and end points.
465
453
  * @function range
@@ -467,20 +455,17 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
467
455
  * @param {Number} b The ending value.
468
456
  * @return {Array} An array of values from `a` to `b`.
469
457
  */
470
-
471
458
  var range = function range(a, b) {
472
459
  var result = [];
473
-
474
460
  for (var i = a; i < b; i++) {
475
461
  result.push(i);
476
462
  }
477
-
478
463
  return result;
479
464
  };
480
465
 
481
466
  var array = /*#__PURE__*/Object.freeze({
482
467
  __proto__: null,
483
- div: div,
468
+ div: div$1,
484
469
  addValue: addValue,
485
470
  addArray: addArray,
486
471
  add: add,
@@ -493,9 +478,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
493
478
  });
494
479
 
495
480
  /* globals jscadUtilsDebug */
481
+
496
482
  var debugColors = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'];
497
483
  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'];
498
484
  var debugCount = 0;
485
+
499
486
  /**
500
487
  * Creates a function that uses `console.log` with a styled name. The name
501
488
  * is checked against the `jscadUtilsDebug` settings `enabled` and `disabled` list.
@@ -514,7 +501,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
514
501
  * @param {String} name The name of the debug function.
515
502
  * @return {Function} A debug function if enabled otherwise an empty function.
516
503
  */
517
-
518
504
  var Debug = function Debug(name) {
519
505
  var checks = Object.assign({
520
506
  enabled: [],
@@ -531,19 +517,15 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
531
517
  });
532
518
  var logger = enabled ? checks.options.browser ? function () {
533
519
  var _console;
534
-
535
520
  for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
536
521
  msg[_key] = arguments[_key];
537
522
  }
538
-
539
523
  (_console = console).log.apply(_console, ['%c%s', style, name].concat(msg));
540
524
  } : function () {
541
525
  var _console2;
542
-
543
526
  for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
544
527
  msg[_key2] = arguments[_key2];
545
528
  }
546
-
547
529
  (_console2 = console).log.apply(_console2, ["".concat(name)].concat(msg));
548
530
  } : function () {
549
531
  return undefined;
@@ -722,7 +704,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
722
704
  }
723
705
  function hex2rgb(h) {
724
706
  h = h.replace(/^\#/, '');
725
-
726
707
  if (h.length === 6) {
727
708
  return [parseInt(h.substr(0, 2), 16), parseInt(h.substr(2, 2), 16), parseInt(h.substr(4, 2), 16)];
728
709
  }
@@ -735,13 +716,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
735
716
  function color(o, r, g, b, a) {
736
717
  if (typeof r !== 'string') return o.setColor(r, g, b, a);
737
718
  if (r === '') return o; // shortcut for no color
738
-
739
719
  var c = name2rgb(r).map(function (x) {
740
720
  return x / 255;
741
721
  });
742
722
  c[3] = g || 1.0;
743
723
  return o.setColor(c);
744
724
  }
725
+
745
726
  /**
746
727
  * Initialize the Color utility. This adds a `.color()` prototype to the `CSG` object.
747
728
  * @param {CSG} CSG The global `CSG` object
@@ -751,6 +732,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
751
732
  // init: function init(proto) {
752
733
  // // if (proto.setColor) {
753
734
  // var _setColor = proto.setColor; // eslint-disable-line no-unused-vars
735
+
754
736
  // /**
755
737
  // * Set the color of a CSG object using a css color name. Also accepts the normal `setColor()` values.
756
738
  // * @example
@@ -789,139 +771,108 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
789
771
  * @param {proto} proto The global `proto` object
790
772
  * @augments proto
791
773
  */
792
-
793
774
  function init(proto) {
794
775
  /**
795
776
  * Short circut out if the prototypes have alrady been added.
796
777
  */
797
- if (proto.prototype._jscadutilsinit) return; // Colors.init(proto);
778
+ if (proto.prototype._jscadutilsinit) return;
798
779
 
780
+ // Colors.init(proto);
799
781
  proto.prototype.color = function (r, g, b, a) {
800
782
  if (!r) return this; // shortcut empty color values to do nothing.
801
-
802
783
  return color(this, r, g, b, a);
803
784
  };
804
-
805
785
  proto.prototype.flush = function flush$1(to, axis, mside, wside) {
806
786
  return flush(this, to, axis, mside, wside);
807
787
  };
808
-
809
788
  proto.prototype.snap = function snap$1(to, axis, orientation, delta) {
810
789
  return snap(this, to, axis, orientation, delta);
811
790
  };
812
-
813
791
  proto.prototype.calcSnap = function calcSnap$1(to, axis, orientation, delta) {
814
792
  return calcSnap(this, to, axis, orientation, delta);
815
793
  };
816
-
817
794
  proto.prototype.midlineTo = function midlineTo$1(axis, to) {
818
795
  return midlineTo(this, axis, to);
819
796
  };
820
-
821
797
  proto.prototype.calcmidlineTo = function midlineTo(axis, to) {
822
798
  return calcmidlineTo(this, axis, to);
823
799
  };
824
-
825
800
  proto.prototype.centerWith = function centerWith$1(axis, to) {
826
801
  depreciated('centerWith', true, 'Use align instead.');
827
802
  return centerWith(this, axis, to);
828
803
  };
829
-
830
804
  if (proto.center) echo('proto already has .center');
831
-
832
805
  proto.prototype.center = function center(axis) {
833
806
  // console.log('center', axis, this.getBounds());
834
807
  return centerWith(this, axis || 'xyz', unitCube());
835
808
  };
836
-
837
809
  proto.prototype.calcCenter = function centerWith(axis) {
838
810
  return calcCenterWith(this, axis || 'xyz', unitCube(), 0);
839
811
  };
840
-
841
812
  proto.prototype.align = function align(to, axis) {
842
813
  // console.log('align', to.getBounds(), axis);
843
814
  return centerWith(this, axis, to);
844
815
  };
845
-
846
816
  proto.prototype.calcAlign = function calcAlign(to, axis, delta) {
847
817
  return calcCenterWith(this, axis, to, delta);
848
818
  };
849
-
850
819
  proto.prototype.enlarge = function enlarge$1(x, y, z) {
851
820
  return enlarge(this, x, y, z);
852
821
  };
853
-
854
822
  proto.prototype.fit = function fit$1(x, y, z, a) {
855
823
  return fit(this, x, y, z, a);
856
824
  };
857
-
858
825
  if (proto.size) echo('proto already has .size');
859
-
860
826
  proto.prototype.size = function () {
861
827
  return size(this.getBounds());
862
828
  };
863
-
864
829
  proto.prototype.centroid = function () {
865
830
  return centroid(this);
866
831
  };
867
-
868
832
  proto.prototype.Zero = function zero$1() {
869
833
  return zero(this);
870
834
  };
871
-
872
835
  proto.prototype.Center = function Center(axes) {
873
836
  return this.align(unitCube(), axes || 'xy');
874
837
  };
875
-
876
838
  proto.Vector2D.prototype.map = function Vector2D_map(cb) {
877
839
  return new proto.Vector2D(cb(this.x), cb(this.y));
878
840
  };
879
-
880
841
  proto.prototype.fillet = function fillet$1(radius, orientation, options) {
881
842
  return fillet(this, radius, orientation, options);
882
843
  };
883
-
884
844
  proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
885
845
  return chamfer(this, radius, orientation, options);
886
846
  };
887
-
888
847
  proto.prototype.bisect = function bisect$1() {
889
848
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
890
849
  args[_key] = arguments[_key];
891
850
  }
892
-
893
851
  return bisect.apply(util, [this].concat(args));
894
852
  };
895
-
896
853
  proto.prototype.slice = function slice$1() {
897
854
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
898
855
  args[_key2] = arguments[_key2];
899
856
  }
900
-
901
857
  return slice.apply(util, [this].concat(args));
902
858
  };
903
-
904
859
  proto.prototype.wedge = function wedge$1() {
905
860
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
906
861
  args[_key3] = arguments[_key3];
907
862
  }
908
-
909
863
  return wedge.apply(util, [this].concat(args));
910
864
  };
911
-
912
865
  proto.prototype.stretch = function stretch$1(axis, distance, offset) {
913
866
  return stretch(this, axis, distance, offset);
914
867
  };
915
-
916
868
  proto.prototype.unionIf = function unionIf(object, condition) {
917
869
  return condition ? this.union(result(this, object)) : this;
918
870
  };
919
-
920
871
  proto.prototype.subtractIf = function subtractIf(object, condition) {
921
872
  return condition ? this.subtract(result(this, object)) : this;
922
873
  };
923
-
924
874
  proto.prototype._translate = proto.prototype.translate;
875
+
925
876
  /**
926
877
  * This modifies the normal `proto.translate` method to accept
927
878
  * multiple translations, adding the translations together.
@@ -929,7 +880,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
929
880
  * a short circut is applied when only one parameter is given.
930
881
  * @return {proto} The resulting object.
931
882
  */
932
-
933
883
  proto.prototype.translate = function translate() {
934
884
  if (arguments.length === 1) {
935
885
  return this._translate(arguments[0]);
@@ -938,34 +888,33 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
938
888
  // console.log('arg', arg);
939
889
  result = undefined(result, arg);
940
890
  return result;
941
- }, [0, 0, 0]); // console.log('translate', t);
891
+ }, [0, 0, 0]);
942
892
 
893
+ // console.log('translate', t);
943
894
  return this._translate(t);
944
895
  }
945
896
  };
946
-
947
897
  proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
948
898
  return addConnector(this, name, point, axis, normal);
949
899
  };
950
-
951
900
  proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
952
901
  var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
953
902
  var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
954
903
  var myConnector = myConnectorName.split('.').reduce(function (a, v) {
955
904
  return a[v];
956
905
  }, this.properties);
906
+
957
907
  /**
958
908
  * Check for missing property.
959
909
  */
960
-
961
910
  if (!myConnector) {
962
911
  error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(','), "]"), 'Missing connector property');
963
912
  }
964
-
965
913
  return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
966
914
  };
915
+ proto.prototype._jscadutilsinit = true;
967
916
 
968
- proto.prototype._jscadutilsinit = true; // console.trace('init', proto.prototype);
917
+ // console.trace('init', proto.prototype);
969
918
  }
970
919
 
971
920
  var init$1 = /*#__PURE__*/Object.freeze({
@@ -973,16 +922,17 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
973
922
  'default': init
974
923
  });
975
924
 
976
- var CSG = jsCadCSG__default['default'].CSG,
977
- CAG = jsCadCSG__default['default'].CAG;
978
- var rectangular_extrude = scadApi__default['default'].extrusions.rectangular_extrude;
979
- var _scadApi$text = scadApi__default['default'].text,
980
- vector_text = _scadApi$text.vector_text,
981
- vector_char = _scadApi$text.vector_char;
982
- var union = scadApi__default['default'].booleanOps.union;
925
+ var CSG = jsCadCSG__default["default"].CSG,
926
+ CAG = jsCadCSG__default["default"].CAG;
927
+ var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
928
+ var _scadApi$text = scadApi__default["default"].text,
929
+ vector_text = _scadApi$text.vector_text,
930
+ vector_char = _scadApi$text.vector_char;
931
+ var union = scadApi__default["default"].booleanOps.union;
983
932
  init(CSG);
984
933
 
985
- var debug = Debug('jscadUtils:group');
934
+ var debug$3 = Debug('jscadUtils:group');
935
+
986
936
  /**
987
937
  * @function JsCadUtilsGroup
988
938
  * @param {string[]} names An array of object names in the group.
@@ -990,7 +940,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
990
940
  * @param {CSG[]} holes An array of CSG objects that will be subtracted after combination.
991
941
  * @namespace JsCadUtilsGroup
992
942
  */
993
-
994
943
  function JsCadUtilsGroup() {
995
944
  var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
996
945
  var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -1000,6 +949,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1000
949
  this.parts = parts;
1001
950
  this.holes = holes;
1002
951
  }
952
+
1003
953
  /**
1004
954
  * Add a CSG object to the current group.
1005
955
  * @param {CSG|JsCadUtilsGroup} object Object to add the parts dictionary.
@@ -1010,17 +960,14 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1010
960
  * @function add
1011
961
  * @memberof! JsCadUtilsGroup
1012
962
  */
1013
-
1014
963
  JsCadUtilsGroup.prototype.add = function (object, name, hidden, subparts, parts) {
1015
- debug('add', object, name, hidden, subparts, parts);
964
+ debug$3('add', object, name, hidden, subparts, parts);
1016
965
  var self = this;
1017
-
1018
966
  if (object.parts) {
1019
967
  if (name) {
1020
968
  // add the combined part
1021
969
  if (!hidden) self.names.push(name);
1022
970
  self.parts[name] = object.combine(parts);
1023
-
1024
971
  if (subparts) {
1025
972
  Object.keys(object.parts).forEach(function (key) {
1026
973
  self.parts[subparts + key] = object.parts[key];
@@ -1034,9 +981,9 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1034
981
  if (!hidden) self.names.push(name);
1035
982
  self.parts[name] = object;
1036
983
  }
1037
-
1038
984
  return self;
1039
985
  };
986
+
1040
987
  /**
1041
988
  * @function combine
1042
989
  * @param {String} [pieces] The parts to combine, if empty, then all named parts.
@@ -1044,45 +991,39 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1044
991
  * @param {Function} map A function that is run before unioning the parts together.
1045
992
  * @return {CSG} A single `CSG` object of the unioned parts.
1046
993
  */
1047
-
1048
-
1049
994
  JsCadUtilsGroup.prototype.combine = function (pieces) {
1050
995
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1051
996
  var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) {
1052
997
  return x;
1053
998
  };
1054
-
1055
999
  try {
1056
1000
  var self = this;
1057
1001
  options = Object.assign({
1058
1002
  noholes: false
1059
1003
  }, options);
1060
1004
  pieces = pieces ? pieces.split(',') : self.names;
1061
-
1062
1005
  if (pieces.length === 0) {
1063
1006
  throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
1064
1007
  }
1065
-
1066
- debug('combine', self.names, self.parts);
1008
+ debug$3('combine', self.names, self.parts);
1067
1009
  var g = union(mapPick(self.parts, pieces, function (value, key, index, object) {
1068
- // debug('combine', value, key, object);
1010
+ debug$3('combine mapPick', value, key, object);
1069
1011
  return map ? map(value, key, index, object) : identity(value);
1070
1012
  }, self.name));
1071
1013
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
1072
1014
  } catch (err) {
1073
- debug('combine error', this, pieces, options, err);
1015
+ debug$3('combine error', this, pieces, options, err);
1074
1016
  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');
1075
1017
  }
1076
1018
  };
1019
+
1077
1020
  /**
1078
1021
  * Apply a function to each element in the group.
1079
- * @param {Function} cb Callback founction applied to each part.
1022
+ * @param {Function} cb Callback function applied to each part.
1080
1023
  * It is called with the parameters `(value, key)`
1081
1024
  * @return {Object} Returns this object so it can be chained
1082
1025
  * @function map
1083
1026
  */
1084
-
1085
-
1086
1027
  JsCadUtilsGroup.prototype.map = function (cb) {
1087
1028
  var self = this;
1088
1029
  self.parts = Object.keys(self.parts).filter(function (k) {
@@ -1091,7 +1032,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1091
1032
  result[key] = cb(self.parts[key], key);
1092
1033
  return result;
1093
1034
  }, {});
1094
-
1095
1035
  if (self.holes) {
1096
1036
  if (Array.isArray(self.holes)) {
1097
1037
  self.holes = self.holes.map(function (hole, idx) {
@@ -1101,9 +1041,9 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1101
1041
  self.holes = cb(self.holes, 'holes');
1102
1042
  }
1103
1043
  }
1104
-
1105
1044
  return self;
1106
1045
  };
1046
+
1107
1047
  /**
1108
1048
  * Clone a group into a new group.
1109
1049
  * @function clone
@@ -1111,47 +1051,41 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1111
1051
  * @param {Function} [map] A function called on each part.
1112
1052
  * @return {JsCadUtilsGroup} The new group.
1113
1053
  */
1114
-
1115
-
1116
1054
  JsCadUtilsGroup.prototype.clone = function (name, map) {
1117
- debug('clone', name, _typeof(name), map);
1055
+ debug$3('clone', name, _typeof(name), map);
1118
1056
  var self = this;
1119
1057
  /**
1120
1058
  * For backwards compatibility
1121
1059
  */
1122
-
1123
1060
  if (typeof name == 'function') {
1124
1061
  map = name;
1125
1062
  name = undefined;
1126
1063
  }
1064
+ if (!map) map = identity;
1127
1065
 
1128
- if (!map) map = identity; // console.warn('clone() has been refactored');
1129
-
1066
+ // console.warn('clone() has been refactored');
1130
1067
  var group = Group(name);
1131
1068
  Object.keys(self.parts).forEach(function (key) {
1132
1069
  var part = self.parts[key];
1133
1070
  var hidden = self.names.indexOf(key) == -1;
1134
1071
  group.add(map(clone(part)), key, hidden);
1135
1072
  });
1136
-
1137
1073
  if (self.holes) {
1138
1074
  group.holes = toArray(self.holes).map(function (part) {
1139
1075
  return map(CSG.fromPolygons(part.toPolygons()), 'holes');
1140
1076
  });
1141
1077
  }
1142
-
1143
1078
  return group;
1144
1079
  };
1080
+
1145
1081
  /**
1146
1082
  * Rotate the group around a solids centroid. This mutates the group.
1147
1083
  * @param {CSG|String} solid The solid to rotate the group around
1148
1084
  * @param {String} axis Axis to rotate
1149
1085
  * @param {Number} angle Angle in degrees
1150
- * @return {JsCadUtilsGroup} The rotoated group.
1086
+ * @return {JsCadUtilsGroup} The rotated group.
1151
1087
  * @function rotate
1152
1088
  */
1153
-
1154
-
1155
1089
  JsCadUtilsGroup.prototype.rotate = function (solid, axis, angle) {
1156
1090
  var self = this;
1157
1091
  var axes = {
@@ -1159,12 +1093,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1159
1093
  y: [0, 1, 0],
1160
1094
  z: [0, 0, 1]
1161
1095
  };
1162
-
1163
1096
  if (typeof solid === 'string') {
1164
1097
  var _names = solid;
1165
1098
  solid = self.combine(_names);
1166
1099
  }
1167
-
1168
1100
  var rotationCenter = solid.centroid();
1169
1101
  var rotationAxis = axes[axis];
1170
1102
  self.map(function (part) {
@@ -1172,6 +1104,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1172
1104
  });
1173
1105
  return self;
1174
1106
  };
1107
+
1175
1108
  /**
1176
1109
  * Combines all parts, named and unnamed.
1177
1110
  * @function combineAll
@@ -1179,12 +1112,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1179
1112
  * @param {Function} map A function run on each part before unioning.
1180
1113
  * @return {CSG} A `CSG` object of all combined parts.
1181
1114
  */
1182
-
1183
-
1184
1115
  JsCadUtilsGroup.prototype.combineAll = function (options, map) {
1185
1116
  var self = this;
1186
1117
  return self.combine(Object.keys(self.parts).join(','), options, map);
1187
1118
  };
1119
+
1188
1120
  /**
1189
1121
  * Snaps a named part of a group to another `CSG` objects
1190
1122
  * bounding box.
@@ -1196,22 +1128,21 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1196
1128
  * @param {Number} [delta=0] An offset to apply with the snap, in millimeters.
1197
1129
  * @return {JsCadUtilsGroup} The group after snapping all parts to the `to` object.
1198
1130
  */
1199
-
1200
-
1201
1131
  JsCadUtilsGroup.prototype.snap = function snap(part, to, axis, orientation, delta) {
1202
1132
  try {
1203
- var self = this; // debug(', self);
1204
-
1133
+ var self = this;
1134
+ // debug(', self);
1205
1135
  var t = calcSnap(self.combine(part), to, axis, orientation, delta);
1206
1136
  self.map(function (part) {
1207
1137
  return part.translate(t);
1208
1138
  });
1209
1139
  return self;
1210
1140
  } catch (err) {
1211
- debug('snap error', this, part, to, axis, delta, err);
1141
+ debug$3('snap error', this, part, to, axis, delta, err);
1212
1142
  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');
1213
1143
  }
1214
1144
  };
1145
+
1215
1146
  /**
1216
1147
  * Aligns all parts in a group to another `CSG` object.
1217
1148
  * @function align
@@ -1222,45 +1153,40 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1222
1153
  * @return {JsCadUtilsGroup} The group after aligning all parts to the `to` object.
1223
1154
 
1224
1155
  */
1225
-
1226
-
1227
1156
  JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
1228
1157
  try {
1229
1158
  var self = this;
1230
1159
  var t = calcCenterWith(self.combine(part, {
1231
1160
  noholes: true
1232
1161
  }), axis, to, delta);
1233
- self.map(function (part
1234
- /*, name */
1235
- ) {
1162
+ self.map(function (part /*, name */) {
1236
1163
  return part.translate(t);
1237
- }); // if (self.holes)
1164
+ });
1165
+
1166
+ // if (self.holes)
1238
1167
  // self.holes = util.ifArray(self.holes, function(hole) {
1239
1168
  // return hole.translate(t);
1240
1169
  // });
1241
1170
 
1242
1171
  return self;
1243
1172
  } catch (err) {
1244
- debug('align error', this, part, to, axis, delta, err);
1173
+ debug$3('align error', this, part, to, axis, delta, err);
1245
1174
  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');
1246
1175
  }
1247
1176
  };
1248
-
1249
1177
  JsCadUtilsGroup.prototype.center = function center(part) {
1250
1178
  var self = this;
1251
1179
  return self.align(part, unitCube(), 'xyz');
1252
1180
  };
1253
-
1254
1181
  JsCadUtilsGroup.prototype.zero = function zero(part) {
1255
1182
  var self = this;
1256
1183
  var bounds = self.parts[part].getBounds();
1257
1184
  return self.translate([0, 0, -bounds[0].z]);
1258
1185
  };
1259
-
1260
1186
  JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
1261
1187
  var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1262
1188
  var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
1263
- debug('connectTo', {
1189
+ debug$3('connectTo', {
1264
1190
  partName: partName,
1265
1191
  connectorName: connectorName,
1266
1192
  to: to,
@@ -1272,17 +1198,18 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1272
1198
  var myConnector = connectorName.split('.').reduce(function (a, v) {
1273
1199
  return a[v];
1274
1200
  }, self.parts[partName].properties);
1275
- debug('toConnector', to instanceof CSG.Connector);
1201
+ debug$3('toConnector', to instanceof CSG.Connector);
1276
1202
  var toConnector = toConnectorName.split('.').reduce(function (a, v) {
1277
1203
  return a[v];
1278
1204
  }, to.properties);
1279
1205
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
1280
- debug('connectTo', matrix);
1206
+ debug$3('connectTo', matrix);
1281
1207
  self.map(function (part) {
1282
1208
  return part.transform(matrix);
1283
1209
  });
1284
1210
  return self;
1285
1211
  };
1212
+
1286
1213
  /**
1287
1214
  * @function midlineTo
1288
1215
  * @param {String} part Comma separated list of parts in the group to align.
@@ -1290,48 +1217,50 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1290
1217
  * @param {String} axis An axis string to align on can be any combination of `x`, `y`, or `z`.
1291
1218
  * @return {JsCadUtilsGroup} The group after aligning all parts to the `to` object.
1292
1219
  */
1293
-
1294
-
1295
1220
  JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
1296
1221
  var self = this;
1297
1222
  var size = self.combine(part).size();
1298
1223
  var t = axisApply(axis, function (i, a) {
1299
1224
  return to - size[a] / 2;
1300
- }); // debug(' part, t);
1225
+ });
1226
+ // debug(' part, t);
1301
1227
  // var t = util.calcCenterWith(self.combine(part), axis, to, delta);
1302
-
1303
1228
  self.map(function (part) {
1304
1229
  return part.translate(t);
1305
- }); // if (self.holes)
1230
+ });
1231
+
1232
+ // if (self.holes)
1306
1233
  // self.holes = util.ifArray(self.holes, function(hole) {
1307
1234
  // return hole.translate(t);
1308
1235
  // });
1309
1236
 
1310
1237
  return self;
1311
1238
  };
1239
+
1312
1240
  /**
1313
- * Translates a group by a given ammount
1241
+ * Translates a group by a given amount
1314
1242
  * @function translate
1315
1243
  * @param {Number|Array} x The `x` value or an array of x, y and z.
1316
1244
  * @param {Number} [y] The `y` value.
1317
1245
  * @param {Number} [z] The `z` value.
1318
1246
  * @return {JsCadUtilsGroup} The translated group.
1319
1247
  */
1320
-
1321
-
1322
1248
  JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
1323
1249
  var self = this;
1324
1250
  var t = Array.isArray(x) ? x : [x, y, z];
1325
- debug('translate', t);
1251
+ debug$3('translate', t);
1326
1252
  self.map(function (part) {
1327
1253
  return part.translate(t);
1328
- }); // if (self.holes)
1254
+ });
1255
+
1256
+ // if (self.holes)
1329
1257
  // self.holes = util.ifArray(self.holes, function(hole) {
1330
1258
  // return hole.translate(t);
1331
1259
  // });
1332
1260
 
1333
1261
  return self;
1334
1262
  };
1263
+
1335
1264
  /**
1336
1265
  * Returns a new group from the list of parts.
1337
1266
  * @function pick
@@ -1339,8 +1268,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1339
1268
  * @param {function} map A function run on each part as its added to the new group.
1340
1269
  * @return {JsCadUtilsGroup} The new group with the picked parts.
1341
1270
  */
1342
-
1343
-
1344
1271
  JsCadUtilsGroup.prototype.pick = function (parts, map) {
1345
1272
  var self = this;
1346
1273
  var p = parts && parts.length > 0 && parts.split(',') || self.names;
@@ -1351,32 +1278,30 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1351
1278
  });
1352
1279
  return g;
1353
1280
  };
1281
+
1354
1282
  /**
1355
1283
  * Converts a group into an array of `CSG` objects.
1356
1284
  * @function array
1357
- * @param {String} parts A comma separated list of parts it include in the new array.
1358
- * @param {Function} map A function run on each part as its added to the new array.
1285
+ * @param {String} [parts] A comma separated list of parts it include in the new array.
1286
+ * @param {Function} [map] A function run on each part as its added to the new array.
1359
1287
  * @return {Array} An array of `CSG` objects
1360
1288
  */
1361
-
1362
-
1363
1289
  JsCadUtilsGroup.prototype.array = function (parts, map) {
1364
1290
  var _this = this;
1365
-
1366
- var self = this; // try {
1367
-
1291
+ var self = this;
1292
+ // try {
1368
1293
  var p = parts && parts.length > 0 && parts.split(',') || self.names;
1369
1294
  if (!map) map = identity;
1370
1295
  var a = [];
1371
1296
  p.forEach(function (name) {
1372
1297
  if (!self.parts[name]) {
1373
- debug('array error', _this, parts);
1298
+ debug$3('array error', _this, parts);
1374
1299
  throw error("group::array error \"".concat(name, "\" not found.\nthis: ").concat(_this, "\nparts: \"").concat(parts, "\"\n"), 'JSCAD_UTILS_GROUP_ERROR');
1375
1300
  }
1376
-
1377
1301
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1378
1302
  });
1379
- return a; // } catch (err) {
1303
+ return a;
1304
+ // } catch (err) {
1380
1305
  // debug('array error', this, parts, err);
1381
1306
  // throw error(
1382
1307
  // `group::array error "${err.message || err.toString()}"
@@ -1388,6 +1313,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1388
1313
  // );
1389
1314
  // }
1390
1315
  };
1316
+
1391
1317
  /**
1392
1318
  * Converts all pieces or the picked pieces of a group into an array of `CSG`
1393
1319
  * objects.
@@ -1396,8 +1322,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1396
1322
  * @return {Array} An array of `CSG` objects.
1397
1323
  * @deprecated Use `array` instead of `toArray`.
1398
1324
  */
1399
-
1400
-
1401
1325
  JsCadUtilsGroup.prototype.toArray = function (pieces) {
1402
1326
  var self = this;
1403
1327
  var piecesArray = pieces ? pieces.split(',') : self.names;
@@ -1406,15 +1330,14 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1406
1330
  return self.parts[piece];
1407
1331
  });
1408
1332
  };
1409
-
1410
1333
  JsCadUtilsGroup.prototype.toString = function () {
1411
- 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}");
1334
+ 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}");
1412
1335
  };
1413
-
1414
1336
  JsCadUtilsGroup.prototype.setName = function (name) {
1415
1337
  this.name = name;
1416
1338
  return this;
1417
1339
  };
1340
+
1418
1341
  /**
1419
1342
  * Creates a `group` object given a comma separated
1420
1343
  * list of names, and an array or object. If an object
@@ -1423,29 +1346,25 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1423
1346
  *
1424
1347
  * You can call the `combine()` function with a list of parts you want combined into one.
1425
1348
  *
1426
- * The `map()` funciton allows you to modify each part
1349
+ * The `map()` function allows you to modify each part
1427
1350
  * contained in the group object.
1428
1351
  *
1429
1352
  * @param {string | object} [objectNames] Comma separated list of part names.
1430
1353
  * @param {array | object} [addObjects] Array or object of parts. If Array, the names list is used as names for each part.
1431
1354
  * @return {JsCadUtilsGroup} An object that has a parts dictionary, a `combine()` and `map()` function.
1432
1355
  */
1433
-
1434
-
1435
1356
  function Group(objectNames, addObjects) {
1436
- debug('Group', objectNames, addObjects);
1357
+ debug$3('Group', objectNames, addObjects);
1437
1358
  var self = {
1438
1359
  name: '',
1439
1360
  names: [],
1440
1361
  parts: {}
1441
1362
  };
1442
-
1443
1363
  if (objectNames) {
1444
1364
  if (addObjects) {
1445
1365
  var names = objectNames;
1446
1366
  var objects = addObjects;
1447
1367
  self.names = names && names.length > 0 && names.split(',') || [];
1448
-
1449
1368
  if (Array.isArray(objects)) {
1450
1369
  self.parts = zipObject(self.names, objects);
1451
1370
  } else if (objects instanceof CSG) {
@@ -1461,7 +1380,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1461
1380
  self.name = objectNames;
1462
1381
  } else {
1463
1382
  var objects = objectNames; // eslint-disable-line no-redeclare
1464
-
1465
1383
  self.names = Object.keys(objects).filter(function (k) {
1466
1384
  return k !== 'holes';
1467
1385
  });
@@ -1470,11 +1388,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1470
1388
  }
1471
1389
  }
1472
1390
  }
1473
-
1474
1391
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1475
1392
  }
1476
1393
 
1477
- var debug$1 = Debug('jscadUtils:util'); // import utilInit from '../src/add-prototype';
1394
+ var debug$2 = Debug('jscadUtils:util');
1395
+ // import utilInit from '../src/add-prototype';
1478
1396
  // utilInit(CSG);
1479
1397
  // console.trace('CSG', CSG.prototype);
1480
1398
 
@@ -1493,7 +1411,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1493
1411
  var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1494
1412
  return (Math.floor(desired / nozzel) + nozzie) * nozzel;
1495
1413
  },
1496
-
1497
1414
  /**
1498
1415
  * Returns the largest number that is a multipel of the
1499
1416
  * nozzel size, just over the desired value.
@@ -1508,6 +1425,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1508
1425
  return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
1509
1426
  }
1510
1427
  };
1428
+
1511
1429
  /**
1512
1430
  * A function that reutrns the first argument. Useful when
1513
1431
  * passing in a callback to modify something, and you want a
@@ -1516,10 +1434,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1516
1434
  * @return {object} the first parameter passed into the function.
1517
1435
  * @function identity
1518
1436
  */
1519
-
1520
1437
  function identity(solid) {
1521
1438
  return solid;
1522
1439
  }
1440
+
1523
1441
  /**
1524
1442
  * If `f` is a funciton, it is executed with `object` as the
1525
1443
  * parameter. This is used in `CSG.unionIf` and `CSG.subtractIf`,
@@ -1531,7 +1449,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1531
1449
  * @return {object} the result of the function or the object.
1532
1450
  * @function result
1533
1451
  */
1534
-
1535
1452
  function result(object, f) {
1536
1453
  if (typeof f === 'function') {
1537
1454
  return f.call(object);
@@ -1539,6 +1456,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1539
1456
  return f;
1540
1457
  }
1541
1458
  }
1459
+
1542
1460
  /**
1543
1461
  * Returns target object with default values assigned. If values already exist, they are not set.
1544
1462
  * @param {object} target The target object to return.
@@ -1547,7 +1465,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1547
1465
  * @function defaults
1548
1466
  * @depricated
1549
1467
  */
1550
-
1551
1468
  function defaults(target, defaults) {
1552
1469
  depreciated('defaults', true, 'use Object.assign instead');
1553
1470
  return Object.assign(defaults, target);
@@ -1558,6 +1475,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1558
1475
  function isNegative(n) {
1559
1476
  return ((n = +n) || 1 / n) < 0;
1560
1477
  }
1478
+
1561
1479
  /**
1562
1480
  * Print a message and CSG object bounds and size to the conosle.
1563
1481
  * @param {String} msg Message to print
@@ -1565,9 +1483,8 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1565
1483
  * @function
1566
1484
  * @depricated use Debug instead
1567
1485
  */
1568
-
1569
1486
  function print(msg, o) {
1570
- debug$1(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1487
+ debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1571
1488
  }
1572
1489
  function jscadToString(o) {
1573
1490
  if (_typeof(o) == 'object') {
@@ -1581,12 +1498,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1581
1498
  }
1582
1499
  function error(msg, name, error) {
1583
1500
  if (console && console.error) console.error(msg, error); // eslint-disable-line no-console
1584
-
1585
1501
  var err = new Error(msg);
1586
1502
  err.name = name || 'JSCAD_UTILS_ERROR';
1587
1503
  err._error = error;
1588
1504
  throw err;
1589
1505
  }
1506
+
1590
1507
  /**
1591
1508
  * Shows a warning or error message. Used to indicate a method
1592
1509
  * has been depricated and what to use instead.
@@ -1595,41 +1512,38 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1595
1512
  * @param {boolean} [error] Throws an error if called when true.
1596
1513
  * @param {string} [message] Instructions on what to use instead of the depricated method.
1597
1514
  */
1598
-
1599
1515
  function depreciated(method, error, message) {
1600
- var msg = method + ' is depreciated.' + (' ' + message || ''); // eslint-disable-next-line no-console
1601
-
1516
+ var msg = method + ' is depreciated.' + (' ' + message || '');
1517
+ // eslint-disable-next-line no-console
1602
1518
  if (!error && console && console.error) console[error ? 'error' : 'warn'](msg); // eslint-disable-line no-console
1603
-
1604
1519
  if (error) {
1605
1520
  var err = new Error(msg);
1606
1521
  err.name = 'JSCAD_UTILS_DEPRECATED';
1607
1522
  throw err;
1608
1523
  }
1609
1524
  }
1525
+
1610
1526
  /**
1611
1527
  * Convert an imperial `inch` to metric `mm`.
1612
1528
  * @param {Number} x Value in inches
1613
1529
  * @return {Number} Result in mm
1614
1530
  * @function inch
1615
1531
  */
1616
-
1617
1532
  function inch(x) {
1618
1533
  return x * 25.4;
1619
1534
  }
1535
+
1620
1536
  /**
1621
1537
  * Convert metric `cm` to imperial `inch`.
1622
1538
  * @param {Number} x Value in cm
1623
1539
  * @return {Number} Result in inches
1624
1540
  * @function cm
1625
1541
  */
1626
-
1627
1542
  function cm(x) {
1628
1543
  return x / 25.4;
1629
1544
  }
1630
1545
  function label(text, x, y, width, height) {
1631
1546
  var l = vector_text(x || 0, y || 0, text); // l contains a list of polylines to draw
1632
-
1633
1547
  var o = [];
1634
1548
  l.forEach(function (pl) {
1635
1549
  // pl = polyline (not closed)
@@ -1637,22 +1551,20 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1637
1551
  w: width || 2,
1638
1552
  h: height || 2
1639
1553
  })); // extrude it to 3D
1640
- }); // console.trace('label', Object.getPrototypeOf(union(o)));
1554
+ });
1555
+ // console.trace('label', Object.getPrototypeOf(union(o)));
1641
1556
  // var foo = union(o);
1642
1557
  // console.trace('typeof', typeof foo);
1643
-
1644
1558
  return center(union(o));
1645
1559
  }
1646
1560
  function text(text) {
1647
1561
  var l = vector_char(0, 0, text); // l contains a list of polylines to draw
1648
-
1649
1562
  var _char = l.segments.reduce(function (result, segment) {
1650
1563
  var path = new CSG.Path2D(segment);
1651
- var cag = path.expandToCAG(2); // debug('reduce', result, segment, path, cag);
1652
-
1564
+ var cag = path.expandToCAG(2);
1565
+ // debug('reduce', result, segment, path, cag);
1653
1566
  return result ? result.union(cag) : cag;
1654
1567
  }, undefined);
1655
-
1656
1568
  return _char;
1657
1569
  }
1658
1570
  function unitCube(length, radius) {
@@ -1663,7 +1575,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1663
1575
  });
1664
1576
  }
1665
1577
  function unitAxis(length, radius, centroid) {
1666
- debug$1('unitAxis', length, radius, centroid);
1578
+ debug$2('unitAxis', length, radius, centroid);
1667
1579
  centroid = centroid || [0, 0, 0];
1668
1580
  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)]);
1669
1581
  unitaxis.properties.origin = new CSG.Connector([0, 0, 0], [1, 0, 0], [0, 1, 0]);
@@ -1675,6 +1587,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1675
1587
  function ifArray(a, cb) {
1676
1588
  return Array.isArray(a) ? a.map(cb) : cb(a);
1677
1589
  }
1590
+
1678
1591
  /**
1679
1592
  * Returns an array of positions along an object on a given axis.
1680
1593
  * @param {CSG} object The object to calculate the segments on.
@@ -1683,16 +1596,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1683
1596
  * @return {Array} An array of segment positions.
1684
1597
  * @function segment
1685
1598
  */
1686
-
1687
1599
  function segment(object, segments, axis) {
1688
1600
  var size = object.size()[axis];
1689
1601
  var width = size / segments;
1690
1602
  var result = [];
1691
-
1692
1603
  for (var i = width; i < size; i += width) {
1693
1604
  result.push(i);
1694
1605
  }
1695
-
1696
1606
  return result;
1697
1607
  }
1698
1608
  function zipObject(names, values) {
@@ -1701,6 +1611,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1701
1611
  return result;
1702
1612
  }, {});
1703
1613
  }
1614
+
1704
1615
  /**
1705
1616
  * Object map function, returns an array of the object mapped into an array.
1706
1617
  * @param {object} o Object to map
@@ -1708,7 +1619,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1708
1619
  * @return {array} an array of the mapped object.
1709
1620
  * @function map
1710
1621
  */
1711
-
1712
1622
  function map(o, f) {
1713
1623
  return Object.keys(o).map(function (key) {
1714
1624
  return f(o[key], key, o);
@@ -1730,13 +1640,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1730
1640
  if (!o[name]) {
1731
1641
  throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(',')));
1732
1642
  }
1733
-
1734
1643
  result.push(f ? f(o[name], name, index, o) : o[name]);
1735
1644
  return result;
1736
1645
  }, []);
1737
1646
  }
1738
1647
  function divA(a, f) {
1739
- return div(a, f);
1648
+ return div$1(a, f);
1740
1649
  }
1741
1650
  function divxyz(size, x, y, z) {
1742
1651
  return {
@@ -1745,7 +1654,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1745
1654
  z: size.z / z
1746
1655
  };
1747
1656
  }
1748
- function div$1(size, d) {
1657
+ function div(size, d) {
1749
1658
  return this.divxyz(size, d, d, d);
1750
1659
  }
1751
1660
  function mulxyz(size, x, y, z) {
@@ -1766,18 +1675,19 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1766
1675
  y: [0, 1, 0],
1767
1676
  z: [0, 0, 1]
1768
1677
  };
1678
+
1769
1679
  /**
1770
1680
  * Returns a `Vector3D` with the size of the object.
1771
1681
  * @param {CSG} o A `CSG` like object or an array of `CSG.Vector3D` objects (the result of getBounds()).
1772
1682
  * @return {CSG.Vector3D} Vector3d with the size of the object
1773
1683
  * @function size
1774
1684
  */
1775
-
1776
1685
  function size(o) {
1777
1686
  var bbox = o.getBounds ? o.getBounds() : o;
1778
1687
  var foo = bbox[1].minus(bbox[0]);
1779
1688
  return foo;
1780
1689
  }
1690
+
1781
1691
  /**
1782
1692
  * Returns a scale factor (0.0-1.0) for an object
1783
1693
  * that will resize it by a value in size units instead
@@ -1787,7 +1697,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1787
1697
  * @return {number} Scale factor
1788
1698
  * @function scale
1789
1699
  */
1790
-
1791
1700
  function scale(size, value) {
1792
1701
  if (value == 0) return 1;
1793
1702
  return 1 + 100 / (size / value) / 100;
@@ -1804,6 +1713,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1804
1713
  objectSize = objectSize || size(object.getBounds());
1805
1714
  return object.translate([-objectSize.x / 2, 0, 0]);
1806
1715
  }
1716
+
1807
1717
  /**
1808
1718
  * Enlarge an object by scale units, while keeping the same
1809
1719
  * centroid. For example `enlarge(mycsg, 1, 1, 1)` enlarges
@@ -1815,16 +1725,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1815
1725
  * @return {CSG} [description]
1816
1726
  * @function enlarge
1817
1727
  */
1818
-
1819
1728
  function enlarge(object, x, y, z) {
1820
1729
  var a;
1821
-
1822
1730
  if (Array.isArray(x)) {
1823
1731
  a = x;
1824
1732
  } else {
1825
1733
  a = [x, y || x, z || x];
1826
1734
  }
1827
-
1828
1735
  var objectSize = size(object);
1829
1736
  var objectCentroid = centroid(object, objectSize);
1830
1737
  var idx = 0;
@@ -1832,11 +1739,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1832
1739
  return scale(i, a[idx++]);
1833
1740
  });
1834
1741
  var new_object = object.scale(t);
1835
- var new_centroid = centroid(new_object); /// Calculate the difference between the original centroid and the new
1742
+ var new_centroid = centroid(new_object);
1836
1743
 
1744
+ /// Calculate the difference between the original centroid and the new
1837
1745
  var delta = new_centroid.minus(objectCentroid).times(-1);
1838
1746
  return new_object.translate(delta);
1839
1747
  }
1748
+
1840
1749
  /**
1841
1750
  * Fit an object inside a bounding box. Often used
1842
1751
  * with text labels.
@@ -1848,10 +1757,8 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1848
1757
  * @return {CSG} [description]
1849
1758
  * @function fit
1850
1759
  */
1851
-
1852
1760
  function fit(object, x, y, z, keep_aspect_ratio) {
1853
1761
  var a;
1854
-
1855
1762
  if (Array.isArray(x)) {
1856
1763
  a = x;
1857
1764
  keep_aspect_ratio = y;
@@ -1861,19 +1768,15 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1861
1768
  } else {
1862
1769
  a = [x, y, z];
1863
1770
  }
1864
-
1865
1771
  var objectSize = size(object.getBounds());
1866
-
1867
1772
  function scale(size, value) {
1868
1773
  if (value == 0) return 1;
1869
1774
  return value / size;
1870
1775
  }
1871
-
1872
1776
  var s = [scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z)];
1873
1777
  var min$1 = min(s);
1874
1778
  return centerWith(object.scale(s.map(function (d, i) {
1875
1779
  if (a[i] === 0) return 1; // don't scale when value is zero
1876
-
1877
1780
  return keep_aspect_ratio ? min$1 : d;
1878
1781
  })), 'xyz', object);
1879
1782
  }
@@ -1903,7 +1806,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1903
1806
  function calcFlush(moveobj, withobj, axes, mside, wside) {
1904
1807
  depreciated('calcFlush', false, 'Use calcSnap instead.');
1905
1808
  var side;
1906
-
1907
1809
  if (mside === 0 || mside === 1) {
1908
1810
  // wside = wside !== undefined ? wside : mside;
1909
1811
  side = [wside !== undefined ? wside : mside, mside];
@@ -1911,14 +1813,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1911
1813
  side = flushSide[mside];
1912
1814
  if (!side) error('invalid side: ' + mside);
1913
1815
  }
1914
-
1915
1816
  var m = moveobj.getBounds();
1916
- var w = withobj.getBounds(); // Add centroid if needed
1817
+ var w = withobj.getBounds();
1917
1818
 
1819
+ // Add centroid if needed
1918
1820
  if (side[0] === -1) {
1919
1821
  w[-1] = toxyz(withobj.centroid());
1920
1822
  }
1921
-
1922
1823
  return this.axisApply(axes, function (i, axis) {
1923
1824
  return w[side[0]][axis] - m[side[1]][axis];
1924
1825
  });
@@ -1926,7 +1827,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1926
1827
  function calcSnap(moveobj, withobj, axes, orientation) {
1927
1828
  var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1928
1829
  var side = flushSide[orientation];
1929
-
1930
1830
  if (!side) {
1931
1831
  var fix = {
1932
1832
  '01': 'outside+',
@@ -1938,14 +1838,13 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1938
1838
  };
1939
1839
  error('calcSnap: invalid side: ' + orientation + ' should be ' + fix['' + orientation + delta]);
1940
1840
  }
1941
-
1942
1841
  var m = moveobj.getBounds();
1943
- var w = withobj.getBounds(); // Add centroid if needed
1842
+ var w = withobj.getBounds();
1944
1843
 
1844
+ // Add centroid if needed
1945
1845
  if (side[0] === -1) {
1946
1846
  w[-1] = withobj.centroid();
1947
1847
  }
1948
-
1949
1848
  var t = axisApply(axes, function (i, axis) {
1950
1849
  return w[side[0]][axis] - m[side[1]][axis];
1951
1850
  });
@@ -1954,10 +1853,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1954
1853
  }) : t;
1955
1854
  }
1956
1855
  function snap(moveobj, withobj, axis, orientation, delta) {
1957
- debug$1('snap', moveobj, withobj, axis, orientation, delta);
1856
+ debug$2('snap', moveobj, withobj, axis, orientation, delta);
1958
1857
  var t = calcSnap(moveobj, withobj, axis, orientation, delta);
1959
1858
  return moveobj.translate(t);
1960
1859
  }
1860
+
1961
1861
  /**
1962
1862
  * Moves an object flush with another object
1963
1863
  * @param {CSG} moveobj Object to move
@@ -1967,12 +1867,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
1967
1867
  * @param {Number} wside 0 or 1
1968
1868
  * @return {CSG} [description]
1969
1869
  */
1970
-
1971
1870
  function flush(moveobj, withobj, axis, mside, wside) {
1972
1871
  return moveobj.translate(calcFlush(moveobj, withobj, axis, mside, wside));
1973
1872
  }
1974
1873
  function axisApply(axes, valfun, a) {
1975
- debug$1('axisApply', axes, valfun, a);
1874
+ debug$2('axisApply', axes, valfun, a);
1976
1875
  var retval = a || [0, 0, 0];
1977
1876
  var lookup = {
1978
1877
  x: 0,
@@ -2007,6 +1906,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2007
1906
  error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
2008
1907
  }
2009
1908
  }
1909
+
2010
1910
  /**
2011
1911
  * Calculates the transform array to move the midline of an object
2012
1912
  * by value. This is useful when you have a diagram that provides
@@ -2017,7 +1917,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2017
1917
  * @param {Number} to Value to move the midline of the object to.
2018
1918
  * @return {Number[]} The tranform array needed to move the object.
2019
1919
  */
2020
-
2021
1920
  function calcmidlineTo(o, axis, to) {
2022
1921
  var bounds = o.getBounds();
2023
1922
  var objectSize = size(bounds);
@@ -2030,8 +1929,8 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2030
1929
  }
2031
1930
  function translator(o, axis, withObj) {
2032
1931
  var objectCentroid = centroid(o);
2033
- var withCentroid = centroid(withObj); // echo('centerWith', centroid, withCentroid);
2034
-
1932
+ var withCentroid = centroid(withObj);
1933
+ // echo('centerWith', centroid, withCentroid);
2035
1934
  var t = axisApply(axis, function (i) {
2036
1935
  return withCentroid[i] - objectCentroid[i];
2037
1936
  });
@@ -2049,6 +1948,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2049
1948
  function centerWith(o, axis, withObj) {
2050
1949
  return o.translate(calcCenterWith(o, axis, withObj));
2051
1950
  }
1951
+
2052
1952
  /**
2053
1953
  * Given an size, bounds and an axis, a Point
2054
1954
  * along the axis will be returned. If no `offset`
@@ -2063,21 +1963,20 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2063
1963
  * @param {Boolean} [nonzero] When true, no offset values under 1e-4 are allowed.
2064
1964
  * @return {Point} The point along the axis.
2065
1965
  */
2066
-
2067
1966
  function getDelta(size, bounds, axis, offset, nonzero) {
2068
1967
  if (!isEmpty(offset) && nonzero) {
2069
1968
  if (Math.abs(offset) < 1e-4) {
2070
1969
  offset = 1e-4 * (isNegative(offset) ? -1 : 1);
2071
1970
  }
2072
- } // if the offset is negative, then it's an offset from
1971
+ }
1972
+ // if the offset is negative, then it's an offset from
2073
1973
  // the positive side of the axis
2074
-
2075
-
2076
1974
  var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
2077
1975
  return axisApply(axis, function (i, a) {
2078
1976
  return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
2079
1977
  });
2080
1978
  }
1979
+
2081
1980
  /**
2082
1981
  * Cut an object into two pieces, along a given axis. The offset
2083
1982
  * allows you to move the cut plane along the cut axis. For example,
@@ -2087,7 +1986,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2087
1986
  *
2088
1987
  * You can angle the cut plane and position the rotation point.
2089
1988
  *
2090
- * ![bisect example](../images/bisect.png)
1989
+ * ![bisect example](./images/bisect.png)
2091
1990
  * @param {CSG} object object to bisect
2092
1991
  * @param {string} axis axis to cut along
2093
1992
  * @param {number} [offset] offset to cut at
@@ -2100,27 +1999,24 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2100
1999
  * @param {CSG.Vector3D} [options.rotationCenter]
2101
2000
  * @return {JsCadUtilsGroup} Returns a group object with a parts object.
2102
2001
  */
2103
-
2104
2002
  function bisect() {
2105
2003
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2106
2004
  args[_key] = arguments[_key];
2107
2005
  }
2108
-
2109
2006
  if (args.length < 2) {
2110
2007
  error('bisect requries an object and an axis', 'JSCAD_UTILS_INVALID_ARGS');
2111
2008
  }
2112
-
2113
2009
  var object = args[0];
2114
2010
  var axis = args[1];
2115
2011
  var offset,
2116
- angle = 0,
2117
- rotateaxis,
2118
- rotateoffset,
2119
- options = {};
2012
+ angle = 0,
2013
+ rotateaxis,
2014
+ rotateoffset,
2015
+ options = {};
2016
+
2120
2017
  /**
2121
2018
  * Allow the options object to include the parameters.
2122
2019
  */
2123
-
2124
2020
  for (var i = 2; i < args.length; i++) {
2125
2021
  if (args[i] instanceof Object) {
2126
2022
  options = args[i];
@@ -2133,26 +2029,21 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2133
2029
  case 2:
2134
2030
  offset = args[i];
2135
2031
  break;
2136
-
2137
2032
  case 3:
2138
2033
  angle = args[i];
2139
2034
  break;
2140
-
2141
2035
  case 4:
2142
2036
  rotateaxis = args[i];
2143
2037
  break;
2144
-
2145
2038
  case 5:
2146
2039
  rotateoffset = args[i];
2147
2040
  break;
2148
-
2149
2041
  case 6:
2150
2042
  options = args[i];
2151
2043
  break;
2152
2044
  }
2153
2045
  }
2154
2046
  }
2155
-
2156
2047
  options = Object.assign({
2157
2048
  addRotationCenter: false
2158
2049
  }, options);
@@ -2180,7 +2071,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2180
2071
  }));
2181
2072
  var theRotationAxis = rotationAxes[rotateaxis];
2182
2073
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
2183
- debug$1('bisect', debug$1.enabled && {
2074
+ debug$2('bisect', debug$2.enabled && {
2184
2075
  axis: axis,
2185
2076
  offset: offset,
2186
2077
  angle: angle,
@@ -2208,7 +2099,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2208
2099
  * @param {CSG.Vector3D} [options.rotationCenter] The location of the rotation center, defaults to [0,0,0].
2209
2100
  * @return {JsCadUtilsGroup} A group with a positive and negative CSG object.
2210
2101
  */
2211
-
2212
2102
  function slice(object) {
2213
2103
  var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
2214
2104
  var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'x';
@@ -2220,22 +2110,22 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2220
2110
  var info = normalVector(axis);
2221
2111
  var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
2222
2112
  var theRotationAxis = rotationAxes[rotateaxis];
2223
- var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]) // .translate(cutDelta)
2113
+ var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1])
2114
+ // .translate(cutDelta)
2224
2115
  .rotate(rotationCenter, theRotationAxis, angle);
2225
2116
  var g = Group('negative,positive', [object.cutByPlane(cutplane.plane).color(options.color && 'red'), object.cutByPlane(cutplane.plane.flipped()).color(options.color && 'blue')]);
2226
-
2227
2117
  if (options.addRotationCenter) {
2228
2118
  var objectSize = size(object);
2229
2119
  g.add(unitAxis(objectSize.length() + 10, 0.1, rotationCenter), 'rotationCenter');
2230
2120
  }
2231
-
2232
2121
  return g;
2233
2122
  }
2123
+
2234
2124
  /**
2235
2125
  * Creates a `JsCadUtilsGroup` object that has `body` and `wedge` objects. The `wedge` object
2236
2126
  * is created by radially cutting the object from the `start` to the `end` angle.
2237
2127
  *
2238
- * ![wedge example](../images/wedge.png)
2128
+ * ![wedge example](./images/wedge.png)
2239
2129
  *
2240
2130
  *
2241
2131
  * @example
@@ -2263,7 +2153,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2263
2153
  * @param {'x'|'y'|'z'} axis The axis to cut the wedge in.
2264
2154
  * @return {JsCadUtilsGroup} A group object with a `body` and `wedge` parts.
2265
2155
  */
2266
-
2267
2156
  function wedge(object, start, end, axis) {
2268
2157
  var a = slice(object, start, axis);
2269
2158
  var b = slice(a.parts.positive, end, axis);
@@ -2272,6 +2161,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2272
2161
  wedge: b.parts.negative.color('red')
2273
2162
  });
2274
2163
  }
2164
+
2275
2165
  /**
2276
2166
  * Wraps the `stretchAtPlane` call using the same
2277
2167
  * logic as `bisect`.
@@ -2281,7 +2171,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2281
2171
  * @param {Number} offset Offset along the axis to cut the object
2282
2172
  * @return {CSG} The stretched object.
2283
2173
  */
2284
-
2285
2174
  function stretch(object, axis, distance, offset) {
2286
2175
  var normal = {
2287
2176
  x: [1, 0, 0],
@@ -2290,10 +2179,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2290
2179
  };
2291
2180
  var bounds = object.getBounds();
2292
2181
  var objectSize = size(object);
2293
- var cutDelta = getDelta(objectSize, bounds, axis, offset, true); // debug('stretch.cutDelta', cutDelta, normal[axis]);
2294
-
2182
+ var cutDelta = getDelta(objectSize, bounds, axis, offset, true);
2183
+ // debug('stretch.cutDelta', cutDelta, normal[axis]);
2295
2184
  return object.stretchAtPlane(normal[axis], cutDelta, distance);
2296
2185
  }
2186
+
2297
2187
  /**
2298
2188
  * Takes two CSG polygons and creates a solid of `height`.
2299
2189
  * Similar to `CSG.extrude`, except you can resize either
@@ -2303,18 +2193,16 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2303
2193
  * @param {number} height height of solid
2304
2194
  * @return {CSG} generated solid
2305
2195
  */
2306
-
2307
2196
  function poly2solid(top, bottom, height) {
2308
2197
  if (top.sides.length == 0) {
2309
2198
  // empty!
2310
2199
  return new CSG();
2311
- } // var offsetVector = CSG.parseOptionAs3DVector(options, "offset", [0, 0, 10]);
2312
-
2313
-
2200
+ }
2201
+ // var offsetVector = CSG.parseOptionAs3DVector(options, "offset", [0, 0, 10]);
2314
2202
  var offsetVector = CSG.Vector3D.Create(0, 0, height);
2315
2203
  var normalVector = CSG.Vector3D.Create(0, 1, 0);
2316
- var polygons = []; // bottom and top
2317
-
2204
+ var polygons = [];
2205
+ // bottom and top
2318
2206
  polygons = polygons.concat(bottom._toPlanePolygons({
2319
2207
  translation: [0, 0, 0],
2320
2208
  normalVector: normalVector,
@@ -2324,40 +2212,38 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2324
2212
  translation: offsetVector,
2325
2213
  normalVector: normalVector,
2326
2214
  flipped: offsetVector.z < 0
2327
- })); // walls
2328
-
2215
+ }));
2216
+ // walls
2329
2217
  var c1 = new CSG.Connector(offsetVector.times(0), [0, 0, offsetVector.z], normalVector);
2330
2218
  var c2 = new CSG.Connector(offsetVector, [0, 0, offsetVector.z], normalVector);
2331
2219
  polygons = polygons.concat(bottom._toWallPolygons({
2332
2220
  cag: top,
2333
2221
  toConnector1: c1,
2334
2222
  toConnector2: c2
2335
- })); // }
2223
+ }));
2224
+ // }
2336
2225
 
2337
2226
  return CSG.fromPolygons(polygons);
2338
2227
  }
2339
2228
  function slices2poly(slices, options, axis) {
2340
- debug$1('slices2poly', slices, options, axis);
2229
+ debug$2('slices2poly', slices, options, axis);
2341
2230
  options = Object.assign({
2342
2231
  twistangle: 0,
2343
2232
  twiststeps: 0
2344
2233
  }, options);
2345
2234
  var twistangle = options && parseFloat(options.twistangle) || 0;
2346
- var twiststeps = options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
2347
-
2348
- if (twistangle == 0 || twiststeps < 1) {
2349
- twiststeps = 1;
2350
- }
2351
-
2235
+ options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
2352
2236
  var normalVector = options.si.normalVector;
2353
- var polygons = []; // bottom and top
2237
+ var polygons = [];
2354
2238
 
2239
+ // bottom and top
2355
2240
  var first$1 = first(slices);
2356
2241
  var last$1 = last(slices);
2357
- debug$1('slices2poly first', first$1, first$1.offset, 'last', last$1);
2358
- var up = first$1.offset[axis] > last$1.offset[axis]; // _toPlanePolygons only works in the 'z' axis. It's hard coded
2359
- // to create the poly using 'x' and 'y'.
2242
+ debug$2('slices2poly first', first$1, first$1.offset, 'last', last$1);
2243
+ var up = first$1.offset[axis] > last$1.offset[axis];
2360
2244
 
2245
+ // _toPlanePolygons only works in the 'z' axis. It's hard coded
2246
+ // to create the poly using 'x' and 'y'.
2361
2247
  polygons = polygons.concat(first$1.poly._toPlanePolygons({
2362
2248
  translation: first$1.offset,
2363
2249
  normalVector: normalVector,
@@ -2368,24 +2254,27 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2368
2254
  translation: last$1.offset,
2369
2255
  normalVector: normalVector[rotateAxis](twistangle),
2370
2256
  flipped: up
2371
- })); // rotate with quick short circut
2257
+ }));
2372
2258
 
2259
+ // rotate with quick short circut
2373
2260
  var rotate = twistangle === 0 ? function rotateZero(v) {
2374
2261
  return v;
2375
2262
  } : function rotate(v, angle, percent) {
2376
2263
  return v[rotateAxis](angle * percent);
2377
- }; // walls
2378
-
2379
- var connectorAxis = last$1.offset.minus(first$1.offset).abs(); // debug('connectorAxis', connectorAxis);
2264
+ };
2380
2265
 
2266
+ // walls
2267
+ var connectorAxis = last$1.offset.minus(first$1.offset).abs();
2268
+ // debug('connectorAxis', connectorAxis);
2381
2269
  slices.forEach(function (slice, idx) {
2382
2270
  if (idx < slices.length - 1) {
2383
2271
  var nextidx = idx + 1;
2384
2272
  var top = !up ? slices[nextidx] : slice;
2385
2273
  var bottom = up ? slices[nextidx] : slice;
2386
2274
  var c1 = new CSG.Connector(bottom.offset, connectorAxis, rotate(normalVector, twistangle, idx / slices.length));
2387
- var c2 = new CSG.Connector(top.offset, connectorAxis, rotate(normalVector, twistangle, nextidx / slices.length)); // debug('slices2poly.slices', c1.point, c2.point);
2275
+ var c2 = new CSG.Connector(top.offset, connectorAxis, rotate(normalVector, twistangle, nextidx / slices.length));
2388
2276
 
2277
+ // debug('slices2poly.slices', c1.point, c2.point);
2389
2278
  polygons = polygons.concat(bottom.poly._toWallPolygons({
2390
2279
  cag: top.poly,
2391
2280
  toConnector1: c1,
@@ -2440,7 +2329,9 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2440
2329
  return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
2441
2330
  })
2442
2331
  }, info, normalVector(axis));
2443
- } // export function solidFromSlices(slices, heights) {
2332
+ }
2333
+
2334
+ // export function solidFromSlices(slices, heights) {
2444
2335
  // var si = {
2445
2336
  // axis: 'z',
2446
2337
  // cutDelta: {},
@@ -2455,7 +2346,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2455
2346
  var b = object.getBounds();
2456
2347
  var absoluteRadius = Math.abs(radius);
2457
2348
  var si = sliceParams(orientation, radius, b);
2458
- debug$1('reShape', absoluteRadius, si);
2349
+ debug$2('reShape', absoluteRadius, si);
2459
2350
  if (si.axis !== 'z') throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
2460
2351
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
2461
2352
  var slice = object.sectionCut(cutplane);
@@ -2466,7 +2357,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2466
2357
  return si.positive ? absoluteRadius : 0;
2467
2358
  });
2468
2359
  var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
2469
- debug$1('reShape first/last', first, last);
2360
+ debug$2('reShape first/last', first, last);
2470
2361
  var slices = slicer(first, last, slice, radius);
2471
2362
  var delta = slices2poly(slices, Object.assign(options, {
2472
2363
  si: si
@@ -2503,9 +2394,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2503
2394
  return slices;
2504
2395
  });
2505
2396
  }
2506
- function calcRotate(part, solid, axis
2507
- /* , angle */
2508
- ) {
2397
+ function calcRotate(part, solid, axis /* , angle */) {
2509
2398
  var axes = {
2510
2399
  x: [1, 0, 0],
2511
2400
  y: [0, 1, 0],
@@ -2520,29 +2409,26 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2520
2409
  }
2521
2410
  function rotateAround(part, solid, axis, angle) {
2522
2411
  var _calcRotate = calcRotate(part, solid, axis),
2523
- rotationCenter = _calcRotate.rotationCenter,
2524
- rotationAxis = _calcRotate.rotationAxis;
2525
-
2412
+ rotationCenter = _calcRotate.rotationCenter,
2413
+ rotationAxis = _calcRotate.rotationAxis;
2526
2414
  return part.rotate(rotationCenter, rotationAxis, angle);
2527
2415
  }
2528
-
2529
2416
  function cloneProperties(from, to) {
2530
2417
  return Object.entries(from).reduce(function (props, _ref) {
2531
2418
  var _ref2 = _slicedToArray(_ref, 2),
2532
- key = _ref2[0],
2533
- value = _ref2[1];
2534
-
2419
+ key = _ref2[0],
2420
+ value = _ref2[1];
2535
2421
  props[key] = value;
2536
2422
  return props;
2537
2423
  }, to);
2538
2424
  }
2539
-
2540
2425
  function clone(o) {
2541
2426
  var c = CSG.fromPolygons(o.toPolygons());
2542
2427
  cloneProperties(o, c);
2543
- debug$1('clone', o, c, CSG);
2428
+ debug$2('clone', o, c, CSG);
2544
2429
  return c;
2545
2430
  }
2431
+
2546
2432
  /**
2547
2433
  * @function addConnector
2548
2434
  * @param {CSG} object The object to add the connector to.
@@ -2552,7 +2438,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2552
2438
  * @param {Array} point=[0,0,0] a 3 axis array direction vector somewhat perpendicular to axis; this defines the “12 o'clock” orientation of the connection.
2553
2439
  * @return {CSG} The CSG object with the new connector added.
2554
2440
  */
2555
-
2556
2441
  function addConnector(object, name) {
2557
2442
  var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0];
2558
2443
  var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [1, 0, 0];
@@ -2561,14 +2446,15 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2561
2446
  return object;
2562
2447
  }
2563
2448
 
2564
- var debug$2 = Debug('jscadUtils:parts');
2449
+ var debug$1 = Debug('jscadUtils:parts');
2565
2450
  var parts = {
2566
- BBox: BBox,
2451
+ BBox: BBox$1,
2567
2452
  Cube: Cube,
2568
2453
  RoundedCube: RoundedCube,
2569
2454
  Cylinder: Cylinder,
2570
2455
  Cone: Cone
2571
2456
  };
2457
+
2572
2458
  /**
2573
2459
  * Returns a CSG cube object with the same extent of all
2574
2460
  * parameters objects passed in.
@@ -2576,37 +2462,35 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2576
2462
  * @param {CSG} ...objects Any number of CSG objects to create a bounding box for.
2577
2463
  * @return {CSG} A box with the size of the extents of all of the passed in objects
2578
2464
  */
2579
-
2580
- function BBox() {
2465
+ function BBox$1() {
2581
2466
  function box(object) {
2582
2467
  return CSG.cube({
2583
2468
  center: object.centroid(),
2584
2469
  radius: object.size().dividedBy(2)
2585
2470
  });
2586
2471
  }
2587
-
2588
2472
  for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
2589
2473
  objects[_key] = arguments[_key];
2590
2474
  }
2591
-
2592
2475
  return objects.reduce(function (bbox, part) {
2593
2476
  var object = bbox ? union([bbox, box(part)]) : part;
2594
2477
  return box(object);
2595
2478
  }, undefined);
2596
2479
  }
2597
2480
  function Cube(width) {
2598
- var r = div(fromxyz(width), 2);
2481
+ var r = div$1(fromxyz(width), 2);
2599
2482
  return CSG.cube({
2600
2483
  center: r,
2601
2484
  radius: r
2602
2485
  });
2603
- } // export function Sphere(diameter) {
2486
+ }
2487
+
2488
+ // export function Sphere(diameter) {
2604
2489
  // return CSG.sphere({
2605
2490
  // cener: [0, 0, 0],
2606
2491
  // radius: diameter / 2
2607
2492
  // });
2608
2493
  // }
2609
-
2610
2494
  /**
2611
2495
  * Creates a cube with the `x` and `y` corners rounded. The `z` faces are flat.
2612
2496
  * Intended to create circut boards and similar objects.
@@ -2618,7 +2502,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2618
2502
  * @param {Number} [corner_radius] Radius of the corners.
2619
2503
  * @return {CSG} A csg rounded cube.
2620
2504
  */
2621
-
2622
2505
  function RoundedCube(x, y, thickness, corner_radius) {
2623
2506
  if (x.getBounds) {
2624
2507
  var size$1 = size(x.getBounds());
@@ -2628,8 +2511,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2628
2511
  } else {
2629
2512
  var r = [x / 2, y / 2]; // eslint-disable-line no-redeclare
2630
2513
  }
2631
-
2632
- debug$2('RoundedCube', size$1, r, thickness, corner_radius);
2514
+ debug$1('RoundedCube', size$1, r, thickness, corner_radius);
2633
2515
  var roundedcube = CAG.roundedRectangle({
2634
2516
  center: [r[0], r[1], 0],
2635
2517
  radius: r,
@@ -2640,6 +2522,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2640
2522
  });
2641
2523
  return roundedcube;
2642
2524
  }
2525
+
2643
2526
  /**
2644
2527
  * A Cylinder primative located at the origin.
2645
2528
  * @param {Number} diameter Diameter of the cylinder
@@ -2648,10 +2531,9 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2648
2531
  * @param {number} [options.resolution] The number of segments to create in 360 degrees of rotation.
2649
2532
  * @return {CSG} A CSG Cylinder
2650
2533
  */
2651
-
2652
2534
  function Cylinder(diameter, height) {
2653
2535
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2654
- debug$2('parts.Cylinder', diameter, height, options);
2536
+ debug$1('parts.Cylinder', diameter, height, options);
2655
2537
  options = Object.assign({
2656
2538
  start: [0, 0, 0],
2657
2539
  end: [0, 0, height],
@@ -2660,6 +2542,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2660
2542
  }, options);
2661
2543
  return CSG.cylinder(options);
2662
2544
  }
2545
+
2663
2546
  /**
2664
2547
  * Creats a cone.
2665
2548
  * @function Cone
@@ -2669,10 +2552,9 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2669
2552
  * @param {Object} options Additional options passed to `CSG.cylinder`.
2670
2553
  * @return {CSG} A CSG cone object.
2671
2554
  */
2672
-
2673
2555
  function Cone(diameter1, diameter2, height) {
2674
2556
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2675
- debug$2('parts.Cone', diameter1, diameter2, height, options);
2557
+ debug$1('parts.Cone', diameter1, diameter2, height, options);
2676
2558
  return CSG.cylinder(Object.assign({
2677
2559
  start: [0, 0, 0],
2678
2560
  end: [0, 0, height],
@@ -2681,14 +2563,14 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2681
2563
  resolution: CSG.defaultResolution2D
2682
2564
  }, options));
2683
2565
  }
2566
+
2684
2567
  /**
2685
2568
  * Creates a hexagon.
2686
2569
  * @param {number} diameter Outside diameter of the hexagon
2687
2570
  * @param {number} height height of the hexagon
2688
2571
  */
2689
-
2690
2572
  function Hexagon(diameter, height) {
2691
- debug$2('hexagon', diameter, height);
2573
+ debug$1('hexagon', diameter, height);
2692
2574
  var radius = diameter / 2;
2693
2575
  var sqrt3 = Math.sqrt(3) / 2;
2694
2576
  var hex = CAG.fromPoints([[radius, 0], [radius / 2, radius * sqrt3], [-radius / 2, radius * sqrt3], [-radius, 0], [-radius / 2, -radius * sqrt3], [radius / 2, -radius * sqrt3]]);
@@ -2696,6 +2578,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2696
2578
  offset: [0, 0, height]
2697
2579
  });
2698
2580
  }
2581
+
2699
2582
  /**
2700
2583
  * Creats a 3 sided prisim
2701
2584
  * @function Triangle
@@ -2703,7 +2586,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2703
2586
  * @param {Number} height The height of the prisim.
2704
2587
  * @return {CSG} A prisim object.
2705
2588
  */
2706
-
2707
2589
  function Triangle(base, height) {
2708
2590
  var radius = base / 2;
2709
2591
  var tri = CAG.fromPoints([[-radius, 0], [radius, 0], [0, Math.sin(30) * radius]]);
@@ -2711,6 +2593,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2711
2593
  offset: [0, 0, height]
2712
2594
  });
2713
2595
  }
2596
+
2714
2597
  /**
2715
2598
  * Create a tube
2716
2599
  * @param {Number} outsideDiameter Outside diameter of the tube.
@@ -2722,16 +2605,15 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2722
2605
  * @param {number} [insideOptions.resolution] The resolution option determines the number of segments to create in 360 degrees of rotation.
2723
2606
  * @returns {CSG} A CSG Tube
2724
2607
  */
2725
-
2726
2608
  function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
2727
2609
  return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
2728
2610
  }
2611
+
2729
2612
  /**
2730
2613
  *
2731
2614
  * @param {Number} width
2732
2615
  * @param {Number} height
2733
2616
  */
2734
-
2735
2617
  function Anchor() {
2736
2618
  var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
2737
2619
  var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
@@ -2776,14 +2658,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2776
2658
  head: head.color('gray'),
2777
2659
  thread: thread.snap(head, 'z', orientation.head).color('silver')
2778
2660
  });
2779
-
2780
2661
  if (headClearSpace) {
2781
2662
  group.add(headClearSpace.enlarge(options.clearance).snap(head, 'z', orientation.clear).color('red'), 'headClearSpace', true);
2782
2663
  }
2783
-
2784
2664
  return group;
2785
2665
  },
2786
-
2787
2666
  /**
2788
2667
  * Creates a `Group` object with a Pan Head Screw.
2789
2668
  * @param {number} headDiameter Diameter of the head of the screw
@@ -2797,14 +2676,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2797
2676
  depreciated('PanHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2798
2677
  var head = Cylinder(headDiameter, headLength);
2799
2678
  var thread = Cylinder(diameter, length);
2800
-
2801
2679
  if (clearLength) {
2802
2680
  var headClearSpace = Cylinder(headDiameter, clearLength);
2803
2681
  }
2804
-
2805
2682
  return Hardware.Screw(head, thread, headClearSpace, options);
2806
2683
  },
2807
-
2808
2684
  /**
2809
2685
  * Creates a `Group` object with a Hex Head Screw.
2810
2686
  * @param {number} headDiameter Diameter of the head of the screw
@@ -2818,14 +2694,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2818
2694
  depreciated('HexHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2819
2695
  var head = Hexagon(headDiameter, headLength);
2820
2696
  var thread = Cylinder(diameter, length);
2821
-
2822
2697
  if (clearLength) {
2823
2698
  var headClearSpace = Hexagon(headDiameter, clearLength);
2824
2699
  }
2825
-
2826
2700
  return Hardware.Screw(head, thread, headClearSpace, options);
2827
2701
  },
2828
-
2829
2702
  /**
2830
2703
  * Create a Flat Head Screw
2831
2704
  * @param {number} headDiameter head diameter
@@ -2837,14 +2710,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2837
2710
  */
2838
2711
  FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
2839
2712
  depreciated('FlatHeadScrew', false, 'Use the jscad-hardware screw methods instead');
2840
- var head = Cone(headDiameter, diameter, headLength); // var head = Cylinder(headDiameter, headLength);
2841
-
2713
+ var head = Cone(headDiameter, diameter, headLength);
2714
+ // var head = Cylinder(headDiameter, headLength);
2842
2715
  var thread = Cylinder(diameter, length);
2843
-
2844
2716
  if (clearLength) {
2845
2717
  var headClearSpace = Cylinder(headDiameter, clearLength);
2846
2718
  }
2847
-
2848
2719
  return Hardware.Screw(head, thread, headClearSpace, options);
2849
2720
  }
2850
2721
  };
@@ -2852,7 +2723,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2852
2723
  var parts$1 = /*#__PURE__*/Object.freeze({
2853
2724
  __proto__: null,
2854
2725
  'default': parts,
2855
- BBox: BBox,
2726
+ BBox: BBox$1,
2856
2727
  Cube: Cube,
2857
2728
  RoundedCube: RoundedCube,
2858
2729
  Cylinder: Cylinder,
@@ -2865,14 +2736,14 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2865
2736
  Hardware: Hardware
2866
2737
  });
2867
2738
 
2868
- var debug$3 = Debug('jscadUtils:boxes');
2739
+ var debug = Debug('jscadUtils:boxes');
2740
+
2869
2741
  /** @typedef {import("./group").JsCadUtilsGroup} JsCadUtilsGroup */
2870
2742
 
2871
2743
  /**
2872
2744
  * jscad box and join utilities. This should be considered experimental,
2873
2745
  * but there are some useful utilities here.
2874
2746
  */
2875
-
2876
2747
  /**
2877
2748
  * Create a [rabbet joint](https://en.wikipedia.org/wiki/Rabbet) in a CSG solid.
2878
2749
  * This was designed for cubes, but should work on other types of objects.
@@ -2887,11 +2758,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2887
2758
  * @function RabbetJoin
2888
2759
  * @deprecated Use `Rabbet` instead.
2889
2760
  */
2890
-
2891
2761
  function RabbetJoin(box, thickness, cutHeight) {
2892
2762
  depreciated('RabbetJoin', true, "Use 'Rabbet' instead");
2893
2763
  return rabbetJoin(box, thickness, cutHeight);
2894
2764
  }
2765
+
2895
2766
  /**
2896
2767
  * Cuts a CSG object into three parts, a top and bottom of `thickness`
2897
2768
  * height, and the remaining middle.
@@ -2900,20 +2771,20 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2900
2771
  * @param {Number} thickness The thickness of the top and bottom parts.
2901
2772
  * @return {JsCadUtilsGroup} A `Group` object with the `top`, `middle` and `bottom` parts.
2902
2773
  */
2903
-
2904
2774
  function topMiddleBottom(box, thickness) {
2905
- debug$3('TopMiddleBottom', box, thickness);
2775
+ debug('TopMiddleBottom', box, thickness);
2906
2776
  var bottom = box.bisect('z', thickness, {
2907
2777
  color: true
2908
2778
  });
2909
2779
  var top = bottom.parts.positive.bisect('z', -thickness);
2910
2780
  return Group('top,middle,bottom', [top.parts.positive, top.parts.negative.color('green'), bottom.parts.negative]);
2911
2781
  }
2782
+
2912
2783
  /**
2913
2784
  * This will bisect an object using a rabett join. Returns a
2914
2785
  * `group` object with `positive` and `negative` parts.
2915
2786
  *
2916
- * * ![parts example](../images/rabett.png)
2787
+ * * ![parts example](./images/rabett.png)
2917
2788
  * @example
2918
2789
  *include('dist/jscad-utils.jscad');
2919
2790
  *
@@ -2937,28 +2808,29 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2937
2808
  * @param {Number} face Size of the join face.
2938
2809
  * @return {JsCadUtilsGroup} A group object with `positive`, `negative` parts.
2939
2810
  */
2940
-
2941
2811
  function Rabett(box, thickness, gap, height, face) {
2942
2812
  var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2943
- debug$3('Rabett', 'thickness', thickness, 'gap', gap, 'height', height, 'face', face);
2813
+ debug('Rabett', 'thickness', thickness, 'gap', gap, 'height', height, 'face', face);
2944
2814
  gap = gap || 0.25;
2945
2815
  var inside = thickness - gap;
2946
- var outside = -thickness + gap; // options.color = true;
2947
-
2948
- debug$3('inside', inside, 'outside', outside);
2949
- var group = Group(); // debug('Rabbet top height:', height, 'options:', options);
2950
-
2816
+ var outside = -thickness + gap;
2817
+ // options.color = true;
2818
+ debug('inside', inside, 'outside', outside);
2819
+ var group = Group();
2820
+ // debug('Rabbet top height:', height, 'options:', options);
2951
2821
  var _box$bisect$parts = box.bisect('z', height, options).parts,
2952
- top = _box$bisect$parts.positive,
2953
- lower2_3rd = _box$bisect$parts.negative; // debug('face', face, 'height', height);
2954
-
2955
- var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face; // debug('Rabbet bottom height:', lowerBisectHeight, 'options:', options);
2822
+ top = _box$bisect$parts.positive,
2823
+ lower2_3rd = _box$bisect$parts.negative;
2956
2824
 
2825
+ // debug('face', face, 'height', height);
2826
+ var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
2827
+ // debug('Rabbet bottom height:', lowerBisectHeight, 'options:', options);
2957
2828
  var _lower2_3rd$bisect$pa = lower2_3rd.bisect('z', lowerBisectHeight, options).parts,
2958
- middle = _lower2_3rd$bisect$pa.positive,
2959
- bottom = _lower2_3rd$bisect$pa.negative;
2829
+ middle = _lower2_3rd$bisect$pa.positive,
2830
+ bottom = _lower2_3rd$bisect$pa.negative;
2960
2831
  var middleTop = middle.color('yellow').subtract(middle.color('darkred').enlarge([outside, outside, 0]));
2961
- group.add(top // .color('blue')
2832
+ group.add(top
2833
+ // .color('blue')
2962
2834
  .union(middleTop), 'top');
2963
2835
  var bottomOutline = middle.color('yellow').subtract(middle.color('orange').enlarge([outside, outside, 0])).enlarge([outside, outside, 0]);
2964
2836
  group.add(bottomOutline, 'middle-top', true);
@@ -2966,6 +2838,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2966
2838
  group.add(bottom.color('orange').union(middle.color('green').subtract(middle.color('red').enlarge([inside, inside, 0])).subtract(middleTop)), 'bottom');
2967
2839
  return group;
2968
2840
  }
2841
+
2969
2842
  /**
2970
2843
  * Used on a hollow object, this will rabett out the top and/or
2971
2844
  * bottom of the object.
@@ -2998,7 +2871,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
2998
2871
  * @return {JsCadUtilsGroup} An A hollow version of the original object..
2999
2872
  * @memberof module:Boxes
3000
2873
  */
3001
-
3002
2874
  var RabettTopBottom = function rabbetTMB(box, thickness) {
3003
2875
  var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
3004
2876
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -3008,13 +2880,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3008
2880
  topWidth: -thickness,
3009
2881
  bottomWidth: thickness
3010
2882
  }, options);
3011
- debug$3('RabettTopBottom', box, thickness, gap, options);
2883
+ debug('RabettTopBottom', box, thickness, gap, options);
3012
2884
  var group = Group('', {
3013
2885
  box: box
3014
2886
  });
3015
2887
  var inside = -thickness - gap;
3016
2888
  var outside = -thickness + gap;
3017
-
3018
2889
  if (options.removableTop) {
3019
2890
  var top = box.bisect('z', options.topWidth, {
3020
2891
  color: true
@@ -3022,7 +2893,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3022
2893
  group.add(top.parts.positive.enlarge([inside, inside, 0]), 'top');
3023
2894
  if (!options.removableBottom) group.add(box.subtract(top.parts.positive.enlarge([outside, outside, 0])), 'bottom');
3024
2895
  }
3025
-
3026
2896
  if (options.removableBottom) {
3027
2897
  var bottom = box.bisect('z', options.bottomWidth, {
3028
2898
  color: true
@@ -3031,17 +2901,15 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3031
2901
  group.add(bottom.parts.negative.enlarge([inside, inside, 0]), 'bottom');
3032
2902
  if (!options.removableTop) group.add(box.subtract(group.parts.bottomCutout), 'top');
3033
2903
  }
3034
-
3035
2904
  if (options.removableBottom && options.removableTop) {
3036
2905
  group.add(box.subtract(union([bottom.parts.negative.enlarge([outside, outside, 0]), top.parts.positive.enlarge([outside, outside, 0])])), 'middle');
3037
2906
  }
3038
-
3039
2907
  return group;
3040
2908
  };
3041
2909
  var CutOut = function cutOut(o, h, box, plug, gap) {
3042
- gap = gap || 0.25; // console.log('cutOut', o.size(), h, b.size());
2910
+ gap = gap || 0.25;
2911
+ // console.log('cutOut', o.size(), h, b.size());
3043
2912
  // var r = getRadius(o);
3044
-
3045
2913
  var s = o.size();
3046
2914
  var cutout = o.intersect(box);
3047
2915
  var cs = o.size();
@@ -3060,7 +2928,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3060
2928
  };
3061
2929
  var Rectangle = function Rectangle(size, thickness, cb) {
3062
2930
  thickness = thickness || 2;
3063
- var s = div(xyz2array(size), 2);
2931
+ var s = div$1(xyz2array(size), 2);
3064
2932
  var r = add(s, thickness);
3065
2933
  var box = CSG.cube({
3066
2934
  center: r,
@@ -3069,10 +2937,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3069
2937
  center: r,
3070
2938
  radius: s
3071
2939
  }));
3072
- if (cb) box = cb(box); // return rabbetTMB(box.color('gray'), thickness, gap, options);
2940
+ if (cb) box = cb(box);
3073
2941
 
2942
+ // return rabbetTMB(box.color('gray'), thickness, gap, options);
3074
2943
  return box;
3075
2944
  };
2945
+
3076
2946
  /**
3077
2947
  * Takes a solid object and returns a hollow version with a selected
3078
2948
  * wall thickness. This is done by reducing the object by half the
@@ -3087,7 +2957,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3087
2957
  * @return {CSG} An A hollow version of the original object..
3088
2958
  * @memberof module:Boxes
3089
2959
  */
3090
-
3091
2960
  var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
3092
2961
  thickness = thickness || 2;
3093
2962
  var size = -thickness * 2;
@@ -3096,6 +2965,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3096
2965
  if (exteriorcb) box = exteriorcb(box);
3097
2966
  return box;
3098
2967
  };
2968
+
3099
2969
  /**
3100
2970
  * Create a box that surounds the object.
3101
2971
  * @param {CSG} o The object to create a bounding box for.
@@ -3103,20 +2973,17 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3103
2973
  * @deprecated use parts.BBox
3104
2974
  * @memberof module:Boxes
3105
2975
  */
3106
-
3107
- var BBox$1 = function BBox(o) {
2976
+ var BBox = function BBox(o) {
3108
2977
  depreciated('BBox', true, "Use 'parts.BBox' instead");
3109
- var s = div(xyz2array(o.size()), 2);
2978
+ var s = div$1(xyz2array(o.size()), 2);
3110
2979
  return CSG.cube({
3111
2980
  center: s,
3112
2981
  radius: s
3113
2982
  }).align(o, 'xyz');
3114
2983
  };
3115
-
3116
2984
  function getRadius(o) {
3117
- return div(xyz2array(o.size()), 2);
2985
+ return div$1(xyz2array(o.size()), 2);
3118
2986
  }
3119
-
3120
2987
  function rabbetJoin(box, thickness) {
3121
2988
  var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
3122
2989
  var r = add(getRadius(box), -thickness / 2);
@@ -3144,7 +3011,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3144
3011
  CutOut: CutOut,
3145
3012
  Rectangle: Rectangle,
3146
3013
  Hollow: Hollow,
3147
- BBox: BBox$1
3014
+ BBox: BBox
3148
3015
  });
3149
3016
 
3150
3017
  var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
@@ -3167,6 +3034,8 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
3167
3034
  exports.triUtils = triUtils;
3168
3035
  exports.util = util;
3169
3036
 
3037
+ Object.defineProperty(exports, '__esModule', { value: true });
3038
+
3170
3039
  return exports;
3171
3040
 
3172
- }({}, jsCadCSG, scadApi));
3041
+ })({}, jsCadCSG, scadApi);