@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
|
@@ -53,13 +53,329 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
53
53
|
});
|
|
54
54
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
55
55
|
"use strict";
|
|
56
|
-
|
|
56
|
+
function _interopDefaultLegacy(e) {
|
|
57
|
+
return e && typeof e === "object" && "default" in e ? e : {
|
|
58
|
+
default: e
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
62
|
+
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
63
|
+
var util = Object.freeze({
|
|
64
|
+
__proto__: null,
|
|
65
|
+
get NOZZEL_SIZE() {
|
|
66
|
+
return NOZZEL_SIZE;
|
|
67
|
+
},
|
|
68
|
+
get nearest() {
|
|
69
|
+
return nearest;
|
|
70
|
+
},
|
|
71
|
+
get identity() {
|
|
72
|
+
return identity;
|
|
73
|
+
},
|
|
74
|
+
get result() {
|
|
75
|
+
return result;
|
|
76
|
+
},
|
|
77
|
+
get defaults() {
|
|
78
|
+
return defaults;
|
|
79
|
+
},
|
|
80
|
+
get isEmpty() {
|
|
81
|
+
return isEmpty;
|
|
82
|
+
},
|
|
83
|
+
get isNegative() {
|
|
84
|
+
return isNegative;
|
|
85
|
+
},
|
|
86
|
+
get print() {
|
|
87
|
+
return print;
|
|
88
|
+
},
|
|
89
|
+
get jscadToString() {
|
|
90
|
+
return jscadToString;
|
|
91
|
+
},
|
|
92
|
+
get error() {
|
|
93
|
+
return error;
|
|
94
|
+
},
|
|
95
|
+
get depreciated() {
|
|
96
|
+
return depreciated;
|
|
97
|
+
},
|
|
98
|
+
get inch() {
|
|
99
|
+
return inch;
|
|
100
|
+
},
|
|
101
|
+
get cm() {
|
|
102
|
+
return cm;
|
|
103
|
+
},
|
|
104
|
+
get label() {
|
|
105
|
+
return label;
|
|
106
|
+
},
|
|
107
|
+
get text() {
|
|
108
|
+
return text;
|
|
109
|
+
},
|
|
110
|
+
get unitCube() {
|
|
111
|
+
return unitCube;
|
|
112
|
+
},
|
|
113
|
+
get unitAxis() {
|
|
114
|
+
return unitAxis;
|
|
115
|
+
},
|
|
116
|
+
get toArray() {
|
|
117
|
+
return toArray;
|
|
118
|
+
},
|
|
119
|
+
get ifArray() {
|
|
120
|
+
return ifArray;
|
|
121
|
+
},
|
|
122
|
+
get segment() {
|
|
123
|
+
return segment;
|
|
124
|
+
},
|
|
125
|
+
get zipObject() {
|
|
126
|
+
return zipObject;
|
|
127
|
+
},
|
|
128
|
+
get map() {
|
|
129
|
+
return map;
|
|
130
|
+
},
|
|
131
|
+
get mapValues() {
|
|
132
|
+
return mapValues;
|
|
133
|
+
},
|
|
134
|
+
get pick() {
|
|
135
|
+
return pick;
|
|
136
|
+
},
|
|
137
|
+
get mapPick() {
|
|
138
|
+
return mapPick;
|
|
139
|
+
},
|
|
140
|
+
get divA() {
|
|
141
|
+
return divA;
|
|
142
|
+
},
|
|
143
|
+
get divxyz() {
|
|
144
|
+
return divxyz;
|
|
145
|
+
},
|
|
146
|
+
get div() {
|
|
147
|
+
return div;
|
|
148
|
+
},
|
|
149
|
+
get mulxyz() {
|
|
150
|
+
return mulxyz;
|
|
151
|
+
},
|
|
152
|
+
get mul() {
|
|
153
|
+
return mul;
|
|
154
|
+
},
|
|
155
|
+
get xyz2array() {
|
|
156
|
+
return xyz2array;
|
|
157
|
+
},
|
|
158
|
+
get rotationAxes() {
|
|
159
|
+
return rotationAxes;
|
|
160
|
+
},
|
|
161
|
+
get size() {
|
|
162
|
+
return size;
|
|
163
|
+
},
|
|
164
|
+
get scale() {
|
|
165
|
+
return scale;
|
|
166
|
+
},
|
|
167
|
+
get center() {
|
|
168
|
+
return center;
|
|
169
|
+
},
|
|
170
|
+
get centerY() {
|
|
171
|
+
return centerY;
|
|
172
|
+
},
|
|
173
|
+
get centerX() {
|
|
174
|
+
return centerX;
|
|
175
|
+
},
|
|
176
|
+
get enlarge() {
|
|
177
|
+
return enlarge;
|
|
178
|
+
},
|
|
179
|
+
get fit() {
|
|
180
|
+
return fit;
|
|
181
|
+
},
|
|
182
|
+
get shift() {
|
|
183
|
+
return shift;
|
|
184
|
+
},
|
|
185
|
+
get zero() {
|
|
186
|
+
return zero;
|
|
187
|
+
},
|
|
188
|
+
get mirrored4() {
|
|
189
|
+
return mirrored4;
|
|
190
|
+
},
|
|
191
|
+
get flushSide() {
|
|
192
|
+
return flushSide;
|
|
193
|
+
},
|
|
194
|
+
get calcFlush() {
|
|
195
|
+
return calcFlush;
|
|
196
|
+
},
|
|
197
|
+
get calcSnap() {
|
|
198
|
+
return calcSnap;
|
|
199
|
+
},
|
|
200
|
+
get snap() {
|
|
201
|
+
return snap;
|
|
202
|
+
},
|
|
203
|
+
get flush() {
|
|
204
|
+
return flush;
|
|
205
|
+
},
|
|
206
|
+
get axisApply() {
|
|
207
|
+
return axisApply;
|
|
208
|
+
},
|
|
209
|
+
get axis2array() {
|
|
210
|
+
return axis2array;
|
|
211
|
+
},
|
|
212
|
+
get centroid() {
|
|
213
|
+
return centroid;
|
|
214
|
+
},
|
|
215
|
+
get calcmidlineTo() {
|
|
216
|
+
return calcmidlineTo;
|
|
217
|
+
},
|
|
218
|
+
get midlineTo() {
|
|
219
|
+
return midlineTo;
|
|
220
|
+
},
|
|
221
|
+
get translator() {
|
|
222
|
+
return translator;
|
|
223
|
+
},
|
|
224
|
+
get calcCenterWith() {
|
|
225
|
+
return calcCenterWith;
|
|
226
|
+
},
|
|
227
|
+
get centerWith() {
|
|
228
|
+
return centerWith;
|
|
229
|
+
},
|
|
230
|
+
get getDelta() {
|
|
231
|
+
return getDelta;
|
|
232
|
+
},
|
|
233
|
+
get bisect() {
|
|
234
|
+
return bisect;
|
|
235
|
+
},
|
|
236
|
+
get slice() {
|
|
237
|
+
return slice;
|
|
238
|
+
},
|
|
239
|
+
get wedge() {
|
|
240
|
+
return wedge;
|
|
241
|
+
},
|
|
242
|
+
get stretch() {
|
|
243
|
+
return stretch;
|
|
244
|
+
},
|
|
245
|
+
get poly2solid() {
|
|
246
|
+
return poly2solid;
|
|
247
|
+
},
|
|
248
|
+
get slices2poly() {
|
|
249
|
+
return slices2poly;
|
|
250
|
+
},
|
|
251
|
+
get normalVector() {
|
|
252
|
+
return normalVector;
|
|
253
|
+
},
|
|
254
|
+
get sliceParams() {
|
|
255
|
+
return sliceParams;
|
|
256
|
+
},
|
|
257
|
+
get reShape() {
|
|
258
|
+
return reShape;
|
|
259
|
+
},
|
|
260
|
+
get chamfer() {
|
|
261
|
+
return chamfer;
|
|
262
|
+
},
|
|
263
|
+
get fillet() {
|
|
264
|
+
return fillet;
|
|
265
|
+
},
|
|
266
|
+
get calcRotate() {
|
|
267
|
+
return calcRotate;
|
|
268
|
+
},
|
|
269
|
+
get rotateAround() {
|
|
270
|
+
return rotateAround;
|
|
271
|
+
},
|
|
272
|
+
get clone() {
|
|
273
|
+
return clone;
|
|
274
|
+
},
|
|
275
|
+
get addConnector() {
|
|
276
|
+
return addConnector;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
function _arrayLikeToArray(r, a) {
|
|
280
|
+
(null == a || a > r.length) && (a = r.length);
|
|
281
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
282
|
+
return n;
|
|
283
|
+
}
|
|
284
|
+
function _arrayWithHoles(r) {
|
|
285
|
+
if (Array.isArray(r)) return r;
|
|
286
|
+
}
|
|
287
|
+
function _defineProperty(e, r, t) {
|
|
288
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
289
|
+
value: t,
|
|
290
|
+
enumerable: !0,
|
|
291
|
+
configurable: !0,
|
|
292
|
+
writable: !0
|
|
293
|
+
}) : e[r] = t, e;
|
|
294
|
+
}
|
|
295
|
+
function _iterableToArrayLimit(r, l) {
|
|
296
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
297
|
+
if (null != t) {
|
|
298
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
299
|
+
try {
|
|
300
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
301
|
+
if (Object(t) !== t) return;
|
|
302
|
+
f = !1;
|
|
303
|
+
} else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
|
|
304
|
+
} catch (r) {
|
|
305
|
+
o = !0, n = r;
|
|
306
|
+
} finally {
|
|
307
|
+
try {
|
|
308
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
309
|
+
} finally {
|
|
310
|
+
if (o) throw n;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return a;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function _nonIterableRest() {
|
|
317
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
318
|
+
}
|
|
319
|
+
function ownKeys(e, r) {
|
|
320
|
+
var t = Object.keys(e);
|
|
321
|
+
if (Object.getOwnPropertySymbols) {
|
|
322
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
323
|
+
r && (o = o.filter(function(r) {
|
|
324
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
325
|
+
})), t.push.apply(t, o);
|
|
326
|
+
}
|
|
327
|
+
return t;
|
|
328
|
+
}
|
|
329
|
+
function _objectSpread2(e) {
|
|
330
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
331
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
332
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
333
|
+
_defineProperty(e, r, t[r]);
|
|
334
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
335
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return e;
|
|
339
|
+
}
|
|
340
|
+
function _slicedToArray(r, e) {
|
|
341
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
342
|
+
}
|
|
343
|
+
function _toPrimitive(t, r) {
|
|
344
|
+
if ("object" != typeof t || !t) return t;
|
|
345
|
+
var e = t[Symbol.toPrimitive];
|
|
346
|
+
if (void 0 !== e) {
|
|
347
|
+
var i = e.call(t, r || "default");
|
|
348
|
+
if ("object" != typeof i) return i;
|
|
349
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
350
|
+
}
|
|
351
|
+
return ("string" === r ? String : Number)(t);
|
|
352
|
+
}
|
|
353
|
+
function _toPropertyKey(t) {
|
|
354
|
+
var i = _toPrimitive(t, "string");
|
|
355
|
+
return "symbol" == typeof i ? i : i + "";
|
|
356
|
+
}
|
|
357
|
+
function _typeof(o) {
|
|
358
|
+
"@babel/helpers - typeof";
|
|
359
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
360
|
+
return typeof o;
|
|
361
|
+
} : function(o) {
|
|
362
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
363
|
+
}, _typeof(o);
|
|
364
|
+
}
|
|
365
|
+
function _unsupportedIterableToArray(r, a) {
|
|
366
|
+
if (r) {
|
|
367
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
368
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
369
|
+
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;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
var toRadians = function toRadians(deg) {
|
|
57
373
|
return deg / 180 * Math.PI;
|
|
58
374
|
};
|
|
59
|
-
|
|
375
|
+
var toDegrees = function toDegrees(rad) {
|
|
60
376
|
return rad * (180 / Math.PI);
|
|
61
377
|
};
|
|
62
|
-
|
|
378
|
+
var solve = function solve(p1, p2) {
|
|
63
379
|
var r = {
|
|
64
380
|
c: 90,
|
|
65
381
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -71,7 +387,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
71
387
|
r.a = 90 - r.b;
|
|
72
388
|
return r;
|
|
73
389
|
};
|
|
74
|
-
|
|
390
|
+
var solve90SA = function solve90SA(r) {
|
|
75
391
|
r = Object.assign(r, {
|
|
76
392
|
C: 90
|
|
77
393
|
});
|
|
@@ -83,7 +399,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
83
399
|
r.b = r.b || r.a / Math.tan(arad);
|
|
84
400
|
return r;
|
|
85
401
|
};
|
|
86
|
-
|
|
402
|
+
var solve90ac = function solve90ac(r) {
|
|
87
403
|
r = Object.assign(r, {
|
|
88
404
|
C: 90
|
|
89
405
|
});
|
|
@@ -104,29 +420,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
104
420
|
}
|
|
105
421
|
var triUtils = Object.freeze({
|
|
106
422
|
__proto__: null,
|
|
423
|
+
toRadians,
|
|
424
|
+
toDegrees,
|
|
107
425
|
solve,
|
|
108
426
|
solve90SA,
|
|
109
427
|
solve90ac,
|
|
110
|
-
solveab
|
|
111
|
-
toDegrees,
|
|
112
|
-
toRadians
|
|
428
|
+
solveab
|
|
113
429
|
});
|
|
114
|
-
|
|
430
|
+
var div$1 = function div(a, f) {
|
|
115
431
|
return a.map(function(e) {
|
|
116
432
|
return e / f;
|
|
117
433
|
});
|
|
118
434
|
};
|
|
119
|
-
|
|
435
|
+
var addValue = function addValue(a, f) {
|
|
120
436
|
return a.map(function(e) {
|
|
121
437
|
return e + f;
|
|
122
438
|
});
|
|
123
439
|
};
|
|
124
|
-
|
|
440
|
+
var addArray = function addArray(a, f) {
|
|
125
441
|
return a.map(function(e, i) {
|
|
126
442
|
return e + f[i];
|
|
127
443
|
});
|
|
128
444
|
};
|
|
129
|
-
|
|
445
|
+
var add = function add(a) {
|
|
130
446
|
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
131
447
|
if (Array.isArray(arg)) {
|
|
132
448
|
result = addArray(result, arg);
|
|
@@ -136,28 +452,28 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
136
452
|
return result;
|
|
137
453
|
}, a);
|
|
138
454
|
};
|
|
139
|
-
|
|
455
|
+
var fromxyz = function fromxyz(object) {
|
|
140
456
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
141
457
|
};
|
|
142
|
-
|
|
458
|
+
var toxyz = function toxyz(a) {
|
|
143
459
|
return {
|
|
144
460
|
x: a[0],
|
|
145
461
|
y: a[1],
|
|
146
462
|
z: a[2]
|
|
147
463
|
};
|
|
148
464
|
};
|
|
149
|
-
|
|
465
|
+
var first = function first(a) {
|
|
150
466
|
return a ? a[0] : undefined;
|
|
151
467
|
};
|
|
152
|
-
|
|
468
|
+
var last = function last(a) {
|
|
153
469
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
154
470
|
};
|
|
155
|
-
|
|
471
|
+
var min = function min(a) {
|
|
156
472
|
return a.reduce(function(result, value) {
|
|
157
473
|
return value < result ? value : result;
|
|
158
474
|
}, Number.MAX_VALUE);
|
|
159
475
|
};
|
|
160
|
-
|
|
476
|
+
var range = function range(a, b) {
|
|
161
477
|
var result = [];
|
|
162
478
|
for (var i = a; i < b; i++) {
|
|
163
479
|
result.push(i);
|
|
@@ -166,21 +482,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
166
482
|
};
|
|
167
483
|
var array = Object.freeze({
|
|
168
484
|
__proto__: null,
|
|
169
|
-
add,
|
|
170
|
-
addArray,
|
|
171
|
-
addValue,
|
|
172
485
|
div: div$1,
|
|
173
|
-
|
|
486
|
+
addValue,
|
|
487
|
+
addArray,
|
|
488
|
+
add,
|
|
174
489
|
fromxyz,
|
|
490
|
+
toxyz,
|
|
491
|
+
first,
|
|
175
492
|
last,
|
|
176
493
|
min,
|
|
177
|
-
range
|
|
178
|
-
toxyz
|
|
494
|
+
range
|
|
179
495
|
});
|
|
180
|
-
|
|
181
|
-
|
|
496
|
+
var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
497
|
+
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" ];
|
|
182
498
|
var debugCount = 0;
|
|
183
|
-
|
|
499
|
+
var Debug = function Debug(name) {
|
|
184
500
|
var checks = Object.assign({
|
|
185
501
|
enabled: [],
|
|
186
502
|
disabled: [],
|
|
@@ -188,21 +504,31 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
188
504
|
browser: true
|
|
189
505
|
}
|
|
190
506
|
}, jscadUtilsDebug || {});
|
|
191
|
-
var style = checks.options.browser ?
|
|
507
|
+
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
192
508
|
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
193
509
|
return check.test(name);
|
|
194
510
|
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
195
511
|
return check.test(name);
|
|
196
512
|
});
|
|
197
|
-
var logger = enabled ? checks.options.browser ? (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
513
|
+
var logger = enabled ? checks.options.browser ? function() {
|
|
514
|
+
var _console;
|
|
515
|
+
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
516
|
+
msg[_key] = arguments[_key];
|
|
517
|
+
}
|
|
518
|
+
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
519
|
+
} : function() {
|
|
520
|
+
var _console2;
|
|
521
|
+
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
522
|
+
msg[_key2] = arguments[_key2];
|
|
523
|
+
}
|
|
524
|
+
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
525
|
+
} : function() {
|
|
526
|
+
return undefined;
|
|
527
|
+
};
|
|
202
528
|
logger.enabled = enabled;
|
|
203
529
|
return logger;
|
|
204
530
|
};
|
|
205
|
-
|
|
531
|
+
var nameArray = {
|
|
206
532
|
aliceblue: "#f0f8ff",
|
|
207
533
|
antiquewhite: "#faebd7",
|
|
208
534
|
aqua: "#00ffff",
|
|
@@ -364,7 +690,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
364
690
|
return [ 0, 0, 0 ];
|
|
365
691
|
}
|
|
366
692
|
}
|
|
367
|
-
|
|
693
|
+
var _name2rgb = {};
|
|
368
694
|
function name2rgb(n) {
|
|
369
695
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
370
696
|
return _name2rgb[n];
|
|
@@ -444,14 +770,23 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
444
770
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
445
771
|
return chamfer(this, radius, orientation, options);
|
|
446
772
|
};
|
|
447
|
-
proto.prototype.bisect = function bisect$1(
|
|
448
|
-
|
|
773
|
+
proto.prototype.bisect = function bisect$1() {
|
|
774
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
775
|
+
args[_key] = arguments[_key];
|
|
776
|
+
}
|
|
777
|
+
return bisect.apply(util, [ this ].concat(args));
|
|
449
778
|
};
|
|
450
|
-
proto.prototype.slice = function slice$1(
|
|
451
|
-
|
|
779
|
+
proto.prototype.slice = function slice$1() {
|
|
780
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
781
|
+
args[_key2] = arguments[_key2];
|
|
782
|
+
}
|
|
783
|
+
return slice.apply(util, [ this ].concat(args));
|
|
452
784
|
};
|
|
453
|
-
proto.prototype.wedge = function wedge$1(
|
|
454
|
-
|
|
785
|
+
proto.prototype.wedge = function wedge$1() {
|
|
786
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
787
|
+
args[_key3] = arguments[_key3];
|
|
788
|
+
}
|
|
789
|
+
return wedge.apply(util, [ this ].concat(args));
|
|
455
790
|
};
|
|
456
791
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
457
792
|
return stretch(this, axis, distance, offset);
|
|
@@ -468,7 +803,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
468
803
|
return this._translate(arguments[0]);
|
|
469
804
|
} else {
|
|
470
805
|
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
471
|
-
result = undefined
|
|
806
|
+
result = undefined(result, arg);
|
|
472
807
|
return result;
|
|
473
808
|
}, [ 0, 0, 0 ]);
|
|
474
809
|
return this._translate(t);
|
|
@@ -477,10 +812,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
477
812
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
478
813
|
return addConnector(this, name, point, axis, normal);
|
|
479
814
|
};
|
|
480
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector
|
|
481
|
-
var
|
|
815
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
816
|
+
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
817
|
+
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
818
|
+
var myConnector = myConnectorName.split(".").reduce(function(a, v) {
|
|
819
|
+
return a[v];
|
|
820
|
+
}, this.properties);
|
|
482
821
|
if (!myConnector) {
|
|
483
|
-
error(
|
|
822
|
+
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
|
|
484
823
|
}
|
|
485
824
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
486
825
|
};
|
|
@@ -490,13 +829,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
490
829
|
__proto__: null,
|
|
491
830
|
default: init
|
|
492
831
|
});
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
832
|
+
var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
|
|
833
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
834
|
+
var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
|
|
835
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
497
836
|
init(CSG);
|
|
498
|
-
|
|
499
|
-
function JsCadUtilsGroup(
|
|
837
|
+
var debug$3 = Debug("jscadUtils:group");
|
|
838
|
+
function JsCadUtilsGroup() {
|
|
839
|
+
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
840
|
+
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
841
|
+
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
500
842
|
this.name = "";
|
|
501
843
|
this.names = names;
|
|
502
844
|
this.parts = parts;
|
|
@@ -524,7 +866,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
524
866
|
}
|
|
525
867
|
return self;
|
|
526
868
|
};
|
|
527
|
-
JsCadUtilsGroup.prototype.combine = function(pieces
|
|
869
|
+
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
870
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
871
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
872
|
+
return x;
|
|
873
|
+
};
|
|
528
874
|
try {
|
|
529
875
|
var self = this;
|
|
530
876
|
options = Object.assign({
|
|
@@ -532,7 +878,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
532
878
|
}, options);
|
|
533
879
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
534
880
|
if (pieces.length === 0) {
|
|
535
|
-
throw new Error(
|
|
881
|
+
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
536
882
|
}
|
|
537
883
|
debug$3("combine", self.names, self.parts);
|
|
538
884
|
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
@@ -542,12 +888,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
542
888
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
543
889
|
} catch (err) {
|
|
544
890
|
debug$3("combine error", this, pieces, options, err);
|
|
545
|
-
throw error(
|
|
891
|
+
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");
|
|
546
892
|
}
|
|
547
893
|
};
|
|
548
894
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
549
895
|
var self = this;
|
|
550
|
-
self.parts = Object.keys(self.parts).filter(
|
|
896
|
+
self.parts = Object.keys(self.parts).filter(function(k) {
|
|
897
|
+
return k !== "holes";
|
|
898
|
+
}).reduce(function(result, key) {
|
|
551
899
|
result[key] = cb(self.parts[key], key);
|
|
552
900
|
return result;
|
|
553
901
|
}, {});
|
|
@@ -563,7 +911,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
563
911
|
return self;
|
|
564
912
|
};
|
|
565
913
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
566
|
-
debug$3("clone", name,
|
|
914
|
+
debug$3("clone", name, _typeof(name), map);
|
|
567
915
|
var self = this;
|
|
568
916
|
if (typeof name == "function") {
|
|
569
917
|
map = name;
|
|
@@ -615,7 +963,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
615
963
|
return self;
|
|
616
964
|
} catch (err) {
|
|
617
965
|
debug$3("snap error", this, part, to, axis, delta, err);
|
|
618
|
-
throw error(
|
|
966
|
+
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");
|
|
619
967
|
}
|
|
620
968
|
};
|
|
621
969
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -630,7 +978,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
630
978
|
return self;
|
|
631
979
|
} catch (err) {
|
|
632
980
|
debug$3("align error", this, part, to, axis, delta, err);
|
|
633
|
-
throw error(
|
|
981
|
+
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");
|
|
634
982
|
}
|
|
635
983
|
};
|
|
636
984
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -642,7 +990,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
642
990
|
var bounds = self.parts[part].getBounds();
|
|
643
991
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
644
992
|
};
|
|
645
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName
|
|
993
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
994
|
+
var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
995
|
+
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
646
996
|
debug$3("connectTo", {
|
|
647
997
|
partName,
|
|
648
998
|
connectorName,
|
|
@@ -652,9 +1002,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
652
1002
|
normalrotation
|
|
653
1003
|
});
|
|
654
1004
|
var self = this;
|
|
655
|
-
var myConnector = connectorName.split(".").reduce((a, v)
|
|
1005
|
+
var myConnector = connectorName.split(".").reduce(function(a, v) {
|
|
1006
|
+
return a[v];
|
|
1007
|
+
}, self.parts[partName].properties);
|
|
656
1008
|
debug$3("toConnector", to instanceof CSG.Connector);
|
|
657
|
-
var toConnector = toConnectorName.split(".").reduce((a, v)
|
|
1009
|
+
var toConnector = toConnectorName.split(".").reduce(function(a, v) {
|
|
1010
|
+
return a[v];
|
|
1011
|
+
}, to.properties);
|
|
658
1012
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
659
1013
|
debug$3("connectTo", matrix);
|
|
660
1014
|
self.map(function(part) {
|
|
@@ -693,14 +1047,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
693
1047
|
return g;
|
|
694
1048
|
};
|
|
695
1049
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1050
|
+
var _this = this;
|
|
696
1051
|
var self = this;
|
|
697
1052
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
698
1053
|
if (!map) map = identity;
|
|
699
1054
|
var a = [];
|
|
700
|
-
p.forEach(name
|
|
1055
|
+
p.forEach(function(name) {
|
|
701
1056
|
if (!self.parts[name]) {
|
|
702
|
-
debug$3("array error",
|
|
703
|
-
throw error(
|
|
1057
|
+
debug$3("array error", _this, parts);
|
|
1058
|
+
throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
|
|
704
1059
|
}
|
|
705
1060
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
706
1061
|
});
|
|
@@ -710,12 +1065,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
710
1065
|
var self = this;
|
|
711
1066
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
712
1067
|
return piecesArray.map(function(piece) {
|
|
713
|
-
if (!self.parts[piece]) console.error(
|
|
1068
|
+
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
714
1069
|
return self.parts[piece];
|
|
715
1070
|
});
|
|
716
1071
|
};
|
|
717
1072
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
718
|
-
return
|
|
1073
|
+
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}");
|
|
719
1074
|
};
|
|
720
1075
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
721
1076
|
this.name = name;
|
|
@@ -745,7 +1100,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
745
1100
|
self.name = objectNames;
|
|
746
1101
|
} else {
|
|
747
1102
|
var objects = objectNames;
|
|
748
|
-
self.names = Object.keys(objects).filter(k
|
|
1103
|
+
self.names = Object.keys(objects).filter(function(k) {
|
|
1104
|
+
return k !== "holes";
|
|
1105
|
+
});
|
|
749
1106
|
self.parts = Object.assign({}, objects);
|
|
750
1107
|
self.holes = objects.holes;
|
|
751
1108
|
}
|
|
@@ -753,13 +1110,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
753
1110
|
}
|
|
754
1111
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
755
1112
|
}
|
|
756
|
-
|
|
1113
|
+
var debug$2 = Debug("jscadUtils:util");
|
|
757
1114
|
var NOZZEL_SIZE = .4;
|
|
758
|
-
|
|
759
|
-
under: function(desired
|
|
1115
|
+
var nearest = {
|
|
1116
|
+
under: function under(desired) {
|
|
1117
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1118
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
760
1119
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
761
1120
|
},
|
|
762
|
-
over: function(desired
|
|
1121
|
+
over: function over(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;
|
|
763
1124
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
764
1125
|
}
|
|
765
1126
|
};
|
|
@@ -787,9 +1148,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
787
1148
|
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
788
1149
|
}
|
|
789
1150
|
function jscadToString(o) {
|
|
790
|
-
if (
|
|
1151
|
+
if (_typeof(o) == "object") {
|
|
791
1152
|
if (o.polygons) {
|
|
792
|
-
return
|
|
1153
|
+
return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
|
|
793
1154
|
}
|
|
794
1155
|
} else {
|
|
795
1156
|
return o.toString();
|
|
@@ -830,12 +1191,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
830
1191
|
}
|
|
831
1192
|
function text(text) {
|
|
832
1193
|
var l = vector_char(0, 0, text);
|
|
833
|
-
var
|
|
1194
|
+
var _char = l.segments.reduce(function(result, segment) {
|
|
834
1195
|
var path = new CSG.Path2D(segment);
|
|
835
1196
|
var cag = path.expandToCAG(2);
|
|
836
1197
|
return result ? result.union(cag) : cag;
|
|
837
1198
|
}, undefined);
|
|
838
|
-
return
|
|
1199
|
+
return _char;
|
|
839
1200
|
}
|
|
840
1201
|
function unitCube(length, radius) {
|
|
841
1202
|
radius = radius || .5;
|
|
@@ -891,7 +1252,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
891
1252
|
function mapPick(o, names, f, options) {
|
|
892
1253
|
return names.reduce(function(result, name, index) {
|
|
893
1254
|
if (!o[name]) {
|
|
894
|
-
throw new Error(
|
|
1255
|
+
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
|
|
895
1256
|
}
|
|
896
1257
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
897
1258
|
return result;
|
|
@@ -923,7 +1284,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
923
1284
|
function xyz2array(size) {
|
|
924
1285
|
return [ size.x, size.y, size.z ];
|
|
925
1286
|
}
|
|
926
|
-
|
|
1287
|
+
var rotationAxes = {
|
|
927
1288
|
x: [ 1, 0, 0 ],
|
|
928
1289
|
y: [ 0, 1, 0 ],
|
|
929
1290
|
z: [ 0, 0, 1 ]
|
|
@@ -1001,7 +1362,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1001
1362
|
function mirrored4(x) {
|
|
1002
1363
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1003
1364
|
}
|
|
1004
|
-
|
|
1365
|
+
var flushSide = {
|
|
1005
1366
|
"above-outside": [ 1, 0 ],
|
|
1006
1367
|
"above-inside": [ 1, 1 ],
|
|
1007
1368
|
"below-outside": [ 0, 1 ],
|
|
@@ -1031,7 +1392,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1031
1392
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1032
1393
|
});
|
|
1033
1394
|
}
|
|
1034
|
-
function calcSnap(moveobj, withobj, axes, orientation
|
|
1395
|
+
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1396
|
+
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1035
1397
|
var side = flushSide[orientation];
|
|
1036
1398
|
if (!side) {
|
|
1037
1399
|
var fix = {
|
|
@@ -1097,7 +1459,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1097
1459
|
objectSize = objectSize || size(bounds);
|
|
1098
1460
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1099
1461
|
} catch (err) {
|
|
1100
|
-
error(
|
|
1462
|
+
error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
|
|
1101
1463
|
}
|
|
1102
1464
|
}
|
|
1103
1465
|
function calcmidlineTo(o, axis, to) {
|
|
@@ -1118,7 +1480,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1118
1480
|
});
|
|
1119
1481
|
return t;
|
|
1120
1482
|
}
|
|
1121
|
-
function calcCenterWith(o, axes, withObj
|
|
1483
|
+
function calcCenterWith(o, axes, withObj) {
|
|
1484
|
+
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1122
1485
|
var objectCentroid = centroid(o);
|
|
1123
1486
|
var withCentroid = centroid(withObj);
|
|
1124
1487
|
var t = axisApply(axes, function(i, axis) {
|
|
@@ -1140,7 +1503,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1140
1503
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1141
1504
|
});
|
|
1142
1505
|
}
|
|
1143
|
-
function bisect(
|
|
1506
|
+
function bisect() {
|
|
1507
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1508
|
+
args[_key] = arguments[_key];
|
|
1509
|
+
}
|
|
1144
1510
|
if (args.length < 2) {
|
|
1145
1511
|
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1146
1512
|
}
|
|
@@ -1221,10 +1587,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1221
1587
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1222
1588
|
return g;
|
|
1223
1589
|
}
|
|
1224
|
-
function slice(object
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1590
|
+
function slice(object) {
|
|
1591
|
+
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
|
|
1592
|
+
var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
|
|
1593
|
+
var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
|
|
1594
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1595
|
+
color: true,
|
|
1596
|
+
addRotationCenter: true
|
|
1597
|
+
};
|
|
1228
1598
|
var info = normalVector(axis);
|
|
1229
1599
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1230
1600
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1441,11 +1811,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1441
1811
|
};
|
|
1442
1812
|
}
|
|
1443
1813
|
function rotateAround(part, solid, axis, angle) {
|
|
1444
|
-
var
|
|
1814
|
+
var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
|
|
1445
1815
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1446
1816
|
}
|
|
1447
|
-
function cloneProperties(from, to
|
|
1448
|
-
return Object.entries(from).reduce((props,
|
|
1817
|
+
function cloneProperties(from, to) {
|
|
1818
|
+
return Object.entries(from).reduce(function(props, _ref) {
|
|
1819
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1449
1820
|
props[key] = value;
|
|
1450
1821
|
return props;
|
|
1451
1822
|
}, to);
|
|
@@ -1456,85 +1827,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1456
1827
|
debug$2("clone", o, c, CSG);
|
|
1457
1828
|
return c;
|
|
1458
1829
|
}
|
|
1459
|
-
function addConnector(object, name
|
|
1830
|
+
function addConnector(object, name) {
|
|
1831
|
+
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1832
|
+
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1833
|
+
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1460
1834
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1461
1835
|
return object;
|
|
1462
1836
|
}
|
|
1463
|
-
var
|
|
1464
|
-
__proto__: null,
|
|
1465
|
-
NOZZEL_SIZE,
|
|
1466
|
-
addConnector,
|
|
1467
|
-
axis2array,
|
|
1468
|
-
axisApply,
|
|
1469
|
-
bisect,
|
|
1470
|
-
calcCenterWith,
|
|
1471
|
-
calcFlush,
|
|
1472
|
-
calcRotate,
|
|
1473
|
-
calcSnap,
|
|
1474
|
-
calcmidlineTo,
|
|
1475
|
-
center,
|
|
1476
|
-
centerWith,
|
|
1477
|
-
centerX,
|
|
1478
|
-
centerY,
|
|
1479
|
-
centroid,
|
|
1480
|
-
chamfer,
|
|
1481
|
-
clone,
|
|
1482
|
-
cm,
|
|
1483
|
-
defaults,
|
|
1484
|
-
depreciated,
|
|
1485
|
-
div,
|
|
1486
|
-
divA,
|
|
1487
|
-
divxyz,
|
|
1488
|
-
enlarge,
|
|
1489
|
-
error,
|
|
1490
|
-
fillet,
|
|
1491
|
-
fit,
|
|
1492
|
-
flush,
|
|
1493
|
-
flushSide,
|
|
1494
|
-
getDelta,
|
|
1495
|
-
identity,
|
|
1496
|
-
ifArray,
|
|
1497
|
-
inch,
|
|
1498
|
-
isEmpty,
|
|
1499
|
-
isNegative,
|
|
1500
|
-
jscadToString,
|
|
1501
|
-
label,
|
|
1502
|
-
map,
|
|
1503
|
-
mapPick,
|
|
1504
|
-
mapValues,
|
|
1505
|
-
midlineTo,
|
|
1506
|
-
mirrored4,
|
|
1507
|
-
mul,
|
|
1508
|
-
mulxyz,
|
|
1509
|
-
nearest,
|
|
1510
|
-
normalVector,
|
|
1511
|
-
pick,
|
|
1512
|
-
poly2solid,
|
|
1513
|
-
print,
|
|
1514
|
-
reShape,
|
|
1515
|
-
result,
|
|
1516
|
-
rotateAround,
|
|
1517
|
-
rotationAxes,
|
|
1518
|
-
scale,
|
|
1519
|
-
segment,
|
|
1520
|
-
shift,
|
|
1521
|
-
size,
|
|
1522
|
-
slice,
|
|
1523
|
-
sliceParams,
|
|
1524
|
-
slices2poly,
|
|
1525
|
-
snap,
|
|
1526
|
-
stretch,
|
|
1527
|
-
text,
|
|
1528
|
-
toArray,
|
|
1529
|
-
translator,
|
|
1530
|
-
unitAxis,
|
|
1531
|
-
unitCube,
|
|
1532
|
-
wedge,
|
|
1533
|
-
xyz2array,
|
|
1534
|
-
zero,
|
|
1535
|
-
zipObject
|
|
1536
|
-
});
|
|
1537
|
-
const debug$1 = Debug("jscadUtils:parts");
|
|
1837
|
+
var debug$1 = Debug("jscadUtils:parts");
|
|
1538
1838
|
var parts = {
|
|
1539
1839
|
BBox: BBox$1,
|
|
1540
1840
|
Cube,
|
|
@@ -1542,13 +1842,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1542
1842
|
Cylinder,
|
|
1543
1843
|
Cone
|
|
1544
1844
|
};
|
|
1545
|
-
function BBox$1(
|
|
1845
|
+
function BBox$1() {
|
|
1546
1846
|
function box(object) {
|
|
1547
1847
|
return CSG.cube({
|
|
1548
1848
|
center: object.centroid(),
|
|
1549
1849
|
radius: object.size().dividedBy(2)
|
|
1550
1850
|
});
|
|
1551
1851
|
}
|
|
1852
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1853
|
+
objects[_key] = arguments[_key];
|
|
1854
|
+
}
|
|
1552
1855
|
return objects.reduce(function(bbox, part) {
|
|
1553
1856
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1554
1857
|
return box(object);
|
|
@@ -1581,7 +1884,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1581
1884
|
});
|
|
1582
1885
|
return roundedcube;
|
|
1583
1886
|
}
|
|
1584
|
-
function Cylinder(diameter, height
|
|
1887
|
+
function Cylinder(diameter, height) {
|
|
1888
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1585
1889
|
debug$1("parts.Cylinder", diameter, height, options);
|
|
1586
1890
|
options = Object.assign({
|
|
1587
1891
|
start: [ 0, 0, 0 ],
|
|
@@ -1591,7 +1895,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1591
1895
|
}, options);
|
|
1592
1896
|
return CSG.cylinder(options);
|
|
1593
1897
|
}
|
|
1594
|
-
function Cone(diameter1, diameter2, height
|
|
1898
|
+
function Cone(diameter1, diameter2, height) {
|
|
1899
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1595
1900
|
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1596
1901
|
return CSG.cylinder(Object.assign({
|
|
1597
1902
|
start: [ 0, 0, 0 ],
|
|
@@ -1620,7 +1925,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1620
1925
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1621
1926
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1622
1927
|
}
|
|
1623
|
-
function Anchor(
|
|
1928
|
+
function Anchor() {
|
|
1929
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1930
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1624
1931
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1625
1932
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1626
1933
|
return Group({
|
|
@@ -1640,7 +1947,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1640
1947
|
});
|
|
1641
1948
|
return board;
|
|
1642
1949
|
}
|
|
1643
|
-
|
|
1950
|
+
var Hardware = {
|
|
1644
1951
|
Orientation: {
|
|
1645
1952
|
up: {
|
|
1646
1953
|
head: "outside-",
|
|
@@ -1651,7 +1958,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1651
1958
|
clear: "inside-"
|
|
1652
1959
|
}
|
|
1653
1960
|
},
|
|
1654
|
-
Screw: function(head, thread, headClearSpace, options) {
|
|
1961
|
+
Screw: function Screw(head, thread, headClearSpace, options) {
|
|
1655
1962
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1656
1963
|
options = Object.assign(options, {
|
|
1657
1964
|
orientation: "up",
|
|
@@ -1667,7 +1974,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1667
1974
|
}
|
|
1668
1975
|
return group;
|
|
1669
1976
|
},
|
|
1670
|
-
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1977
|
+
PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1671
1978
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1672
1979
|
var head = Cylinder(headDiameter, headLength);
|
|
1673
1980
|
var thread = Cylinder(diameter, length);
|
|
@@ -1676,7 +1983,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1676
1983
|
}
|
|
1677
1984
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1678
1985
|
},
|
|
1679
|
-
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1986
|
+
HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1680
1987
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1681
1988
|
var head = Hexagon(headDiameter, headLength);
|
|
1682
1989
|
var thread = Cylinder(diameter, length);
|
|
@@ -1685,7 +1992,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1685
1992
|
}
|
|
1686
1993
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1687
1994
|
},
|
|
1688
|
-
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1995
|
+
FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1689
1996
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1690
1997
|
var head = Cone(headDiameter, diameter, headLength);
|
|
1691
1998
|
var thread = Cylinder(diameter, length);
|
|
@@ -1697,20 +2004,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1697
2004
|
};
|
|
1698
2005
|
var parts$1 = Object.freeze({
|
|
1699
2006
|
__proto__: null,
|
|
1700
|
-
|
|
2007
|
+
default: parts,
|
|
1701
2008
|
BBox: BBox$1,
|
|
1702
|
-
Board,
|
|
1703
|
-
Cone,
|
|
1704
2009
|
Cube,
|
|
2010
|
+
RoundedCube,
|
|
1705
2011
|
Cylinder,
|
|
1706
|
-
|
|
2012
|
+
Cone,
|
|
1707
2013
|
Hexagon,
|
|
1708
|
-
RoundedCube,
|
|
1709
2014
|
Triangle,
|
|
1710
2015
|
Tube,
|
|
1711
|
-
|
|
2016
|
+
Anchor,
|
|
2017
|
+
Board,
|
|
2018
|
+
Hardware
|
|
1712
2019
|
});
|
|
1713
|
-
|
|
2020
|
+
var debug = Debug("jscadUtils:boxes");
|
|
1714
2021
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
1715
2022
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
1716
2023
|
return rabbetJoin(box, thickness, cutHeight);
|
|
@@ -1723,16 +2030,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1723
2030
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
1724
2031
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
1725
2032
|
}
|
|
1726
|
-
function Rabett(box, thickness, gap, height, face
|
|
2033
|
+
function Rabett(box, thickness, gap, height, face) {
|
|
2034
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1727
2035
|
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1728
2036
|
gap = gap || .25;
|
|
1729
2037
|
var inside = thickness - gap;
|
|
1730
2038
|
var outside = -thickness + gap;
|
|
1731
2039
|
debug("inside", inside, "outside", outside);
|
|
1732
2040
|
var group = Group();
|
|
1733
|
-
var
|
|
2041
|
+
var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
|
|
1734
2042
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
1735
|
-
var
|
|
2043
|
+
var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
|
|
1736
2044
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
1737
2045
|
group.add(top.union(middleTop), "top");
|
|
1738
2046
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -1741,7 +2049,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1741
2049
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
1742
2050
|
return group;
|
|
1743
2051
|
}
|
|
1744
|
-
|
|
2052
|
+
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
2053
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2054
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1745
2055
|
options = Object.assign({
|
|
1746
2056
|
removableTop: true,
|
|
1747
2057
|
removableBottom: true,
|
|
@@ -1774,7 +2084,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1774
2084
|
}
|
|
1775
2085
|
return group;
|
|
1776
2086
|
};
|
|
1777
|
-
|
|
2087
|
+
var CutOut = function cutOut(o, h, box, plug, gap) {
|
|
1778
2088
|
gap = gap || .25;
|
|
1779
2089
|
var s = o.size();
|
|
1780
2090
|
var cutout = o.intersect(box);
|
|
@@ -1792,7 +2102,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1792
2102
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
1793
2103
|
});
|
|
1794
2104
|
};
|
|
1795
|
-
|
|
2105
|
+
var Rectangle = function Rectangle(size, thickness, cb) {
|
|
1796
2106
|
thickness = thickness || 2;
|
|
1797
2107
|
var s = div$1(xyz2array(size), 2);
|
|
1798
2108
|
var r = add(s, thickness);
|
|
@@ -1806,7 +2116,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1806
2116
|
if (cb) box = cb(box);
|
|
1807
2117
|
return box;
|
|
1808
2118
|
};
|
|
1809
|
-
|
|
2119
|
+
var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
|
|
1810
2120
|
thickness = thickness || 2;
|
|
1811
2121
|
var size = -thickness * 2;
|
|
1812
2122
|
interiorcb = interiorcb || identity;
|
|
@@ -1814,7 +2124,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1814
2124
|
if (exteriorcb) box = exteriorcb(box);
|
|
1815
2125
|
return box;
|
|
1816
2126
|
};
|
|
1817
|
-
|
|
2127
|
+
var BBox = function BBox(o) {
|
|
1818
2128
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
1819
2129
|
var s = div$1(xyz2array(o.size()), 2);
|
|
1820
2130
|
return CSG.cube({
|
|
@@ -1825,7 +2135,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1825
2135
|
function getRadius(o) {
|
|
1826
2136
|
return div$1(xyz2array(o.size()), 2);
|
|
1827
2137
|
}
|
|
1828
|
-
function rabbetJoin(box, thickness
|
|
2138
|
+
function rabbetJoin(box, thickness) {
|
|
2139
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1829
2140
|
var r = add(getRadius(box), -thickness / 2);
|
|
1830
2141
|
r[2] = thickness / 2;
|
|
1831
2142
|
var cutter = CSG.cube({
|
|
@@ -1843,17 +2154,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1843
2154
|
}
|
|
1844
2155
|
var Boxes = Object.freeze({
|
|
1845
2156
|
__proto__: null,
|
|
1846
|
-
BBox,
|
|
1847
|
-
CutOut,
|
|
1848
|
-
Hollow,
|
|
1849
2157
|
RabbetJoin,
|
|
2158
|
+
topMiddleBottom,
|
|
1850
2159
|
Rabett,
|
|
1851
2160
|
RabettTopBottom,
|
|
2161
|
+
CutOut,
|
|
1852
2162
|
Rectangle,
|
|
1853
|
-
|
|
2163
|
+
Hollow,
|
|
2164
|
+
BBox
|
|
1854
2165
|
});
|
|
1855
|
-
|
|
1856
|
-
...util,
|
|
2166
|
+
var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
|
|
1857
2167
|
group: Group,
|
|
1858
2168
|
init: init$1,
|
|
1859
2169
|
triangle: triUtils,
|
|
@@ -1861,7 +2171,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1861
2171
|
parts: parts$1,
|
|
1862
2172
|
Boxes,
|
|
1863
2173
|
Debug
|
|
1864
|
-
};
|
|
2174
|
+
});
|
|
1865
2175
|
exports.Boxes = Boxes;
|
|
1866
2176
|
exports.Debug = Debug;
|
|
1867
2177
|
exports.Group = Group;
|
|
@@ -1871,6 +2181,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1871
2181
|
exports.parts = parts$1;
|
|
1872
2182
|
exports.triUtils = triUtils;
|
|
1873
2183
|
exports.util = util;
|
|
2184
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2185
|
+
value: true
|
|
2186
|
+
});
|
|
1874
2187
|
return exports;
|
|
1875
2188
|
}({}, jsCadCSG, scadApi);
|
|
1876
2189
|
const debug = jscadUtils.Debug("jscadUtils:initJscadutils");
|
|
@@ -1888,7 +2201,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1888
2201
|
|
|
1889
2202
|
var jscadUtilsPluginInit = [];
|
|
1890
2203
|
|
|
1891
|
-
util = {
|
|
2204
|
+
var util = {
|
|
1892
2205
|
init: (...a) => {
|
|
1893
2206
|
initJscadutils(...a);
|
|
1894
2207
|
jscadUtilsPluginInit.forEach(p => {
|