@jwc/jscad-utils 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compat.js +409 -286
- package/dist/examples/bisect.jscad +511 -198
- package/dist/examples/boxes.jscad +511 -198
- package/dist/examples/chamfer.jscad +511 -198
- package/dist/examples/fillet.jscad +511 -198
- package/dist/examples/fit.jscad +511 -198
- package/dist/examples/groups.jscad +511 -198
- package/dist/examples/midlineTo.jscad +511 -198
- package/dist/examples/parts-hexagon.jscad +511 -198
- package/dist/examples/rabett-tb.jscad +511 -198
- package/dist/examples/rabett.jscad +511 -198
- package/dist/examples/rabett2.jscad +511 -198
- package/dist/examples/retraction-test.jscad +511 -198
- package/dist/examples/size.jscad +511 -198
- package/dist/examples/snap.jscad +511 -198
- package/dist/examples/text.jscad +511 -198
- package/dist/examples/wedge.jscad +511 -198
- package/dist/index.js +408 -285
- package/package.json +12 -6
- package/src/boxes.js +1 -1
- package/src/compat.js +1 -1
|
@@ -58,13 +58,329 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
58
58
|
});
|
|
59
59
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
60
60
|
"use strict";
|
|
61
|
-
|
|
61
|
+
function _interopDefaultLegacy(e) {
|
|
62
|
+
return e && typeof e === "object" && "default" in e ? e : {
|
|
63
|
+
default: e
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
67
|
+
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
68
|
+
var util = Object.freeze({
|
|
69
|
+
__proto__: null,
|
|
70
|
+
get NOZZEL_SIZE() {
|
|
71
|
+
return NOZZEL_SIZE;
|
|
72
|
+
},
|
|
73
|
+
get nearest() {
|
|
74
|
+
return nearest;
|
|
75
|
+
},
|
|
76
|
+
get identity() {
|
|
77
|
+
return identity;
|
|
78
|
+
},
|
|
79
|
+
get result() {
|
|
80
|
+
return result;
|
|
81
|
+
},
|
|
82
|
+
get defaults() {
|
|
83
|
+
return defaults;
|
|
84
|
+
},
|
|
85
|
+
get isEmpty() {
|
|
86
|
+
return isEmpty;
|
|
87
|
+
},
|
|
88
|
+
get isNegative() {
|
|
89
|
+
return isNegative;
|
|
90
|
+
},
|
|
91
|
+
get print() {
|
|
92
|
+
return print;
|
|
93
|
+
},
|
|
94
|
+
get jscadToString() {
|
|
95
|
+
return jscadToString;
|
|
96
|
+
},
|
|
97
|
+
get error() {
|
|
98
|
+
return error;
|
|
99
|
+
},
|
|
100
|
+
get depreciated() {
|
|
101
|
+
return depreciated;
|
|
102
|
+
},
|
|
103
|
+
get inch() {
|
|
104
|
+
return inch;
|
|
105
|
+
},
|
|
106
|
+
get cm() {
|
|
107
|
+
return cm;
|
|
108
|
+
},
|
|
109
|
+
get label() {
|
|
110
|
+
return label;
|
|
111
|
+
},
|
|
112
|
+
get text() {
|
|
113
|
+
return text;
|
|
114
|
+
},
|
|
115
|
+
get unitCube() {
|
|
116
|
+
return unitCube;
|
|
117
|
+
},
|
|
118
|
+
get unitAxis() {
|
|
119
|
+
return unitAxis;
|
|
120
|
+
},
|
|
121
|
+
get toArray() {
|
|
122
|
+
return toArray;
|
|
123
|
+
},
|
|
124
|
+
get ifArray() {
|
|
125
|
+
return ifArray;
|
|
126
|
+
},
|
|
127
|
+
get segment() {
|
|
128
|
+
return segment;
|
|
129
|
+
},
|
|
130
|
+
get zipObject() {
|
|
131
|
+
return zipObject;
|
|
132
|
+
},
|
|
133
|
+
get map() {
|
|
134
|
+
return map;
|
|
135
|
+
},
|
|
136
|
+
get mapValues() {
|
|
137
|
+
return mapValues;
|
|
138
|
+
},
|
|
139
|
+
get pick() {
|
|
140
|
+
return pick;
|
|
141
|
+
},
|
|
142
|
+
get mapPick() {
|
|
143
|
+
return mapPick;
|
|
144
|
+
},
|
|
145
|
+
get divA() {
|
|
146
|
+
return divA;
|
|
147
|
+
},
|
|
148
|
+
get divxyz() {
|
|
149
|
+
return divxyz;
|
|
150
|
+
},
|
|
151
|
+
get div() {
|
|
152
|
+
return div;
|
|
153
|
+
},
|
|
154
|
+
get mulxyz() {
|
|
155
|
+
return mulxyz;
|
|
156
|
+
},
|
|
157
|
+
get mul() {
|
|
158
|
+
return mul;
|
|
159
|
+
},
|
|
160
|
+
get xyz2array() {
|
|
161
|
+
return xyz2array;
|
|
162
|
+
},
|
|
163
|
+
get rotationAxes() {
|
|
164
|
+
return rotationAxes;
|
|
165
|
+
},
|
|
166
|
+
get size() {
|
|
167
|
+
return size;
|
|
168
|
+
},
|
|
169
|
+
get scale() {
|
|
170
|
+
return scale;
|
|
171
|
+
},
|
|
172
|
+
get center() {
|
|
173
|
+
return center;
|
|
174
|
+
},
|
|
175
|
+
get centerY() {
|
|
176
|
+
return centerY;
|
|
177
|
+
},
|
|
178
|
+
get centerX() {
|
|
179
|
+
return centerX;
|
|
180
|
+
},
|
|
181
|
+
get enlarge() {
|
|
182
|
+
return enlarge;
|
|
183
|
+
},
|
|
184
|
+
get fit() {
|
|
185
|
+
return fit;
|
|
186
|
+
},
|
|
187
|
+
get shift() {
|
|
188
|
+
return shift;
|
|
189
|
+
},
|
|
190
|
+
get zero() {
|
|
191
|
+
return zero;
|
|
192
|
+
},
|
|
193
|
+
get mirrored4() {
|
|
194
|
+
return mirrored4;
|
|
195
|
+
},
|
|
196
|
+
get flushSide() {
|
|
197
|
+
return flushSide;
|
|
198
|
+
},
|
|
199
|
+
get calcFlush() {
|
|
200
|
+
return calcFlush;
|
|
201
|
+
},
|
|
202
|
+
get calcSnap() {
|
|
203
|
+
return calcSnap;
|
|
204
|
+
},
|
|
205
|
+
get snap() {
|
|
206
|
+
return snap;
|
|
207
|
+
},
|
|
208
|
+
get flush() {
|
|
209
|
+
return flush;
|
|
210
|
+
},
|
|
211
|
+
get axisApply() {
|
|
212
|
+
return axisApply;
|
|
213
|
+
},
|
|
214
|
+
get axis2array() {
|
|
215
|
+
return axis2array;
|
|
216
|
+
},
|
|
217
|
+
get centroid() {
|
|
218
|
+
return centroid;
|
|
219
|
+
},
|
|
220
|
+
get calcmidlineTo() {
|
|
221
|
+
return calcmidlineTo;
|
|
222
|
+
},
|
|
223
|
+
get midlineTo() {
|
|
224
|
+
return midlineTo;
|
|
225
|
+
},
|
|
226
|
+
get translator() {
|
|
227
|
+
return translator;
|
|
228
|
+
},
|
|
229
|
+
get calcCenterWith() {
|
|
230
|
+
return calcCenterWith;
|
|
231
|
+
},
|
|
232
|
+
get centerWith() {
|
|
233
|
+
return centerWith;
|
|
234
|
+
},
|
|
235
|
+
get getDelta() {
|
|
236
|
+
return getDelta;
|
|
237
|
+
},
|
|
238
|
+
get bisect() {
|
|
239
|
+
return bisect;
|
|
240
|
+
},
|
|
241
|
+
get slice() {
|
|
242
|
+
return slice;
|
|
243
|
+
},
|
|
244
|
+
get wedge() {
|
|
245
|
+
return wedge;
|
|
246
|
+
},
|
|
247
|
+
get stretch() {
|
|
248
|
+
return stretch;
|
|
249
|
+
},
|
|
250
|
+
get poly2solid() {
|
|
251
|
+
return poly2solid;
|
|
252
|
+
},
|
|
253
|
+
get slices2poly() {
|
|
254
|
+
return slices2poly;
|
|
255
|
+
},
|
|
256
|
+
get normalVector() {
|
|
257
|
+
return normalVector;
|
|
258
|
+
},
|
|
259
|
+
get sliceParams() {
|
|
260
|
+
return sliceParams;
|
|
261
|
+
},
|
|
262
|
+
get reShape() {
|
|
263
|
+
return reShape;
|
|
264
|
+
},
|
|
265
|
+
get chamfer() {
|
|
266
|
+
return chamfer;
|
|
267
|
+
},
|
|
268
|
+
get fillet() {
|
|
269
|
+
return fillet;
|
|
270
|
+
},
|
|
271
|
+
get calcRotate() {
|
|
272
|
+
return calcRotate;
|
|
273
|
+
},
|
|
274
|
+
get rotateAround() {
|
|
275
|
+
return rotateAround;
|
|
276
|
+
},
|
|
277
|
+
get clone() {
|
|
278
|
+
return clone;
|
|
279
|
+
},
|
|
280
|
+
get addConnector() {
|
|
281
|
+
return addConnector;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
function _arrayLikeToArray(r, a) {
|
|
285
|
+
(null == a || a > r.length) && (a = r.length);
|
|
286
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
287
|
+
return n;
|
|
288
|
+
}
|
|
289
|
+
function _arrayWithHoles(r) {
|
|
290
|
+
if (Array.isArray(r)) return r;
|
|
291
|
+
}
|
|
292
|
+
function _defineProperty(e, r, t) {
|
|
293
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
294
|
+
value: t,
|
|
295
|
+
enumerable: !0,
|
|
296
|
+
configurable: !0,
|
|
297
|
+
writable: !0
|
|
298
|
+
}) : e[r] = t, e;
|
|
299
|
+
}
|
|
300
|
+
function _iterableToArrayLimit(r, l) {
|
|
301
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
302
|
+
if (null != t) {
|
|
303
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
304
|
+
try {
|
|
305
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
306
|
+
if (Object(t) !== t) return;
|
|
307
|
+
f = !1;
|
|
308
|
+
} else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
|
|
309
|
+
} catch (r) {
|
|
310
|
+
o = !0, n = r;
|
|
311
|
+
} finally {
|
|
312
|
+
try {
|
|
313
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
314
|
+
} finally {
|
|
315
|
+
if (o) throw n;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return a;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function _nonIterableRest() {
|
|
322
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
323
|
+
}
|
|
324
|
+
function ownKeys(e, r) {
|
|
325
|
+
var t = Object.keys(e);
|
|
326
|
+
if (Object.getOwnPropertySymbols) {
|
|
327
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
328
|
+
r && (o = o.filter(function(r) {
|
|
329
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
330
|
+
})), t.push.apply(t, o);
|
|
331
|
+
}
|
|
332
|
+
return t;
|
|
333
|
+
}
|
|
334
|
+
function _objectSpread2(e) {
|
|
335
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
336
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
337
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
338
|
+
_defineProperty(e, r, t[r]);
|
|
339
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
340
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
return e;
|
|
344
|
+
}
|
|
345
|
+
function _slicedToArray(r, e) {
|
|
346
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
347
|
+
}
|
|
348
|
+
function _toPrimitive(t, r) {
|
|
349
|
+
if ("object" != typeof t || !t) return t;
|
|
350
|
+
var e = t[Symbol.toPrimitive];
|
|
351
|
+
if (void 0 !== e) {
|
|
352
|
+
var i = e.call(t, r || "default");
|
|
353
|
+
if ("object" != typeof i) return i;
|
|
354
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
355
|
+
}
|
|
356
|
+
return ("string" === r ? String : Number)(t);
|
|
357
|
+
}
|
|
358
|
+
function _toPropertyKey(t) {
|
|
359
|
+
var i = _toPrimitive(t, "string");
|
|
360
|
+
return "symbol" == typeof i ? i : i + "";
|
|
361
|
+
}
|
|
362
|
+
function _typeof(o) {
|
|
363
|
+
"@babel/helpers - typeof";
|
|
364
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
365
|
+
return typeof o;
|
|
366
|
+
} : function(o) {
|
|
367
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
368
|
+
}, _typeof(o);
|
|
369
|
+
}
|
|
370
|
+
function _unsupportedIterableToArray(r, a) {
|
|
371
|
+
if (r) {
|
|
372
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
373
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
374
|
+
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;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
var toRadians = function toRadians(deg) {
|
|
62
378
|
return deg / 180 * Math.PI;
|
|
63
379
|
};
|
|
64
|
-
|
|
380
|
+
var toDegrees = function toDegrees(rad) {
|
|
65
381
|
return rad * (180 / Math.PI);
|
|
66
382
|
};
|
|
67
|
-
|
|
383
|
+
var solve = function solve(p1, p2) {
|
|
68
384
|
var r = {
|
|
69
385
|
c: 90,
|
|
70
386
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -76,7 +392,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
76
392
|
r.a = 90 - r.b;
|
|
77
393
|
return r;
|
|
78
394
|
};
|
|
79
|
-
|
|
395
|
+
var solve90SA = function solve90SA(r) {
|
|
80
396
|
r = Object.assign(r, {
|
|
81
397
|
C: 90
|
|
82
398
|
});
|
|
@@ -88,7 +404,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
88
404
|
r.b = r.b || r.a / Math.tan(arad);
|
|
89
405
|
return r;
|
|
90
406
|
};
|
|
91
|
-
|
|
407
|
+
var solve90ac = function solve90ac(r) {
|
|
92
408
|
r = Object.assign(r, {
|
|
93
409
|
C: 90
|
|
94
410
|
});
|
|
@@ -109,29 +425,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
109
425
|
}
|
|
110
426
|
var triUtils = Object.freeze({
|
|
111
427
|
__proto__: null,
|
|
428
|
+
toRadians,
|
|
429
|
+
toDegrees,
|
|
112
430
|
solve,
|
|
113
431
|
solve90SA,
|
|
114
432
|
solve90ac,
|
|
115
|
-
solveab
|
|
116
|
-
toDegrees,
|
|
117
|
-
toRadians
|
|
433
|
+
solveab
|
|
118
434
|
});
|
|
119
|
-
|
|
435
|
+
var div$1 = function div(a, f) {
|
|
120
436
|
return a.map(function(e) {
|
|
121
437
|
return e / f;
|
|
122
438
|
});
|
|
123
439
|
};
|
|
124
|
-
|
|
440
|
+
var addValue = function addValue(a, f) {
|
|
125
441
|
return a.map(function(e) {
|
|
126
442
|
return e + f;
|
|
127
443
|
});
|
|
128
444
|
};
|
|
129
|
-
|
|
445
|
+
var addArray = function addArray(a, f) {
|
|
130
446
|
return a.map(function(e, i) {
|
|
131
447
|
return e + f[i];
|
|
132
448
|
});
|
|
133
449
|
};
|
|
134
|
-
|
|
450
|
+
var add = function add(a) {
|
|
135
451
|
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
136
452
|
if (Array.isArray(arg)) {
|
|
137
453
|
result = addArray(result, arg);
|
|
@@ -141,28 +457,28 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
141
457
|
return result;
|
|
142
458
|
}, a);
|
|
143
459
|
};
|
|
144
|
-
|
|
460
|
+
var fromxyz = function fromxyz(object) {
|
|
145
461
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
146
462
|
};
|
|
147
|
-
|
|
463
|
+
var toxyz = function toxyz(a) {
|
|
148
464
|
return {
|
|
149
465
|
x: a[0],
|
|
150
466
|
y: a[1],
|
|
151
467
|
z: a[2]
|
|
152
468
|
};
|
|
153
469
|
};
|
|
154
|
-
|
|
470
|
+
var first = function first(a) {
|
|
155
471
|
return a ? a[0] : undefined;
|
|
156
472
|
};
|
|
157
|
-
|
|
473
|
+
var last = function last(a) {
|
|
158
474
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
159
475
|
};
|
|
160
|
-
|
|
476
|
+
var min = function min(a) {
|
|
161
477
|
return a.reduce(function(result, value) {
|
|
162
478
|
return value < result ? value : result;
|
|
163
479
|
}, Number.MAX_VALUE);
|
|
164
480
|
};
|
|
165
|
-
|
|
481
|
+
var range = function range(a, b) {
|
|
166
482
|
var result = [];
|
|
167
483
|
for (var i = a; i < b; i++) {
|
|
168
484
|
result.push(i);
|
|
@@ -171,21 +487,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
171
487
|
};
|
|
172
488
|
var array = Object.freeze({
|
|
173
489
|
__proto__: null,
|
|
174
|
-
add,
|
|
175
|
-
addArray,
|
|
176
|
-
addValue,
|
|
177
490
|
div: div$1,
|
|
178
|
-
|
|
491
|
+
addValue,
|
|
492
|
+
addArray,
|
|
493
|
+
add,
|
|
179
494
|
fromxyz,
|
|
495
|
+
toxyz,
|
|
496
|
+
first,
|
|
180
497
|
last,
|
|
181
498
|
min,
|
|
182
|
-
range
|
|
183
|
-
toxyz
|
|
499
|
+
range
|
|
184
500
|
});
|
|
185
|
-
|
|
186
|
-
|
|
501
|
+
var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
502
|
+
var termColors = [ "\\033[0;34m", "\\033[0;32m", "\\033[0;36m", "\\033[0;31m", "\\033[0;35m", "\\033[0;33m", "\\033[1;33m", "\\033[0;30m", "\\033[1;34m" ];
|
|
187
503
|
var debugCount = 0;
|
|
188
|
-
|
|
504
|
+
var Debug = function Debug(name) {
|
|
189
505
|
var checks = Object.assign({
|
|
190
506
|
enabled: [],
|
|
191
507
|
disabled: [],
|
|
@@ -193,21 +509,31 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
193
509
|
browser: true
|
|
194
510
|
}
|
|
195
511
|
}, jscadUtilsDebug || {});
|
|
196
|
-
var style = checks.options.browser ?
|
|
512
|
+
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
197
513
|
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
198
514
|
return check.test(name);
|
|
199
515
|
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
200
516
|
return check.test(name);
|
|
201
517
|
});
|
|
202
|
-
var logger = enabled ? checks.options.browser ? (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
518
|
+
var logger = enabled ? checks.options.browser ? function() {
|
|
519
|
+
var _console;
|
|
520
|
+
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
521
|
+
msg[_key] = arguments[_key];
|
|
522
|
+
}
|
|
523
|
+
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
524
|
+
} : function() {
|
|
525
|
+
var _console2;
|
|
526
|
+
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
527
|
+
msg[_key2] = arguments[_key2];
|
|
528
|
+
}
|
|
529
|
+
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
530
|
+
} : function() {
|
|
531
|
+
return undefined;
|
|
532
|
+
};
|
|
207
533
|
logger.enabled = enabled;
|
|
208
534
|
return logger;
|
|
209
535
|
};
|
|
210
|
-
|
|
536
|
+
var nameArray = {
|
|
211
537
|
aliceblue: "#f0f8ff",
|
|
212
538
|
antiquewhite: "#faebd7",
|
|
213
539
|
aqua: "#00ffff",
|
|
@@ -369,7 +695,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
369
695
|
return [ 0, 0, 0 ];
|
|
370
696
|
}
|
|
371
697
|
}
|
|
372
|
-
|
|
698
|
+
var _name2rgb = {};
|
|
373
699
|
function name2rgb(n) {
|
|
374
700
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
375
701
|
return _name2rgb[n];
|
|
@@ -449,14 +775,23 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
449
775
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
450
776
|
return chamfer(this, radius, orientation, options);
|
|
451
777
|
};
|
|
452
|
-
proto.prototype.bisect = function bisect$1(
|
|
453
|
-
|
|
778
|
+
proto.prototype.bisect = function bisect$1() {
|
|
779
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
780
|
+
args[_key] = arguments[_key];
|
|
781
|
+
}
|
|
782
|
+
return bisect.apply(util, [ this ].concat(args));
|
|
454
783
|
};
|
|
455
|
-
proto.prototype.slice = function slice$1(
|
|
456
|
-
|
|
784
|
+
proto.prototype.slice = function slice$1() {
|
|
785
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
786
|
+
args[_key2] = arguments[_key2];
|
|
787
|
+
}
|
|
788
|
+
return slice.apply(util, [ this ].concat(args));
|
|
457
789
|
};
|
|
458
|
-
proto.prototype.wedge = function wedge$1(
|
|
459
|
-
|
|
790
|
+
proto.prototype.wedge = function wedge$1() {
|
|
791
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
792
|
+
args[_key3] = arguments[_key3];
|
|
793
|
+
}
|
|
794
|
+
return wedge.apply(util, [ this ].concat(args));
|
|
460
795
|
};
|
|
461
796
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
462
797
|
return stretch(this, axis, distance, offset);
|
|
@@ -473,7 +808,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
473
808
|
return this._translate(arguments[0]);
|
|
474
809
|
} else {
|
|
475
810
|
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
476
|
-
result = undefined
|
|
811
|
+
result = undefined(result, arg);
|
|
477
812
|
return result;
|
|
478
813
|
}, [ 0, 0, 0 ]);
|
|
479
814
|
return this._translate(t);
|
|
@@ -482,10 +817,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
482
817
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
483
818
|
return addConnector(this, name, point, axis, normal);
|
|
484
819
|
};
|
|
485
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector
|
|
486
|
-
var
|
|
820
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
821
|
+
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
822
|
+
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
823
|
+
var myConnector = myConnectorName.split(".").reduce(function(a, v) {
|
|
824
|
+
return a[v];
|
|
825
|
+
}, this.properties);
|
|
487
826
|
if (!myConnector) {
|
|
488
|
-
error(
|
|
827
|
+
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
|
|
489
828
|
}
|
|
490
829
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
491
830
|
};
|
|
@@ -495,13 +834,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
495
834
|
__proto__: null,
|
|
496
835
|
default: init
|
|
497
836
|
});
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
837
|
+
var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
|
|
838
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
839
|
+
var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
|
|
840
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
502
841
|
init(CSG);
|
|
503
|
-
|
|
504
|
-
function JsCadUtilsGroup(
|
|
842
|
+
var debug$3 = Debug("jscadUtils:group");
|
|
843
|
+
function JsCadUtilsGroup() {
|
|
844
|
+
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
845
|
+
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
846
|
+
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
505
847
|
this.name = "";
|
|
506
848
|
this.names = names;
|
|
507
849
|
this.parts = parts;
|
|
@@ -529,7 +871,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
529
871
|
}
|
|
530
872
|
return self;
|
|
531
873
|
};
|
|
532
|
-
JsCadUtilsGroup.prototype.combine = function(pieces
|
|
874
|
+
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
875
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
876
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
877
|
+
return x;
|
|
878
|
+
};
|
|
533
879
|
try {
|
|
534
880
|
var self = this;
|
|
535
881
|
options = Object.assign({
|
|
@@ -537,7 +883,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
537
883
|
}, options);
|
|
538
884
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
539
885
|
if (pieces.length === 0) {
|
|
540
|
-
throw new Error(
|
|
886
|
+
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
541
887
|
}
|
|
542
888
|
debug$3("combine", self.names, self.parts);
|
|
543
889
|
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
@@ -547,12 +893,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
547
893
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
548
894
|
} catch (err) {
|
|
549
895
|
debug$3("combine error", this, pieces, options, err);
|
|
550
|
-
throw error(
|
|
896
|
+
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");
|
|
551
897
|
}
|
|
552
898
|
};
|
|
553
899
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
554
900
|
var self = this;
|
|
555
|
-
self.parts = Object.keys(self.parts).filter(
|
|
901
|
+
self.parts = Object.keys(self.parts).filter(function(k) {
|
|
902
|
+
return k !== "holes";
|
|
903
|
+
}).reduce(function(result, key) {
|
|
556
904
|
result[key] = cb(self.parts[key], key);
|
|
557
905
|
return result;
|
|
558
906
|
}, {});
|
|
@@ -568,7 +916,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
568
916
|
return self;
|
|
569
917
|
};
|
|
570
918
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
571
|
-
debug$3("clone", name,
|
|
919
|
+
debug$3("clone", name, _typeof(name), map);
|
|
572
920
|
var self = this;
|
|
573
921
|
if (typeof name == "function") {
|
|
574
922
|
map = name;
|
|
@@ -620,7 +968,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
620
968
|
return self;
|
|
621
969
|
} catch (err) {
|
|
622
970
|
debug$3("snap error", this, part, to, axis, delta, err);
|
|
623
|
-
throw error(
|
|
971
|
+
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");
|
|
624
972
|
}
|
|
625
973
|
};
|
|
626
974
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -635,7 +983,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
635
983
|
return self;
|
|
636
984
|
} catch (err) {
|
|
637
985
|
debug$3("align error", this, part, to, axis, delta, err);
|
|
638
|
-
throw error(
|
|
986
|
+
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");
|
|
639
987
|
}
|
|
640
988
|
};
|
|
641
989
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -647,7 +995,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
647
995
|
var bounds = self.parts[part].getBounds();
|
|
648
996
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
649
997
|
};
|
|
650
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName
|
|
998
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
999
|
+
var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1000
|
+
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
651
1001
|
debug$3("connectTo", {
|
|
652
1002
|
partName,
|
|
653
1003
|
connectorName,
|
|
@@ -657,9 +1007,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
657
1007
|
normalrotation
|
|
658
1008
|
});
|
|
659
1009
|
var self = this;
|
|
660
|
-
var myConnector = connectorName.split(".").reduce((a, v)
|
|
1010
|
+
var myConnector = connectorName.split(".").reduce(function(a, v) {
|
|
1011
|
+
return a[v];
|
|
1012
|
+
}, self.parts[partName].properties);
|
|
661
1013
|
debug$3("toConnector", to instanceof CSG.Connector);
|
|
662
|
-
var toConnector = toConnectorName.split(".").reduce((a, v)
|
|
1014
|
+
var toConnector = toConnectorName.split(".").reduce(function(a, v) {
|
|
1015
|
+
return a[v];
|
|
1016
|
+
}, to.properties);
|
|
663
1017
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
664
1018
|
debug$3("connectTo", matrix);
|
|
665
1019
|
self.map(function(part) {
|
|
@@ -698,14 +1052,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
698
1052
|
return g;
|
|
699
1053
|
};
|
|
700
1054
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1055
|
+
var _this = this;
|
|
701
1056
|
var self = this;
|
|
702
1057
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
703
1058
|
if (!map) map = identity;
|
|
704
1059
|
var a = [];
|
|
705
|
-
p.forEach(name
|
|
1060
|
+
p.forEach(function(name) {
|
|
706
1061
|
if (!self.parts[name]) {
|
|
707
|
-
debug$3("array error",
|
|
708
|
-
throw error(
|
|
1062
|
+
debug$3("array error", _this, parts);
|
|
1063
|
+
throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
|
|
709
1064
|
}
|
|
710
1065
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
711
1066
|
});
|
|
@@ -715,12 +1070,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
715
1070
|
var self = this;
|
|
716
1071
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
717
1072
|
return piecesArray.map(function(piece) {
|
|
718
|
-
if (!self.parts[piece]) console.error(
|
|
1073
|
+
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
719
1074
|
return self.parts[piece];
|
|
720
1075
|
});
|
|
721
1076
|
};
|
|
722
1077
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
723
|
-
return
|
|
1078
|
+
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}");
|
|
724
1079
|
};
|
|
725
1080
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
726
1081
|
this.name = name;
|
|
@@ -750,7 +1105,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
750
1105
|
self.name = objectNames;
|
|
751
1106
|
} else {
|
|
752
1107
|
var objects = objectNames;
|
|
753
|
-
self.names = Object.keys(objects).filter(k
|
|
1108
|
+
self.names = Object.keys(objects).filter(function(k) {
|
|
1109
|
+
return k !== "holes";
|
|
1110
|
+
});
|
|
754
1111
|
self.parts = Object.assign({}, objects);
|
|
755
1112
|
self.holes = objects.holes;
|
|
756
1113
|
}
|
|
@@ -758,13 +1115,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
758
1115
|
}
|
|
759
1116
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
760
1117
|
}
|
|
761
|
-
|
|
1118
|
+
var debug$2 = Debug("jscadUtils:util");
|
|
762
1119
|
var NOZZEL_SIZE = .4;
|
|
763
|
-
|
|
764
|
-
under: function(desired
|
|
1120
|
+
var nearest = {
|
|
1121
|
+
under: function under(desired) {
|
|
1122
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1123
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
765
1124
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
766
1125
|
},
|
|
767
|
-
over: function(desired
|
|
1126
|
+
over: function over(desired) {
|
|
1127
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1128
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
768
1129
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
769
1130
|
}
|
|
770
1131
|
};
|
|
@@ -792,9 +1153,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
792
1153
|
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
793
1154
|
}
|
|
794
1155
|
function jscadToString(o) {
|
|
795
|
-
if (
|
|
1156
|
+
if (_typeof(o) == "object") {
|
|
796
1157
|
if (o.polygons) {
|
|
797
|
-
return
|
|
1158
|
+
return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
|
|
798
1159
|
}
|
|
799
1160
|
} else {
|
|
800
1161
|
return o.toString();
|
|
@@ -835,12 +1196,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
835
1196
|
}
|
|
836
1197
|
function text(text) {
|
|
837
1198
|
var l = vector_char(0, 0, text);
|
|
838
|
-
var
|
|
1199
|
+
var _char = l.segments.reduce(function(result, segment) {
|
|
839
1200
|
var path = new CSG.Path2D(segment);
|
|
840
1201
|
var cag = path.expandToCAG(2);
|
|
841
1202
|
return result ? result.union(cag) : cag;
|
|
842
1203
|
}, undefined);
|
|
843
|
-
return
|
|
1204
|
+
return _char;
|
|
844
1205
|
}
|
|
845
1206
|
function unitCube(length, radius) {
|
|
846
1207
|
radius = radius || .5;
|
|
@@ -896,7 +1257,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
896
1257
|
function mapPick(o, names, f, options) {
|
|
897
1258
|
return names.reduce(function(result, name, index) {
|
|
898
1259
|
if (!o[name]) {
|
|
899
|
-
throw new Error(
|
|
1260
|
+
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
|
|
900
1261
|
}
|
|
901
1262
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
902
1263
|
return result;
|
|
@@ -928,7 +1289,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
928
1289
|
function xyz2array(size) {
|
|
929
1290
|
return [ size.x, size.y, size.z ];
|
|
930
1291
|
}
|
|
931
|
-
|
|
1292
|
+
var rotationAxes = {
|
|
932
1293
|
x: [ 1, 0, 0 ],
|
|
933
1294
|
y: [ 0, 1, 0 ],
|
|
934
1295
|
z: [ 0, 0, 1 ]
|
|
@@ -1006,7 +1367,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1006
1367
|
function mirrored4(x) {
|
|
1007
1368
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1008
1369
|
}
|
|
1009
|
-
|
|
1370
|
+
var flushSide = {
|
|
1010
1371
|
"above-outside": [ 1, 0 ],
|
|
1011
1372
|
"above-inside": [ 1, 1 ],
|
|
1012
1373
|
"below-outside": [ 0, 1 ],
|
|
@@ -1036,7 +1397,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1036
1397
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1037
1398
|
});
|
|
1038
1399
|
}
|
|
1039
|
-
function calcSnap(moveobj, withobj, axes, orientation
|
|
1400
|
+
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1401
|
+
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1040
1402
|
var side = flushSide[orientation];
|
|
1041
1403
|
if (!side) {
|
|
1042
1404
|
var fix = {
|
|
@@ -1102,7 +1464,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1102
1464
|
objectSize = objectSize || size(bounds);
|
|
1103
1465
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1104
1466
|
} catch (err) {
|
|
1105
|
-
error(
|
|
1467
|
+
error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
|
|
1106
1468
|
}
|
|
1107
1469
|
}
|
|
1108
1470
|
function calcmidlineTo(o, axis, to) {
|
|
@@ -1123,7 +1485,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1123
1485
|
});
|
|
1124
1486
|
return t;
|
|
1125
1487
|
}
|
|
1126
|
-
function calcCenterWith(o, axes, withObj
|
|
1488
|
+
function calcCenterWith(o, axes, withObj) {
|
|
1489
|
+
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1127
1490
|
var objectCentroid = centroid(o);
|
|
1128
1491
|
var withCentroid = centroid(withObj);
|
|
1129
1492
|
var t = axisApply(axes, function(i, axis) {
|
|
@@ -1145,7 +1508,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1145
1508
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1146
1509
|
});
|
|
1147
1510
|
}
|
|
1148
|
-
function bisect(
|
|
1511
|
+
function bisect() {
|
|
1512
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1513
|
+
args[_key] = arguments[_key];
|
|
1514
|
+
}
|
|
1149
1515
|
if (args.length < 2) {
|
|
1150
1516
|
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1151
1517
|
}
|
|
@@ -1226,10 +1592,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1226
1592
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1227
1593
|
return g;
|
|
1228
1594
|
}
|
|
1229
|
-
function slice(object
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1595
|
+
function slice(object) {
|
|
1596
|
+
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
|
|
1597
|
+
var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
|
|
1598
|
+
var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
|
|
1599
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1600
|
+
color: true,
|
|
1601
|
+
addRotationCenter: true
|
|
1602
|
+
};
|
|
1233
1603
|
var info = normalVector(axis);
|
|
1234
1604
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1235
1605
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1446,11 +1816,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1446
1816
|
};
|
|
1447
1817
|
}
|
|
1448
1818
|
function rotateAround(part, solid, axis, angle) {
|
|
1449
|
-
var
|
|
1819
|
+
var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
|
|
1450
1820
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1451
1821
|
}
|
|
1452
|
-
function cloneProperties(from, to
|
|
1453
|
-
return Object.entries(from).reduce((props,
|
|
1822
|
+
function cloneProperties(from, to) {
|
|
1823
|
+
return Object.entries(from).reduce(function(props, _ref) {
|
|
1824
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1454
1825
|
props[key] = value;
|
|
1455
1826
|
return props;
|
|
1456
1827
|
}, to);
|
|
@@ -1461,85 +1832,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1461
1832
|
debug$2("clone", o, c, CSG);
|
|
1462
1833
|
return c;
|
|
1463
1834
|
}
|
|
1464
|
-
function addConnector(object, name
|
|
1835
|
+
function addConnector(object, name) {
|
|
1836
|
+
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1837
|
+
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1838
|
+
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1465
1839
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1466
1840
|
return object;
|
|
1467
1841
|
}
|
|
1468
|
-
var
|
|
1469
|
-
__proto__: null,
|
|
1470
|
-
NOZZEL_SIZE,
|
|
1471
|
-
addConnector,
|
|
1472
|
-
axis2array,
|
|
1473
|
-
axisApply,
|
|
1474
|
-
bisect,
|
|
1475
|
-
calcCenterWith,
|
|
1476
|
-
calcFlush,
|
|
1477
|
-
calcRotate,
|
|
1478
|
-
calcSnap,
|
|
1479
|
-
calcmidlineTo,
|
|
1480
|
-
center,
|
|
1481
|
-
centerWith,
|
|
1482
|
-
centerX,
|
|
1483
|
-
centerY,
|
|
1484
|
-
centroid,
|
|
1485
|
-
chamfer,
|
|
1486
|
-
clone,
|
|
1487
|
-
cm,
|
|
1488
|
-
defaults,
|
|
1489
|
-
depreciated,
|
|
1490
|
-
div,
|
|
1491
|
-
divA,
|
|
1492
|
-
divxyz,
|
|
1493
|
-
enlarge,
|
|
1494
|
-
error,
|
|
1495
|
-
fillet,
|
|
1496
|
-
fit,
|
|
1497
|
-
flush,
|
|
1498
|
-
flushSide,
|
|
1499
|
-
getDelta,
|
|
1500
|
-
identity,
|
|
1501
|
-
ifArray,
|
|
1502
|
-
inch,
|
|
1503
|
-
isEmpty,
|
|
1504
|
-
isNegative,
|
|
1505
|
-
jscadToString,
|
|
1506
|
-
label,
|
|
1507
|
-
map,
|
|
1508
|
-
mapPick,
|
|
1509
|
-
mapValues,
|
|
1510
|
-
midlineTo,
|
|
1511
|
-
mirrored4,
|
|
1512
|
-
mul,
|
|
1513
|
-
mulxyz,
|
|
1514
|
-
nearest,
|
|
1515
|
-
normalVector,
|
|
1516
|
-
pick,
|
|
1517
|
-
poly2solid,
|
|
1518
|
-
print,
|
|
1519
|
-
reShape,
|
|
1520
|
-
result,
|
|
1521
|
-
rotateAround,
|
|
1522
|
-
rotationAxes,
|
|
1523
|
-
scale,
|
|
1524
|
-
segment,
|
|
1525
|
-
shift,
|
|
1526
|
-
size,
|
|
1527
|
-
slice,
|
|
1528
|
-
sliceParams,
|
|
1529
|
-
slices2poly,
|
|
1530
|
-
snap,
|
|
1531
|
-
stretch,
|
|
1532
|
-
text,
|
|
1533
|
-
toArray,
|
|
1534
|
-
translator,
|
|
1535
|
-
unitAxis,
|
|
1536
|
-
unitCube,
|
|
1537
|
-
wedge,
|
|
1538
|
-
xyz2array,
|
|
1539
|
-
zero,
|
|
1540
|
-
zipObject
|
|
1541
|
-
});
|
|
1542
|
-
const debug$1 = Debug("jscadUtils:parts");
|
|
1842
|
+
var debug$1 = Debug("jscadUtils:parts");
|
|
1543
1843
|
var parts = {
|
|
1544
1844
|
BBox: BBox$1,
|
|
1545
1845
|
Cube,
|
|
@@ -1547,13 +1847,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1547
1847
|
Cylinder,
|
|
1548
1848
|
Cone
|
|
1549
1849
|
};
|
|
1550
|
-
function BBox$1(
|
|
1850
|
+
function BBox$1() {
|
|
1551
1851
|
function box(object) {
|
|
1552
1852
|
return CSG.cube({
|
|
1553
1853
|
center: object.centroid(),
|
|
1554
1854
|
radius: object.size().dividedBy(2)
|
|
1555
1855
|
});
|
|
1556
1856
|
}
|
|
1857
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1858
|
+
objects[_key] = arguments[_key];
|
|
1859
|
+
}
|
|
1557
1860
|
return objects.reduce(function(bbox, part) {
|
|
1558
1861
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1559
1862
|
return box(object);
|
|
@@ -1586,7 +1889,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1586
1889
|
});
|
|
1587
1890
|
return roundedcube;
|
|
1588
1891
|
}
|
|
1589
|
-
function Cylinder(diameter, height
|
|
1892
|
+
function Cylinder(diameter, height) {
|
|
1893
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1590
1894
|
debug$1("parts.Cylinder", diameter, height, options);
|
|
1591
1895
|
options = Object.assign({
|
|
1592
1896
|
start: [ 0, 0, 0 ],
|
|
@@ -1596,7 +1900,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1596
1900
|
}, options);
|
|
1597
1901
|
return CSG.cylinder(options);
|
|
1598
1902
|
}
|
|
1599
|
-
function Cone(diameter1, diameter2, height
|
|
1903
|
+
function Cone(diameter1, diameter2, height) {
|
|
1904
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1600
1905
|
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1601
1906
|
return CSG.cylinder(Object.assign({
|
|
1602
1907
|
start: [ 0, 0, 0 ],
|
|
@@ -1625,7 +1930,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1625
1930
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1626
1931
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1627
1932
|
}
|
|
1628
|
-
function Anchor(
|
|
1933
|
+
function Anchor() {
|
|
1934
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1935
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1629
1936
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1630
1937
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1631
1938
|
return Group({
|
|
@@ -1645,7 +1952,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1645
1952
|
});
|
|
1646
1953
|
return board;
|
|
1647
1954
|
}
|
|
1648
|
-
|
|
1955
|
+
var Hardware = {
|
|
1649
1956
|
Orientation: {
|
|
1650
1957
|
up: {
|
|
1651
1958
|
head: "outside-",
|
|
@@ -1656,7 +1963,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1656
1963
|
clear: "inside-"
|
|
1657
1964
|
}
|
|
1658
1965
|
},
|
|
1659
|
-
Screw: function(head, thread, headClearSpace, options) {
|
|
1966
|
+
Screw: function Screw(head, thread, headClearSpace, options) {
|
|
1660
1967
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1661
1968
|
options = Object.assign(options, {
|
|
1662
1969
|
orientation: "up",
|
|
@@ -1672,7 +1979,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1672
1979
|
}
|
|
1673
1980
|
return group;
|
|
1674
1981
|
},
|
|
1675
|
-
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1982
|
+
PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1676
1983
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1677
1984
|
var head = Cylinder(headDiameter, headLength);
|
|
1678
1985
|
var thread = Cylinder(diameter, length);
|
|
@@ -1681,7 +1988,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1681
1988
|
}
|
|
1682
1989
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1683
1990
|
},
|
|
1684
|
-
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1991
|
+
HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1685
1992
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1686
1993
|
var head = Hexagon(headDiameter, headLength);
|
|
1687
1994
|
var thread = Cylinder(diameter, length);
|
|
@@ -1690,7 +1997,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1690
1997
|
}
|
|
1691
1998
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1692
1999
|
},
|
|
1693
|
-
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2000
|
+
FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1694
2001
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1695
2002
|
var head = Cone(headDiameter, diameter, headLength);
|
|
1696
2003
|
var thread = Cylinder(diameter, length);
|
|
@@ -1702,20 +2009,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1702
2009
|
};
|
|
1703
2010
|
var parts$1 = Object.freeze({
|
|
1704
2011
|
__proto__: null,
|
|
1705
|
-
|
|
2012
|
+
default: parts,
|
|
1706
2013
|
BBox: BBox$1,
|
|
1707
|
-
Board,
|
|
1708
|
-
Cone,
|
|
1709
2014
|
Cube,
|
|
2015
|
+
RoundedCube,
|
|
1710
2016
|
Cylinder,
|
|
1711
|
-
|
|
2017
|
+
Cone,
|
|
1712
2018
|
Hexagon,
|
|
1713
|
-
RoundedCube,
|
|
1714
2019
|
Triangle,
|
|
1715
2020
|
Tube,
|
|
1716
|
-
|
|
2021
|
+
Anchor,
|
|
2022
|
+
Board,
|
|
2023
|
+
Hardware
|
|
1717
2024
|
});
|
|
1718
|
-
|
|
2025
|
+
var debug = Debug("jscadUtils:boxes");
|
|
1719
2026
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
1720
2027
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
1721
2028
|
return rabbetJoin(box, thickness, cutHeight);
|
|
@@ -1728,16 +2035,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1728
2035
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
1729
2036
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
1730
2037
|
}
|
|
1731
|
-
function Rabett(box, thickness, gap, height, face
|
|
2038
|
+
function Rabett(box, thickness, gap, height, face) {
|
|
2039
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1732
2040
|
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1733
2041
|
gap = gap || .25;
|
|
1734
2042
|
var inside = thickness - gap;
|
|
1735
2043
|
var outside = -thickness + gap;
|
|
1736
2044
|
debug("inside", inside, "outside", outside);
|
|
1737
2045
|
var group = Group();
|
|
1738
|
-
var
|
|
2046
|
+
var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
|
|
1739
2047
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
1740
|
-
var
|
|
2048
|
+
var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
|
|
1741
2049
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
1742
2050
|
group.add(top.union(middleTop), "top");
|
|
1743
2051
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -1746,7 +2054,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1746
2054
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
1747
2055
|
return group;
|
|
1748
2056
|
}
|
|
1749
|
-
|
|
2057
|
+
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
2058
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2059
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1750
2060
|
options = Object.assign({
|
|
1751
2061
|
removableTop: true,
|
|
1752
2062
|
removableBottom: true,
|
|
@@ -1779,7 +2089,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1779
2089
|
}
|
|
1780
2090
|
return group;
|
|
1781
2091
|
};
|
|
1782
|
-
|
|
2092
|
+
var CutOut = function cutOut(o, h, box, plug, gap) {
|
|
1783
2093
|
gap = gap || .25;
|
|
1784
2094
|
var s = o.size();
|
|
1785
2095
|
var cutout = o.intersect(box);
|
|
@@ -1797,7 +2107,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1797
2107
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
1798
2108
|
});
|
|
1799
2109
|
};
|
|
1800
|
-
|
|
2110
|
+
var Rectangle = function Rectangle(size, thickness, cb) {
|
|
1801
2111
|
thickness = thickness || 2;
|
|
1802
2112
|
var s = div$1(xyz2array(size), 2);
|
|
1803
2113
|
var r = add(s, thickness);
|
|
@@ -1811,7 +2121,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1811
2121
|
if (cb) box = cb(box);
|
|
1812
2122
|
return box;
|
|
1813
2123
|
};
|
|
1814
|
-
|
|
2124
|
+
var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
|
|
1815
2125
|
thickness = thickness || 2;
|
|
1816
2126
|
var size = -thickness * 2;
|
|
1817
2127
|
interiorcb = interiorcb || identity;
|
|
@@ -1819,7 +2129,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1819
2129
|
if (exteriorcb) box = exteriorcb(box);
|
|
1820
2130
|
return box;
|
|
1821
2131
|
};
|
|
1822
|
-
|
|
2132
|
+
var BBox = function BBox(o) {
|
|
1823
2133
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
1824
2134
|
var s = div$1(xyz2array(o.size()), 2);
|
|
1825
2135
|
return CSG.cube({
|
|
@@ -1830,7 +2140,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1830
2140
|
function getRadius(o) {
|
|
1831
2141
|
return div$1(xyz2array(o.size()), 2);
|
|
1832
2142
|
}
|
|
1833
|
-
function rabbetJoin(box, thickness
|
|
2143
|
+
function rabbetJoin(box, thickness) {
|
|
2144
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1834
2145
|
var r = add(getRadius(box), -thickness / 2);
|
|
1835
2146
|
r[2] = thickness / 2;
|
|
1836
2147
|
var cutter = CSG.cube({
|
|
@@ -1848,17 +2159,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1848
2159
|
}
|
|
1849
2160
|
var Boxes = Object.freeze({
|
|
1850
2161
|
__proto__: null,
|
|
1851
|
-
BBox,
|
|
1852
|
-
CutOut,
|
|
1853
|
-
Hollow,
|
|
1854
2162
|
RabbetJoin,
|
|
2163
|
+
topMiddleBottom,
|
|
1855
2164
|
Rabett,
|
|
1856
2165
|
RabettTopBottom,
|
|
2166
|
+
CutOut,
|
|
1857
2167
|
Rectangle,
|
|
1858
|
-
|
|
2168
|
+
Hollow,
|
|
2169
|
+
BBox
|
|
1859
2170
|
});
|
|
1860
|
-
|
|
1861
|
-
...util,
|
|
2171
|
+
var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
|
|
1862
2172
|
group: Group,
|
|
1863
2173
|
init: init$1,
|
|
1864
2174
|
triangle: triUtils,
|
|
@@ -1866,7 +2176,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1866
2176
|
parts: parts$1,
|
|
1867
2177
|
Boxes,
|
|
1868
2178
|
Debug
|
|
1869
|
-
};
|
|
2179
|
+
});
|
|
1870
2180
|
exports.Boxes = Boxes;
|
|
1871
2181
|
exports.Debug = Debug;
|
|
1872
2182
|
exports.Group = Group;
|
|
@@ -1876,6 +2186,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1876
2186
|
exports.parts = parts$1;
|
|
1877
2187
|
exports.triUtils = triUtils;
|
|
1878
2188
|
exports.util = util;
|
|
2189
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2190
|
+
value: true
|
|
2191
|
+
});
|
|
1879
2192
|
return exports;
|
|
1880
2193
|
}({}, jsCadCSG, scadApi);
|
|
1881
2194
|
const debug = jscadUtils.Debug("jscadUtils:initJscadutils");
|
|
@@ -1893,7 +2206,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1893
2206
|
|
|
1894
2207
|
var jscadUtilsPluginInit = [];
|
|
1895
2208
|
|
|
1896
|
-
util = {
|
|
2209
|
+
var util = {
|
|
1897
2210
|
init: (...a) => {
|
|
1898
2211
|
initJscadutils(...a);
|
|
1899
2212
|
jscadUtilsPluginInit.forEach(p => {
|