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