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