@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.
@@ -153,7 +153,7 @@ function initJscadutils(_CSG, options = {}) {
153
153
  return divxyz;
154
154
  },
155
155
  get div() {
156
- return div$1;
156
+ return div;
157
157
  },
158
158
  get mulxyz() {
159
159
  return mulxyz;
@@ -285,104 +285,98 @@ function initJscadutils(_CSG, options = {}) {
285
285
  return addConnector;
286
286
  }
287
287
  });
288
- function _typeof(obj) {
289
- "@babel/helpers - typeof";
290
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
291
- _typeof = function(obj) {
292
- return typeof obj;
293
- };
294
- } else {
295
- _typeof = function(obj) {
296
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
297
- };
298
- }
299
- return _typeof(obj);
300
- }
301
- function _defineProperty(obj, key, value) {
302
- if (key in obj) {
303
- Object.defineProperty(obj, key, {
304
- value,
305
- enumerable: true,
306
- configurable: true,
307
- writable: true
308
- });
309
- } else {
310
- obj[key] = value;
311
- }
312
- return obj;
313
- }
314
- function ownKeys(object, enumerableOnly) {
315
- var keys = Object.keys(object);
316
- if (Object.getOwnPropertySymbols) {
317
- var symbols = Object.getOwnPropertySymbols(object);
318
- if (enumerableOnly) symbols = symbols.filter((function(sym) {
319
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
320
- }));
321
- keys.push.apply(keys, symbols);
322
- }
323
- return keys;
324
- }
325
- function _objectSpread2(target) {
326
- for (var i = 1; i < arguments.length; i++) {
327
- var source = arguments[i] != null ? arguments[i] : {};
328
- if (i % 2) {
329
- ownKeys(Object(source), true).forEach((function(key) {
330
- _defineProperty(target, key, source[key]);
331
- }));
332
- } else if (Object.getOwnPropertyDescriptors) {
333
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
334
- } else {
335
- ownKeys(Object(source)).forEach((function(key) {
336
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
337
- }));
288
+ function _arrayLikeToArray(r, a) {
289
+ (null == a || a > r.length) && (a = r.length);
290
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
291
+ return n;
292
+ }
293
+ function _arrayWithHoles(r) {
294
+ if (Array.isArray(r)) return r;
295
+ }
296
+ function _defineProperty(e, r, t) {
297
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
298
+ value: t,
299
+ enumerable: !0,
300
+ configurable: !0,
301
+ writable: !0
302
+ }) : e[r] = t, e;
303
+ }
304
+ function _iterableToArrayLimit(r, l) {
305
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
306
+ if (null != t) {
307
+ var e, n, i, u, a = [], f = !0, o = !1;
308
+ try {
309
+ if (i = (t = t.call(r)).next, 0 === l) {
310
+ if (Object(t) !== t) return;
311
+ f = !1;
312
+ } else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
313
+ } catch (r) {
314
+ o = !0, n = r;
315
+ } finally {
316
+ try {
317
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
318
+ } finally {
319
+ if (o) throw n;
320
+ }
338
321
  }
322
+ return a;
339
323
  }
340
- return target;
341
324
  }
342
- function _slicedToArray(arr, i) {
343
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
344
- }
345
- function _arrayWithHoles(arr) {
346
- if (Array.isArray(arr)) return arr;
325
+ function _nonIterableRest() {
326
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
347
327
  }
348
- function _iterableToArrayLimit(arr, i) {
349
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
350
- var _arr = [];
351
- var _n = true;
352
- var _d = false;
353
- var _e = undefined;
354
- try {
355
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
356
- _arr.push(_s.value);
357
- if (i && _arr.length === i) break;
358
- }
359
- } catch (err) {
360
- _d = true;
361
- _e = err;
362
- } finally {
363
- try {
364
- if (!_n && _i["return"] != null) _i["return"]();
365
- } finally {
366
- if (_d) throw _e;
367
- }
328
+ function ownKeys(e, r) {
329
+ var t = Object.keys(e);
330
+ if (Object.getOwnPropertySymbols) {
331
+ var o = Object.getOwnPropertySymbols(e);
332
+ r && (o = o.filter(function(r) {
333
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
334
+ })), t.push.apply(t, o);
368
335
  }
369
- return _arr;
336
+ return t;
370
337
  }
371
- function _unsupportedIterableToArray(o, minLen) {
372
- if (!o) return;
373
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
374
- var n = Object.prototype.toString.call(o).slice(8, -1);
375
- if (n === "Object" && o.constructor) n = o.constructor.name;
376
- if (n === "Map" || n === "Set") return Array.from(o);
377
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
338
+ function _objectSpread2(e) {
339
+ for (var r = 1; r < arguments.length; r++) {
340
+ var t = null != arguments[r] ? arguments[r] : {};
341
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
342
+ _defineProperty(e, r, t[r]);
343
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
344
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
345
+ });
346
+ }
347
+ return e;
348
+ }
349
+ function _slicedToArray(r, e) {
350
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
351
+ }
352
+ function _toPrimitive(t, r) {
353
+ if ("object" != typeof t || !t) return t;
354
+ var e = t[Symbol.toPrimitive];
355
+ if (void 0 !== e) {
356
+ var i = e.call(t, r || "default");
357
+ if ("object" != typeof i) return i;
358
+ throw new TypeError("@@toPrimitive must return a primitive value.");
359
+ }
360
+ return ("string" === r ? String : Number)(t);
378
361
  }
379
- function _arrayLikeToArray(arr, len) {
380
- if (len == null || len > arr.length) len = arr.length;
381
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
382
- return arr2;
362
+ function _toPropertyKey(t) {
363
+ var i = _toPrimitive(t, "string");
364
+ return "symbol" == typeof i ? i : i + "";
383
365
  }
384
- function _nonIterableRest() {
385
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
366
+ function _typeof(o) {
367
+ "@babel/helpers - typeof";
368
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
369
+ return typeof o;
370
+ } : function(o) {
371
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
372
+ }, _typeof(o);
373
+ }
374
+ function _unsupportedIterableToArray(r, a) {
375
+ if (r) {
376
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
377
+ var t = {}.toString.call(r).slice(8, -1);
378
+ 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;
379
+ }
386
380
  }
387
381
  var toRadians = function toRadians(deg) {
388
382
  return deg / 180 * Math.PI;
@@ -442,30 +436,30 @@ function initJscadutils(_CSG, options = {}) {
442
436
  solve90ac,
443
437
  solveab
444
438
  });
445
- var div = function div(a, f) {
446
- return a.map((function(e) {
439
+ var div$1 = function div(a, f) {
440
+ return a.map(function(e) {
447
441
  return e / f;
448
- }));
442
+ });
449
443
  };
450
444
  var addValue = function addValue(a, f) {
451
- return a.map((function(e) {
445
+ return a.map(function(e) {
452
446
  return e + f;
453
- }));
447
+ });
454
448
  };
455
449
  var addArray = function addArray(a, f) {
456
- return a.map((function(e, i) {
450
+ return a.map(function(e, i) {
457
451
  return e + f[i];
458
- }));
452
+ });
459
453
  };
460
454
  var add = function add(a) {
461
- return Array.prototype.slice.call(arguments, 1).reduce((function(result, arg) {
455
+ return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
462
456
  if (Array.isArray(arg)) {
463
457
  result = addArray(result, arg);
464
458
  } else {
465
459
  result = addValue(result, arg);
466
460
  }
467
461
  return result;
468
- }), a);
462
+ }, a);
469
463
  };
470
464
  var fromxyz = function fromxyz(object) {
471
465
  return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
@@ -484,9 +478,9 @@ function initJscadutils(_CSG, options = {}) {
484
478
  return a && a.length > 0 ? a[a.length - 1] : undefined;
485
479
  };
486
480
  var min = function min(a) {
487
- return a.reduce((function(result, value) {
481
+ return a.reduce(function(result, value) {
488
482
  return value < result ? value : result;
489
- }), Number.MAX_VALUE);
483
+ }, Number.MAX_VALUE);
490
484
  };
491
485
  var range = function range(a, b) {
492
486
  var result = [];
@@ -497,7 +491,7 @@ function initJscadutils(_CSG, options = {}) {
497
491
  };
498
492
  var array = Object.freeze({
499
493
  __proto__: null,
500
- div,
494
+ div: div$1,
501
495
  addValue,
502
496
  addArray,
503
497
  add,
@@ -520,11 +514,11 @@ function initJscadutils(_CSG, options = {}) {
520
514
  }
521
515
  }, jscadUtilsDebug || {});
522
516
  var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
523
- var enabled = checks.enabled.some((function checkEnabled(check) {
517
+ var enabled = checks.enabled.some(function checkEnabled(check) {
524
518
  return check.test(name);
525
- })) && !checks.disabled.some((function checkEnabled(check) {
519
+ }) && !checks.disabled.some(function checkEnabled(check) {
526
520
  return check.test(name);
527
- }));
521
+ });
528
522
  var logger = enabled ? checks.options.browser ? function() {
529
523
  var _console;
530
524
  for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -711,9 +705,9 @@ function initJscadutils(_CSG, options = {}) {
711
705
  function color(o, r, g, b, a) {
712
706
  if (typeof r !== "string") return o.setColor(r, g, b, a);
713
707
  if (r === "") return o;
714
- var c = name2rgb(r).map((function(x) {
708
+ var c = name2rgb(r).map(function(x) {
715
709
  return x / 255;
716
- }));
710
+ });
717
711
  c[3] = g || 1;
718
712
  return o.setColor(c);
719
713
  }
@@ -815,10 +809,10 @@ function initJscadutils(_CSG, options = {}) {
815
809
  if (arguments.length === 1) {
816
810
  return this._translate(arguments[0]);
817
811
  } else {
818
- var t = Array.prototype.slice.call(arguments, 0).reduce((function(result, arg) {
812
+ var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
819
813
  result = undefined(result, arg);
820
814
  return result;
821
- }), [ 0, 0, 0 ]);
815
+ }, [ 0, 0, 0 ]);
822
816
  return this._translate(t);
823
817
  }
824
818
  };
@@ -828,9 +822,9 @@ function initJscadutils(_CSG, options = {}) {
828
822
  proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
829
823
  var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
830
824
  var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
831
- var myConnector = myConnectorName.split(".").reduce((function(a, v) {
825
+ var myConnector = myConnectorName.split(".").reduce(function(a, v) {
832
826
  return a[v];
833
- }), this.properties);
827
+ }, this.properties);
834
828
  if (!myConnector) {
835
829
  error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
836
830
  }
@@ -847,7 +841,7 @@ function initJscadutils(_CSG, options = {}) {
847
841
  var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
848
842
  var union = scadApi__default["default"].booleanOps.union;
849
843
  init(CSG);
850
- var debug = Debug("jscadUtils:group");
844
+ var debug$3 = Debug("jscadUtils:group");
851
845
  function JsCadUtilsGroup() {
852
846
  var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
853
847
  var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -858,16 +852,16 @@ function initJscadutils(_CSG, options = {}) {
858
852
  this.holes = holes;
859
853
  }
860
854
  JsCadUtilsGroup.prototype.add = function(object, name, hidden, subparts, parts) {
861
- debug("add", object, name, hidden, subparts, parts);
855
+ debug$3("add", object, name, hidden, subparts, parts);
862
856
  var self = this;
863
857
  if (object.parts) {
864
858
  if (name) {
865
859
  if (!hidden) self.names.push(name);
866
860
  self.parts[name] = object.combine(parts);
867
861
  if (subparts) {
868
- Object.keys(object.parts).forEach((function(key) {
862
+ Object.keys(object.parts).forEach(function(key) {
869
863
  self.parts[subparts + key] = object.parts[key];
870
- }));
864
+ });
871
865
  }
872
866
  } else {
873
867
  Object.assign(self.parts, object.parts);
@@ -893,29 +887,30 @@ function initJscadutils(_CSG, options = {}) {
893
887
  if (pieces.length === 0) {
894
888
  throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
895
889
  }
896
- debug("combine", self.names, self.parts);
897
- var g = union(mapPick(self.parts, pieces, (function(value, key, index, object) {
890
+ debug$3("combine", self.names, self.parts);
891
+ var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
892
+ debug$3("combine mapPick", value, key, object);
898
893
  return map ? map(value, key, index, object) : identity(value);
899
- }), self.name));
894
+ }, self.name));
900
895
  return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
901
896
  } catch (err) {
902
- debug("combine error", this, pieces, options, err);
897
+ debug$3("combine error", this, pieces, options, err);
903
898
  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");
904
899
  }
905
900
  };
906
901
  JsCadUtilsGroup.prototype.map = function(cb) {
907
902
  var self = this;
908
- self.parts = Object.keys(self.parts).filter((function(k) {
903
+ self.parts = Object.keys(self.parts).filter(function(k) {
909
904
  return k !== "holes";
910
- })).reduce((function(result, key) {
905
+ }).reduce(function(result, key) {
911
906
  result[key] = cb(self.parts[key], key);
912
907
  return result;
913
- }), {});
908
+ }, {});
914
909
  if (self.holes) {
915
910
  if (Array.isArray(self.holes)) {
916
- self.holes = self.holes.map((function(hole, idx) {
911
+ self.holes = self.holes.map(function(hole, idx) {
917
912
  return cb(hole, idx);
918
- }));
913
+ });
919
914
  } else {
920
915
  self.holes = cb(self.holes, "holes");
921
916
  }
@@ -923,7 +918,7 @@ function initJscadutils(_CSG, options = {}) {
923
918
  return self;
924
919
  };
925
920
  JsCadUtilsGroup.prototype.clone = function(name, map) {
926
- debug("clone", name, _typeof(name), map);
921
+ debug$3("clone", name, _typeof(name), map);
927
922
  var self = this;
928
923
  if (typeof name == "function") {
929
924
  map = name;
@@ -931,15 +926,15 @@ function initJscadutils(_CSG, options = {}) {
931
926
  }
932
927
  if (!map) map = identity;
933
928
  var group = Group(name);
934
- Object.keys(self.parts).forEach((function(key) {
929
+ Object.keys(self.parts).forEach(function(key) {
935
930
  var part = self.parts[key];
936
931
  var hidden = self.names.indexOf(key) == -1;
937
932
  group.add(map(clone(part)), key, hidden);
938
- }));
933
+ });
939
934
  if (self.holes) {
940
- group.holes = toArray(self.holes).map((function(part) {
935
+ group.holes = toArray(self.holes).map(function(part) {
941
936
  return map(CSG.fromPolygons(part.toPolygons()), "holes");
942
- }));
937
+ });
943
938
  }
944
939
  return group;
945
940
  };
@@ -956,9 +951,9 @@ function initJscadutils(_CSG, options = {}) {
956
951
  }
957
952
  var rotationCenter = solid.centroid();
958
953
  var rotationAxis = axes[axis];
959
- self.map((function(part) {
954
+ self.map(function(part) {
960
955
  return part.rotate(rotationCenter, rotationAxis, angle);
961
- }));
956
+ });
962
957
  return self;
963
958
  };
964
959
  JsCadUtilsGroup.prototype.combineAll = function(options, map) {
@@ -969,12 +964,12 @@ function initJscadutils(_CSG, options = {}) {
969
964
  try {
970
965
  var self = this;
971
966
  var t = calcSnap(self.combine(part), to, axis, orientation, delta);
972
- self.map((function(part) {
967
+ self.map(function(part) {
973
968
  return part.translate(t);
974
- }));
969
+ });
975
970
  return self;
976
971
  } catch (err) {
977
- debug("snap error", this, part, to, axis, delta, err);
972
+ debug$3("snap error", this, part, to, axis, delta, err);
978
973
  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");
979
974
  }
980
975
  };
@@ -984,12 +979,12 @@ function initJscadutils(_CSG, options = {}) {
984
979
  var t = calcCenterWith(self.combine(part, {
985
980
  noholes: true
986
981
  }), axis, to, delta);
987
- self.map((function(part) {
982
+ self.map(function(part) {
988
983
  return part.translate(t);
989
- }));
984
+ });
990
985
  return self;
991
986
  } catch (err) {
992
- debug("align error", this, part, to, axis, delta, err);
987
+ debug$3("align error", this, part, to, axis, delta, err);
993
988
  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");
994
989
  }
995
990
  };
@@ -1005,7 +1000,7 @@ function initJscadutils(_CSG, options = {}) {
1005
1000
  JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
1006
1001
  var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1007
1002
  var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
1008
- debug("connectTo", {
1003
+ debug$3("connectTo", {
1009
1004
  partName,
1010
1005
  connectorName,
1011
1006
  to,
@@ -1014,38 +1009,38 @@ function initJscadutils(_CSG, options = {}) {
1014
1009
  normalrotation
1015
1010
  });
1016
1011
  var self = this;
1017
- var myConnector = connectorName.split(".").reduce((function(a, v) {
1012
+ var myConnector = connectorName.split(".").reduce(function(a, v) {
1018
1013
  return a[v];
1019
- }), self.parts[partName].properties);
1020
- debug("toConnector", to instanceof CSG.Connector);
1021
- var toConnector = toConnectorName.split(".").reduce((function(a, v) {
1014
+ }, self.parts[partName].properties);
1015
+ debug$3("toConnector", to instanceof CSG.Connector);
1016
+ var toConnector = toConnectorName.split(".").reduce(function(a, v) {
1022
1017
  return a[v];
1023
- }), to.properties);
1018
+ }, to.properties);
1024
1019
  var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
1025
- debug("connectTo", matrix);
1026
- self.map((function(part) {
1020
+ debug$3("connectTo", matrix);
1021
+ self.map(function(part) {
1027
1022
  return part.transform(matrix);
1028
- }));
1023
+ });
1029
1024
  return self;
1030
1025
  };
1031
1026
  JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
1032
1027
  var self = this;
1033
1028
  var size = self.combine(part).size();
1034
- var t = axisApply(axis, (function(i, a) {
1029
+ var t = axisApply(axis, function(i, a) {
1035
1030
  return to - size[a] / 2;
1036
- }));
1037
- self.map((function(part) {
1031
+ });
1032
+ self.map(function(part) {
1038
1033
  return part.translate(t);
1039
- }));
1034
+ });
1040
1035
  return self;
1041
1036
  };
1042
1037
  JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
1043
1038
  var self = this;
1044
1039
  var t = Array.isArray(x) ? x : [ x, y, z ];
1045
- debug("translate", t);
1046
- self.map((function(part) {
1040
+ debug$3("translate", t);
1041
+ self.map(function(part) {
1047
1042
  return part.translate(t);
1048
- }));
1043
+ });
1049
1044
  return self;
1050
1045
  };
1051
1046
  JsCadUtilsGroup.prototype.pick = function(parts, map) {
@@ -1053,9 +1048,9 @@ function initJscadutils(_CSG, options = {}) {
1053
1048
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1054
1049
  if (!map) map = identity;
1055
1050
  var g = Group();
1056
- p.forEach((function(name) {
1051
+ p.forEach(function(name) {
1057
1052
  g.add(map(CSG.fromPolygons(self.parts[name].toPolygons()), name), name);
1058
- }));
1053
+ });
1059
1054
  return g;
1060
1055
  };
1061
1056
  JsCadUtilsGroup.prototype.array = function(parts, map) {
@@ -1064,32 +1059,32 @@ function initJscadutils(_CSG, options = {}) {
1064
1059
  var p = parts && parts.length > 0 && parts.split(",") || self.names;
1065
1060
  if (!map) map = identity;
1066
1061
  var a = [];
1067
- p.forEach((function(name) {
1062
+ p.forEach(function(name) {
1068
1063
  if (!self.parts[name]) {
1069
- debug("array error", _this, parts);
1064
+ debug$3("array error", _this, parts);
1070
1065
  throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
1071
1066
  }
1072
1067
  a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
1073
- }));
1068
+ });
1074
1069
  return a;
1075
1070
  };
1076
1071
  JsCadUtilsGroup.prototype.toArray = function(pieces) {
1077
1072
  var self = this;
1078
1073
  var piecesArray = pieces ? pieces.split(",") : self.names;
1079
- return piecesArray.map((function(piece) {
1074
+ return piecesArray.map(function(piece) {
1080
1075
  if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
1081
1076
  return self.parts[piece];
1082
- }));
1077
+ });
1083
1078
  };
1084
1079
  JsCadUtilsGroup.prototype.toString = function() {
1085
- 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}');
1080
+ 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}");
1086
1081
  };
1087
1082
  JsCadUtilsGroup.prototype.setName = function(name) {
1088
1083
  this.name = name;
1089
1084
  return this;
1090
1085
  };
1091
1086
  function Group(objectNames, addObjects) {
1092
- debug("Group", objectNames, addObjects);
1087
+ debug$3("Group", objectNames, addObjects);
1093
1088
  var self = {
1094
1089
  name: "",
1095
1090
  names: [],
@@ -1112,9 +1107,9 @@ function initJscadutils(_CSG, options = {}) {
1112
1107
  self.name = objectNames;
1113
1108
  } else {
1114
1109
  var objects = objectNames;
1115
- self.names = Object.keys(objects).filter((function(k) {
1110
+ self.names = Object.keys(objects).filter(function(k) {
1116
1111
  return k !== "holes";
1117
- }));
1112
+ });
1118
1113
  self.parts = Object.assign({}, objects);
1119
1114
  self.holes = objects.holes;
1120
1115
  }
@@ -1122,7 +1117,7 @@ function initJscadutils(_CSG, options = {}) {
1122
1117
  }
1123
1118
  return new JsCadUtilsGroup(self.names, self.parts, self.holes);
1124
1119
  }
1125
- var debug$1 = Debug("jscadUtils:util");
1120
+ var debug$2 = Debug("jscadUtils:util");
1126
1121
  var NOZZEL_SIZE = .4;
1127
1122
  var nearest = {
1128
1123
  under: function under(desired) {
@@ -1157,7 +1152,7 @@ function initJscadutils(_CSG, options = {}) {
1157
1152
  return ((n = +n) || 1 / n) < 0;
1158
1153
  }
1159
1154
  function print(msg, o) {
1160
- debug$1(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1155
+ debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
1161
1156
  }
1162
1157
  function jscadToString(o) {
1163
1158
  if (_typeof(o) == "object") {
@@ -1193,21 +1188,21 @@ function initJscadutils(_CSG, options = {}) {
1193
1188
  function label(text, x, y, width, height) {
1194
1189
  var l = vector_text(x || 0, y || 0, text);
1195
1190
  var o = [];
1196
- l.forEach((function(pl) {
1191
+ l.forEach(function(pl) {
1197
1192
  o.push(rectangular_extrude(pl, {
1198
1193
  w: width || 2,
1199
1194
  h: height || 2
1200
1195
  }));
1201
- }));
1196
+ });
1202
1197
  return center(union(o));
1203
1198
  }
1204
1199
  function text(text) {
1205
1200
  var l = vector_char(0, 0, text);
1206
- var _char = l.segments.reduce((function(result, segment) {
1201
+ var _char = l.segments.reduce(function(result, segment) {
1207
1202
  var path = new CSG.Path2D(segment);
1208
1203
  var cag = path.expandToCAG(2);
1209
1204
  return result ? result.union(cag) : cag;
1210
- }), undefined);
1205
+ }, undefined);
1211
1206
  return _char;
1212
1207
  }
1213
1208
  function unitCube(length, radius) {
@@ -1218,7 +1213,7 @@ function initJscadutils(_CSG, options = {}) {
1218
1213
  });
1219
1214
  }
1220
1215
  function unitAxis(length, radius, centroid) {
1221
- debug$1("unitAxis", length, radius, centroid);
1216
+ debug$2("unitAxis", length, radius, centroid);
1222
1217
  centroid = centroid || [ 0, 0, 0 ];
1223
1218
  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) ]);
1224
1219
  unitaxis.properties.origin = new CSG.Connector([ 0, 0, 0 ], [ 1, 0, 0 ], [ 0, 1, 0 ]);
@@ -1240,38 +1235,38 @@ function initJscadutils(_CSG, options = {}) {
1240
1235
  return result;
1241
1236
  }
1242
1237
  function zipObject(names, values) {
1243
- return names.reduce((function(result, value, idx) {
1238
+ return names.reduce(function(result, value, idx) {
1244
1239
  result[value] = values[idx];
1245
1240
  return result;
1246
- }), {});
1241
+ }, {});
1247
1242
  }
1248
1243
  function map(o, f) {
1249
- return Object.keys(o).map((function(key) {
1244
+ return Object.keys(o).map(function(key) {
1250
1245
  return f(o[key], key, o);
1251
- }));
1246
+ });
1252
1247
  }
1253
1248
  function mapValues(o, f) {
1254
- return Object.keys(o).map((function(key) {
1249
+ return Object.keys(o).map(function(key) {
1255
1250
  return f(o[key], key);
1256
- }));
1251
+ });
1257
1252
  }
1258
1253
  function pick(o, names) {
1259
- return names.reduce((function(result, name) {
1254
+ return names.reduce(function(result, name) {
1260
1255
  result[name] = o[name];
1261
1256
  return result;
1262
- }), {});
1257
+ }, {});
1263
1258
  }
1264
1259
  function mapPick(o, names, f, options) {
1265
- return names.reduce((function(result, name, index) {
1260
+ return names.reduce(function(result, name, index) {
1266
1261
  if (!o[name]) {
1267
1262
  throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
1268
1263
  }
1269
1264
  result.push(f ? f(o[name], name, index, o) : o[name]);
1270
1265
  return result;
1271
- }), []);
1266
+ }, []);
1272
1267
  }
1273
1268
  function divA(a, f) {
1274
- return div(a, f);
1269
+ return div$1(a, f);
1275
1270
  }
1276
1271
  function divxyz(size, x, y, z) {
1277
1272
  return {
@@ -1280,7 +1275,7 @@ function initJscadutils(_CSG, options = {}) {
1280
1275
  z: size.z / z
1281
1276
  };
1282
1277
  }
1283
- function div$1(size, d) {
1278
+ function div(size, d) {
1284
1279
  return this.divxyz(size, d, d, d);
1285
1280
  }
1286
1281
  function mulxyz(size, x, y, z) {
@@ -1332,9 +1327,9 @@ function initJscadutils(_CSG, options = {}) {
1332
1327
  var objectSize = size(object);
1333
1328
  var objectCentroid = centroid(object, objectSize);
1334
1329
  var idx = 0;
1335
- var t = map(objectSize, (function(i) {
1330
+ var t = map(objectSize, function(i) {
1336
1331
  return scale(i, a[idx++]);
1337
- }));
1332
+ });
1338
1333
  var new_object = object.scale(t);
1339
1334
  var new_centroid = centroid(new_object);
1340
1335
  var delta = new_centroid.minus(objectCentroid).times(-1);
@@ -1358,10 +1353,10 @@ function initJscadutils(_CSG, options = {}) {
1358
1353
  }
1359
1354
  var s = [ scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z) ];
1360
1355
  var min$1 = min(s);
1361
- return centerWith(object.scale(s.map((function(d, i) {
1356
+ return centerWith(object.scale(s.map(function(d, i) {
1362
1357
  if (a[i] === 0) return 1;
1363
1358
  return keep_aspect_ratio ? min$1 : d;
1364
- }))), "xyz", object);
1359
+ })), "xyz", object);
1365
1360
  }
1366
1361
  function shift(object, x, y, z) {
1367
1362
  var hsize = this.div(this.size(object.getBounds()), 2);
@@ -1400,9 +1395,9 @@ function initJscadutils(_CSG, options = {}) {
1400
1395
  if (side[0] === -1) {
1401
1396
  w[-1] = toxyz(withobj.centroid());
1402
1397
  }
1403
- return this.axisApply(axes, (function(i, axis) {
1398
+ return this.axisApply(axes, function(i, axis) {
1404
1399
  return w[side[0]][axis] - m[side[1]][axis];
1405
- }));
1400
+ });
1406
1401
  }
1407
1402
  function calcSnap(moveobj, withobj, axes, orientation) {
1408
1403
  var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
@@ -1423,15 +1418,15 @@ function initJscadutils(_CSG, options = {}) {
1423
1418
  if (side[0] === -1) {
1424
1419
  w[-1] = withobj.centroid();
1425
1420
  }
1426
- var t = axisApply(axes, (function(i, axis) {
1421
+ var t = axisApply(axes, function(i, axis) {
1427
1422
  return w[side[0]][axis] - m[side[1]][axis];
1428
- }));
1429
- return delta ? axisApply(axes, (function(i) {
1423
+ });
1424
+ return delta ? axisApply(axes, function(i) {
1430
1425
  return t[i] + delta;
1431
- })) : t;
1426
+ }) : t;
1432
1427
  }
1433
1428
  function snap(moveobj, withobj, axis, orientation, delta) {
1434
- debug$1("snap", moveobj, withobj, axis, orientation, delta);
1429
+ debug$2("snap", moveobj, withobj, axis, orientation, delta);
1435
1430
  var t = calcSnap(moveobj, withobj, axis, orientation, delta);
1436
1431
  return moveobj.translate(t);
1437
1432
  }
@@ -1439,16 +1434,16 @@ function initJscadutils(_CSG, options = {}) {
1439
1434
  return moveobj.translate(calcFlush(moveobj, withobj, axis, mside, wside));
1440
1435
  }
1441
1436
  function axisApply(axes, valfun, a) {
1442
- debug$1("axisApply", axes, valfun, a);
1437
+ debug$2("axisApply", axes, valfun, a);
1443
1438
  var retval = a || [ 0, 0, 0 ];
1444
1439
  var lookup = {
1445
1440
  x: 0,
1446
1441
  y: 1,
1447
1442
  z: 2
1448
1443
  };
1449
- axes.split("").forEach((function(axis) {
1444
+ axes.split("").forEach(function(axis) {
1450
1445
  retval[lookup[axis]] = valfun(lookup[axis], axis);
1451
- }));
1446
+ });
1452
1447
  return retval;
1453
1448
  }
1454
1449
  function axis2array(axes, valfun) {
@@ -1459,10 +1454,10 @@ function initJscadutils(_CSG, options = {}) {
1459
1454
  y: 1,
1460
1455
  z: 2
1461
1456
  };
1462
- axes.split("").forEach((function(axis) {
1457
+ axes.split("").forEach(function(axis) {
1463
1458
  var i = lookup[axis];
1464
1459
  a[i] = valfun(i, axis);
1465
- }));
1460
+ });
1466
1461
  return a;
1467
1462
  }
1468
1463
  function centroid(o, objectSize) {
@@ -1477,9 +1472,9 @@ function initJscadutils(_CSG, options = {}) {
1477
1472
  function calcmidlineTo(o, axis, to) {
1478
1473
  var bounds = o.getBounds();
1479
1474
  var objectSize = size(bounds);
1480
- return axisApply(axis, (function(i, a) {
1475
+ return axisApply(axis, function(i, a) {
1481
1476
  return to - objectSize[a] / 2;
1482
- }));
1477
+ });
1483
1478
  }
1484
1479
  function midlineTo(o, axis, to) {
1485
1480
  return o.translate(calcmidlineTo(o, axis, to));
@@ -1487,18 +1482,18 @@ function initJscadutils(_CSG, options = {}) {
1487
1482
  function translator(o, axis, withObj) {
1488
1483
  var objectCentroid = centroid(o);
1489
1484
  var withCentroid = centroid(withObj);
1490
- var t = axisApply(axis, (function(i) {
1485
+ var t = axisApply(axis, function(i) {
1491
1486
  return withCentroid[i] - objectCentroid[i];
1492
- }));
1487
+ });
1493
1488
  return t;
1494
1489
  }
1495
1490
  function calcCenterWith(o, axes, withObj) {
1496
1491
  var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1497
1492
  var objectCentroid = centroid(o);
1498
1493
  var withCentroid = centroid(withObj);
1499
- var t = axisApply(axes, (function(i, axis) {
1494
+ var t = axisApply(axes, function(i, axis) {
1500
1495
  return withCentroid[axis] - objectCentroid[axis];
1501
- }));
1496
+ });
1502
1497
  return delta ? add(t, delta) : t;
1503
1498
  }
1504
1499
  function centerWith(o, axis, withObj) {
@@ -1511,9 +1506,9 @@ function initJscadutils(_CSG, options = {}) {
1511
1506
  }
1512
1507
  }
1513
1508
  var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
1514
- return axisApply(axis, (function(i, a) {
1509
+ return axisApply(axis, function(i, a) {
1515
1510
  return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
1516
- }));
1511
+ });
1517
1512
  }
1518
1513
  function bisect() {
1519
1514
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -1576,14 +1571,14 @@ function initJscadutils(_CSG, options = {}) {
1576
1571
  }[[ axis, rotateaxis ].sort().join("")];
1577
1572
  var centroid = object.centroid();
1578
1573
  var rotateDelta = getDelta(objectSize, bounds, rotateOffsetAxis, rotateoffset);
1579
- var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", (function(i, a) {
1574
+ var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", function(i, a) {
1580
1575
  if (a == axis) return cutDelta[i];
1581
1576
  if (a == rotateOffsetAxis) return rotateDelta[i];
1582
1577
  return centroid[a];
1583
- })));
1578
+ }));
1584
1579
  var theRotationAxis = rotationAxes[rotateaxis];
1585
1580
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
1586
- debug$1("bisect", debug$1.enabled && {
1581
+ debug$2("bisect", debug$2.enabled && {
1587
1582
  axis,
1588
1583
  offset,
1589
1584
  angle,
@@ -1664,21 +1659,18 @@ function initJscadutils(_CSG, options = {}) {
1664
1659
  return CSG.fromPolygons(polygons);
1665
1660
  }
1666
1661
  function slices2poly(slices, options, axis) {
1667
- debug$1("slices2poly", slices, options, axis);
1662
+ debug$2("slices2poly", slices, options, axis);
1668
1663
  options = Object.assign({
1669
1664
  twistangle: 0,
1670
1665
  twiststeps: 0
1671
1666
  }, options);
1672
1667
  var twistangle = options && parseFloat(options.twistangle) || 0;
1673
- var twiststeps = options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
1674
- if (twistangle == 0 || twiststeps < 1) {
1675
- twiststeps = 1;
1676
- }
1668
+ options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
1677
1669
  var normalVector = options.si.normalVector;
1678
1670
  var polygons = [];
1679
1671
  var first$1 = first(slices);
1680
1672
  var last$1 = last(slices);
1681
- debug$1("slices2poly first", first$1, first$1.offset, "last", last$1);
1673
+ debug$2("slices2poly first", first$1, first$1.offset, "last", last$1);
1682
1674
  var up = first$1.offset[axis] > last$1.offset[axis];
1683
1675
  polygons = polygons.concat(first$1.poly._toPlanePolygons({
1684
1676
  translation: first$1.offset,
@@ -1697,7 +1689,7 @@ function initJscadutils(_CSG, options = {}) {
1697
1689
  return v[rotateAxis](angle * percent);
1698
1690
  };
1699
1691
  var connectorAxis = last$1.offset.minus(first$1.offset).abs();
1700
- slices.forEach((function(slice, idx) {
1692
+ slices.forEach(function(slice, idx) {
1701
1693
  if (idx < slices.length - 1) {
1702
1694
  var nextidx = idx + 1;
1703
1695
  var top = !up ? slices[nextidx] : slice;
@@ -1710,7 +1702,7 @@ function initJscadutils(_CSG, options = {}) {
1710
1702
  toConnector2: c2
1711
1703
  }));
1712
1704
  }
1713
- }));
1705
+ });
1714
1706
  return CSG.fromPolygons(polygons);
1715
1707
  }
1716
1708
  function normalVector(axis) {
@@ -1751,12 +1743,12 @@ function initJscadutils(_CSG, options = {}) {
1751
1743
  var info = dirInfo["dir" + direction];
1752
1744
  return Object.assign({
1753
1745
  axis,
1754
- cutDelta: axisApply(axis, (function(i, a) {
1746
+ cutDelta: axisApply(axis, function(i, a) {
1755
1747
  return bounds[info.sizeIdx][a] + Math.abs(radius) * info.sizeDir;
1756
- })),
1757
- moveDelta: axisApply(axis, (function(i, a) {
1748
+ }),
1749
+ moveDelta: axisApply(axis, function(i, a) {
1758
1750
  return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
1759
- }))
1751
+ })
1760
1752
  }, info, normalVector(axis));
1761
1753
  }
1762
1754
  function reShape(object, radius, orientation, options, slicer) {
@@ -1764,18 +1756,18 @@ function initJscadutils(_CSG, options = {}) {
1764
1756
  var b = object.getBounds();
1765
1757
  var absoluteRadius = Math.abs(radius);
1766
1758
  var si = sliceParams(orientation, radius, b);
1767
- debug$1("reShape", absoluteRadius, si);
1759
+ debug$2("reShape", absoluteRadius, si);
1768
1760
  if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
1769
1761
  var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
1770
1762
  var slice = object.sectionCut(cutplane);
1771
- var first = axisApply(si.axis, (function() {
1763
+ var first = axisApply(si.axis, function() {
1772
1764
  return si.positive ? 0 : absoluteRadius;
1773
- }));
1774
- var last = axisApply(si.axis, (function() {
1765
+ });
1766
+ var last = axisApply(si.axis, function() {
1775
1767
  return si.positive ? absoluteRadius : 0;
1776
- }));
1768
+ });
1777
1769
  var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
1778
- debug$1("reShape first/last", first, last);
1770
+ debug$2("reShape first/last", first, last);
1779
1771
  var slices = slicer(first, last, slice, radius);
1780
1772
  var delta = slices2poly(slices, Object.assign(options, {
1781
1773
  si
@@ -1784,7 +1776,7 @@ function initJscadutils(_CSG, options = {}) {
1784
1776
  return union([ options.unionOriginal ? object : remainder, delta.translate(si.moveDelta) ]);
1785
1777
  }
1786
1778
  function chamfer(object, radius, orientation, options) {
1787
- return reShape(object, radius, orientation, options, (function(first, last, slice) {
1779
+ return reShape(object, radius, orientation, options, function(first, last, slice) {
1788
1780
  return [ {
1789
1781
  poly: slice,
1790
1782
  offset: new CSG.Vector3D(first)
@@ -1792,15 +1784,15 @@ function initJscadutils(_CSG, options = {}) {
1792
1784
  poly: enlarge(slice, [ -radius * 2, -radius * 2 ]),
1793
1785
  offset: new CSG.Vector3D(last)
1794
1786
  } ];
1795
- }));
1787
+ });
1796
1788
  }
1797
1789
  function fillet(object, radius, orientation, options) {
1798
1790
  options = options || {};
1799
- return reShape(object, radius, orientation, options, (function(first, last, slice) {
1791
+ return reShape(object, radius, orientation, options, function(first, last, slice) {
1800
1792
  var v1 = new CSG.Vector3D(first);
1801
1793
  var v2 = new CSG.Vector3D(last);
1802
1794
  var res = options.resolution || CSG.defaultResolution3D;
1803
- var slices = range(0, res).map((function(i) {
1795
+ var slices = range(0, res).map(function(i) {
1804
1796
  var p = i > 0 ? i / (res - 1) : 0;
1805
1797
  var v = v1.lerp(v2, p);
1806
1798
  var size = -radius * 2 - Math.cos(Math.asin(p)) * (-radius * 2);
@@ -1808,9 +1800,9 @@ function initJscadutils(_CSG, options = {}) {
1808
1800
  poly: enlarge(slice, [ size, size ]),
1809
1801
  offset: v
1810
1802
  };
1811
- }));
1803
+ });
1812
1804
  return slices;
1813
- }));
1805
+ });
1814
1806
  }
1815
1807
  function calcRotate(part, solid, axis) {
1816
1808
  var axes = {
@@ -1830,16 +1822,16 @@ function initJscadutils(_CSG, options = {}) {
1830
1822
  return part.rotate(rotationCenter, rotationAxis, angle);
1831
1823
  }
1832
1824
  function cloneProperties(from, to) {
1833
- return Object.entries(from).reduce((function(props, _ref) {
1825
+ return Object.entries(from).reduce(function(props, _ref) {
1834
1826
  var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
1835
1827
  props[key] = value;
1836
1828
  return props;
1837
- }), to);
1829
+ }, to);
1838
1830
  }
1839
1831
  function clone(o) {
1840
1832
  var c = CSG.fromPolygons(o.toPolygons());
1841
1833
  cloneProperties(o, c);
1842
- debug$1("clone", o, c, CSG);
1834
+ debug$2("clone", o, c, CSG);
1843
1835
  return c;
1844
1836
  }
1845
1837
  function addConnector(object, name) {
@@ -1849,15 +1841,15 @@ function initJscadutils(_CSG, options = {}) {
1849
1841
  object.properties[name] = new CSG.Connector(point, axis, normal);
1850
1842
  return object;
1851
1843
  }
1852
- var debug$2 = Debug("jscadUtils:parts");
1844
+ var debug$1 = Debug("jscadUtils:parts");
1853
1845
  var parts = {
1854
- BBox,
1846
+ BBox: BBox$1,
1855
1847
  Cube,
1856
1848
  RoundedCube,
1857
1849
  Cylinder,
1858
1850
  Cone
1859
1851
  };
1860
- function BBox() {
1852
+ function BBox$1() {
1861
1853
  function box(object) {
1862
1854
  return CSG.cube({
1863
1855
  center: object.centroid(),
@@ -1867,13 +1859,13 @@ function initJscadutils(_CSG, options = {}) {
1867
1859
  for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
1868
1860
  objects[_key] = arguments[_key];
1869
1861
  }
1870
- return objects.reduce((function(bbox, part) {
1862
+ return objects.reduce(function(bbox, part) {
1871
1863
  var object = bbox ? union([ bbox, box(part) ]) : part;
1872
1864
  return box(object);
1873
- }), undefined);
1865
+ }, undefined);
1874
1866
  }
1875
1867
  function Cube(width) {
1876
- var r = div(fromxyz(width), 2);
1868
+ var r = div$1(fromxyz(width), 2);
1877
1869
  return CSG.cube({
1878
1870
  center: r,
1879
1871
  radius: r
@@ -1888,7 +1880,7 @@ function initJscadutils(_CSG, options = {}) {
1888
1880
  } else {
1889
1881
  var r = [ x / 2, y / 2 ];
1890
1882
  }
1891
- debug$2("RoundedCube", size$1, r, thickness, corner_radius);
1883
+ debug$1("RoundedCube", size$1, r, thickness, corner_radius);
1892
1884
  var roundedcube = CAG.roundedRectangle({
1893
1885
  center: [ r[0], r[1], 0 ],
1894
1886
  radius: r,
@@ -1901,7 +1893,7 @@ function initJscadutils(_CSG, options = {}) {
1901
1893
  }
1902
1894
  function Cylinder(diameter, height) {
1903
1895
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1904
- debug$2("parts.Cylinder", diameter, height, options);
1896
+ debug$1("parts.Cylinder", diameter, height, options);
1905
1897
  options = Object.assign({
1906
1898
  start: [ 0, 0, 0 ],
1907
1899
  end: [ 0, 0, height ],
@@ -1912,7 +1904,7 @@ function initJscadutils(_CSG, options = {}) {
1912
1904
  }
1913
1905
  function Cone(diameter1, diameter2, height) {
1914
1906
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1915
- debug$2("parts.Cone", diameter1, diameter2, height, options);
1907
+ debug$1("parts.Cone", diameter1, diameter2, height, options);
1916
1908
  return CSG.cylinder(Object.assign({
1917
1909
  start: [ 0, 0, 0 ],
1918
1910
  end: [ 0, 0, height ],
@@ -1922,7 +1914,7 @@ function initJscadutils(_CSG, options = {}) {
1922
1914
  }, options));
1923
1915
  }
1924
1916
  function Hexagon(diameter, height) {
1925
- debug$2("hexagon", diameter, height);
1917
+ debug$1("hexagon", diameter, height);
1926
1918
  var radius = diameter / 2;
1927
1919
  var sqrt3 = Math.sqrt(3) / 2;
1928
1920
  var hex = CAG.fromPoints([ [ radius, 0 ], [ radius / 2, radius * sqrt3 ], [ -radius / 2, radius * sqrt3 ], [ -radius, 0 ], [ -radius / 2, -radius * sqrt3 ], [ radius / 2, -radius * sqrt3 ] ]);
@@ -2020,7 +2012,7 @@ function initJscadutils(_CSG, options = {}) {
2020
2012
  var parts$1 = Object.freeze({
2021
2013
  __proto__: null,
2022
2014
  default: parts,
2023
- BBox,
2015
+ BBox: BBox$1,
2024
2016
  Cube,
2025
2017
  RoundedCube,
2026
2018
  Cylinder,
@@ -2032,13 +2024,13 @@ function initJscadutils(_CSG, options = {}) {
2032
2024
  Board,
2033
2025
  Hardware
2034
2026
  });
2035
- var debug$3 = Debug("jscadUtils:boxes");
2027
+ var debug = Debug("jscadUtils:boxes");
2036
2028
  function RabbetJoin(box, thickness, cutHeight) {
2037
2029
  depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
2038
2030
  return rabbetJoin(box, thickness, cutHeight);
2039
2031
  }
2040
2032
  function topMiddleBottom(box, thickness) {
2041
- debug$3("TopMiddleBottom", box, thickness);
2033
+ debug("TopMiddleBottom", box, thickness);
2042
2034
  var bottom = box.bisect("z", thickness, {
2043
2035
  color: true
2044
2036
  });
@@ -2047,11 +2039,11 @@ function initJscadutils(_CSG, options = {}) {
2047
2039
  }
2048
2040
  function Rabett(box, thickness, gap, height, face) {
2049
2041
  var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2050
- debug$3("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
2042
+ debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
2051
2043
  gap = gap || .25;
2052
2044
  var inside = thickness - gap;
2053
2045
  var outside = -thickness + gap;
2054
- debug$3("inside", inside, "outside", outside);
2046
+ debug("inside", inside, "outside", outside);
2055
2047
  var group = Group();
2056
2048
  var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
2057
2049
  var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
@@ -2073,7 +2065,7 @@ function initJscadutils(_CSG, options = {}) {
2073
2065
  topWidth: -thickness,
2074
2066
  bottomWidth: thickness
2075
2067
  }, options);
2076
- debug$3("RabettTopBottom", box, thickness, gap, options);
2068
+ debug("RabettTopBottom", box, thickness, gap, options);
2077
2069
  var group = Group("", {
2078
2070
  box
2079
2071
  });
@@ -2119,7 +2111,7 @@ function initJscadutils(_CSG, options = {}) {
2119
2111
  };
2120
2112
  var Rectangle = function Rectangle(size, thickness, cb) {
2121
2113
  thickness = thickness || 2;
2122
- var s = div(xyz2array(size), 2);
2114
+ var s = div$1(xyz2array(size), 2);
2123
2115
  var r = add(s, thickness);
2124
2116
  var box = CSG.cube({
2125
2117
  center: r,
@@ -2139,16 +2131,16 @@ function initJscadutils(_CSG, options = {}) {
2139
2131
  if (exteriorcb) box = exteriorcb(box);
2140
2132
  return box;
2141
2133
  };
2142
- var BBox$1 = function BBox(o) {
2134
+ var BBox = function BBox(o) {
2143
2135
  depreciated("BBox", true, "Use 'parts.BBox' instead");
2144
- var s = div(xyz2array(o.size()), 2);
2136
+ var s = div$1(xyz2array(o.size()), 2);
2145
2137
  return CSG.cube({
2146
2138
  center: s,
2147
2139
  radius: s
2148
2140
  }).align(o, "xyz");
2149
2141
  };
2150
2142
  function getRadius(o) {
2151
- return div(xyz2array(o.size()), 2);
2143
+ return div$1(xyz2array(o.size()), 2);
2152
2144
  }
2153
2145
  function rabbetJoin(box, thickness) {
2154
2146
  var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
@@ -2176,7 +2168,7 @@ function initJscadutils(_CSG, options = {}) {
2176
2168
  CutOut,
2177
2169
  Rectangle,
2178
2170
  Hollow,
2179
- BBox: BBox$1
2171
+ BBox
2180
2172
  });
2181
2173
  var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
2182
2174
  group: Group,
@@ -2196,6 +2188,9 @@ function initJscadutils(_CSG, options = {}) {
2196
2188
  exports.parts = parts$1;
2197
2189
  exports.triUtils = triUtils;
2198
2190
  exports.util = util;
2191
+ Object.defineProperty(exports, "__esModule", {
2192
+ value: true
2193
+ });
2199
2194
  return exports;
2200
2195
  }({}, jsCadCSG, scadApi);
2201
2196
  const debug = jscadUtils.Debug("jscadUtils:initJscadutils");