@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
|
@@ -101,13 +101,329 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
101
101
|
});
|
|
102
102
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
103
103
|
"use strict";
|
|
104
|
-
|
|
104
|
+
function _interopDefaultLegacy(e) {
|
|
105
|
+
return e && typeof e === "object" && "default" in e ? e : {
|
|
106
|
+
default: e
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
110
|
+
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
111
|
+
var util = Object.freeze({
|
|
112
|
+
__proto__: null,
|
|
113
|
+
get NOZZEL_SIZE() {
|
|
114
|
+
return NOZZEL_SIZE;
|
|
115
|
+
},
|
|
116
|
+
get nearest() {
|
|
117
|
+
return nearest;
|
|
118
|
+
},
|
|
119
|
+
get identity() {
|
|
120
|
+
return identity;
|
|
121
|
+
},
|
|
122
|
+
get result() {
|
|
123
|
+
return result;
|
|
124
|
+
},
|
|
125
|
+
get defaults() {
|
|
126
|
+
return defaults;
|
|
127
|
+
},
|
|
128
|
+
get isEmpty() {
|
|
129
|
+
return isEmpty;
|
|
130
|
+
},
|
|
131
|
+
get isNegative() {
|
|
132
|
+
return isNegative;
|
|
133
|
+
},
|
|
134
|
+
get print() {
|
|
135
|
+
return print;
|
|
136
|
+
},
|
|
137
|
+
get jscadToString() {
|
|
138
|
+
return jscadToString;
|
|
139
|
+
},
|
|
140
|
+
get error() {
|
|
141
|
+
return error;
|
|
142
|
+
},
|
|
143
|
+
get depreciated() {
|
|
144
|
+
return depreciated;
|
|
145
|
+
},
|
|
146
|
+
get inch() {
|
|
147
|
+
return inch;
|
|
148
|
+
},
|
|
149
|
+
get cm() {
|
|
150
|
+
return cm;
|
|
151
|
+
},
|
|
152
|
+
get label() {
|
|
153
|
+
return label;
|
|
154
|
+
},
|
|
155
|
+
get text() {
|
|
156
|
+
return text;
|
|
157
|
+
},
|
|
158
|
+
get unitCube() {
|
|
159
|
+
return unitCube;
|
|
160
|
+
},
|
|
161
|
+
get unitAxis() {
|
|
162
|
+
return unitAxis;
|
|
163
|
+
},
|
|
164
|
+
get toArray() {
|
|
165
|
+
return toArray;
|
|
166
|
+
},
|
|
167
|
+
get ifArray() {
|
|
168
|
+
return ifArray;
|
|
169
|
+
},
|
|
170
|
+
get segment() {
|
|
171
|
+
return segment;
|
|
172
|
+
},
|
|
173
|
+
get zipObject() {
|
|
174
|
+
return zipObject;
|
|
175
|
+
},
|
|
176
|
+
get map() {
|
|
177
|
+
return map;
|
|
178
|
+
},
|
|
179
|
+
get mapValues() {
|
|
180
|
+
return mapValues;
|
|
181
|
+
},
|
|
182
|
+
get pick() {
|
|
183
|
+
return pick;
|
|
184
|
+
},
|
|
185
|
+
get mapPick() {
|
|
186
|
+
return mapPick;
|
|
187
|
+
},
|
|
188
|
+
get divA() {
|
|
189
|
+
return divA;
|
|
190
|
+
},
|
|
191
|
+
get divxyz() {
|
|
192
|
+
return divxyz;
|
|
193
|
+
},
|
|
194
|
+
get div() {
|
|
195
|
+
return div;
|
|
196
|
+
},
|
|
197
|
+
get mulxyz() {
|
|
198
|
+
return mulxyz;
|
|
199
|
+
},
|
|
200
|
+
get mul() {
|
|
201
|
+
return mul;
|
|
202
|
+
},
|
|
203
|
+
get xyz2array() {
|
|
204
|
+
return xyz2array;
|
|
205
|
+
},
|
|
206
|
+
get rotationAxes() {
|
|
207
|
+
return rotationAxes;
|
|
208
|
+
},
|
|
209
|
+
get size() {
|
|
210
|
+
return size;
|
|
211
|
+
},
|
|
212
|
+
get scale() {
|
|
213
|
+
return scale;
|
|
214
|
+
},
|
|
215
|
+
get center() {
|
|
216
|
+
return center;
|
|
217
|
+
},
|
|
218
|
+
get centerY() {
|
|
219
|
+
return centerY;
|
|
220
|
+
},
|
|
221
|
+
get centerX() {
|
|
222
|
+
return centerX;
|
|
223
|
+
},
|
|
224
|
+
get enlarge() {
|
|
225
|
+
return enlarge;
|
|
226
|
+
},
|
|
227
|
+
get fit() {
|
|
228
|
+
return fit;
|
|
229
|
+
},
|
|
230
|
+
get shift() {
|
|
231
|
+
return shift;
|
|
232
|
+
},
|
|
233
|
+
get zero() {
|
|
234
|
+
return zero;
|
|
235
|
+
},
|
|
236
|
+
get mirrored4() {
|
|
237
|
+
return mirrored4;
|
|
238
|
+
},
|
|
239
|
+
get flushSide() {
|
|
240
|
+
return flushSide;
|
|
241
|
+
},
|
|
242
|
+
get calcFlush() {
|
|
243
|
+
return calcFlush;
|
|
244
|
+
},
|
|
245
|
+
get calcSnap() {
|
|
246
|
+
return calcSnap;
|
|
247
|
+
},
|
|
248
|
+
get snap() {
|
|
249
|
+
return snap;
|
|
250
|
+
},
|
|
251
|
+
get flush() {
|
|
252
|
+
return flush;
|
|
253
|
+
},
|
|
254
|
+
get axisApply() {
|
|
255
|
+
return axisApply;
|
|
256
|
+
},
|
|
257
|
+
get axis2array() {
|
|
258
|
+
return axis2array;
|
|
259
|
+
},
|
|
260
|
+
get centroid() {
|
|
261
|
+
return centroid;
|
|
262
|
+
},
|
|
263
|
+
get calcmidlineTo() {
|
|
264
|
+
return calcmidlineTo;
|
|
265
|
+
},
|
|
266
|
+
get midlineTo() {
|
|
267
|
+
return midlineTo;
|
|
268
|
+
},
|
|
269
|
+
get translator() {
|
|
270
|
+
return translator;
|
|
271
|
+
},
|
|
272
|
+
get calcCenterWith() {
|
|
273
|
+
return calcCenterWith;
|
|
274
|
+
},
|
|
275
|
+
get centerWith() {
|
|
276
|
+
return centerWith;
|
|
277
|
+
},
|
|
278
|
+
get getDelta() {
|
|
279
|
+
return getDelta;
|
|
280
|
+
},
|
|
281
|
+
get bisect() {
|
|
282
|
+
return bisect;
|
|
283
|
+
},
|
|
284
|
+
get slice() {
|
|
285
|
+
return slice;
|
|
286
|
+
},
|
|
287
|
+
get wedge() {
|
|
288
|
+
return wedge;
|
|
289
|
+
},
|
|
290
|
+
get stretch() {
|
|
291
|
+
return stretch;
|
|
292
|
+
},
|
|
293
|
+
get poly2solid() {
|
|
294
|
+
return poly2solid;
|
|
295
|
+
},
|
|
296
|
+
get slices2poly() {
|
|
297
|
+
return slices2poly;
|
|
298
|
+
},
|
|
299
|
+
get normalVector() {
|
|
300
|
+
return normalVector;
|
|
301
|
+
},
|
|
302
|
+
get sliceParams() {
|
|
303
|
+
return sliceParams;
|
|
304
|
+
},
|
|
305
|
+
get reShape() {
|
|
306
|
+
return reShape;
|
|
307
|
+
},
|
|
308
|
+
get chamfer() {
|
|
309
|
+
return chamfer;
|
|
310
|
+
},
|
|
311
|
+
get fillet() {
|
|
312
|
+
return fillet;
|
|
313
|
+
},
|
|
314
|
+
get calcRotate() {
|
|
315
|
+
return calcRotate;
|
|
316
|
+
},
|
|
317
|
+
get rotateAround() {
|
|
318
|
+
return rotateAround;
|
|
319
|
+
},
|
|
320
|
+
get clone() {
|
|
321
|
+
return clone;
|
|
322
|
+
},
|
|
323
|
+
get addConnector() {
|
|
324
|
+
return addConnector;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
function _arrayLikeToArray(r, a) {
|
|
328
|
+
(null == a || a > r.length) && (a = r.length);
|
|
329
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
330
|
+
return n;
|
|
331
|
+
}
|
|
332
|
+
function _arrayWithHoles(r) {
|
|
333
|
+
if (Array.isArray(r)) return r;
|
|
334
|
+
}
|
|
335
|
+
function _defineProperty(e, r, t) {
|
|
336
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
337
|
+
value: t,
|
|
338
|
+
enumerable: !0,
|
|
339
|
+
configurable: !0,
|
|
340
|
+
writable: !0
|
|
341
|
+
}) : e[r] = t, e;
|
|
342
|
+
}
|
|
343
|
+
function _iterableToArrayLimit(r, l) {
|
|
344
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
345
|
+
if (null != t) {
|
|
346
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
347
|
+
try {
|
|
348
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
349
|
+
if (Object(t) !== t) return;
|
|
350
|
+
f = !1;
|
|
351
|
+
} else for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ;
|
|
352
|
+
} catch (r) {
|
|
353
|
+
o = !0, n = r;
|
|
354
|
+
} finally {
|
|
355
|
+
try {
|
|
356
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
357
|
+
} finally {
|
|
358
|
+
if (o) throw n;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return a;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function _nonIterableRest() {
|
|
365
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
366
|
+
}
|
|
367
|
+
function ownKeys(e, r) {
|
|
368
|
+
var t = Object.keys(e);
|
|
369
|
+
if (Object.getOwnPropertySymbols) {
|
|
370
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
371
|
+
r && (o = o.filter(function(r) {
|
|
372
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
373
|
+
})), t.push.apply(t, o);
|
|
374
|
+
}
|
|
375
|
+
return t;
|
|
376
|
+
}
|
|
377
|
+
function _objectSpread2(e) {
|
|
378
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
379
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
380
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
381
|
+
_defineProperty(e, r, t[r]);
|
|
382
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
383
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return e;
|
|
387
|
+
}
|
|
388
|
+
function _slicedToArray(r, e) {
|
|
389
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
390
|
+
}
|
|
391
|
+
function _toPrimitive(t, r) {
|
|
392
|
+
if ("object" != typeof t || !t) return t;
|
|
393
|
+
var e = t[Symbol.toPrimitive];
|
|
394
|
+
if (void 0 !== e) {
|
|
395
|
+
var i = e.call(t, r || "default");
|
|
396
|
+
if ("object" != typeof i) return i;
|
|
397
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
398
|
+
}
|
|
399
|
+
return ("string" === r ? String : Number)(t);
|
|
400
|
+
}
|
|
401
|
+
function _toPropertyKey(t) {
|
|
402
|
+
var i = _toPrimitive(t, "string");
|
|
403
|
+
return "symbol" == typeof i ? i : i + "";
|
|
404
|
+
}
|
|
405
|
+
function _typeof(o) {
|
|
406
|
+
"@babel/helpers - typeof";
|
|
407
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
408
|
+
return typeof o;
|
|
409
|
+
} : function(o) {
|
|
410
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
411
|
+
}, _typeof(o);
|
|
412
|
+
}
|
|
413
|
+
function _unsupportedIterableToArray(r, a) {
|
|
414
|
+
if (r) {
|
|
415
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
416
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
417
|
+
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;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
var toRadians = function toRadians(deg) {
|
|
105
421
|
return deg / 180 * Math.PI;
|
|
106
422
|
};
|
|
107
|
-
|
|
423
|
+
var toDegrees = function toDegrees(rad) {
|
|
108
424
|
return rad * (180 / Math.PI);
|
|
109
425
|
};
|
|
110
|
-
|
|
426
|
+
var solve = function solve(p1, p2) {
|
|
111
427
|
var r = {
|
|
112
428
|
c: 90,
|
|
113
429
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -119,7 +435,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
119
435
|
r.a = 90 - r.b;
|
|
120
436
|
return r;
|
|
121
437
|
};
|
|
122
|
-
|
|
438
|
+
var solve90SA = function solve90SA(r) {
|
|
123
439
|
r = Object.assign(r, {
|
|
124
440
|
C: 90
|
|
125
441
|
});
|
|
@@ -131,7 +447,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
131
447
|
r.b = r.b || r.a / Math.tan(arad);
|
|
132
448
|
return r;
|
|
133
449
|
};
|
|
134
|
-
|
|
450
|
+
var solve90ac = function solve90ac(r) {
|
|
135
451
|
r = Object.assign(r, {
|
|
136
452
|
C: 90
|
|
137
453
|
});
|
|
@@ -152,29 +468,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
152
468
|
}
|
|
153
469
|
var triUtils = Object.freeze({
|
|
154
470
|
__proto__: null,
|
|
471
|
+
toRadians,
|
|
472
|
+
toDegrees,
|
|
155
473
|
solve,
|
|
156
474
|
solve90SA,
|
|
157
475
|
solve90ac,
|
|
158
|
-
solveab
|
|
159
|
-
toDegrees,
|
|
160
|
-
toRadians
|
|
476
|
+
solveab
|
|
161
477
|
});
|
|
162
|
-
|
|
478
|
+
var div$1 = function div(a, f) {
|
|
163
479
|
return a.map(function(e) {
|
|
164
480
|
return e / f;
|
|
165
481
|
});
|
|
166
482
|
};
|
|
167
|
-
|
|
483
|
+
var addValue = function addValue(a, f) {
|
|
168
484
|
return a.map(function(e) {
|
|
169
485
|
return e + f;
|
|
170
486
|
});
|
|
171
487
|
};
|
|
172
|
-
|
|
488
|
+
var addArray = function addArray(a, f) {
|
|
173
489
|
return a.map(function(e, i) {
|
|
174
490
|
return e + f[i];
|
|
175
491
|
});
|
|
176
492
|
};
|
|
177
|
-
|
|
493
|
+
var add = function add(a) {
|
|
178
494
|
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
179
495
|
if (Array.isArray(arg)) {
|
|
180
496
|
result = addArray(result, arg);
|
|
@@ -184,28 +500,28 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
184
500
|
return result;
|
|
185
501
|
}, a);
|
|
186
502
|
};
|
|
187
|
-
|
|
503
|
+
var fromxyz = function fromxyz(object) {
|
|
188
504
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
189
505
|
};
|
|
190
|
-
|
|
506
|
+
var toxyz = function toxyz(a) {
|
|
191
507
|
return {
|
|
192
508
|
x: a[0],
|
|
193
509
|
y: a[1],
|
|
194
510
|
z: a[2]
|
|
195
511
|
};
|
|
196
512
|
};
|
|
197
|
-
|
|
513
|
+
var first = function first(a) {
|
|
198
514
|
return a ? a[0] : undefined;
|
|
199
515
|
};
|
|
200
|
-
|
|
516
|
+
var last = function last(a) {
|
|
201
517
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
202
518
|
};
|
|
203
|
-
|
|
519
|
+
var min = function min(a) {
|
|
204
520
|
return a.reduce(function(result, value) {
|
|
205
521
|
return value < result ? value : result;
|
|
206
522
|
}, Number.MAX_VALUE);
|
|
207
523
|
};
|
|
208
|
-
|
|
524
|
+
var range = function range(a, b) {
|
|
209
525
|
var result = [];
|
|
210
526
|
for (var i = a; i < b; i++) {
|
|
211
527
|
result.push(i);
|
|
@@ -214,21 +530,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
214
530
|
};
|
|
215
531
|
var array = Object.freeze({
|
|
216
532
|
__proto__: null,
|
|
217
|
-
add,
|
|
218
|
-
addArray,
|
|
219
|
-
addValue,
|
|
220
533
|
div: div$1,
|
|
221
|
-
|
|
534
|
+
addValue,
|
|
535
|
+
addArray,
|
|
536
|
+
add,
|
|
222
537
|
fromxyz,
|
|
538
|
+
toxyz,
|
|
539
|
+
first,
|
|
223
540
|
last,
|
|
224
541
|
min,
|
|
225
|
-
range
|
|
226
|
-
toxyz
|
|
542
|
+
range
|
|
227
543
|
});
|
|
228
|
-
|
|
229
|
-
|
|
544
|
+
var debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
545
|
+
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" ];
|
|
230
546
|
var debugCount = 0;
|
|
231
|
-
|
|
547
|
+
var Debug = function Debug(name) {
|
|
232
548
|
var checks = Object.assign({
|
|
233
549
|
enabled: [],
|
|
234
550
|
disabled: [],
|
|
@@ -236,21 +552,31 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
236
552
|
browser: true
|
|
237
553
|
}
|
|
238
554
|
}, jscadUtilsDebug || {});
|
|
239
|
-
var style = checks.options.browser ?
|
|
555
|
+
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
240
556
|
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
241
557
|
return check.test(name);
|
|
242
558
|
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
243
559
|
return check.test(name);
|
|
244
560
|
});
|
|
245
|
-
var logger = enabled ? checks.options.browser ? (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
561
|
+
var logger = enabled ? checks.options.browser ? function() {
|
|
562
|
+
var _console;
|
|
563
|
+
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
564
|
+
msg[_key] = arguments[_key];
|
|
565
|
+
}
|
|
566
|
+
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
567
|
+
} : function() {
|
|
568
|
+
var _console2;
|
|
569
|
+
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
570
|
+
msg[_key2] = arguments[_key2];
|
|
571
|
+
}
|
|
572
|
+
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
573
|
+
} : function() {
|
|
574
|
+
return undefined;
|
|
575
|
+
};
|
|
250
576
|
logger.enabled = enabled;
|
|
251
577
|
return logger;
|
|
252
578
|
};
|
|
253
|
-
|
|
579
|
+
var nameArray = {
|
|
254
580
|
aliceblue: "#f0f8ff",
|
|
255
581
|
antiquewhite: "#faebd7",
|
|
256
582
|
aqua: "#00ffff",
|
|
@@ -412,7 +738,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
412
738
|
return [ 0, 0, 0 ];
|
|
413
739
|
}
|
|
414
740
|
}
|
|
415
|
-
|
|
741
|
+
var _name2rgb = {};
|
|
416
742
|
function name2rgb(n) {
|
|
417
743
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
418
744
|
return _name2rgb[n];
|
|
@@ -492,14 +818,23 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
492
818
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
493
819
|
return chamfer(this, radius, orientation, options);
|
|
494
820
|
};
|
|
495
|
-
proto.prototype.bisect = function bisect$1(
|
|
496
|
-
|
|
821
|
+
proto.prototype.bisect = function bisect$1() {
|
|
822
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
823
|
+
args[_key] = arguments[_key];
|
|
824
|
+
}
|
|
825
|
+
return bisect.apply(util, [ this ].concat(args));
|
|
497
826
|
};
|
|
498
|
-
proto.prototype.slice = function slice$1(
|
|
499
|
-
|
|
827
|
+
proto.prototype.slice = function slice$1() {
|
|
828
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
829
|
+
args[_key2] = arguments[_key2];
|
|
830
|
+
}
|
|
831
|
+
return slice.apply(util, [ this ].concat(args));
|
|
500
832
|
};
|
|
501
|
-
proto.prototype.wedge = function wedge$1(
|
|
502
|
-
|
|
833
|
+
proto.prototype.wedge = function wedge$1() {
|
|
834
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
835
|
+
args[_key3] = arguments[_key3];
|
|
836
|
+
}
|
|
837
|
+
return wedge.apply(util, [ this ].concat(args));
|
|
503
838
|
};
|
|
504
839
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
505
840
|
return stretch(this, axis, distance, offset);
|
|
@@ -516,7 +851,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
516
851
|
return this._translate(arguments[0]);
|
|
517
852
|
} else {
|
|
518
853
|
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
519
|
-
result = undefined
|
|
854
|
+
result = undefined(result, arg);
|
|
520
855
|
return result;
|
|
521
856
|
}, [ 0, 0, 0 ]);
|
|
522
857
|
return this._translate(t);
|
|
@@ -525,10 +860,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
525
860
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
526
861
|
return addConnector(this, name, point, axis, normal);
|
|
527
862
|
};
|
|
528
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector
|
|
529
|
-
var
|
|
863
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
864
|
+
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
865
|
+
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
866
|
+
var myConnector = myConnectorName.split(".").reduce(function(a, v) {
|
|
867
|
+
return a[v];
|
|
868
|
+
}, this.properties);
|
|
530
869
|
if (!myConnector) {
|
|
531
|
-
error(
|
|
870
|
+
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
|
|
532
871
|
}
|
|
533
872
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
534
873
|
};
|
|
@@ -538,13 +877,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
538
877
|
__proto__: null,
|
|
539
878
|
default: init
|
|
540
879
|
});
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
880
|
+
var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
|
|
881
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
882
|
+
var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
|
|
883
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
545
884
|
init(CSG);
|
|
546
|
-
|
|
547
|
-
function JsCadUtilsGroup(
|
|
885
|
+
var debug$3 = Debug("jscadUtils:group");
|
|
886
|
+
function JsCadUtilsGroup() {
|
|
887
|
+
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
888
|
+
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
889
|
+
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
548
890
|
this.name = "";
|
|
549
891
|
this.names = names;
|
|
550
892
|
this.parts = parts;
|
|
@@ -572,7 +914,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
572
914
|
}
|
|
573
915
|
return self;
|
|
574
916
|
};
|
|
575
|
-
JsCadUtilsGroup.prototype.combine = function(pieces
|
|
917
|
+
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
918
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
919
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
920
|
+
return x;
|
|
921
|
+
};
|
|
576
922
|
try {
|
|
577
923
|
var self = this;
|
|
578
924
|
options = Object.assign({
|
|
@@ -580,7 +926,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
580
926
|
}, options);
|
|
581
927
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
582
928
|
if (pieces.length === 0) {
|
|
583
|
-
throw new Error(
|
|
929
|
+
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
584
930
|
}
|
|
585
931
|
debug$3("combine", self.names, self.parts);
|
|
586
932
|
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
@@ -590,12 +936,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
590
936
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
591
937
|
} catch (err) {
|
|
592
938
|
debug$3("combine error", this, pieces, options, err);
|
|
593
|
-
throw error(
|
|
939
|
+
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");
|
|
594
940
|
}
|
|
595
941
|
};
|
|
596
942
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
597
943
|
var self = this;
|
|
598
|
-
self.parts = Object.keys(self.parts).filter(
|
|
944
|
+
self.parts = Object.keys(self.parts).filter(function(k) {
|
|
945
|
+
return k !== "holes";
|
|
946
|
+
}).reduce(function(result, key) {
|
|
599
947
|
result[key] = cb(self.parts[key], key);
|
|
600
948
|
return result;
|
|
601
949
|
}, {});
|
|
@@ -611,7 +959,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
611
959
|
return self;
|
|
612
960
|
};
|
|
613
961
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
614
|
-
debug$3("clone", name,
|
|
962
|
+
debug$3("clone", name, _typeof(name), map);
|
|
615
963
|
var self = this;
|
|
616
964
|
if (typeof name == "function") {
|
|
617
965
|
map = name;
|
|
@@ -663,7 +1011,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
663
1011
|
return self;
|
|
664
1012
|
} catch (err) {
|
|
665
1013
|
debug$3("snap error", this, part, to, axis, delta, err);
|
|
666
|
-
throw error(
|
|
1014
|
+
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");
|
|
667
1015
|
}
|
|
668
1016
|
};
|
|
669
1017
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -678,7 +1026,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
678
1026
|
return self;
|
|
679
1027
|
} catch (err) {
|
|
680
1028
|
debug$3("align error", this, part, to, axis, delta, err);
|
|
681
|
-
throw error(
|
|
1029
|
+
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");
|
|
682
1030
|
}
|
|
683
1031
|
};
|
|
684
1032
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -690,7 +1038,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
690
1038
|
var bounds = self.parts[part].getBounds();
|
|
691
1039
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
692
1040
|
};
|
|
693
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName
|
|
1041
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
1042
|
+
var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1043
|
+
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
694
1044
|
debug$3("connectTo", {
|
|
695
1045
|
partName,
|
|
696
1046
|
connectorName,
|
|
@@ -700,9 +1050,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
700
1050
|
normalrotation
|
|
701
1051
|
});
|
|
702
1052
|
var self = this;
|
|
703
|
-
var myConnector = connectorName.split(".").reduce((a, v)
|
|
1053
|
+
var myConnector = connectorName.split(".").reduce(function(a, v) {
|
|
1054
|
+
return a[v];
|
|
1055
|
+
}, self.parts[partName].properties);
|
|
704
1056
|
debug$3("toConnector", to instanceof CSG.Connector);
|
|
705
|
-
var toConnector = toConnectorName.split(".").reduce((a, v)
|
|
1057
|
+
var toConnector = toConnectorName.split(".").reduce(function(a, v) {
|
|
1058
|
+
return a[v];
|
|
1059
|
+
}, to.properties);
|
|
706
1060
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
707
1061
|
debug$3("connectTo", matrix);
|
|
708
1062
|
self.map(function(part) {
|
|
@@ -741,14 +1095,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
741
1095
|
return g;
|
|
742
1096
|
};
|
|
743
1097
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1098
|
+
var _this = this;
|
|
744
1099
|
var self = this;
|
|
745
1100
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
746
1101
|
if (!map) map = identity;
|
|
747
1102
|
var a = [];
|
|
748
|
-
p.forEach(name
|
|
1103
|
+
p.forEach(function(name) {
|
|
749
1104
|
if (!self.parts[name]) {
|
|
750
|
-
debug$3("array error",
|
|
751
|
-
throw error(
|
|
1105
|
+
debug$3("array error", _this, parts);
|
|
1106
|
+
throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
|
|
752
1107
|
}
|
|
753
1108
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
754
1109
|
});
|
|
@@ -758,12 +1113,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
758
1113
|
var self = this;
|
|
759
1114
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
760
1115
|
return piecesArray.map(function(piece) {
|
|
761
|
-
if (!self.parts[piece]) console.error(
|
|
1116
|
+
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
762
1117
|
return self.parts[piece];
|
|
763
1118
|
});
|
|
764
1119
|
};
|
|
765
1120
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
766
|
-
return
|
|
1121
|
+
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}");
|
|
767
1122
|
};
|
|
768
1123
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
769
1124
|
this.name = name;
|
|
@@ -793,7 +1148,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
793
1148
|
self.name = objectNames;
|
|
794
1149
|
} else {
|
|
795
1150
|
var objects = objectNames;
|
|
796
|
-
self.names = Object.keys(objects).filter(k
|
|
1151
|
+
self.names = Object.keys(objects).filter(function(k) {
|
|
1152
|
+
return k !== "holes";
|
|
1153
|
+
});
|
|
797
1154
|
self.parts = Object.assign({}, objects);
|
|
798
1155
|
self.holes = objects.holes;
|
|
799
1156
|
}
|
|
@@ -801,13 +1158,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
801
1158
|
}
|
|
802
1159
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
803
1160
|
}
|
|
804
|
-
|
|
1161
|
+
var debug$2 = Debug("jscadUtils:util");
|
|
805
1162
|
var NOZZEL_SIZE = .4;
|
|
806
|
-
|
|
807
|
-
under: function(desired
|
|
1163
|
+
var nearest = {
|
|
1164
|
+
under: function under(desired) {
|
|
1165
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1166
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
808
1167
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
809
1168
|
},
|
|
810
|
-
over: function(desired
|
|
1169
|
+
over: function over(desired) {
|
|
1170
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1171
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
811
1172
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
812
1173
|
}
|
|
813
1174
|
};
|
|
@@ -835,9 +1196,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
835
1196
|
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
836
1197
|
}
|
|
837
1198
|
function jscadToString(o) {
|
|
838
|
-
if (
|
|
1199
|
+
if (_typeof(o) == "object") {
|
|
839
1200
|
if (o.polygons) {
|
|
840
|
-
return
|
|
1201
|
+
return "{\npolygons: ".concat(o.polygons.length, ',\nproperties: "').concat(Object.keys(o.properties), '"\n}\n');
|
|
841
1202
|
}
|
|
842
1203
|
} else {
|
|
843
1204
|
return o.toString();
|
|
@@ -878,12 +1239,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
878
1239
|
}
|
|
879
1240
|
function text(text) {
|
|
880
1241
|
var l = vector_char(0, 0, text);
|
|
881
|
-
var
|
|
1242
|
+
var _char = l.segments.reduce(function(result, segment) {
|
|
882
1243
|
var path = new CSG.Path2D(segment);
|
|
883
1244
|
var cag = path.expandToCAG(2);
|
|
884
1245
|
return result ? result.union(cag) : cag;
|
|
885
1246
|
}, undefined);
|
|
886
|
-
return
|
|
1247
|
+
return _char;
|
|
887
1248
|
}
|
|
888
1249
|
function unitCube(length, radius) {
|
|
889
1250
|
radius = radius || .5;
|
|
@@ -939,7 +1300,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
939
1300
|
function mapPick(o, names, f, options) {
|
|
940
1301
|
return names.reduce(function(result, name, index) {
|
|
941
1302
|
if (!o[name]) {
|
|
942
|
-
throw new Error(
|
|
1303
|
+
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
|
|
943
1304
|
}
|
|
944
1305
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
945
1306
|
return result;
|
|
@@ -971,7 +1332,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
971
1332
|
function xyz2array(size) {
|
|
972
1333
|
return [ size.x, size.y, size.z ];
|
|
973
1334
|
}
|
|
974
|
-
|
|
1335
|
+
var rotationAxes = {
|
|
975
1336
|
x: [ 1, 0, 0 ],
|
|
976
1337
|
y: [ 0, 1, 0 ],
|
|
977
1338
|
z: [ 0, 0, 1 ]
|
|
@@ -1049,7 +1410,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1049
1410
|
function mirrored4(x) {
|
|
1050
1411
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1051
1412
|
}
|
|
1052
|
-
|
|
1413
|
+
var flushSide = {
|
|
1053
1414
|
"above-outside": [ 1, 0 ],
|
|
1054
1415
|
"above-inside": [ 1, 1 ],
|
|
1055
1416
|
"below-outside": [ 0, 1 ],
|
|
@@ -1079,7 +1440,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1079
1440
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1080
1441
|
});
|
|
1081
1442
|
}
|
|
1082
|
-
function calcSnap(moveobj, withobj, axes, orientation
|
|
1443
|
+
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1444
|
+
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1083
1445
|
var side = flushSide[orientation];
|
|
1084
1446
|
if (!side) {
|
|
1085
1447
|
var fix = {
|
|
@@ -1145,7 +1507,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1145
1507
|
objectSize = objectSize || size(bounds);
|
|
1146
1508
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1147
1509
|
} catch (err) {
|
|
1148
|
-
error(
|
|
1510
|
+
error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
|
|
1149
1511
|
}
|
|
1150
1512
|
}
|
|
1151
1513
|
function calcmidlineTo(o, axis, to) {
|
|
@@ -1166,7 +1528,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1166
1528
|
});
|
|
1167
1529
|
return t;
|
|
1168
1530
|
}
|
|
1169
|
-
function calcCenterWith(o, axes, withObj
|
|
1531
|
+
function calcCenterWith(o, axes, withObj) {
|
|
1532
|
+
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1170
1533
|
var objectCentroid = centroid(o);
|
|
1171
1534
|
var withCentroid = centroid(withObj);
|
|
1172
1535
|
var t = axisApply(axes, function(i, axis) {
|
|
@@ -1188,7 +1551,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1188
1551
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1189
1552
|
});
|
|
1190
1553
|
}
|
|
1191
|
-
function bisect(
|
|
1554
|
+
function bisect() {
|
|
1555
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1556
|
+
args[_key] = arguments[_key];
|
|
1557
|
+
}
|
|
1192
1558
|
if (args.length < 2) {
|
|
1193
1559
|
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1194
1560
|
}
|
|
@@ -1269,10 +1635,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1269
1635
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1270
1636
|
return g;
|
|
1271
1637
|
}
|
|
1272
|
-
function slice(object
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1638
|
+
function slice(object) {
|
|
1639
|
+
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
|
|
1640
|
+
var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "x";
|
|
1641
|
+
var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "z";
|
|
1642
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1643
|
+
color: true,
|
|
1644
|
+
addRotationCenter: true
|
|
1645
|
+
};
|
|
1276
1646
|
var info = normalVector(axis);
|
|
1277
1647
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1278
1648
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1489,11 +1859,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1489
1859
|
};
|
|
1490
1860
|
}
|
|
1491
1861
|
function rotateAround(part, solid, axis, angle) {
|
|
1492
|
-
var
|
|
1862
|
+
var _calcRotate = calcRotate(part, solid, axis), rotationCenter = _calcRotate.rotationCenter, rotationAxis = _calcRotate.rotationAxis;
|
|
1493
1863
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1494
1864
|
}
|
|
1495
|
-
function cloneProperties(from, to
|
|
1496
|
-
return Object.entries(from).reduce((props,
|
|
1865
|
+
function cloneProperties(from, to) {
|
|
1866
|
+
return Object.entries(from).reduce(function(props, _ref) {
|
|
1867
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1497
1868
|
props[key] = value;
|
|
1498
1869
|
return props;
|
|
1499
1870
|
}, to);
|
|
@@ -1504,85 +1875,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1504
1875
|
debug$2("clone", o, c, CSG);
|
|
1505
1876
|
return c;
|
|
1506
1877
|
}
|
|
1507
|
-
function addConnector(object, name
|
|
1878
|
+
function addConnector(object, name) {
|
|
1879
|
+
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1880
|
+
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1881
|
+
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1508
1882
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1509
1883
|
return object;
|
|
1510
1884
|
}
|
|
1511
|
-
var
|
|
1512
|
-
__proto__: null,
|
|
1513
|
-
NOZZEL_SIZE,
|
|
1514
|
-
addConnector,
|
|
1515
|
-
axis2array,
|
|
1516
|
-
axisApply,
|
|
1517
|
-
bisect,
|
|
1518
|
-
calcCenterWith,
|
|
1519
|
-
calcFlush,
|
|
1520
|
-
calcRotate,
|
|
1521
|
-
calcSnap,
|
|
1522
|
-
calcmidlineTo,
|
|
1523
|
-
center,
|
|
1524
|
-
centerWith,
|
|
1525
|
-
centerX,
|
|
1526
|
-
centerY,
|
|
1527
|
-
centroid,
|
|
1528
|
-
chamfer,
|
|
1529
|
-
clone,
|
|
1530
|
-
cm,
|
|
1531
|
-
defaults,
|
|
1532
|
-
depreciated,
|
|
1533
|
-
div,
|
|
1534
|
-
divA,
|
|
1535
|
-
divxyz,
|
|
1536
|
-
enlarge,
|
|
1537
|
-
error,
|
|
1538
|
-
fillet,
|
|
1539
|
-
fit,
|
|
1540
|
-
flush,
|
|
1541
|
-
flushSide,
|
|
1542
|
-
getDelta,
|
|
1543
|
-
identity,
|
|
1544
|
-
ifArray,
|
|
1545
|
-
inch,
|
|
1546
|
-
isEmpty,
|
|
1547
|
-
isNegative,
|
|
1548
|
-
jscadToString,
|
|
1549
|
-
label,
|
|
1550
|
-
map,
|
|
1551
|
-
mapPick,
|
|
1552
|
-
mapValues,
|
|
1553
|
-
midlineTo,
|
|
1554
|
-
mirrored4,
|
|
1555
|
-
mul,
|
|
1556
|
-
mulxyz,
|
|
1557
|
-
nearest,
|
|
1558
|
-
normalVector,
|
|
1559
|
-
pick,
|
|
1560
|
-
poly2solid,
|
|
1561
|
-
print,
|
|
1562
|
-
reShape,
|
|
1563
|
-
result,
|
|
1564
|
-
rotateAround,
|
|
1565
|
-
rotationAxes,
|
|
1566
|
-
scale,
|
|
1567
|
-
segment,
|
|
1568
|
-
shift,
|
|
1569
|
-
size,
|
|
1570
|
-
slice,
|
|
1571
|
-
sliceParams,
|
|
1572
|
-
slices2poly,
|
|
1573
|
-
snap,
|
|
1574
|
-
stretch,
|
|
1575
|
-
text,
|
|
1576
|
-
toArray,
|
|
1577
|
-
translator,
|
|
1578
|
-
unitAxis,
|
|
1579
|
-
unitCube,
|
|
1580
|
-
wedge,
|
|
1581
|
-
xyz2array,
|
|
1582
|
-
zero,
|
|
1583
|
-
zipObject
|
|
1584
|
-
});
|
|
1585
|
-
const debug$1 = Debug("jscadUtils:parts");
|
|
1885
|
+
var debug$1 = Debug("jscadUtils:parts");
|
|
1586
1886
|
var parts = {
|
|
1587
1887
|
BBox: BBox$1,
|
|
1588
1888
|
Cube,
|
|
@@ -1590,13 +1890,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1590
1890
|
Cylinder,
|
|
1591
1891
|
Cone
|
|
1592
1892
|
};
|
|
1593
|
-
function BBox$1(
|
|
1893
|
+
function BBox$1() {
|
|
1594
1894
|
function box(object) {
|
|
1595
1895
|
return CSG.cube({
|
|
1596
1896
|
center: object.centroid(),
|
|
1597
1897
|
radius: object.size().dividedBy(2)
|
|
1598
1898
|
});
|
|
1599
1899
|
}
|
|
1900
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1901
|
+
objects[_key] = arguments[_key];
|
|
1902
|
+
}
|
|
1600
1903
|
return objects.reduce(function(bbox, part) {
|
|
1601
1904
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1602
1905
|
return box(object);
|
|
@@ -1629,7 +1932,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1629
1932
|
});
|
|
1630
1933
|
return roundedcube;
|
|
1631
1934
|
}
|
|
1632
|
-
function Cylinder(diameter, height
|
|
1935
|
+
function Cylinder(diameter, height) {
|
|
1936
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1633
1937
|
debug$1("parts.Cylinder", diameter, height, options);
|
|
1634
1938
|
options = Object.assign({
|
|
1635
1939
|
start: [ 0, 0, 0 ],
|
|
@@ -1639,7 +1943,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1639
1943
|
}, options);
|
|
1640
1944
|
return CSG.cylinder(options);
|
|
1641
1945
|
}
|
|
1642
|
-
function Cone(diameter1, diameter2, height
|
|
1946
|
+
function Cone(diameter1, diameter2, height) {
|
|
1947
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1643
1948
|
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1644
1949
|
return CSG.cylinder(Object.assign({
|
|
1645
1950
|
start: [ 0, 0, 0 ],
|
|
@@ -1668,7 +1973,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1668
1973
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1669
1974
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1670
1975
|
}
|
|
1671
|
-
function Anchor(
|
|
1976
|
+
function Anchor() {
|
|
1977
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1978
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1672
1979
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1673
1980
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1674
1981
|
return Group({
|
|
@@ -1688,7 +1995,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1688
1995
|
});
|
|
1689
1996
|
return board;
|
|
1690
1997
|
}
|
|
1691
|
-
|
|
1998
|
+
var Hardware = {
|
|
1692
1999
|
Orientation: {
|
|
1693
2000
|
up: {
|
|
1694
2001
|
head: "outside-",
|
|
@@ -1699,7 +2006,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1699
2006
|
clear: "inside-"
|
|
1700
2007
|
}
|
|
1701
2008
|
},
|
|
1702
|
-
Screw: function(head, thread, headClearSpace, options) {
|
|
2009
|
+
Screw: function Screw(head, thread, headClearSpace, options) {
|
|
1703
2010
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1704
2011
|
options = Object.assign(options, {
|
|
1705
2012
|
orientation: "up",
|
|
@@ -1715,7 +2022,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1715
2022
|
}
|
|
1716
2023
|
return group;
|
|
1717
2024
|
},
|
|
1718
|
-
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2025
|
+
PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1719
2026
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1720
2027
|
var head = Cylinder(headDiameter, headLength);
|
|
1721
2028
|
var thread = Cylinder(diameter, length);
|
|
@@ -1724,7 +2031,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1724
2031
|
}
|
|
1725
2032
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1726
2033
|
},
|
|
1727
|
-
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2034
|
+
HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1728
2035
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1729
2036
|
var head = Hexagon(headDiameter, headLength);
|
|
1730
2037
|
var thread = Cylinder(diameter, length);
|
|
@@ -1733,7 +2040,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1733
2040
|
}
|
|
1734
2041
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1735
2042
|
},
|
|
1736
|
-
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2043
|
+
FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1737
2044
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1738
2045
|
var head = Cone(headDiameter, diameter, headLength);
|
|
1739
2046
|
var thread = Cylinder(diameter, length);
|
|
@@ -1745,20 +2052,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1745
2052
|
};
|
|
1746
2053
|
var parts$1 = Object.freeze({
|
|
1747
2054
|
__proto__: null,
|
|
1748
|
-
|
|
2055
|
+
default: parts,
|
|
1749
2056
|
BBox: BBox$1,
|
|
1750
|
-
Board,
|
|
1751
|
-
Cone,
|
|
1752
2057
|
Cube,
|
|
2058
|
+
RoundedCube,
|
|
1753
2059
|
Cylinder,
|
|
1754
|
-
|
|
2060
|
+
Cone,
|
|
1755
2061
|
Hexagon,
|
|
1756
|
-
RoundedCube,
|
|
1757
2062
|
Triangle,
|
|
1758
2063
|
Tube,
|
|
1759
|
-
|
|
2064
|
+
Anchor,
|
|
2065
|
+
Board,
|
|
2066
|
+
Hardware
|
|
1760
2067
|
});
|
|
1761
|
-
|
|
2068
|
+
var debug = Debug("jscadUtils:boxes");
|
|
1762
2069
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
1763
2070
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
1764
2071
|
return rabbetJoin(box, thickness, cutHeight);
|
|
@@ -1771,16 +2078,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1771
2078
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
1772
2079
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
1773
2080
|
}
|
|
1774
|
-
function Rabett(box, thickness, gap, height, face
|
|
2081
|
+
function Rabett(box, thickness, gap, height, face) {
|
|
2082
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1775
2083
|
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1776
2084
|
gap = gap || .25;
|
|
1777
2085
|
var inside = thickness - gap;
|
|
1778
2086
|
var outside = -thickness + gap;
|
|
1779
2087
|
debug("inside", inside, "outside", outside);
|
|
1780
2088
|
var group = Group();
|
|
1781
|
-
var
|
|
2089
|
+
var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
|
|
1782
2090
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
1783
|
-
var
|
|
2091
|
+
var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
|
|
1784
2092
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
1785
2093
|
group.add(top.union(middleTop), "top");
|
|
1786
2094
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -1789,7 +2097,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1789
2097
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
1790
2098
|
return group;
|
|
1791
2099
|
}
|
|
1792
|
-
|
|
2100
|
+
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
2101
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2102
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1793
2103
|
options = Object.assign({
|
|
1794
2104
|
removableTop: true,
|
|
1795
2105
|
removableBottom: true,
|
|
@@ -1822,7 +2132,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1822
2132
|
}
|
|
1823
2133
|
return group;
|
|
1824
2134
|
};
|
|
1825
|
-
|
|
2135
|
+
var CutOut = function cutOut(o, h, box, plug, gap) {
|
|
1826
2136
|
gap = gap || .25;
|
|
1827
2137
|
var s = o.size();
|
|
1828
2138
|
var cutout = o.intersect(box);
|
|
@@ -1840,7 +2150,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1840
2150
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
1841
2151
|
});
|
|
1842
2152
|
};
|
|
1843
|
-
|
|
2153
|
+
var Rectangle = function Rectangle(size, thickness, cb) {
|
|
1844
2154
|
thickness = thickness || 2;
|
|
1845
2155
|
var s = div$1(xyz2array(size), 2);
|
|
1846
2156
|
var r = add(s, thickness);
|
|
@@ -1854,7 +2164,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1854
2164
|
if (cb) box = cb(box);
|
|
1855
2165
|
return box;
|
|
1856
2166
|
};
|
|
1857
|
-
|
|
2167
|
+
var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
|
|
1858
2168
|
thickness = thickness || 2;
|
|
1859
2169
|
var size = -thickness * 2;
|
|
1860
2170
|
interiorcb = interiorcb || identity;
|
|
@@ -1862,7 +2172,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1862
2172
|
if (exteriorcb) box = exteriorcb(box);
|
|
1863
2173
|
return box;
|
|
1864
2174
|
};
|
|
1865
|
-
|
|
2175
|
+
var BBox = function BBox(o) {
|
|
1866
2176
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
1867
2177
|
var s = div$1(xyz2array(o.size()), 2);
|
|
1868
2178
|
return CSG.cube({
|
|
@@ -1873,7 +2183,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1873
2183
|
function getRadius(o) {
|
|
1874
2184
|
return div$1(xyz2array(o.size()), 2);
|
|
1875
2185
|
}
|
|
1876
|
-
function rabbetJoin(box, thickness
|
|
2186
|
+
function rabbetJoin(box, thickness) {
|
|
2187
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1877
2188
|
var r = add(getRadius(box), -thickness / 2);
|
|
1878
2189
|
r[2] = thickness / 2;
|
|
1879
2190
|
var cutter = CSG.cube({
|
|
@@ -1891,17 +2202,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1891
2202
|
}
|
|
1892
2203
|
var Boxes = Object.freeze({
|
|
1893
2204
|
__proto__: null,
|
|
1894
|
-
BBox,
|
|
1895
|
-
CutOut,
|
|
1896
|
-
Hollow,
|
|
1897
2205
|
RabbetJoin,
|
|
2206
|
+
topMiddleBottom,
|
|
1898
2207
|
Rabett,
|
|
1899
2208
|
RabettTopBottom,
|
|
2209
|
+
CutOut,
|
|
1900
2210
|
Rectangle,
|
|
1901
|
-
|
|
2211
|
+
Hollow,
|
|
2212
|
+
BBox
|
|
1902
2213
|
});
|
|
1903
|
-
|
|
1904
|
-
...util,
|
|
2214
|
+
var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
|
|
1905
2215
|
group: Group,
|
|
1906
2216
|
init: init$1,
|
|
1907
2217
|
triangle: triUtils,
|
|
@@ -1909,7 +2219,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1909
2219
|
parts: parts$1,
|
|
1910
2220
|
Boxes,
|
|
1911
2221
|
Debug
|
|
1912
|
-
};
|
|
2222
|
+
});
|
|
1913
2223
|
exports.Boxes = Boxes;
|
|
1914
2224
|
exports.Debug = Debug;
|
|
1915
2225
|
exports.Group = Group;
|
|
@@ -1919,6 +2229,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1919
2229
|
exports.parts = parts$1;
|
|
1920
2230
|
exports.triUtils = triUtils;
|
|
1921
2231
|
exports.util = util;
|
|
2232
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2233
|
+
value: true
|
|
2234
|
+
});
|
|
1922
2235
|
return exports;
|
|
1923
2236
|
}({}, jsCadCSG, scadApi);
|
|
1924
2237
|
const debug = jscadUtils.Debug("jscadUtils:initJscadutils");
|
|
@@ -1936,7 +2249,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1936
2249
|
|
|
1937
2250
|
var jscadUtilsPluginInit = [];
|
|
1938
2251
|
|
|
1939
|
-
util = {
|
|
2252
|
+
var util = {
|
|
1940
2253
|
init: (...a) => {
|
|
1941
2254
|
initJscadutils(...a);
|
|
1942
2255
|
jscadUtilsPluginInit.forEach(p => {
|