@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
|
@@ -74,13 +74,329 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
74
74
|
});
|
|
75
75
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
76
76
|
"use strict";
|
|
77
|
-
|
|
77
|
+
function _interopDefaultLegacy(e) {
|
|
78
|
+
return e && typeof e === "object" && "default" in e ? e : {
|
|
79
|
+
default: e
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
83
|
+
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
84
|
+
var util = Object.freeze({
|
|
85
|
+
__proto__: null,
|
|
86
|
+
get NOZZEL_SIZE() {
|
|
87
|
+
return NOZZEL_SIZE;
|
|
88
|
+
},
|
|
89
|
+
get nearest() {
|
|
90
|
+
return nearest;
|
|
91
|
+
},
|
|
92
|
+
get identity() {
|
|
93
|
+
return identity;
|
|
94
|
+
},
|
|
95
|
+
get result() {
|
|
96
|
+
return result;
|
|
97
|
+
},
|
|
98
|
+
get defaults() {
|
|
99
|
+
return defaults;
|
|
100
|
+
},
|
|
101
|
+
get isEmpty() {
|
|
102
|
+
return isEmpty;
|
|
103
|
+
},
|
|
104
|
+
get isNegative() {
|
|
105
|
+
return isNegative;
|
|
106
|
+
},
|
|
107
|
+
get print() {
|
|
108
|
+
return print;
|
|
109
|
+
},
|
|
110
|
+
get jscadToString() {
|
|
111
|
+
return jscadToString;
|
|
112
|
+
},
|
|
113
|
+
get error() {
|
|
114
|
+
return error;
|
|
115
|
+
},
|
|
116
|
+
get depreciated() {
|
|
117
|
+
return depreciated;
|
|
118
|
+
},
|
|
119
|
+
get inch() {
|
|
120
|
+
return inch;
|
|
121
|
+
},
|
|
122
|
+
get cm() {
|
|
123
|
+
return cm;
|
|
124
|
+
},
|
|
125
|
+
get label() {
|
|
126
|
+
return label;
|
|
127
|
+
},
|
|
128
|
+
get text() {
|
|
129
|
+
return text;
|
|
130
|
+
},
|
|
131
|
+
get unitCube() {
|
|
132
|
+
return unitCube;
|
|
133
|
+
},
|
|
134
|
+
get unitAxis() {
|
|
135
|
+
return unitAxis;
|
|
136
|
+
},
|
|
137
|
+
get toArray() {
|
|
138
|
+
return toArray;
|
|
139
|
+
},
|
|
140
|
+
get ifArray() {
|
|
141
|
+
return ifArray;
|
|
142
|
+
},
|
|
143
|
+
get segment() {
|
|
144
|
+
return segment;
|
|
145
|
+
},
|
|
146
|
+
get zipObject() {
|
|
147
|
+
return zipObject;
|
|
148
|
+
},
|
|
149
|
+
get map() {
|
|
150
|
+
return map;
|
|
151
|
+
},
|
|
152
|
+
get mapValues() {
|
|
153
|
+
return mapValues;
|
|
154
|
+
},
|
|
155
|
+
get pick() {
|
|
156
|
+
return pick;
|
|
157
|
+
},
|
|
158
|
+
get mapPick() {
|
|
159
|
+
return mapPick;
|
|
160
|
+
},
|
|
161
|
+
get divA() {
|
|
162
|
+
return divA;
|
|
163
|
+
},
|
|
164
|
+
get divxyz() {
|
|
165
|
+
return divxyz;
|
|
166
|
+
},
|
|
167
|
+
get div() {
|
|
168
|
+
return div;
|
|
169
|
+
},
|
|
170
|
+
get mulxyz() {
|
|
171
|
+
return mulxyz;
|
|
172
|
+
},
|
|
173
|
+
get mul() {
|
|
174
|
+
return mul;
|
|
175
|
+
},
|
|
176
|
+
get xyz2array() {
|
|
177
|
+
return xyz2array;
|
|
178
|
+
},
|
|
179
|
+
get rotationAxes() {
|
|
180
|
+
return rotationAxes;
|
|
181
|
+
},
|
|
182
|
+
get size() {
|
|
183
|
+
return size;
|
|
184
|
+
},
|
|
185
|
+
get scale() {
|
|
186
|
+
return scale;
|
|
187
|
+
},
|
|
188
|
+
get center() {
|
|
189
|
+
return center;
|
|
190
|
+
},
|
|
191
|
+
get centerY() {
|
|
192
|
+
return centerY;
|
|
193
|
+
},
|
|
194
|
+
get centerX() {
|
|
195
|
+
return centerX;
|
|
196
|
+
},
|
|
197
|
+
get enlarge() {
|
|
198
|
+
return enlarge;
|
|
199
|
+
},
|
|
200
|
+
get fit() {
|
|
201
|
+
return fit;
|
|
202
|
+
},
|
|
203
|
+
get shift() {
|
|
204
|
+
return shift;
|
|
205
|
+
},
|
|
206
|
+
get zero() {
|
|
207
|
+
return zero;
|
|
208
|
+
},
|
|
209
|
+
get mirrored4() {
|
|
210
|
+
return mirrored4;
|
|
211
|
+
},
|
|
212
|
+
get flushSide() {
|
|
213
|
+
return flushSide;
|
|
214
|
+
},
|
|
215
|
+
get calcFlush() {
|
|
216
|
+
return calcFlush;
|
|
217
|
+
},
|
|
218
|
+
get calcSnap() {
|
|
219
|
+
return calcSnap;
|
|
220
|
+
},
|
|
221
|
+
get snap() {
|
|
222
|
+
return snap;
|
|
223
|
+
},
|
|
224
|
+
get flush() {
|
|
225
|
+
return flush;
|
|
226
|
+
},
|
|
227
|
+
get axisApply() {
|
|
228
|
+
return axisApply;
|
|
229
|
+
},
|
|
230
|
+
get axis2array() {
|
|
231
|
+
return axis2array;
|
|
232
|
+
},
|
|
233
|
+
get centroid() {
|
|
234
|
+
return centroid;
|
|
235
|
+
},
|
|
236
|
+
get calcmidlineTo() {
|
|
237
|
+
return calcmidlineTo;
|
|
238
|
+
},
|
|
239
|
+
get midlineTo() {
|
|
240
|
+
return midlineTo;
|
|
241
|
+
},
|
|
242
|
+
get translator() {
|
|
243
|
+
return translator;
|
|
244
|
+
},
|
|
245
|
+
get calcCenterWith() {
|
|
246
|
+
return calcCenterWith;
|
|
247
|
+
},
|
|
248
|
+
get centerWith() {
|
|
249
|
+
return centerWith;
|
|
250
|
+
},
|
|
251
|
+
get getDelta() {
|
|
252
|
+
return getDelta;
|
|
253
|
+
},
|
|
254
|
+
get bisect() {
|
|
255
|
+
return bisect;
|
|
256
|
+
},
|
|
257
|
+
get slice() {
|
|
258
|
+
return slice;
|
|
259
|
+
},
|
|
260
|
+
get wedge() {
|
|
261
|
+
return wedge;
|
|
262
|
+
},
|
|
263
|
+
get stretch() {
|
|
264
|
+
return stretch;
|
|
265
|
+
},
|
|
266
|
+
get poly2solid() {
|
|
267
|
+
return poly2solid;
|
|
268
|
+
},
|
|
269
|
+
get slices2poly() {
|
|
270
|
+
return slices2poly;
|
|
271
|
+
},
|
|
272
|
+
get normalVector() {
|
|
273
|
+
return normalVector;
|
|
274
|
+
},
|
|
275
|
+
get sliceParams() {
|
|
276
|
+
return sliceParams;
|
|
277
|
+
},
|
|
278
|
+
get reShape() {
|
|
279
|
+
return reShape;
|
|
280
|
+
},
|
|
281
|
+
get chamfer() {
|
|
282
|
+
return chamfer;
|
|
283
|
+
},
|
|
284
|
+
get fillet() {
|
|
285
|
+
return fillet;
|
|
286
|
+
},
|
|
287
|
+
get calcRotate() {
|
|
288
|
+
return calcRotate;
|
|
289
|
+
},
|
|
290
|
+
get rotateAround() {
|
|
291
|
+
return rotateAround;
|
|
292
|
+
},
|
|
293
|
+
get clone() {
|
|
294
|
+
return clone;
|
|
295
|
+
},
|
|
296
|
+
get addConnector() {
|
|
297
|
+
return addConnector;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
function _arrayLikeToArray(r, a) {
|
|
301
|
+
(null == a || a > r.length) && (a = r.length);
|
|
302
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
303
|
+
return n;
|
|
304
|
+
}
|
|
305
|
+
function _arrayWithHoles(r) {
|
|
306
|
+
if (Array.isArray(r)) return r;
|
|
307
|
+
}
|
|
308
|
+
function _defineProperty(e, r, t) {
|
|
309
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
310
|
+
value: t,
|
|
311
|
+
enumerable: !0,
|
|
312
|
+
configurable: !0,
|
|
313
|
+
writable: !0
|
|
314
|
+
}) : e[r] = t, e;
|
|
315
|
+
}
|
|
316
|
+
function _iterableToArrayLimit(r, l) {
|
|
317
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
318
|
+
if (null != t) {
|
|
319
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
320
|
+
try {
|
|
321
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
322
|
+
if (Object(t) !== t) return;
|
|
323
|
+
f = !1;
|
|
324
|
+
} else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
|
|
325
|
+
} catch (r) {
|
|
326
|
+
o = !0, n = r;
|
|
327
|
+
} finally {
|
|
328
|
+
try {
|
|
329
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
330
|
+
} finally {
|
|
331
|
+
if (o) throw n;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return a;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function _nonIterableRest() {
|
|
338
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
339
|
+
}
|
|
340
|
+
function ownKeys(e, r) {
|
|
341
|
+
var t = Object.keys(e);
|
|
342
|
+
if (Object.getOwnPropertySymbols) {
|
|
343
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
344
|
+
r && (o = o.filter(function(r) {
|
|
345
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
346
|
+
})), t.push.apply(t, o);
|
|
347
|
+
}
|
|
348
|
+
return t;
|
|
349
|
+
}
|
|
350
|
+
function _objectSpread2(e) {
|
|
351
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
352
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
353
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
354
|
+
_defineProperty(e, r, t[r]);
|
|
355
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
356
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
return e;
|
|
360
|
+
}
|
|
361
|
+
function _slicedToArray(r, e) {
|
|
362
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
363
|
+
}
|
|
364
|
+
function _toPrimitive(t, r) {
|
|
365
|
+
if ("object" != typeof t || !t) return t;
|
|
366
|
+
var e = t[Symbol.toPrimitive];
|
|
367
|
+
if (void 0 !== e) {
|
|
368
|
+
var i = e.call(t, r || "default");
|
|
369
|
+
if ("object" != typeof i) return i;
|
|
370
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
371
|
+
}
|
|
372
|
+
return ("string" === r ? String : Number)(t);
|
|
373
|
+
}
|
|
374
|
+
function _toPropertyKey(t) {
|
|
375
|
+
var i = _toPrimitive(t, "string");
|
|
376
|
+
return "symbol" == typeof i ? i : i + "";
|
|
377
|
+
}
|
|
378
|
+
function _typeof(o) {
|
|
379
|
+
"@babel/helpers - typeof";
|
|
380
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
381
|
+
return typeof o;
|
|
382
|
+
} : function(o) {
|
|
383
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
384
|
+
}, _typeof(o);
|
|
385
|
+
}
|
|
386
|
+
function _unsupportedIterableToArray(r, a) {
|
|
387
|
+
if (r) {
|
|
388
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
389
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
390
|
+
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;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
var toRadians = function toRadians(deg) {
|
|
78
394
|
return deg / 180 * Math.PI;
|
|
79
395
|
};
|
|
80
|
-
|
|
396
|
+
var toDegrees = function toDegrees(rad) {
|
|
81
397
|
return rad * (180 / Math.PI);
|
|
82
398
|
};
|
|
83
|
-
|
|
399
|
+
var solve = function solve(p1, p2) {
|
|
84
400
|
var r = {
|
|
85
401
|
c: 90,
|
|
86
402
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -92,7 +408,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
92
408
|
r.a = 90 - r.b;
|
|
93
409
|
return r;
|
|
94
410
|
};
|
|
95
|
-
|
|
411
|
+
var solve90SA = function solve90SA(r) {
|
|
96
412
|
r = Object.assign(r, {
|
|
97
413
|
C: 90
|
|
98
414
|
});
|
|
@@ -104,7 +420,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
104
420
|
r.b = r.b || r.a / Math.tan(arad);
|
|
105
421
|
return r;
|
|
106
422
|
};
|
|
107
|
-
|
|
423
|
+
var solve90ac = function solve90ac(r) {
|
|
108
424
|
r = Object.assign(r, {
|
|
109
425
|
C: 90
|
|
110
426
|
});
|
|
@@ -125,29 +441,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
125
441
|
}
|
|
126
442
|
var triUtils = Object.freeze({
|
|
127
443
|
__proto__: null,
|
|
444
|
+
toRadians,
|
|
445
|
+
toDegrees,
|
|
128
446
|
solve,
|
|
129
447
|
solve90SA,
|
|
130
448
|
solve90ac,
|
|
131
|
-
solveab
|
|
132
|
-
toDegrees,
|
|
133
|
-
toRadians
|
|
449
|
+
solveab
|
|
134
450
|
});
|
|
135
|
-
|
|
451
|
+
var div$1 = function div(a, f) {
|
|
136
452
|
return a.map(function(e) {
|
|
137
453
|
return e / f;
|
|
138
454
|
});
|
|
139
455
|
};
|
|
140
|
-
|
|
456
|
+
var addValue = function addValue(a, f) {
|
|
141
457
|
return a.map(function(e) {
|
|
142
458
|
return e + f;
|
|
143
459
|
});
|
|
144
460
|
};
|
|
145
|
-
|
|
461
|
+
var addArray = function addArray(a, f) {
|
|
146
462
|
return a.map(function(e, i) {
|
|
147
463
|
return e + f[i];
|
|
148
464
|
});
|
|
149
465
|
};
|
|
150
|
-
|
|
466
|
+
var add = function add(a) {
|
|
151
467
|
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
152
468
|
if (Array.isArray(arg)) {
|
|
153
469
|
result = addArray(result, arg);
|
|
@@ -157,28 +473,28 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
157
473
|
return result;
|
|
158
474
|
}, a);
|
|
159
475
|
};
|
|
160
|
-
|
|
476
|
+
var fromxyz = function fromxyz(object) {
|
|
161
477
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
162
478
|
};
|
|
163
|
-
|
|
479
|
+
var toxyz = function toxyz(a) {
|
|
164
480
|
return {
|
|
165
481
|
x: a[0],
|
|
166
482
|
y: a[1],
|
|
167
483
|
z: a[2]
|
|
168
484
|
};
|
|
169
485
|
};
|
|
170
|
-
|
|
486
|
+
var first = function first(a) {
|
|
171
487
|
return a ? a[0] : undefined;
|
|
172
488
|
};
|
|
173
|
-
|
|
489
|
+
var last = function last(a) {
|
|
174
490
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
175
491
|
};
|
|
176
|
-
|
|
492
|
+
var min = function min(a) {
|
|
177
493
|
return a.reduce(function(result, value) {
|
|
178
494
|
return value < result ? value : result;
|
|
179
495
|
}, Number.MAX_VALUE);
|
|
180
496
|
};
|
|
181
|
-
|
|
497
|
+
var range = function range(a, b) {
|
|
182
498
|
var result = [];
|
|
183
499
|
for (var i = a; i < b; i++) {
|
|
184
500
|
result.push(i);
|
|
@@ -187,21 +503,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
187
503
|
};
|
|
188
504
|
var array = Object.freeze({
|
|
189
505
|
__proto__: null,
|
|
190
|
-
add,
|
|
191
|
-
addArray,
|
|
192
|
-
addValue,
|
|
193
506
|
div: div$1,
|
|
194
|
-
|
|
507
|
+
addValue,
|
|
508
|
+
addArray,
|
|
509
|
+
add,
|
|
195
510
|
fromxyz,
|
|
511
|
+
toxyz,
|
|
512
|
+
first,
|
|
196
513
|
last,
|
|
197
514
|
min,
|
|
198
|
-
range
|
|
199
|
-
toxyz
|
|
515
|
+
range
|
|
200
516
|
});
|
|
201
|
-
|
|
202
|
-
|
|
517
|
+
var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
518
|
+
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" ];
|
|
203
519
|
var debugCount = 0;
|
|
204
|
-
|
|
520
|
+
var Debug = function Debug(name) {
|
|
205
521
|
var checks = Object.assign({
|
|
206
522
|
enabled: [],
|
|
207
523
|
disabled: [],
|
|
@@ -209,21 +525,31 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
209
525
|
browser: true
|
|
210
526
|
}
|
|
211
527
|
}, jscadUtilsDebug || {});
|
|
212
|
-
var style = checks.options.browser ?
|
|
528
|
+
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
213
529
|
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
214
530
|
return check.test(name);
|
|
215
531
|
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
216
532
|
return check.test(name);
|
|
217
533
|
});
|
|
218
|
-
var logger = enabled ? checks.options.browser ? (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
534
|
+
var logger = enabled ? checks.options.browser ? function() {
|
|
535
|
+
var _console;
|
|
536
|
+
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
537
|
+
msg[_key] = arguments[_key];
|
|
538
|
+
}
|
|
539
|
+
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
540
|
+
} : function() {
|
|
541
|
+
var _console2;
|
|
542
|
+
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
543
|
+
msg[_key2] = arguments[_key2];
|
|
544
|
+
}
|
|
545
|
+
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
546
|
+
} : function() {
|
|
547
|
+
return undefined;
|
|
548
|
+
};
|
|
223
549
|
logger.enabled = enabled;
|
|
224
550
|
return logger;
|
|
225
551
|
};
|
|
226
|
-
|
|
552
|
+
var nameArray = {
|
|
227
553
|
aliceblue: "#f0f8ff",
|
|
228
554
|
antiquewhite: "#faebd7",
|
|
229
555
|
aqua: "#00ffff",
|
|
@@ -385,7 +711,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
385
711
|
return [ 0, 0, 0 ];
|
|
386
712
|
}
|
|
387
713
|
}
|
|
388
|
-
|
|
714
|
+
var _name2rgb = {};
|
|
389
715
|
function name2rgb(n) {
|
|
390
716
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
391
717
|
return _name2rgb[n];
|
|
@@ -465,14 +791,23 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
465
791
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
466
792
|
return chamfer(this, radius, orientation, options);
|
|
467
793
|
};
|
|
468
|
-
proto.prototype.bisect = function bisect$1(
|
|
469
|
-
|
|
794
|
+
proto.prototype.bisect = function bisect$1() {
|
|
795
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
796
|
+
args[_key] = arguments[_key];
|
|
797
|
+
}
|
|
798
|
+
return bisect.apply(util, [ this ].concat(args));
|
|
470
799
|
};
|
|
471
|
-
proto.prototype.slice = function slice$1(
|
|
472
|
-
|
|
800
|
+
proto.prototype.slice = function slice$1() {
|
|
801
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
802
|
+
args[_key2] = arguments[_key2];
|
|
803
|
+
}
|
|
804
|
+
return slice.apply(util, [ this ].concat(args));
|
|
473
805
|
};
|
|
474
|
-
proto.prototype.wedge = function wedge$1(
|
|
475
|
-
|
|
806
|
+
proto.prototype.wedge = function wedge$1() {
|
|
807
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
808
|
+
args[_key3] = arguments[_key3];
|
|
809
|
+
}
|
|
810
|
+
return wedge.apply(util, [ this ].concat(args));
|
|
476
811
|
};
|
|
477
812
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
478
813
|
return stretch(this, axis, distance, offset);
|
|
@@ -489,7 +824,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
489
824
|
return this._translate(arguments[0]);
|
|
490
825
|
} else {
|
|
491
826
|
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
492
|
-
result = undefined
|
|
827
|
+
result = undefined(result, arg);
|
|
493
828
|
return result;
|
|
494
829
|
}, [ 0, 0, 0 ]);
|
|
495
830
|
return this._translate(t);
|
|
@@ -498,10 +833,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
498
833
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
499
834
|
return addConnector(this, name, point, axis, normal);
|
|
500
835
|
};
|
|
501
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector
|
|
502
|
-
var
|
|
836
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
837
|
+
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
838
|
+
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
839
|
+
var myConnector = myConnectorName.split(".").reduce(function(a, v) {
|
|
840
|
+
return a[v];
|
|
841
|
+
}, this.properties);
|
|
503
842
|
if (!myConnector) {
|
|
504
|
-
error(
|
|
843
|
+
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
|
|
505
844
|
}
|
|
506
845
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
507
846
|
};
|
|
@@ -511,13 +850,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
511
850
|
__proto__: null,
|
|
512
851
|
default: init
|
|
513
852
|
});
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
853
|
+
var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
|
|
854
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
855
|
+
var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
|
|
856
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
518
857
|
init(CSG);
|
|
519
|
-
|
|
520
|
-
function JsCadUtilsGroup(
|
|
858
|
+
var debug$3 = Debug("jscadUtils:group");
|
|
859
|
+
function JsCadUtilsGroup() {
|
|
860
|
+
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
861
|
+
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
862
|
+
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
521
863
|
this.name = "";
|
|
522
864
|
this.names = names;
|
|
523
865
|
this.parts = parts;
|
|
@@ -545,7 +887,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
545
887
|
}
|
|
546
888
|
return self;
|
|
547
889
|
};
|
|
548
|
-
JsCadUtilsGroup.prototype.combine = function(pieces
|
|
890
|
+
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
891
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
892
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
893
|
+
return x;
|
|
894
|
+
};
|
|
549
895
|
try {
|
|
550
896
|
var self = this;
|
|
551
897
|
options = Object.assign({
|
|
@@ -553,7 +899,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
553
899
|
}, options);
|
|
554
900
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
555
901
|
if (pieces.length === 0) {
|
|
556
|
-
throw new Error(
|
|
902
|
+
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
557
903
|
}
|
|
558
904
|
debug$3("combine", self.names, self.parts);
|
|
559
905
|
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
@@ -563,12 +909,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
563
909
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
564
910
|
} catch (err) {
|
|
565
911
|
debug$3("combine error", this, pieces, options, err);
|
|
566
|
-
throw error(
|
|
912
|
+
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");
|
|
567
913
|
}
|
|
568
914
|
};
|
|
569
915
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
570
916
|
var self = this;
|
|
571
|
-
self.parts = Object.keys(self.parts).filter(
|
|
917
|
+
self.parts = Object.keys(self.parts).filter(function(k) {
|
|
918
|
+
return k !== "holes";
|
|
919
|
+
}).reduce(function(result, key) {
|
|
572
920
|
result[key] = cb(self.parts[key], key);
|
|
573
921
|
return result;
|
|
574
922
|
}, {});
|
|
@@ -584,7 +932,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
584
932
|
return self;
|
|
585
933
|
};
|
|
586
934
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
587
|
-
debug$3("clone", name,
|
|
935
|
+
debug$3("clone", name, _typeof(name), map);
|
|
588
936
|
var self = this;
|
|
589
937
|
if (typeof name == "function") {
|
|
590
938
|
map = name;
|
|
@@ -636,7 +984,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
636
984
|
return self;
|
|
637
985
|
} catch (err) {
|
|
638
986
|
debug$3("snap error", this, part, to, axis, delta, err);
|
|
639
|
-
throw error(
|
|
987
|
+
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");
|
|
640
988
|
}
|
|
641
989
|
};
|
|
642
990
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -651,7 +999,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
651
999
|
return self;
|
|
652
1000
|
} catch (err) {
|
|
653
1001
|
debug$3("align error", this, part, to, axis, delta, err);
|
|
654
|
-
throw error(
|
|
1002
|
+
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");
|
|
655
1003
|
}
|
|
656
1004
|
};
|
|
657
1005
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -663,7 +1011,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
663
1011
|
var bounds = self.parts[part].getBounds();
|
|
664
1012
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
665
1013
|
};
|
|
666
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName
|
|
1014
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
1015
|
+
var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1016
|
+
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
667
1017
|
debug$3("connectTo", {
|
|
668
1018
|
partName,
|
|
669
1019
|
connectorName,
|
|
@@ -673,9 +1023,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
673
1023
|
normalrotation
|
|
674
1024
|
});
|
|
675
1025
|
var self = this;
|
|
676
|
-
var myConnector = connectorName.split(".").reduce((a, v)
|
|
1026
|
+
var myConnector = connectorName.split(".").reduce(function(a, v) {
|
|
1027
|
+
return a[v];
|
|
1028
|
+
}, self.parts[partName].properties);
|
|
677
1029
|
debug$3("toConnector", to instanceof CSG.Connector);
|
|
678
|
-
var toConnector = toConnectorName.split(".").reduce((a, v)
|
|
1030
|
+
var toConnector = toConnectorName.split(".").reduce(function(a, v) {
|
|
1031
|
+
return a[v];
|
|
1032
|
+
}, to.properties);
|
|
679
1033
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
680
1034
|
debug$3("connectTo", matrix);
|
|
681
1035
|
self.map(function(part) {
|
|
@@ -714,14 +1068,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
714
1068
|
return g;
|
|
715
1069
|
};
|
|
716
1070
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1071
|
+
var _this = this;
|
|
717
1072
|
var self = this;
|
|
718
1073
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
719
1074
|
if (!map) map = identity;
|
|
720
1075
|
var a = [];
|
|
721
|
-
p.forEach(name
|
|
1076
|
+
p.forEach(function(name) {
|
|
722
1077
|
if (!self.parts[name]) {
|
|
723
|
-
debug$3("array error",
|
|
724
|
-
throw error(
|
|
1078
|
+
debug$3("array error", _this, parts);
|
|
1079
|
+
throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
|
|
725
1080
|
}
|
|
726
1081
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
727
1082
|
});
|
|
@@ -731,12 +1086,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
731
1086
|
var self = this;
|
|
732
1087
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
733
1088
|
return piecesArray.map(function(piece) {
|
|
734
|
-
if (!self.parts[piece]) console.error(
|
|
1089
|
+
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
735
1090
|
return self.parts[piece];
|
|
736
1091
|
});
|
|
737
1092
|
};
|
|
738
1093
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
739
|
-
return
|
|
1094
|
+
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}");
|
|
740
1095
|
};
|
|
741
1096
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
742
1097
|
this.name = name;
|
|
@@ -766,7 +1121,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
766
1121
|
self.name = objectNames;
|
|
767
1122
|
} else {
|
|
768
1123
|
var objects = objectNames;
|
|
769
|
-
self.names = Object.keys(objects).filter(k
|
|
1124
|
+
self.names = Object.keys(objects).filter(function(k) {
|
|
1125
|
+
return k !== "holes";
|
|
1126
|
+
});
|
|
770
1127
|
self.parts = Object.assign({}, objects);
|
|
771
1128
|
self.holes = objects.holes;
|
|
772
1129
|
}
|
|
@@ -774,13 +1131,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
774
1131
|
}
|
|
775
1132
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
776
1133
|
}
|
|
777
|
-
|
|
1134
|
+
var debug$2 = Debug("jscadUtils:util");
|
|
778
1135
|
var NOZZEL_SIZE = .4;
|
|
779
|
-
|
|
780
|
-
under: function(desired
|
|
1136
|
+
var nearest = {
|
|
1137
|
+
under: function under(desired) {
|
|
1138
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1139
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
781
1140
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
782
1141
|
},
|
|
783
|
-
over: function(desired
|
|
1142
|
+
over: function over(desired) {
|
|
1143
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1144
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
784
1145
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
785
1146
|
}
|
|
786
1147
|
};
|
|
@@ -808,9 +1169,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
808
1169
|
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
809
1170
|
}
|
|
810
1171
|
function jscadToString(o) {
|
|
811
|
-
if (
|
|
1172
|
+
if (_typeof(o) == "object") {
|
|
812
1173
|
if (o.polygons) {
|
|
813
|
-
return
|
|
1174
|
+
return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
|
|
814
1175
|
}
|
|
815
1176
|
} else {
|
|
816
1177
|
return o.toString();
|
|
@@ -851,12 +1212,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
851
1212
|
}
|
|
852
1213
|
function text(text) {
|
|
853
1214
|
var l = vector_char(0, 0, text);
|
|
854
|
-
var
|
|
1215
|
+
var _char = l.segments.reduce(function(result, segment) {
|
|
855
1216
|
var path = new CSG.Path2D(segment);
|
|
856
1217
|
var cag = path.expandToCAG(2);
|
|
857
1218
|
return result ? result.union(cag) : cag;
|
|
858
1219
|
}, undefined);
|
|
859
|
-
return
|
|
1220
|
+
return _char;
|
|
860
1221
|
}
|
|
861
1222
|
function unitCube(length, radius) {
|
|
862
1223
|
radius = radius || .5;
|
|
@@ -912,7 +1273,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
912
1273
|
function mapPick(o, names, f, options) {
|
|
913
1274
|
return names.reduce(function(result, name, index) {
|
|
914
1275
|
if (!o[name]) {
|
|
915
|
-
throw new Error(
|
|
1276
|
+
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
|
|
916
1277
|
}
|
|
917
1278
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
918
1279
|
return result;
|
|
@@ -944,7 +1305,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
944
1305
|
function xyz2array(size) {
|
|
945
1306
|
return [ size.x, size.y, size.z ];
|
|
946
1307
|
}
|
|
947
|
-
|
|
1308
|
+
var rotationAxes = {
|
|
948
1309
|
x: [ 1, 0, 0 ],
|
|
949
1310
|
y: [ 0, 1, 0 ],
|
|
950
1311
|
z: [ 0, 0, 1 ]
|
|
@@ -1022,7 +1383,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1022
1383
|
function mirrored4(x) {
|
|
1023
1384
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1024
1385
|
}
|
|
1025
|
-
|
|
1386
|
+
var flushSide = {
|
|
1026
1387
|
"above-outside": [ 1, 0 ],
|
|
1027
1388
|
"above-inside": [ 1, 1 ],
|
|
1028
1389
|
"below-outside": [ 0, 1 ],
|
|
@@ -1052,7 +1413,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1052
1413
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1053
1414
|
});
|
|
1054
1415
|
}
|
|
1055
|
-
function calcSnap(moveobj, withobj, axes, orientation
|
|
1416
|
+
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1417
|
+
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1056
1418
|
var side = flushSide[orientation];
|
|
1057
1419
|
if (!side) {
|
|
1058
1420
|
var fix = {
|
|
@@ -1118,7 +1480,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1118
1480
|
objectSize = objectSize || size(bounds);
|
|
1119
1481
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1120
1482
|
} catch (err) {
|
|
1121
|
-
error(
|
|
1483
|
+
error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
|
|
1122
1484
|
}
|
|
1123
1485
|
}
|
|
1124
1486
|
function calcmidlineTo(o, axis, to) {
|
|
@@ -1139,7 +1501,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1139
1501
|
});
|
|
1140
1502
|
return t;
|
|
1141
1503
|
}
|
|
1142
|
-
function calcCenterWith(o, axes, withObj
|
|
1504
|
+
function calcCenterWith(o, axes, withObj) {
|
|
1505
|
+
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1143
1506
|
var objectCentroid = centroid(o);
|
|
1144
1507
|
var withCentroid = centroid(withObj);
|
|
1145
1508
|
var t = axisApply(axes, function(i, axis) {
|
|
@@ -1161,7 +1524,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1161
1524
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1162
1525
|
});
|
|
1163
1526
|
}
|
|
1164
|
-
function bisect(
|
|
1527
|
+
function bisect() {
|
|
1528
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1529
|
+
args[_key] = arguments[_key];
|
|
1530
|
+
}
|
|
1165
1531
|
if (args.length < 2) {
|
|
1166
1532
|
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1167
1533
|
}
|
|
@@ -1242,10 +1608,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1242
1608
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1243
1609
|
return g;
|
|
1244
1610
|
}
|
|
1245
|
-
function slice(object
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1611
|
+
function slice(object) {
|
|
1612
|
+
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
|
|
1613
|
+
var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
|
|
1614
|
+
var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
|
|
1615
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1616
|
+
color: true,
|
|
1617
|
+
addRotationCenter: true
|
|
1618
|
+
};
|
|
1249
1619
|
var info = normalVector(axis);
|
|
1250
1620
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1251
1621
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1462,11 +1832,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1462
1832
|
};
|
|
1463
1833
|
}
|
|
1464
1834
|
function rotateAround(part, solid, axis, angle) {
|
|
1465
|
-
var
|
|
1835
|
+
var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
|
|
1466
1836
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1467
1837
|
}
|
|
1468
|
-
function cloneProperties(from, to
|
|
1469
|
-
return Object.entries(from).reduce((props,
|
|
1838
|
+
function cloneProperties(from, to) {
|
|
1839
|
+
return Object.entries(from).reduce(function(props, _ref) {
|
|
1840
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1470
1841
|
props[key] = value;
|
|
1471
1842
|
return props;
|
|
1472
1843
|
}, to);
|
|
@@ -1477,85 +1848,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1477
1848
|
debug$2("clone", o, c, CSG);
|
|
1478
1849
|
return c;
|
|
1479
1850
|
}
|
|
1480
|
-
function addConnector(object, name
|
|
1851
|
+
function addConnector(object, name) {
|
|
1852
|
+
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1853
|
+
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1854
|
+
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1481
1855
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1482
1856
|
return object;
|
|
1483
1857
|
}
|
|
1484
|
-
var
|
|
1485
|
-
__proto__: null,
|
|
1486
|
-
NOZZEL_SIZE,
|
|
1487
|
-
addConnector,
|
|
1488
|
-
axis2array,
|
|
1489
|
-
axisApply,
|
|
1490
|
-
bisect,
|
|
1491
|
-
calcCenterWith,
|
|
1492
|
-
calcFlush,
|
|
1493
|
-
calcRotate,
|
|
1494
|
-
calcSnap,
|
|
1495
|
-
calcmidlineTo,
|
|
1496
|
-
center,
|
|
1497
|
-
centerWith,
|
|
1498
|
-
centerX,
|
|
1499
|
-
centerY,
|
|
1500
|
-
centroid,
|
|
1501
|
-
chamfer,
|
|
1502
|
-
clone,
|
|
1503
|
-
cm,
|
|
1504
|
-
defaults,
|
|
1505
|
-
depreciated,
|
|
1506
|
-
div,
|
|
1507
|
-
divA,
|
|
1508
|
-
divxyz,
|
|
1509
|
-
enlarge,
|
|
1510
|
-
error,
|
|
1511
|
-
fillet,
|
|
1512
|
-
fit,
|
|
1513
|
-
flush,
|
|
1514
|
-
flushSide,
|
|
1515
|
-
getDelta,
|
|
1516
|
-
identity,
|
|
1517
|
-
ifArray,
|
|
1518
|
-
inch,
|
|
1519
|
-
isEmpty,
|
|
1520
|
-
isNegative,
|
|
1521
|
-
jscadToString,
|
|
1522
|
-
label,
|
|
1523
|
-
map,
|
|
1524
|
-
mapPick,
|
|
1525
|
-
mapValues,
|
|
1526
|
-
midlineTo,
|
|
1527
|
-
mirrored4,
|
|
1528
|
-
mul,
|
|
1529
|
-
mulxyz,
|
|
1530
|
-
nearest,
|
|
1531
|
-
normalVector,
|
|
1532
|
-
pick,
|
|
1533
|
-
poly2solid,
|
|
1534
|
-
print,
|
|
1535
|
-
reShape,
|
|
1536
|
-
result,
|
|
1537
|
-
rotateAround,
|
|
1538
|
-
rotationAxes,
|
|
1539
|
-
scale,
|
|
1540
|
-
segment,
|
|
1541
|
-
shift,
|
|
1542
|
-
size,
|
|
1543
|
-
slice,
|
|
1544
|
-
sliceParams,
|
|
1545
|
-
slices2poly,
|
|
1546
|
-
snap,
|
|
1547
|
-
stretch,
|
|
1548
|
-
text,
|
|
1549
|
-
toArray,
|
|
1550
|
-
translator,
|
|
1551
|
-
unitAxis,
|
|
1552
|
-
unitCube,
|
|
1553
|
-
wedge,
|
|
1554
|
-
xyz2array,
|
|
1555
|
-
zero,
|
|
1556
|
-
zipObject
|
|
1557
|
-
});
|
|
1558
|
-
const debug$1 = Debug("jscadUtils:parts");
|
|
1858
|
+
var debug$1 = Debug("jscadUtils:parts");
|
|
1559
1859
|
var parts = {
|
|
1560
1860
|
BBox: BBox$1,
|
|
1561
1861
|
Cube,
|
|
@@ -1563,13 +1863,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1563
1863
|
Cylinder,
|
|
1564
1864
|
Cone
|
|
1565
1865
|
};
|
|
1566
|
-
function BBox$1(
|
|
1866
|
+
function BBox$1() {
|
|
1567
1867
|
function box(object) {
|
|
1568
1868
|
return CSG.cube({
|
|
1569
1869
|
center: object.centroid(),
|
|
1570
1870
|
radius: object.size().dividedBy(2)
|
|
1571
1871
|
});
|
|
1572
1872
|
}
|
|
1873
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1874
|
+
objects[_key] = arguments[_key];
|
|
1875
|
+
}
|
|
1573
1876
|
return objects.reduce(function(bbox, part) {
|
|
1574
1877
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1575
1878
|
return box(object);
|
|
@@ -1602,7 +1905,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1602
1905
|
});
|
|
1603
1906
|
return roundedcube;
|
|
1604
1907
|
}
|
|
1605
|
-
function Cylinder(diameter, height
|
|
1908
|
+
function Cylinder(diameter, height) {
|
|
1909
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1606
1910
|
debug$1("parts.Cylinder", diameter, height, options);
|
|
1607
1911
|
options = Object.assign({
|
|
1608
1912
|
start: [ 0, 0, 0 ],
|
|
@@ -1612,7 +1916,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1612
1916
|
}, options);
|
|
1613
1917
|
return CSG.cylinder(options);
|
|
1614
1918
|
}
|
|
1615
|
-
function Cone(diameter1, diameter2, height
|
|
1919
|
+
function Cone(diameter1, diameter2, height) {
|
|
1920
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1616
1921
|
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1617
1922
|
return CSG.cylinder(Object.assign({
|
|
1618
1923
|
start: [ 0, 0, 0 ],
|
|
@@ -1641,7 +1946,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1641
1946
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1642
1947
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1643
1948
|
}
|
|
1644
|
-
function Anchor(
|
|
1949
|
+
function Anchor() {
|
|
1950
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1951
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1645
1952
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1646
1953
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1647
1954
|
return Group({
|
|
@@ -1661,7 +1968,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1661
1968
|
});
|
|
1662
1969
|
return board;
|
|
1663
1970
|
}
|
|
1664
|
-
|
|
1971
|
+
var Hardware = {
|
|
1665
1972
|
Orientation: {
|
|
1666
1973
|
up: {
|
|
1667
1974
|
head: "outside-",
|
|
@@ -1672,7 +1979,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1672
1979
|
clear: "inside-"
|
|
1673
1980
|
}
|
|
1674
1981
|
},
|
|
1675
|
-
Screw: function(head, thread, headClearSpace, options) {
|
|
1982
|
+
Screw: function Screw(head, thread, headClearSpace, options) {
|
|
1676
1983
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1677
1984
|
options = Object.assign(options, {
|
|
1678
1985
|
orientation: "up",
|
|
@@ -1688,7 +1995,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1688
1995
|
}
|
|
1689
1996
|
return group;
|
|
1690
1997
|
},
|
|
1691
|
-
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1998
|
+
PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1692
1999
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1693
2000
|
var head = Cylinder(headDiameter, headLength);
|
|
1694
2001
|
var thread = Cylinder(diameter, length);
|
|
@@ -1697,7 +2004,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1697
2004
|
}
|
|
1698
2005
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1699
2006
|
},
|
|
1700
|
-
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2007
|
+
HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1701
2008
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1702
2009
|
var head = Hexagon(headDiameter, headLength);
|
|
1703
2010
|
var thread = Cylinder(diameter, length);
|
|
@@ -1706,7 +2013,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1706
2013
|
}
|
|
1707
2014
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1708
2015
|
},
|
|
1709
|
-
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2016
|
+
FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1710
2017
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1711
2018
|
var head = Cone(headDiameter, diameter, headLength);
|
|
1712
2019
|
var thread = Cylinder(diameter, length);
|
|
@@ -1718,20 +2025,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1718
2025
|
};
|
|
1719
2026
|
var parts$1 = Object.freeze({
|
|
1720
2027
|
__proto__: null,
|
|
1721
|
-
|
|
2028
|
+
default: parts,
|
|
1722
2029
|
BBox: BBox$1,
|
|
1723
|
-
Board,
|
|
1724
|
-
Cone,
|
|
1725
2030
|
Cube,
|
|
2031
|
+
RoundedCube,
|
|
1726
2032
|
Cylinder,
|
|
1727
|
-
|
|
2033
|
+
Cone,
|
|
1728
2034
|
Hexagon,
|
|
1729
|
-
RoundedCube,
|
|
1730
2035
|
Triangle,
|
|
1731
2036
|
Tube,
|
|
1732
|
-
|
|
2037
|
+
Anchor,
|
|
2038
|
+
Board,
|
|
2039
|
+
Hardware
|
|
1733
2040
|
});
|
|
1734
|
-
|
|
2041
|
+
var debug = Debug("jscadUtils:boxes");
|
|
1735
2042
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
1736
2043
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
1737
2044
|
return rabbetJoin(box, thickness, cutHeight);
|
|
@@ -1744,16 +2051,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1744
2051
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
1745
2052
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
1746
2053
|
}
|
|
1747
|
-
function Rabett(box, thickness, gap, height, face
|
|
2054
|
+
function Rabett(box, thickness, gap, height, face) {
|
|
2055
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1748
2056
|
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1749
2057
|
gap = gap || .25;
|
|
1750
2058
|
var inside = thickness - gap;
|
|
1751
2059
|
var outside = -thickness + gap;
|
|
1752
2060
|
debug("inside", inside, "outside", outside);
|
|
1753
2061
|
var group = Group();
|
|
1754
|
-
var
|
|
2062
|
+
var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
|
|
1755
2063
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
1756
|
-
var
|
|
2064
|
+
var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
|
|
1757
2065
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
1758
2066
|
group.add(top.union(middleTop), "top");
|
|
1759
2067
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -1762,7 +2070,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1762
2070
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
1763
2071
|
return group;
|
|
1764
2072
|
}
|
|
1765
|
-
|
|
2073
|
+
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
2074
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2075
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1766
2076
|
options = Object.assign({
|
|
1767
2077
|
removableTop: true,
|
|
1768
2078
|
removableBottom: true,
|
|
@@ -1795,7 +2105,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1795
2105
|
}
|
|
1796
2106
|
return group;
|
|
1797
2107
|
};
|
|
1798
|
-
|
|
2108
|
+
var CutOut = function cutOut(o, h, box, plug, gap) {
|
|
1799
2109
|
gap = gap || .25;
|
|
1800
2110
|
var s = o.size();
|
|
1801
2111
|
var cutout = o.intersect(box);
|
|
@@ -1813,7 +2123,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1813
2123
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
1814
2124
|
});
|
|
1815
2125
|
};
|
|
1816
|
-
|
|
2126
|
+
var Rectangle = function Rectangle(size, thickness, cb) {
|
|
1817
2127
|
thickness = thickness || 2;
|
|
1818
2128
|
var s = div$1(xyz2array(size), 2);
|
|
1819
2129
|
var r = add(s, thickness);
|
|
@@ -1827,7 +2137,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1827
2137
|
if (cb) box = cb(box);
|
|
1828
2138
|
return box;
|
|
1829
2139
|
};
|
|
1830
|
-
|
|
2140
|
+
var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
|
|
1831
2141
|
thickness = thickness || 2;
|
|
1832
2142
|
var size = -thickness * 2;
|
|
1833
2143
|
interiorcb = interiorcb || identity;
|
|
@@ -1835,7 +2145,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1835
2145
|
if (exteriorcb) box = exteriorcb(box);
|
|
1836
2146
|
return box;
|
|
1837
2147
|
};
|
|
1838
|
-
|
|
2148
|
+
var BBox = function BBox(o) {
|
|
1839
2149
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
1840
2150
|
var s = div$1(xyz2array(o.size()), 2);
|
|
1841
2151
|
return CSG.cube({
|
|
@@ -1846,7 +2156,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1846
2156
|
function getRadius(o) {
|
|
1847
2157
|
return div$1(xyz2array(o.size()), 2);
|
|
1848
2158
|
}
|
|
1849
|
-
function rabbetJoin(box, thickness
|
|
2159
|
+
function rabbetJoin(box, thickness) {
|
|
2160
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1850
2161
|
var r = add(getRadius(box), -thickness / 2);
|
|
1851
2162
|
r[2] = thickness / 2;
|
|
1852
2163
|
var cutter = CSG.cube({
|
|
@@ -1864,17 +2175,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1864
2175
|
}
|
|
1865
2176
|
var Boxes = Object.freeze({
|
|
1866
2177
|
__proto__: null,
|
|
1867
|
-
BBox,
|
|
1868
|
-
CutOut,
|
|
1869
|
-
Hollow,
|
|
1870
2178
|
RabbetJoin,
|
|
2179
|
+
topMiddleBottom,
|
|
1871
2180
|
Rabett,
|
|
1872
2181
|
RabettTopBottom,
|
|
2182
|
+
CutOut,
|
|
1873
2183
|
Rectangle,
|
|
1874
|
-
|
|
2184
|
+
Hollow,
|
|
2185
|
+
BBox
|
|
1875
2186
|
});
|
|
1876
|
-
|
|
1877
|
-
...util,
|
|
2187
|
+
var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
|
|
1878
2188
|
group: Group,
|
|
1879
2189
|
init: init$1,
|
|
1880
2190
|
triangle: triUtils,
|
|
@@ -1882,7 +2192,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1882
2192
|
parts: parts$1,
|
|
1883
2193
|
Boxes,
|
|
1884
2194
|
Debug
|
|
1885
|
-
};
|
|
2195
|
+
});
|
|
1886
2196
|
exports.Boxes = Boxes;
|
|
1887
2197
|
exports.Debug = Debug;
|
|
1888
2198
|
exports.Group = Group;
|
|
@@ -1892,6 +2202,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1892
2202
|
exports.parts = parts$1;
|
|
1893
2203
|
exports.triUtils = triUtils;
|
|
1894
2204
|
exports.util = util;
|
|
2205
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2206
|
+
value: true
|
|
2207
|
+
});
|
|
1895
2208
|
return exports;
|
|
1896
2209
|
}({}, jsCadCSG, scadApi);
|
|
1897
2210
|
const debug = jscadUtils.Debug("jscadUtils:initJscadutils");
|
|
@@ -1909,7 +2222,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1909
2222
|
|
|
1910
2223
|
var jscadUtilsPluginInit = [];
|
|
1911
2224
|
|
|
1912
|
-
util = {
|
|
2225
|
+
var util = {
|
|
1913
2226
|
init: (...a) => {
|
|
1914
2227
|
initJscadutils(...a);
|
|
1915
2228
|
jscadUtilsPluginInit.forEach(p => {
|