@jwc/jscad-utils 4.8.4 → 5.0.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/README.md +4 -4
- package/dist/compat.js +659 -841
- package/dist/examples/bisect.jscad +342 -658
- package/dist/examples/boxes.jscad +342 -658
- package/dist/examples/chamfer.jscad +342 -658
- package/dist/examples/fillet.jscad +342 -658
- package/dist/examples/fit.jscad +342 -658
- package/dist/examples/groups.jscad +342 -658
- package/dist/examples/midlineTo.jscad +342 -658
- package/dist/examples/parts-hexagon.jscad +342 -658
- package/dist/examples/rabett-tb.jscad +342 -658
- package/dist/examples/rabett.jscad +342 -658
- package/dist/examples/rabett2.jscad +342 -658
- package/dist/examples/retraction-test.jscad +342 -658
- package/dist/examples/size.jscad +342 -658
- package/dist/examples/snap.jscad +342 -658
- package/dist/examples/text.jscad +342 -658
- package/dist/examples/wedge.jscad +342 -658
- package/dist/index.js +659 -841
- package/package.json +16 -52
- package/src/add-prototype.js +87 -7
- package/src/boxes.js +1 -1
- package/src/color.js +36 -46
- package/src/util.js +35 -33
package/dist/examples/text.jscad
CHANGED
|
@@ -54,335 +54,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
54
54
|
});
|
|
55
55
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
56
56
|
"use strict";
|
|
57
|
-
function
|
|
58
|
-
return e && typeof e === "object" && "default" in e ? e : {
|
|
59
|
-
default: e
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
63
|
-
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
64
|
-
var util = Object.freeze({
|
|
65
|
-
__proto__: null,
|
|
66
|
-
get NOZZEL_SIZE() {
|
|
67
|
-
return NOZZEL_SIZE;
|
|
68
|
-
},
|
|
69
|
-
get nearest() {
|
|
70
|
-
return nearest;
|
|
71
|
-
},
|
|
72
|
-
get identity() {
|
|
73
|
-
return identity;
|
|
74
|
-
},
|
|
75
|
-
get result() {
|
|
76
|
-
return result;
|
|
77
|
-
},
|
|
78
|
-
get defaults() {
|
|
79
|
-
return defaults;
|
|
80
|
-
},
|
|
81
|
-
get isEmpty() {
|
|
82
|
-
return isEmpty;
|
|
83
|
-
},
|
|
84
|
-
get isNegative() {
|
|
85
|
-
return isNegative;
|
|
86
|
-
},
|
|
87
|
-
get print() {
|
|
88
|
-
return print;
|
|
89
|
-
},
|
|
90
|
-
get jscadToString() {
|
|
91
|
-
return jscadToString;
|
|
92
|
-
},
|
|
93
|
-
get error() {
|
|
94
|
-
return error;
|
|
95
|
-
},
|
|
96
|
-
get depreciated() {
|
|
97
|
-
return depreciated;
|
|
98
|
-
},
|
|
99
|
-
get inch() {
|
|
100
|
-
return inch;
|
|
101
|
-
},
|
|
102
|
-
get cm() {
|
|
103
|
-
return cm;
|
|
104
|
-
},
|
|
105
|
-
get label() {
|
|
106
|
-
return label;
|
|
107
|
-
},
|
|
108
|
-
get text() {
|
|
109
|
-
return text;
|
|
110
|
-
},
|
|
111
|
-
get unitCube() {
|
|
112
|
-
return unitCube;
|
|
113
|
-
},
|
|
114
|
-
get unitAxis() {
|
|
115
|
-
return unitAxis;
|
|
116
|
-
},
|
|
117
|
-
get toArray() {
|
|
118
|
-
return toArray;
|
|
119
|
-
},
|
|
120
|
-
get ifArray() {
|
|
121
|
-
return ifArray;
|
|
122
|
-
},
|
|
123
|
-
get segment() {
|
|
124
|
-
return segment;
|
|
125
|
-
},
|
|
126
|
-
get zipObject() {
|
|
127
|
-
return zipObject;
|
|
128
|
-
},
|
|
129
|
-
get map() {
|
|
130
|
-
return map;
|
|
131
|
-
},
|
|
132
|
-
get mapValues() {
|
|
133
|
-
return mapValues;
|
|
134
|
-
},
|
|
135
|
-
get pick() {
|
|
136
|
-
return pick;
|
|
137
|
-
},
|
|
138
|
-
get mapPick() {
|
|
139
|
-
return mapPick;
|
|
140
|
-
},
|
|
141
|
-
get divA() {
|
|
142
|
-
return divA;
|
|
143
|
-
},
|
|
144
|
-
get divxyz() {
|
|
145
|
-
return divxyz;
|
|
146
|
-
},
|
|
147
|
-
get div() {
|
|
148
|
-
return div$1;
|
|
149
|
-
},
|
|
150
|
-
get mulxyz() {
|
|
151
|
-
return mulxyz;
|
|
152
|
-
},
|
|
153
|
-
get mul() {
|
|
154
|
-
return mul;
|
|
155
|
-
},
|
|
156
|
-
get xyz2array() {
|
|
157
|
-
return xyz2array;
|
|
158
|
-
},
|
|
159
|
-
get rotationAxes() {
|
|
160
|
-
return rotationAxes;
|
|
161
|
-
},
|
|
162
|
-
get size() {
|
|
163
|
-
return size;
|
|
164
|
-
},
|
|
165
|
-
get scale() {
|
|
166
|
-
return scale;
|
|
167
|
-
},
|
|
168
|
-
get center() {
|
|
169
|
-
return center;
|
|
170
|
-
},
|
|
171
|
-
get centerY() {
|
|
172
|
-
return centerY;
|
|
173
|
-
},
|
|
174
|
-
get centerX() {
|
|
175
|
-
return centerX;
|
|
176
|
-
},
|
|
177
|
-
get enlarge() {
|
|
178
|
-
return enlarge;
|
|
179
|
-
},
|
|
180
|
-
get fit() {
|
|
181
|
-
return fit;
|
|
182
|
-
},
|
|
183
|
-
get shift() {
|
|
184
|
-
return shift;
|
|
185
|
-
},
|
|
186
|
-
get zero() {
|
|
187
|
-
return zero;
|
|
188
|
-
},
|
|
189
|
-
get mirrored4() {
|
|
190
|
-
return mirrored4;
|
|
191
|
-
},
|
|
192
|
-
get flushSide() {
|
|
193
|
-
return flushSide;
|
|
194
|
-
},
|
|
195
|
-
get calcFlush() {
|
|
196
|
-
return calcFlush;
|
|
197
|
-
},
|
|
198
|
-
get calcSnap() {
|
|
199
|
-
return calcSnap;
|
|
200
|
-
},
|
|
201
|
-
get snap() {
|
|
202
|
-
return snap;
|
|
203
|
-
},
|
|
204
|
-
get flush() {
|
|
205
|
-
return flush;
|
|
206
|
-
},
|
|
207
|
-
get axisApply() {
|
|
208
|
-
return axisApply;
|
|
209
|
-
},
|
|
210
|
-
get axis2array() {
|
|
211
|
-
return axis2array;
|
|
212
|
-
},
|
|
213
|
-
get centroid() {
|
|
214
|
-
return centroid;
|
|
215
|
-
},
|
|
216
|
-
get calcmidlineTo() {
|
|
217
|
-
return calcmidlineTo;
|
|
218
|
-
},
|
|
219
|
-
get midlineTo() {
|
|
220
|
-
return midlineTo;
|
|
221
|
-
},
|
|
222
|
-
get translator() {
|
|
223
|
-
return translator;
|
|
224
|
-
},
|
|
225
|
-
get calcCenterWith() {
|
|
226
|
-
return calcCenterWith;
|
|
227
|
-
},
|
|
228
|
-
get centerWith() {
|
|
229
|
-
return centerWith;
|
|
230
|
-
},
|
|
231
|
-
get getDelta() {
|
|
232
|
-
return getDelta;
|
|
233
|
-
},
|
|
234
|
-
get bisect() {
|
|
235
|
-
return bisect;
|
|
236
|
-
},
|
|
237
|
-
get slice() {
|
|
238
|
-
return slice;
|
|
239
|
-
},
|
|
240
|
-
get wedge() {
|
|
241
|
-
return wedge;
|
|
242
|
-
},
|
|
243
|
-
get stretch() {
|
|
244
|
-
return stretch;
|
|
245
|
-
},
|
|
246
|
-
get poly2solid() {
|
|
247
|
-
return poly2solid;
|
|
248
|
-
},
|
|
249
|
-
get slices2poly() {
|
|
250
|
-
return slices2poly;
|
|
251
|
-
},
|
|
252
|
-
get normalVector() {
|
|
253
|
-
return normalVector;
|
|
254
|
-
},
|
|
255
|
-
get sliceParams() {
|
|
256
|
-
return sliceParams;
|
|
257
|
-
},
|
|
258
|
-
get reShape() {
|
|
259
|
-
return reShape;
|
|
260
|
-
},
|
|
261
|
-
get chamfer() {
|
|
262
|
-
return chamfer;
|
|
263
|
-
},
|
|
264
|
-
get fillet() {
|
|
265
|
-
return fillet;
|
|
266
|
-
},
|
|
267
|
-
get calcRotate() {
|
|
268
|
-
return calcRotate;
|
|
269
|
-
},
|
|
270
|
-
get rotateAround() {
|
|
271
|
-
return rotateAround;
|
|
272
|
-
},
|
|
273
|
-
get clone() {
|
|
274
|
-
return clone;
|
|
275
|
-
},
|
|
276
|
-
get addConnector() {
|
|
277
|
-
return addConnector;
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
function _typeof(obj) {
|
|
281
|
-
"@babel/helpers - typeof";
|
|
282
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
283
|
-
_typeof = function(obj) {
|
|
284
|
-
return typeof obj;
|
|
285
|
-
};
|
|
286
|
-
} else {
|
|
287
|
-
_typeof = function(obj) {
|
|
288
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
return _typeof(obj);
|
|
292
|
-
}
|
|
293
|
-
function _defineProperty(obj, key, value) {
|
|
294
|
-
if (key in obj) {
|
|
295
|
-
Object.defineProperty(obj, key, {
|
|
296
|
-
value,
|
|
297
|
-
enumerable: true,
|
|
298
|
-
configurable: true,
|
|
299
|
-
writable: true
|
|
300
|
-
});
|
|
301
|
-
} else {
|
|
302
|
-
obj[key] = value;
|
|
303
|
-
}
|
|
304
|
-
return obj;
|
|
305
|
-
}
|
|
306
|
-
function ownKeys(object, enumerableOnly) {
|
|
307
|
-
var keys = Object.keys(object);
|
|
308
|
-
if (Object.getOwnPropertySymbols) {
|
|
309
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
310
|
-
if (enumerableOnly) symbols = symbols.filter((function(sym) {
|
|
311
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
312
|
-
}));
|
|
313
|
-
keys.push.apply(keys, symbols);
|
|
314
|
-
}
|
|
315
|
-
return keys;
|
|
316
|
-
}
|
|
317
|
-
function _objectSpread2(target) {
|
|
318
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
319
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
320
|
-
if (i % 2) {
|
|
321
|
-
ownKeys(Object(source), true).forEach((function(key) {
|
|
322
|
-
_defineProperty(target, key, source[key]);
|
|
323
|
-
}));
|
|
324
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
325
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
326
|
-
} else {
|
|
327
|
-
ownKeys(Object(source)).forEach((function(key) {
|
|
328
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return target;
|
|
333
|
-
}
|
|
334
|
-
function _slicedToArray(arr, i) {
|
|
335
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
336
|
-
}
|
|
337
|
-
function _arrayWithHoles(arr) {
|
|
338
|
-
if (Array.isArray(arr)) return arr;
|
|
339
|
-
}
|
|
340
|
-
function _iterableToArrayLimit(arr, i) {
|
|
341
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
342
|
-
var _arr = [];
|
|
343
|
-
var _n = true;
|
|
344
|
-
var _d = false;
|
|
345
|
-
var _e = undefined;
|
|
346
|
-
try {
|
|
347
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
348
|
-
_arr.push(_s.value);
|
|
349
|
-
if (i && _arr.length === i) break;
|
|
350
|
-
}
|
|
351
|
-
} catch (err) {
|
|
352
|
-
_d = true;
|
|
353
|
-
_e = err;
|
|
354
|
-
} finally {
|
|
355
|
-
try {
|
|
356
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
357
|
-
} finally {
|
|
358
|
-
if (_d) throw _e;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return _arr;
|
|
362
|
-
}
|
|
363
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
364
|
-
if (!o) return;
|
|
365
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
366
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
367
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
368
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
369
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
370
|
-
}
|
|
371
|
-
function _arrayLikeToArray(arr, len) {
|
|
372
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
373
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
374
|
-
return arr2;
|
|
375
|
-
}
|
|
376
|
-
function _nonIterableRest() {
|
|
377
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
378
|
-
}
|
|
379
|
-
var toRadians = function toRadians(deg) {
|
|
57
|
+
const toRadians = function toRadians(deg) {
|
|
380
58
|
return deg / 180 * Math.PI;
|
|
381
59
|
};
|
|
382
|
-
|
|
60
|
+
const toDegrees = function toDegrees(rad) {
|
|
383
61
|
return rad * (180 / Math.PI);
|
|
384
62
|
};
|
|
385
|
-
|
|
63
|
+
const solve = function(p1, p2) {
|
|
386
64
|
var r = {
|
|
387
65
|
c: 90,
|
|
388
66
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -394,7 +72,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
394
72
|
r.a = 90 - r.b;
|
|
395
73
|
return r;
|
|
396
74
|
};
|
|
397
|
-
|
|
75
|
+
const solve90SA = function(r) {
|
|
398
76
|
r = Object.assign(r, {
|
|
399
77
|
C: 90
|
|
400
78
|
});
|
|
@@ -406,7 +84,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
406
84
|
r.b = r.b || r.a / Math.tan(arad);
|
|
407
85
|
return r;
|
|
408
86
|
};
|
|
409
|
-
|
|
87
|
+
const solve90ac = function(r) {
|
|
410
88
|
r = Object.assign(r, {
|
|
411
89
|
C: 90
|
|
412
90
|
});
|
|
@@ -427,60 +105,60 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
427
105
|
}
|
|
428
106
|
var triUtils = Object.freeze({
|
|
429
107
|
__proto__: null,
|
|
430
|
-
toRadians,
|
|
431
|
-
toDegrees,
|
|
432
108
|
solve,
|
|
433
109
|
solve90SA,
|
|
434
110
|
solve90ac,
|
|
435
|
-
solveab
|
|
111
|
+
solveab,
|
|
112
|
+
toDegrees,
|
|
113
|
+
toRadians
|
|
436
114
|
});
|
|
437
|
-
|
|
438
|
-
return a.map(
|
|
115
|
+
const div$1 = function(a, f) {
|
|
116
|
+
return a.map(function(e) {
|
|
439
117
|
return e / f;
|
|
440
|
-
})
|
|
118
|
+
});
|
|
441
119
|
};
|
|
442
|
-
|
|
443
|
-
return a.map(
|
|
120
|
+
const addValue = function(a, f) {
|
|
121
|
+
return a.map(function(e) {
|
|
444
122
|
return e + f;
|
|
445
|
-
})
|
|
123
|
+
});
|
|
446
124
|
};
|
|
447
|
-
|
|
448
|
-
return a.map(
|
|
125
|
+
const addArray = function(a, f) {
|
|
126
|
+
return a.map(function(e, i) {
|
|
449
127
|
return e + f[i];
|
|
450
|
-
})
|
|
128
|
+
});
|
|
451
129
|
};
|
|
452
|
-
|
|
453
|
-
return Array.prototype.slice.call(arguments, 1).reduce(
|
|
130
|
+
const add = function(a) {
|
|
131
|
+
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
454
132
|
if (Array.isArray(arg)) {
|
|
455
133
|
result = addArray(result, arg);
|
|
456
134
|
} else {
|
|
457
135
|
result = addValue(result, arg);
|
|
458
136
|
}
|
|
459
137
|
return result;
|
|
460
|
-
}
|
|
138
|
+
}, a);
|
|
461
139
|
};
|
|
462
|
-
|
|
140
|
+
const fromxyz = function(object) {
|
|
463
141
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
464
142
|
};
|
|
465
|
-
|
|
143
|
+
const toxyz = function(a) {
|
|
466
144
|
return {
|
|
467
145
|
x: a[0],
|
|
468
146
|
y: a[1],
|
|
469
147
|
z: a[2]
|
|
470
148
|
};
|
|
471
149
|
};
|
|
472
|
-
|
|
150
|
+
const first = function(a) {
|
|
473
151
|
return a ? a[0] : undefined;
|
|
474
152
|
};
|
|
475
|
-
|
|
153
|
+
const last = function(a) {
|
|
476
154
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
477
155
|
};
|
|
478
|
-
|
|
479
|
-
return a.reduce(
|
|
156
|
+
const min = function(a) {
|
|
157
|
+
return a.reduce(function(result, value) {
|
|
480
158
|
return value < result ? value : result;
|
|
481
|
-
}
|
|
159
|
+
}, Number.MAX_VALUE);
|
|
482
160
|
};
|
|
483
|
-
|
|
161
|
+
const range = function(a, b) {
|
|
484
162
|
var result = [];
|
|
485
163
|
for (var i = a; i < b; i++) {
|
|
486
164
|
result.push(i);
|
|
@@ -489,21 +167,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
489
167
|
};
|
|
490
168
|
var array = Object.freeze({
|
|
491
169
|
__proto__: null,
|
|
492
|
-
div,
|
|
493
|
-
addValue,
|
|
494
|
-
addArray,
|
|
495
170
|
add,
|
|
496
|
-
|
|
497
|
-
|
|
171
|
+
addArray,
|
|
172
|
+
addValue,
|
|
173
|
+
div: div$1,
|
|
498
174
|
first,
|
|
175
|
+
fromxyz,
|
|
499
176
|
last,
|
|
500
177
|
min,
|
|
501
|
-
range
|
|
178
|
+
range,
|
|
179
|
+
toxyz
|
|
502
180
|
});
|
|
503
|
-
|
|
504
|
-
|
|
181
|
+
const debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
182
|
+
const 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" ];
|
|
505
183
|
var debugCount = 0;
|
|
506
|
-
|
|
184
|
+
const Debug = function(name) {
|
|
507
185
|
var checks = Object.assign({
|
|
508
186
|
enabled: [],
|
|
509
187
|
disabled: [],
|
|
@@ -511,31 +189,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
511
189
|
browser: true
|
|
512
190
|
}
|
|
513
191
|
}, jscadUtilsDebug || {});
|
|
514
|
-
var style = checks.options.browser ?
|
|
515
|
-
var enabled = checks.enabled.some(
|
|
192
|
+
var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
|
|
193
|
+
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
516
194
|
return check.test(name);
|
|
517
|
-
})
|
|
195
|
+
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
518
196
|
return check.test(name);
|
|
519
|
-
})
|
|
520
|
-
var logger = enabled ? checks.options.browser ?
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
526
|
-
} : function() {
|
|
527
|
-
var _console2;
|
|
528
|
-
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
529
|
-
msg[_key2] = arguments[_key2];
|
|
530
|
-
}
|
|
531
|
-
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
532
|
-
} : function() {
|
|
533
|
-
return undefined;
|
|
534
|
-
};
|
|
197
|
+
});
|
|
198
|
+
var logger = enabled ? checks.options.browser ? (...msg) => {
|
|
199
|
+
console.log("%c%s", style, name, ...msg);
|
|
200
|
+
} : (...msg) => {
|
|
201
|
+
console.log(`${name}`, ...msg);
|
|
202
|
+
} : () => undefined;
|
|
535
203
|
logger.enabled = enabled;
|
|
536
204
|
return logger;
|
|
537
205
|
};
|
|
538
|
-
|
|
206
|
+
const nameArray = {
|
|
539
207
|
aliceblue: "#f0f8ff",
|
|
540
208
|
antiquewhite: "#faebd7",
|
|
541
209
|
aqua: "#00ffff",
|
|
@@ -693,9 +361,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
693
361
|
h = h.replace(/^\#/, "");
|
|
694
362
|
if (h.length === 6) {
|
|
695
363
|
return [ parseInt(h.substr(0, 2), 16), parseInt(h.substr(2, 2), 16), parseInt(h.substr(4, 2), 16) ];
|
|
364
|
+
} else {
|
|
365
|
+
return [ 0, 0, 0 ];
|
|
696
366
|
}
|
|
697
367
|
}
|
|
698
|
-
|
|
368
|
+
const _name2rgb = {};
|
|
699
369
|
function name2rgb(n) {
|
|
700
370
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
701
371
|
return _name2rgb[n];
|
|
@@ -703,9 +373,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
703
373
|
function color(o, r, g, b, a) {
|
|
704
374
|
if (typeof r !== "string") return o.setColor(r, g, b, a);
|
|
705
375
|
if (r === "") return o;
|
|
706
|
-
var c = name2rgb(r).map(
|
|
376
|
+
var c = name2rgb(r).map(function(x) {
|
|
707
377
|
return x / 255;
|
|
708
|
-
})
|
|
378
|
+
});
|
|
709
379
|
c[3] = g || 1;
|
|
710
380
|
return o.setColor(c);
|
|
711
381
|
}
|
|
@@ -775,23 +445,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
775
445
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
776
446
|
return chamfer(this, radius, orientation, options);
|
|
777
447
|
};
|
|
778
|
-
proto.prototype.bisect = function bisect$1() {
|
|
779
|
-
|
|
780
|
-
args[_key] = arguments[_key];
|
|
781
|
-
}
|
|
782
|
-
return bisect.apply(util, [ this ].concat(args));
|
|
448
|
+
proto.prototype.bisect = function bisect$1(...args) {
|
|
449
|
+
return bisect(this, ...args);
|
|
783
450
|
};
|
|
784
|
-
proto.prototype.slice = function slice$1() {
|
|
785
|
-
|
|
786
|
-
args[_key2] = arguments[_key2];
|
|
787
|
-
}
|
|
788
|
-
return slice.apply(util, [ this ].concat(args));
|
|
451
|
+
proto.prototype.slice = function slice$1(...args) {
|
|
452
|
+
return slice(this, ...args);
|
|
789
453
|
};
|
|
790
|
-
proto.prototype.wedge = function wedge$1() {
|
|
791
|
-
|
|
792
|
-
args[_key3] = arguments[_key3];
|
|
793
|
-
}
|
|
794
|
-
return wedge.apply(util, [ this ].concat(args));
|
|
454
|
+
proto.prototype.wedge = function wedge$1(...args) {
|
|
455
|
+
return wedge(this, ...args);
|
|
795
456
|
};
|
|
796
457
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
797
458
|
return stretch(this, axis, distance, offset);
|
|
@@ -807,24 +468,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
807
468
|
if (arguments.length === 1) {
|
|
808
469
|
return this._translate(arguments[0]);
|
|
809
470
|
} else {
|
|
810
|
-
var t = Array.prototype.slice.call(arguments, 0).reduce(
|
|
811
|
-
result = undefined(result, arg);
|
|
471
|
+
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
472
|
+
result = undefined.addArray(result, arg);
|
|
812
473
|
return result;
|
|
813
|
-
}
|
|
474
|
+
}, [ 0, 0, 0 ]);
|
|
814
475
|
return this._translate(t);
|
|
815
476
|
}
|
|
816
477
|
};
|
|
817
478
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
818
479
|
return addConnector(this, name, point, axis, normal);
|
|
819
480
|
};
|
|
820
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
821
|
-
var
|
|
822
|
-
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
823
|
-
var myConnector = myConnectorName.split(".").reduce((function(a, v) {
|
|
824
|
-
return a[v];
|
|
825
|
-
}), this.properties);
|
|
481
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector, mirror = false, normalrotation = 0) {
|
|
482
|
+
var myConnector = myConnectorName.split(".").reduce((a, v) => a[v], this.properties);
|
|
826
483
|
if (!myConnector) {
|
|
827
|
-
error(
|
|
484
|
+
error(`The connector '${myConnectorName}' does not exist on the object [${Object.keys(this.properties).join(",")}]`, "Missing connector property");
|
|
828
485
|
}
|
|
829
486
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
830
487
|
};
|
|
@@ -834,32 +491,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
834
491
|
__proto__: null,
|
|
835
492
|
default: init
|
|
836
493
|
});
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
494
|
+
const {CSG, CAG} = jsCadCSG;
|
|
495
|
+
const {rectangular_extrude} = scadApi.extrusions;
|
|
496
|
+
const {vector_text, vector_char} = scadApi.text;
|
|
497
|
+
const {union} = scadApi.booleanOps;
|
|
841
498
|
init(CSG);
|
|
842
|
-
|
|
843
|
-
function JsCadUtilsGroup() {
|
|
844
|
-
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
845
|
-
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
846
|
-
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
499
|
+
const debug$3 = Debug("jscadUtils:group");
|
|
500
|
+
function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
|
|
847
501
|
this.name = "";
|
|
848
502
|
this.names = names;
|
|
849
503
|
this.parts = parts;
|
|
850
504
|
this.holes = holes;
|
|
851
505
|
}
|
|
852
506
|
JsCadUtilsGroup.prototype.add = function(object, name, hidden, subparts, parts) {
|
|
853
|
-
debug("add", object, name, hidden, subparts, parts);
|
|
507
|
+
debug$3("add", object, name, hidden, subparts, parts);
|
|
854
508
|
var self = this;
|
|
855
509
|
if (object.parts) {
|
|
856
510
|
if (name) {
|
|
857
511
|
if (!hidden) self.names.push(name);
|
|
858
512
|
self.parts[name] = object.combine(parts);
|
|
859
513
|
if (subparts) {
|
|
860
|
-
Object.keys(object.parts).forEach(
|
|
514
|
+
Object.keys(object.parts).forEach(function(key) {
|
|
861
515
|
self.parts[subparts + key] = object.parts[key];
|
|
862
|
-
})
|
|
516
|
+
});
|
|
863
517
|
}
|
|
864
518
|
} else {
|
|
865
519
|
Object.assign(self.parts, object.parts);
|
|
@@ -871,11 +525,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
871
525
|
}
|
|
872
526
|
return self;
|
|
873
527
|
};
|
|
874
|
-
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
875
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
876
|
-
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
877
|
-
return x;
|
|
878
|
-
};
|
|
528
|
+
JsCadUtilsGroup.prototype.combine = function(pieces, options = {}, map = x => x) {
|
|
879
529
|
try {
|
|
880
530
|
var self = this;
|
|
881
531
|
options = Object.assign({
|
|
@@ -883,31 +533,30 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
883
533
|
}, options);
|
|
884
534
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
885
535
|
if (pieces.length === 0) {
|
|
886
|
-
throw new Error(
|
|
536
|
+
throw new Error(`no pieces found in ${self.name} pieces: ${pieces} parts: ${Object.keys(self.parts)} names: ${self.names}`);
|
|
887
537
|
}
|
|
888
|
-
debug("combine", self.names, self.parts);
|
|
889
|
-
var g = union(mapPick(self.parts, pieces,
|
|
538
|
+
debug$3("combine", self.names, self.parts);
|
|
539
|
+
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
540
|
+
debug$3("combine mapPick", value, key, object);
|
|
890
541
|
return map ? map(value, key, index, object) : identity(value);
|
|
891
|
-
}
|
|
542
|
+
}, self.name));
|
|
892
543
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
893
544
|
} catch (err) {
|
|
894
|
-
debug("combine error", this, pieces, options, err);
|
|
895
|
-
throw error(
|
|
545
|
+
debug$3("combine error", this, pieces, options, err);
|
|
546
|
+
throw error(`group::combine error "${err.message || err.toString()}"\nthis: ${this}\npieces: "${pieces}"\noptions: ${JSON.stringify(options, null, 2)}\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
|
|
896
547
|
}
|
|
897
548
|
};
|
|
898
549
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
899
550
|
var self = this;
|
|
900
|
-
self.parts = Object.keys(self.parts).filter((function(
|
|
901
|
-
return k !== "holes";
|
|
902
|
-
})).reduce((function(result, key) {
|
|
551
|
+
self.parts = Object.keys(self.parts).filter(k => k !== "holes").reduce(function(result, key) {
|
|
903
552
|
result[key] = cb(self.parts[key], key);
|
|
904
553
|
return result;
|
|
905
|
-
}
|
|
554
|
+
}, {});
|
|
906
555
|
if (self.holes) {
|
|
907
556
|
if (Array.isArray(self.holes)) {
|
|
908
|
-
self.holes = self.holes.map(
|
|
557
|
+
self.holes = self.holes.map(function(hole, idx) {
|
|
909
558
|
return cb(hole, idx);
|
|
910
|
-
})
|
|
559
|
+
});
|
|
911
560
|
} else {
|
|
912
561
|
self.holes = cb(self.holes, "holes");
|
|
913
562
|
}
|
|
@@ -915,7 +564,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
915
564
|
return self;
|
|
916
565
|
};
|
|
917
566
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
918
|
-
debug("clone", name,
|
|
567
|
+
debug$3("clone", name, typeof name, map);
|
|
919
568
|
var self = this;
|
|
920
569
|
if (typeof name == "function") {
|
|
921
570
|
map = name;
|
|
@@ -923,15 +572,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
923
572
|
}
|
|
924
573
|
if (!map) map = identity;
|
|
925
574
|
var group = Group(name);
|
|
926
|
-
Object.keys(self.parts).forEach(
|
|
575
|
+
Object.keys(self.parts).forEach(function(key) {
|
|
927
576
|
var part = self.parts[key];
|
|
928
577
|
var hidden = self.names.indexOf(key) == -1;
|
|
929
578
|
group.add(map(clone(part)), key, hidden);
|
|
930
|
-
})
|
|
579
|
+
});
|
|
931
580
|
if (self.holes) {
|
|
932
|
-
group.holes = toArray(self.holes).map(
|
|
581
|
+
group.holes = toArray(self.holes).map(function(part) {
|
|
933
582
|
return map(CSG.fromPolygons(part.toPolygons()), "holes");
|
|
934
|
-
})
|
|
583
|
+
});
|
|
935
584
|
}
|
|
936
585
|
return group;
|
|
937
586
|
};
|
|
@@ -948,9 +597,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
948
597
|
}
|
|
949
598
|
var rotationCenter = solid.centroid();
|
|
950
599
|
var rotationAxis = axes[axis];
|
|
951
|
-
self.map(
|
|
600
|
+
self.map(function(part) {
|
|
952
601
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
953
|
-
})
|
|
602
|
+
});
|
|
954
603
|
return self;
|
|
955
604
|
};
|
|
956
605
|
JsCadUtilsGroup.prototype.combineAll = function(options, map) {
|
|
@@ -961,13 +610,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
961
610
|
try {
|
|
962
611
|
var self = this;
|
|
963
612
|
var t = calcSnap(self.combine(part), to, axis, orientation, delta);
|
|
964
|
-
self.map(
|
|
613
|
+
self.map(function(part) {
|
|
965
614
|
return part.translate(t);
|
|
966
|
-
})
|
|
615
|
+
});
|
|
967
616
|
return self;
|
|
968
617
|
} catch (err) {
|
|
969
|
-
debug("snap error", this, part, to, axis, delta, err);
|
|
970
|
-
throw error(
|
|
618
|
+
debug$3("snap error", this, part, to, axis, delta, err);
|
|
619
|
+
throw error(`group::snap error "${err.message || err.toString()}"\nthis: ${this}\npart: "${part}"\nto: ${to}\naxis: "${axis}"\norientation: "${orientation}"\ndelta: "${delta}"\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
|
|
971
620
|
}
|
|
972
621
|
};
|
|
973
622
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -976,13 +625,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
976
625
|
var t = calcCenterWith(self.combine(part, {
|
|
977
626
|
noholes: true
|
|
978
627
|
}), axis, to, delta);
|
|
979
|
-
self.map(
|
|
628
|
+
self.map(function(part) {
|
|
980
629
|
return part.translate(t);
|
|
981
|
-
})
|
|
630
|
+
});
|
|
982
631
|
return self;
|
|
983
632
|
} catch (err) {
|
|
984
|
-
debug("align error", this, part, to, axis, delta, err);
|
|
985
|
-
throw error(
|
|
633
|
+
debug$3("align error", this, part, to, axis, delta, err);
|
|
634
|
+
throw error(`group::align error "${err.message || err.toString()}"\nthis: ${this}\npart: "${part}"\nto: ${to}\naxis: "${axis}"\ndelta: "${delta}"\nstack: ${err.stack}\n`, "JSCAD_UTILS_GROUP_ERROR");
|
|
986
635
|
}
|
|
987
636
|
};
|
|
988
637
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -994,10 +643,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
994
643
|
var bounds = self.parts[part].getBounds();
|
|
995
644
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
996
645
|
};
|
|
997
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
998
|
-
|
|
999
|
-
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
1000
|
-
debug("connectTo", {
|
|
646
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
|
|
647
|
+
debug$3("connectTo", {
|
|
1001
648
|
partName,
|
|
1002
649
|
connectorName,
|
|
1003
650
|
to,
|
|
@@ -1006,38 +653,34 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1006
653
|
normalrotation
|
|
1007
654
|
});
|
|
1008
655
|
var self = this;
|
|
1009
|
-
var myConnector = connectorName.split(".").reduce((
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
debug("toConnector", to instanceof CSG.Connector);
|
|
1013
|
-
var toConnector = toConnectorName.split(".").reduce((function(a, v) {
|
|
1014
|
-
return a[v];
|
|
1015
|
-
}), to.properties);
|
|
656
|
+
var myConnector = connectorName.split(".").reduce((a, v) => a[v], self.parts[partName].properties);
|
|
657
|
+
debug$3("toConnector", to instanceof CSG.Connector);
|
|
658
|
+
var toConnector = toConnectorName.split(".").reduce((a, v) => a[v], to.properties);
|
|
1016
659
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
1017
|
-
debug("connectTo", matrix);
|
|
1018
|
-
self.map(
|
|
660
|
+
debug$3("connectTo", matrix);
|
|
661
|
+
self.map(function(part) {
|
|
1019
662
|
return part.transform(matrix);
|
|
1020
|
-
})
|
|
663
|
+
});
|
|
1021
664
|
return self;
|
|
1022
665
|
};
|
|
1023
666
|
JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
|
|
1024
667
|
var self = this;
|
|
1025
668
|
var size = self.combine(part).size();
|
|
1026
|
-
var t = axisApply(axis,
|
|
669
|
+
var t = axisApply(axis, function(i, a) {
|
|
1027
670
|
return to - size[a] / 2;
|
|
1028
|
-
})
|
|
1029
|
-
self.map(
|
|
671
|
+
});
|
|
672
|
+
self.map(function(part) {
|
|
1030
673
|
return part.translate(t);
|
|
1031
|
-
})
|
|
674
|
+
});
|
|
1032
675
|
return self;
|
|
1033
676
|
};
|
|
1034
677
|
JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
|
|
1035
678
|
var self = this;
|
|
1036
679
|
var t = Array.isArray(x) ? x : [ x, y, z ];
|
|
1037
|
-
debug("translate", t);
|
|
1038
|
-
self.map(
|
|
680
|
+
debug$3("translate", t);
|
|
681
|
+
self.map(function(part) {
|
|
1039
682
|
return part.translate(t);
|
|
1040
|
-
})
|
|
683
|
+
});
|
|
1041
684
|
return self;
|
|
1042
685
|
};
|
|
1043
686
|
JsCadUtilsGroup.prototype.pick = function(parts, map) {
|
|
@@ -1045,43 +688,42 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1045
688
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1046
689
|
if (!map) map = identity;
|
|
1047
690
|
var g = Group();
|
|
1048
|
-
p.forEach(
|
|
691
|
+
p.forEach(function(name) {
|
|
1049
692
|
g.add(map(CSG.fromPolygons(self.parts[name].toPolygons()), name), name);
|
|
1050
|
-
})
|
|
693
|
+
});
|
|
1051
694
|
return g;
|
|
1052
695
|
};
|
|
1053
696
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1054
|
-
var _this = this;
|
|
1055
697
|
var self = this;
|
|
1056
698
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1057
699
|
if (!map) map = identity;
|
|
1058
700
|
var a = [];
|
|
1059
|
-
p.forEach(
|
|
701
|
+
p.forEach(name => {
|
|
1060
702
|
if (!self.parts[name]) {
|
|
1061
|
-
debug("array error",
|
|
1062
|
-
throw error(
|
|
703
|
+
debug$3("array error", this, parts);
|
|
704
|
+
throw error(`group::array error "${name}" not found.\nthis: ${this}\nparts: "${parts}"\n`, "JSCAD_UTILS_GROUP_ERROR");
|
|
1063
705
|
}
|
|
1064
706
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
1065
|
-
})
|
|
707
|
+
});
|
|
1066
708
|
return a;
|
|
1067
709
|
};
|
|
1068
710
|
JsCadUtilsGroup.prototype.toArray = function(pieces) {
|
|
1069
711
|
var self = this;
|
|
1070
712
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
1071
|
-
return piecesArray.map(
|
|
1072
|
-
if (!self.parts[piece]) console.error(
|
|
713
|
+
return piecesArray.map(function(piece) {
|
|
714
|
+
if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
|
|
1073
715
|
return self.parts[piece];
|
|
1074
|
-
})
|
|
716
|
+
});
|
|
1075
717
|
};
|
|
1076
718
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
1077
|
-
return
|
|
719
|
+
return `{\n name: "${this.name}",\n names: "${this.names.join(",")}", \n parts: "${Object.keys(this.parts)}",\n holes: ${Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0}\n}`;
|
|
1078
720
|
};
|
|
1079
721
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
1080
722
|
this.name = name;
|
|
1081
723
|
return this;
|
|
1082
724
|
};
|
|
1083
725
|
function Group(objectNames, addObjects) {
|
|
1084
|
-
debug("Group", objectNames, addObjects);
|
|
726
|
+
debug$3("Group", objectNames, addObjects);
|
|
1085
727
|
var self = {
|
|
1086
728
|
name: "",
|
|
1087
729
|
names: [],
|
|
@@ -1104,9 +746,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1104
746
|
self.name = objectNames;
|
|
1105
747
|
} else {
|
|
1106
748
|
var objects = objectNames;
|
|
1107
|
-
self.names = Object.keys(objects).filter(
|
|
1108
|
-
return k !== "holes";
|
|
1109
|
-
}));
|
|
749
|
+
self.names = Object.keys(objects).filter(k => k !== "holes");
|
|
1110
750
|
self.parts = Object.assign({}, objects);
|
|
1111
751
|
self.holes = objects.holes;
|
|
1112
752
|
}
|
|
@@ -1114,17 +754,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1114
754
|
}
|
|
1115
755
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
1116
756
|
}
|
|
1117
|
-
|
|
757
|
+
const debug$2 = Debug("jscadUtils:util");
|
|
1118
758
|
var NOZZEL_SIZE = .4;
|
|
1119
|
-
|
|
1120
|
-
under: function
|
|
1121
|
-
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1122
|
-
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
759
|
+
const nearest = {
|
|
760
|
+
under: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
|
|
1123
761
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
1124
762
|
},
|
|
1125
|
-
over: function
|
|
1126
|
-
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1127
|
-
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
763
|
+
over: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
|
|
1128
764
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
1129
765
|
}
|
|
1130
766
|
};
|
|
@@ -1149,12 +785,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1149
785
|
return ((n = +n) || 1 / n) < 0;
|
|
1150
786
|
}
|
|
1151
787
|
function print(msg, o) {
|
|
1152
|
-
debug$
|
|
788
|
+
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
1153
789
|
}
|
|
1154
790
|
function jscadToString(o) {
|
|
1155
|
-
if (
|
|
791
|
+
if (typeof o == "object") {
|
|
1156
792
|
if (o.polygons) {
|
|
1157
|
-
return
|
|
793
|
+
return `{\npolygons: ${o.polygons.length},\nproperties: "${Object.keys(o.properties)}"\n}\n`;
|
|
1158
794
|
}
|
|
1159
795
|
} else {
|
|
1160
796
|
return o.toString();
|
|
@@ -1185,22 +821,22 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1185
821
|
function label(text, x, y, width, height) {
|
|
1186
822
|
var l = vector_text(x || 0, y || 0, text);
|
|
1187
823
|
var o = [];
|
|
1188
|
-
l.forEach(
|
|
824
|
+
l.forEach(function(pl) {
|
|
1189
825
|
o.push(rectangular_extrude(pl, {
|
|
1190
826
|
w: width || 2,
|
|
1191
827
|
h: height || 2
|
|
1192
828
|
}));
|
|
1193
|
-
})
|
|
829
|
+
});
|
|
1194
830
|
return center(union(o));
|
|
1195
831
|
}
|
|
1196
832
|
function text(text) {
|
|
1197
833
|
var l = vector_char(0, 0, text);
|
|
1198
|
-
var
|
|
834
|
+
var char = l.segments.reduce(function(result, segment) {
|
|
1199
835
|
var path = new CSG.Path2D(segment);
|
|
1200
836
|
var cag = path.expandToCAG(2);
|
|
1201
837
|
return result ? result.union(cag) : cag;
|
|
1202
|
-
}
|
|
1203
|
-
return
|
|
838
|
+
}, undefined);
|
|
839
|
+
return char;
|
|
1204
840
|
}
|
|
1205
841
|
function unitCube(length, radius) {
|
|
1206
842
|
radius = radius || .5;
|
|
@@ -1210,7 +846,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1210
846
|
});
|
|
1211
847
|
}
|
|
1212
848
|
function unitAxis(length, radius, centroid) {
|
|
1213
|
-
debug$
|
|
849
|
+
debug$2("unitAxis", length, radius, centroid);
|
|
1214
850
|
centroid = centroid || [ 0, 0, 0 ];
|
|
1215
851
|
var unitaxis = unitCube(length, radius).setColor(1, 0, 0).union([ unitCube(length, radius).rotateY(90).setColor(0, 1, 0), unitCube(length, radius).rotateX(90).setColor(0, 0, 1) ]);
|
|
1216
852
|
unitaxis.properties.origin = new CSG.Connector([ 0, 0, 0 ], [ 1, 0, 0 ], [ 0, 1, 0 ]);
|
|
@@ -1232,38 +868,38 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1232
868
|
return result;
|
|
1233
869
|
}
|
|
1234
870
|
function zipObject(names, values) {
|
|
1235
|
-
return names.reduce(
|
|
871
|
+
return names.reduce(function(result, value, idx) {
|
|
1236
872
|
result[value] = values[idx];
|
|
1237
873
|
return result;
|
|
1238
|
-
}
|
|
874
|
+
}, {});
|
|
1239
875
|
}
|
|
1240
876
|
function map(o, f) {
|
|
1241
|
-
return Object.keys(o).map(
|
|
877
|
+
return Object.keys(o).map(function(key) {
|
|
1242
878
|
return f(o[key], key, o);
|
|
1243
|
-
})
|
|
879
|
+
});
|
|
1244
880
|
}
|
|
1245
881
|
function mapValues(o, f) {
|
|
1246
|
-
return Object.keys(o).map(
|
|
882
|
+
return Object.keys(o).map(function(key) {
|
|
1247
883
|
return f(o[key], key);
|
|
1248
|
-
})
|
|
884
|
+
});
|
|
1249
885
|
}
|
|
1250
886
|
function pick(o, names) {
|
|
1251
|
-
return names.reduce(
|
|
887
|
+
return names.reduce(function(result, name) {
|
|
1252
888
|
result[name] = o[name];
|
|
1253
889
|
return result;
|
|
1254
|
-
}
|
|
890
|
+
}, {});
|
|
1255
891
|
}
|
|
1256
892
|
function mapPick(o, names, f, options) {
|
|
1257
|
-
return names.reduce(
|
|
893
|
+
return names.reduce(function(result, name, index) {
|
|
1258
894
|
if (!o[name]) {
|
|
1259
|
-
throw new Error(
|
|
895
|
+
throw new Error(`${name} not found in ${options.name}: ${Object.keys(o).join(",")}`);
|
|
1260
896
|
}
|
|
1261
897
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
1262
898
|
return result;
|
|
1263
|
-
}
|
|
899
|
+
}, []);
|
|
1264
900
|
}
|
|
1265
901
|
function divA(a, f) {
|
|
1266
|
-
return div(a, f);
|
|
902
|
+
return div$1(a, f);
|
|
1267
903
|
}
|
|
1268
904
|
function divxyz(size, x, y, z) {
|
|
1269
905
|
return {
|
|
@@ -1272,7 +908,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1272
908
|
z: size.z / z
|
|
1273
909
|
};
|
|
1274
910
|
}
|
|
1275
|
-
function div
|
|
911
|
+
function div(size, d) {
|
|
1276
912
|
return this.divxyz(size, d, d, d);
|
|
1277
913
|
}
|
|
1278
914
|
function mulxyz(size, x, y, z) {
|
|
@@ -1288,7 +924,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1288
924
|
function xyz2array(size) {
|
|
1289
925
|
return [ size.x, size.y, size.z ];
|
|
1290
926
|
}
|
|
1291
|
-
|
|
927
|
+
const rotationAxes = {
|
|
1292
928
|
x: [ 1, 0, 0 ],
|
|
1293
929
|
y: [ 0, 1, 0 ],
|
|
1294
930
|
z: [ 0, 0, 1 ]
|
|
@@ -1324,9 +960,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1324
960
|
var objectSize = size(object);
|
|
1325
961
|
var objectCentroid = centroid(object, objectSize);
|
|
1326
962
|
var idx = 0;
|
|
1327
|
-
var t = map(objectSize,
|
|
963
|
+
var t = map(objectSize, function(i) {
|
|
1328
964
|
return scale(i, a[idx++]);
|
|
1329
|
-
})
|
|
965
|
+
});
|
|
1330
966
|
var new_object = object.scale(t);
|
|
1331
967
|
var new_centroid = centroid(new_object);
|
|
1332
968
|
var delta = new_centroid.minus(objectCentroid).times(-1);
|
|
@@ -1350,10 +986,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1350
986
|
}
|
|
1351
987
|
var s = [ scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z) ];
|
|
1352
988
|
var min$1 = min(s);
|
|
1353
|
-
return centerWith(object.scale(s.map(
|
|
989
|
+
return centerWith(object.scale(s.map(function(d, i) {
|
|
1354
990
|
if (a[i] === 0) return 1;
|
|
1355
991
|
return keep_aspect_ratio ? min$1 : d;
|
|
1356
|
-
}))
|
|
992
|
+
})), "xyz", object);
|
|
1357
993
|
}
|
|
1358
994
|
function shift(object, x, y, z) {
|
|
1359
995
|
var hsize = this.div(this.size(object.getBounds()), 2);
|
|
@@ -1366,7 +1002,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1366
1002
|
function mirrored4(x) {
|
|
1367
1003
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1368
1004
|
}
|
|
1369
|
-
|
|
1005
|
+
const flushSide = {
|
|
1370
1006
|
"above-outside": [ 1, 0 ],
|
|
1371
1007
|
"above-inside": [ 1, 1 ],
|
|
1372
1008
|
"below-outside": [ 0, 1 ],
|
|
@@ -1392,12 +1028,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1392
1028
|
if (side[0] === -1) {
|
|
1393
1029
|
w[-1] = toxyz(withobj.centroid());
|
|
1394
1030
|
}
|
|
1395
|
-
return this.axisApply(axes,
|
|
1031
|
+
return this.axisApply(axes, function(i, axis) {
|
|
1396
1032
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1397
|
-
})
|
|
1033
|
+
});
|
|
1398
1034
|
}
|
|
1399
|
-
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1400
|
-
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1035
|
+
function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
|
|
1401
1036
|
var side = flushSide[orientation];
|
|
1402
1037
|
if (!side) {
|
|
1403
1038
|
var fix = {
|
|
@@ -1415,15 +1050,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1415
1050
|
if (side[0] === -1) {
|
|
1416
1051
|
w[-1] = withobj.centroid();
|
|
1417
1052
|
}
|
|
1418
|
-
var t = axisApply(axes,
|
|
1053
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1419
1054
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1420
|
-
})
|
|
1421
|
-
return delta ? axisApply(axes,
|
|
1055
|
+
});
|
|
1056
|
+
return delta ? axisApply(axes, function(i) {
|
|
1422
1057
|
return t[i] + delta;
|
|
1423
|
-
})
|
|
1058
|
+
}) : t;
|
|
1424
1059
|
}
|
|
1425
1060
|
function snap(moveobj, withobj, axis, orientation, delta) {
|
|
1426
|
-
debug$
|
|
1061
|
+
debug$2("snap", moveobj, withobj, axis, orientation, delta);
|
|
1427
1062
|
var t = calcSnap(moveobj, withobj, axis, orientation, delta);
|
|
1428
1063
|
return moveobj.translate(t);
|
|
1429
1064
|
}
|
|
@@ -1431,16 +1066,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1431
1066
|
return moveobj.translate(calcFlush(moveobj, withobj, axis, mside, wside));
|
|
1432
1067
|
}
|
|
1433
1068
|
function axisApply(axes, valfun, a) {
|
|
1434
|
-
debug$
|
|
1069
|
+
debug$2("axisApply", axes, valfun, a);
|
|
1435
1070
|
var retval = a || [ 0, 0, 0 ];
|
|
1436
1071
|
var lookup = {
|
|
1437
1072
|
x: 0,
|
|
1438
1073
|
y: 1,
|
|
1439
1074
|
z: 2
|
|
1440
1075
|
};
|
|
1441
|
-
axes.split("").forEach(
|
|
1076
|
+
axes.split("").forEach(function(axis) {
|
|
1442
1077
|
retval[lookup[axis]] = valfun(lookup[axis], axis);
|
|
1443
|
-
})
|
|
1078
|
+
});
|
|
1444
1079
|
return retval;
|
|
1445
1080
|
}
|
|
1446
1081
|
function axis2array(axes, valfun) {
|
|
@@ -1451,10 +1086,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1451
1086
|
y: 1,
|
|
1452
1087
|
z: 2
|
|
1453
1088
|
};
|
|
1454
|
-
axes.split("").forEach(
|
|
1089
|
+
axes.split("").forEach(function(axis) {
|
|
1455
1090
|
var i = lookup[axis];
|
|
1456
1091
|
a[i] = valfun(i, axis);
|
|
1457
|
-
})
|
|
1092
|
+
});
|
|
1458
1093
|
return a;
|
|
1459
1094
|
}
|
|
1460
1095
|
function centroid(o, objectSize) {
|
|
@@ -1463,15 +1098,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1463
1098
|
objectSize = objectSize || size(bounds);
|
|
1464
1099
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1465
1100
|
} catch (err) {
|
|
1466
|
-
error(
|
|
1101
|
+
error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
|
|
1467
1102
|
}
|
|
1468
1103
|
}
|
|
1469
1104
|
function calcmidlineTo(o, axis, to) {
|
|
1470
1105
|
var bounds = o.getBounds();
|
|
1471
1106
|
var objectSize = size(bounds);
|
|
1472
|
-
return axisApply(axis,
|
|
1107
|
+
return axisApply(axis, function(i, a) {
|
|
1473
1108
|
return to - objectSize[a] / 2;
|
|
1474
|
-
})
|
|
1109
|
+
});
|
|
1475
1110
|
}
|
|
1476
1111
|
function midlineTo(o, axis, to) {
|
|
1477
1112
|
return o.translate(calcmidlineTo(o, axis, to));
|
|
@@ -1479,18 +1114,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1479
1114
|
function translator(o, axis, withObj) {
|
|
1480
1115
|
var objectCentroid = centroid(o);
|
|
1481
1116
|
var withCentroid = centroid(withObj);
|
|
1482
|
-
var t = axisApply(axis,
|
|
1117
|
+
var t = axisApply(axis, function(i) {
|
|
1483
1118
|
return withCentroid[i] - objectCentroid[i];
|
|
1484
|
-
})
|
|
1119
|
+
});
|
|
1485
1120
|
return t;
|
|
1486
1121
|
}
|
|
1487
|
-
function calcCenterWith(o, axes, withObj) {
|
|
1488
|
-
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1122
|
+
function calcCenterWith(o, axes, withObj, delta = 0) {
|
|
1489
1123
|
var objectCentroid = centroid(o);
|
|
1490
1124
|
var withCentroid = centroid(withObj);
|
|
1491
|
-
var t = axisApply(axes,
|
|
1125
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1492
1126
|
return withCentroid[axis] - objectCentroid[axis];
|
|
1493
|
-
})
|
|
1127
|
+
});
|
|
1494
1128
|
return delta ? add(t, delta) : t;
|
|
1495
1129
|
}
|
|
1496
1130
|
function centerWith(o, axis, withObj) {
|
|
@@ -1503,16 +1137,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1503
1137
|
}
|
|
1504
1138
|
}
|
|
1505
1139
|
var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
|
|
1506
|
-
return axisApply(axis,
|
|
1140
|
+
return axisApply(axis, function(i, a) {
|
|
1507
1141
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1508
|
-
})
|
|
1142
|
+
});
|
|
1509
1143
|
}
|
|
1510
|
-
function bisect() {
|
|
1511
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1512
|
-
args[_key] = arguments[_key];
|
|
1513
|
-
}
|
|
1144
|
+
function bisect(...args) {
|
|
1514
1145
|
if (args.length < 2) {
|
|
1515
|
-
error("bisect
|
|
1146
|
+
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1516
1147
|
}
|
|
1517
1148
|
var object = args[0];
|
|
1518
1149
|
var axis = args[1];
|
|
@@ -1568,14 +1199,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1568
1199
|
}[[ axis, rotateaxis ].sort().join("")];
|
|
1569
1200
|
var centroid = object.centroid();
|
|
1570
1201
|
var rotateDelta = getDelta(objectSize, bounds, rotateOffsetAxis, rotateoffset);
|
|
1571
|
-
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz",
|
|
1202
|
+
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", function(i, a) {
|
|
1572
1203
|
if (a == axis) return cutDelta[i];
|
|
1573
1204
|
if (a == rotateOffsetAxis) return rotateDelta[i];
|
|
1574
1205
|
return centroid[a];
|
|
1575
|
-
}))
|
|
1206
|
+
}));
|
|
1576
1207
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
1577
1208
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
|
|
1578
|
-
debug$
|
|
1209
|
+
debug$2("bisect", debug$2.enabled && {
|
|
1579
1210
|
axis,
|
|
1580
1211
|
offset,
|
|
1581
1212
|
angle,
|
|
@@ -1591,14 +1222,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1591
1222
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1592
1223
|
return g;
|
|
1593
1224
|
}
|
|
1594
|
-
function slice(object
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1599
|
-
color: true,
|
|
1600
|
-
addRotationCenter: true
|
|
1601
|
-
};
|
|
1225
|
+
function slice(object, angle = 15, axis = "x", rotateaxis = "z", options = {
|
|
1226
|
+
color: true,
|
|
1227
|
+
addRotationCenter: true
|
|
1228
|
+
}) {
|
|
1602
1229
|
var info = normalVector(axis);
|
|
1603
1230
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1604
1231
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1656,21 +1283,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1656
1283
|
return CSG.fromPolygons(polygons);
|
|
1657
1284
|
}
|
|
1658
1285
|
function slices2poly(slices, options, axis) {
|
|
1659
|
-
debug$
|
|
1286
|
+
debug$2("slices2poly", slices, options, axis);
|
|
1660
1287
|
options = Object.assign({
|
|
1661
1288
|
twistangle: 0,
|
|
1662
1289
|
twiststeps: 0
|
|
1663
1290
|
}, options);
|
|
1664
1291
|
var twistangle = options && parseFloat(options.twistangle) || 0;
|
|
1665
|
-
|
|
1666
|
-
if (twistangle == 0 || twiststeps < 1) {
|
|
1667
|
-
twiststeps = 1;
|
|
1668
|
-
}
|
|
1292
|
+
options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
|
|
1669
1293
|
var normalVector = options.si.normalVector;
|
|
1670
1294
|
var polygons = [];
|
|
1671
1295
|
var first$1 = first(slices);
|
|
1672
1296
|
var last$1 = last(slices);
|
|
1673
|
-
debug$
|
|
1297
|
+
debug$2("slices2poly first", first$1, first$1.offset, "last", last$1);
|
|
1674
1298
|
var up = first$1.offset[axis] > last$1.offset[axis];
|
|
1675
1299
|
polygons = polygons.concat(first$1.poly._toPlanePolygons({
|
|
1676
1300
|
translation: first$1.offset,
|
|
@@ -1689,7 +1313,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1689
1313
|
return v[rotateAxis](angle * percent);
|
|
1690
1314
|
};
|
|
1691
1315
|
var connectorAxis = last$1.offset.minus(first$1.offset).abs();
|
|
1692
|
-
slices.forEach(
|
|
1316
|
+
slices.forEach(function(slice, idx) {
|
|
1693
1317
|
if (idx < slices.length - 1) {
|
|
1694
1318
|
var nextidx = idx + 1;
|
|
1695
1319
|
var top = !up ? slices[nextidx] : slice;
|
|
@@ -1702,7 +1326,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1702
1326
|
toConnector2: c2
|
|
1703
1327
|
}));
|
|
1704
1328
|
}
|
|
1705
|
-
})
|
|
1329
|
+
});
|
|
1706
1330
|
return CSG.fromPolygons(polygons);
|
|
1707
1331
|
}
|
|
1708
1332
|
function normalVector(axis) {
|
|
@@ -1743,12 +1367,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1743
1367
|
var info = dirInfo["dir" + direction];
|
|
1744
1368
|
return Object.assign({
|
|
1745
1369
|
axis,
|
|
1746
|
-
cutDelta: axisApply(axis,
|
|
1370
|
+
cutDelta: axisApply(axis, function(i, a) {
|
|
1747
1371
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.sizeDir;
|
|
1748
|
-
})
|
|
1749
|
-
moveDelta: axisApply(axis,
|
|
1372
|
+
}),
|
|
1373
|
+
moveDelta: axisApply(axis, function(i, a) {
|
|
1750
1374
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
|
|
1751
|
-
})
|
|
1375
|
+
})
|
|
1752
1376
|
}, info, normalVector(axis));
|
|
1753
1377
|
}
|
|
1754
1378
|
function reShape(object, radius, orientation, options, slicer) {
|
|
@@ -1756,18 +1380,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1756
1380
|
var b = object.getBounds();
|
|
1757
1381
|
var absoluteRadius = Math.abs(radius);
|
|
1758
1382
|
var si = sliceParams(orientation, radius, b);
|
|
1759
|
-
debug$
|
|
1760
|
-
if (si.axis !== "z") throw new Error('reShape error: CAG.
|
|
1383
|
+
debug$2("reShape", absoluteRadius, si);
|
|
1384
|
+
if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolygons only uses the "z" axis. You must use the "z" axis for now.');
|
|
1761
1385
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
|
|
1762
1386
|
var slice = object.sectionCut(cutplane);
|
|
1763
|
-
var first = axisApply(si.axis,
|
|
1387
|
+
var first = axisApply(si.axis, function() {
|
|
1764
1388
|
return si.positive ? 0 : absoluteRadius;
|
|
1765
|
-
})
|
|
1766
|
-
var last = axisApply(si.axis,
|
|
1389
|
+
});
|
|
1390
|
+
var last = axisApply(si.axis, function() {
|
|
1767
1391
|
return si.positive ? absoluteRadius : 0;
|
|
1768
|
-
})
|
|
1392
|
+
});
|
|
1769
1393
|
var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
|
|
1770
|
-
debug$
|
|
1394
|
+
debug$2("reShape first/last", first, last);
|
|
1771
1395
|
var slices = slicer(first, last, slice, radius);
|
|
1772
1396
|
var delta = slices2poly(slices, Object.assign(options, {
|
|
1773
1397
|
si
|
|
@@ -1776,7 +1400,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1776
1400
|
return union([ options.unionOriginal ? object : remainder, delta.translate(si.moveDelta) ]);
|
|
1777
1401
|
}
|
|
1778
1402
|
function chamfer(object, radius, orientation, options) {
|
|
1779
|
-
return reShape(object, radius, orientation, options,
|
|
1403
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1780
1404
|
return [ {
|
|
1781
1405
|
poly: slice,
|
|
1782
1406
|
offset: new CSG.Vector3D(first)
|
|
@@ -1784,15 +1408,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1784
1408
|
poly: enlarge(slice, [ -radius * 2, -radius * 2 ]),
|
|
1785
1409
|
offset: new CSG.Vector3D(last)
|
|
1786
1410
|
} ];
|
|
1787
|
-
})
|
|
1411
|
+
});
|
|
1788
1412
|
}
|
|
1789
1413
|
function fillet(object, radius, orientation, options) {
|
|
1790
1414
|
options = options || {};
|
|
1791
|
-
return reShape(object, radius, orientation, options,
|
|
1415
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1792
1416
|
var v1 = new CSG.Vector3D(first);
|
|
1793
1417
|
var v2 = new CSG.Vector3D(last);
|
|
1794
1418
|
var res = options.resolution || CSG.defaultResolution3D;
|
|
1795
|
-
var slices = range(0, res).map(
|
|
1419
|
+
var slices = range(0, res).map(function(i) {
|
|
1796
1420
|
var p = i > 0 ? i / (res - 1) : 0;
|
|
1797
1421
|
var v = v1.lerp(v2, p);
|
|
1798
1422
|
var size = -radius * 2 - Math.cos(Math.asin(p)) * (-radius * 2);
|
|
@@ -1800,9 +1424,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1800
1424
|
poly: enlarge(slice, [ size, size ]),
|
|
1801
1425
|
offset: v
|
|
1802
1426
|
};
|
|
1803
|
-
})
|
|
1427
|
+
});
|
|
1804
1428
|
return slices;
|
|
1805
|
-
})
|
|
1429
|
+
});
|
|
1806
1430
|
}
|
|
1807
1431
|
function calcRotate(part, solid, axis) {
|
|
1808
1432
|
var axes = {
|
|
@@ -1818,54 +1442,121 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1818
1442
|
};
|
|
1819
1443
|
}
|
|
1820
1444
|
function rotateAround(part, solid, axis, angle) {
|
|
1821
|
-
var
|
|
1445
|
+
var {rotationCenter, rotationAxis} = calcRotate(part, solid, axis);
|
|
1822
1446
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1823
1447
|
}
|
|
1824
|
-
function cloneProperties(from, to) {
|
|
1825
|
-
return Object.entries(from).reduce((
|
|
1826
|
-
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1448
|
+
function cloneProperties(from, to, depth = 0) {
|
|
1449
|
+
return Object.entries(from).reduce((props, [key, value]) => {
|
|
1827
1450
|
props[key] = value;
|
|
1828
1451
|
return props;
|
|
1829
|
-
}
|
|
1452
|
+
}, to);
|
|
1830
1453
|
}
|
|
1831
1454
|
function clone(o) {
|
|
1832
1455
|
var c = CSG.fromPolygons(o.toPolygons());
|
|
1833
1456
|
cloneProperties(o, c);
|
|
1834
|
-
debug$
|
|
1457
|
+
debug$2("clone", o, c, CSG);
|
|
1835
1458
|
return c;
|
|
1836
1459
|
}
|
|
1837
|
-
function addConnector(object, name) {
|
|
1838
|
-
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1839
|
-
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1840
|
-
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1460
|
+
function addConnector(object, name, point = [ 0, 0, 0 ], axis = [ 1, 0, 0 ], normal = [ 0, 0, 1 ]) {
|
|
1841
1461
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1842
1462
|
return object;
|
|
1843
1463
|
}
|
|
1844
|
-
var
|
|
1464
|
+
var util = Object.freeze({
|
|
1465
|
+
__proto__: null,
|
|
1466
|
+
NOZZEL_SIZE,
|
|
1467
|
+
addConnector,
|
|
1468
|
+
axis2array,
|
|
1469
|
+
axisApply,
|
|
1470
|
+
bisect,
|
|
1471
|
+
calcCenterWith,
|
|
1472
|
+
calcFlush,
|
|
1473
|
+
calcRotate,
|
|
1474
|
+
calcSnap,
|
|
1475
|
+
calcmidlineTo,
|
|
1476
|
+
center,
|
|
1477
|
+
centerWith,
|
|
1478
|
+
centerX,
|
|
1479
|
+
centerY,
|
|
1480
|
+
centroid,
|
|
1481
|
+
chamfer,
|
|
1482
|
+
clone,
|
|
1483
|
+
cm,
|
|
1484
|
+
defaults,
|
|
1485
|
+
depreciated,
|
|
1486
|
+
div,
|
|
1487
|
+
divA,
|
|
1488
|
+
divxyz,
|
|
1489
|
+
enlarge,
|
|
1490
|
+
error,
|
|
1491
|
+
fillet,
|
|
1492
|
+
fit,
|
|
1493
|
+
flush,
|
|
1494
|
+
flushSide,
|
|
1495
|
+
getDelta,
|
|
1496
|
+
identity,
|
|
1497
|
+
ifArray,
|
|
1498
|
+
inch,
|
|
1499
|
+
isEmpty,
|
|
1500
|
+
isNegative,
|
|
1501
|
+
jscadToString,
|
|
1502
|
+
label,
|
|
1503
|
+
map,
|
|
1504
|
+
mapPick,
|
|
1505
|
+
mapValues,
|
|
1506
|
+
midlineTo,
|
|
1507
|
+
mirrored4,
|
|
1508
|
+
mul,
|
|
1509
|
+
mulxyz,
|
|
1510
|
+
nearest,
|
|
1511
|
+
normalVector,
|
|
1512
|
+
pick,
|
|
1513
|
+
poly2solid,
|
|
1514
|
+
print,
|
|
1515
|
+
reShape,
|
|
1516
|
+
result,
|
|
1517
|
+
rotateAround,
|
|
1518
|
+
rotationAxes,
|
|
1519
|
+
scale,
|
|
1520
|
+
segment,
|
|
1521
|
+
shift,
|
|
1522
|
+
size,
|
|
1523
|
+
slice,
|
|
1524
|
+
sliceParams,
|
|
1525
|
+
slices2poly,
|
|
1526
|
+
snap,
|
|
1527
|
+
stretch,
|
|
1528
|
+
text,
|
|
1529
|
+
toArray,
|
|
1530
|
+
translator,
|
|
1531
|
+
unitAxis,
|
|
1532
|
+
unitCube,
|
|
1533
|
+
wedge,
|
|
1534
|
+
xyz2array,
|
|
1535
|
+
zero,
|
|
1536
|
+
zipObject
|
|
1537
|
+
});
|
|
1538
|
+
const debug$1 = Debug("jscadUtils:parts");
|
|
1845
1539
|
var parts = {
|
|
1846
|
-
BBox,
|
|
1540
|
+
BBox: BBox$1,
|
|
1847
1541
|
Cube,
|
|
1848
1542
|
RoundedCube,
|
|
1849
1543
|
Cylinder,
|
|
1850
1544
|
Cone
|
|
1851
1545
|
};
|
|
1852
|
-
function BBox() {
|
|
1546
|
+
function BBox$1(...objects) {
|
|
1853
1547
|
function box(object) {
|
|
1854
1548
|
return CSG.cube({
|
|
1855
1549
|
center: object.centroid(),
|
|
1856
1550
|
radius: object.size().dividedBy(2)
|
|
1857
1551
|
});
|
|
1858
1552
|
}
|
|
1859
|
-
|
|
1860
|
-
objects[_key] = arguments[_key];
|
|
1861
|
-
}
|
|
1862
|
-
return objects.reduce((function(bbox, part) {
|
|
1553
|
+
return objects.reduce(function(bbox, part) {
|
|
1863
1554
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1864
1555
|
return box(object);
|
|
1865
|
-
}
|
|
1556
|
+
}, undefined);
|
|
1866
1557
|
}
|
|
1867
1558
|
function Cube(width) {
|
|
1868
|
-
var r = div(fromxyz(width), 2);
|
|
1559
|
+
var r = div$1(fromxyz(width), 2);
|
|
1869
1560
|
return CSG.cube({
|
|
1870
1561
|
center: r,
|
|
1871
1562
|
radius: r
|
|
@@ -1880,7 +1571,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1880
1571
|
} else {
|
|
1881
1572
|
var r = [ x / 2, y / 2 ];
|
|
1882
1573
|
}
|
|
1883
|
-
debug$
|
|
1574
|
+
debug$1("RoundedCube", size$1, r, thickness, corner_radius);
|
|
1884
1575
|
var roundedcube = CAG.roundedRectangle({
|
|
1885
1576
|
center: [ r[0], r[1], 0 ],
|
|
1886
1577
|
radius: r,
|
|
@@ -1891,9 +1582,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1891
1582
|
});
|
|
1892
1583
|
return roundedcube;
|
|
1893
1584
|
}
|
|
1894
|
-
function Cylinder(diameter, height) {
|
|
1895
|
-
|
|
1896
|
-
debug$2("parts.Cylinder", diameter, height, options);
|
|
1585
|
+
function Cylinder(diameter, height, options = {}) {
|
|
1586
|
+
debug$1("parts.Cylinder", diameter, height, options);
|
|
1897
1587
|
options = Object.assign({
|
|
1898
1588
|
start: [ 0, 0, 0 ],
|
|
1899
1589
|
end: [ 0, 0, height ],
|
|
@@ -1902,9 +1592,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1902
1592
|
}, options);
|
|
1903
1593
|
return CSG.cylinder(options);
|
|
1904
1594
|
}
|
|
1905
|
-
function Cone(diameter1, diameter2, height) {
|
|
1906
|
-
|
|
1907
|
-
debug$2("parts.Cone", diameter1, diameter2, height, options);
|
|
1595
|
+
function Cone(diameter1, diameter2, height, options = {}) {
|
|
1596
|
+
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1908
1597
|
return CSG.cylinder(Object.assign({
|
|
1909
1598
|
start: [ 0, 0, 0 ],
|
|
1910
1599
|
end: [ 0, 0, height ],
|
|
@@ -1914,7 +1603,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1914
1603
|
}, options));
|
|
1915
1604
|
}
|
|
1916
1605
|
function Hexagon(diameter, height) {
|
|
1917
|
-
debug$
|
|
1606
|
+
debug$1("hexagon", diameter, height);
|
|
1918
1607
|
var radius = diameter / 2;
|
|
1919
1608
|
var sqrt3 = Math.sqrt(3) / 2;
|
|
1920
1609
|
var hex = CAG.fromPoints([ [ radius, 0 ], [ radius / 2, radius * sqrt3 ], [ -radius / 2, radius * sqrt3 ], [ -radius, 0 ], [ -radius / 2, -radius * sqrt3 ], [ radius / 2, -radius * sqrt3 ] ]);
|
|
@@ -1932,9 +1621,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1932
1621
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1933
1622
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1934
1623
|
}
|
|
1935
|
-
function Anchor() {
|
|
1936
|
-
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1937
|
-
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1624
|
+
function Anchor(width = 10, height = 10) {
|
|
1938
1625
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1939
1626
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1940
1627
|
return Group({
|
|
@@ -1954,7 +1641,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1954
1641
|
});
|
|
1955
1642
|
return board;
|
|
1956
1643
|
}
|
|
1957
|
-
|
|
1644
|
+
const Hardware = {
|
|
1958
1645
|
Orientation: {
|
|
1959
1646
|
up: {
|
|
1960
1647
|
head: "outside-",
|
|
@@ -1965,7 +1652,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1965
1652
|
clear: "inside-"
|
|
1966
1653
|
}
|
|
1967
1654
|
},
|
|
1968
|
-
Screw: function
|
|
1655
|
+
Screw: function(head, thread, headClearSpace, options) {
|
|
1969
1656
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1970
1657
|
options = Object.assign(options, {
|
|
1971
1658
|
orientation: "up",
|
|
@@ -1981,7 +1668,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1981
1668
|
}
|
|
1982
1669
|
return group;
|
|
1983
1670
|
},
|
|
1984
|
-
PanHeadScrew: function
|
|
1671
|
+
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1985
1672
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1986
1673
|
var head = Cylinder(headDiameter, headLength);
|
|
1987
1674
|
var thread = Cylinder(diameter, length);
|
|
@@ -1990,7 +1677,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1990
1677
|
}
|
|
1991
1678
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
1992
1679
|
},
|
|
1993
|
-
HexHeadScrew: function
|
|
1680
|
+
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
1994
1681
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
1995
1682
|
var head = Hexagon(headDiameter, headLength);
|
|
1996
1683
|
var thread = Cylinder(diameter, length);
|
|
@@ -1999,7 +1686,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1999
1686
|
}
|
|
2000
1687
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
2001
1688
|
},
|
|
2002
|
-
FlatHeadScrew: function
|
|
1689
|
+
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2003
1690
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
2004
1691
|
var head = Cone(headDiameter, diameter, headLength);
|
|
2005
1692
|
var thread = Cylinder(diameter, length);
|
|
@@ -2011,43 +1698,42 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2011
1698
|
};
|
|
2012
1699
|
var parts$1 = Object.freeze({
|
|
2013
1700
|
__proto__: null,
|
|
2014
|
-
|
|
2015
|
-
BBox,
|
|
1701
|
+
Anchor,
|
|
1702
|
+
BBox: BBox$1,
|
|
1703
|
+
Board,
|
|
1704
|
+
Cone,
|
|
2016
1705
|
Cube,
|
|
2017
|
-
RoundedCube,
|
|
2018
1706
|
Cylinder,
|
|
2019
|
-
|
|
1707
|
+
Hardware,
|
|
2020
1708
|
Hexagon,
|
|
1709
|
+
RoundedCube,
|
|
2021
1710
|
Triangle,
|
|
2022
1711
|
Tube,
|
|
2023
|
-
|
|
2024
|
-
Board,
|
|
2025
|
-
Hardware
|
|
1712
|
+
default: parts
|
|
2026
1713
|
});
|
|
2027
|
-
|
|
1714
|
+
const debug = Debug("jscadUtils:boxes");
|
|
2028
1715
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
2029
1716
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
2030
1717
|
return rabbetJoin(box, thickness, cutHeight);
|
|
2031
1718
|
}
|
|
2032
1719
|
function topMiddleBottom(box, thickness) {
|
|
2033
|
-
debug
|
|
1720
|
+
debug("TopMiddleBottom", box, thickness);
|
|
2034
1721
|
var bottom = box.bisect("z", thickness, {
|
|
2035
1722
|
color: true
|
|
2036
1723
|
});
|
|
2037
1724
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
2038
1725
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
2039
1726
|
}
|
|
2040
|
-
function Rabett(box, thickness, gap, height, face) {
|
|
2041
|
-
|
|
2042
|
-
debug$3("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1727
|
+
function Rabett(box, thickness, gap, height, face, options = {}) {
|
|
1728
|
+
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
2043
1729
|
gap = gap || .25;
|
|
2044
1730
|
var inside = thickness - gap;
|
|
2045
1731
|
var outside = -thickness + gap;
|
|
2046
|
-
debug
|
|
1732
|
+
debug("inside", inside, "outside", outside);
|
|
2047
1733
|
var group = Group();
|
|
2048
|
-
var
|
|
1734
|
+
var {positive: top, negative: lower2_3rd} = box.bisect("z", height, options).parts;
|
|
2049
1735
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
2050
|
-
var
|
|
1736
|
+
var {positive: middle, negative: bottom} = lower2_3rd.bisect("z", lowerBisectHeight, options).parts;
|
|
2051
1737
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
2052
1738
|
group.add(top.union(middleTop), "top");
|
|
2053
1739
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -2056,16 +1742,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2056
1742
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
2057
1743
|
return group;
|
|
2058
1744
|
}
|
|
2059
|
-
|
|
2060
|
-
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2061
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1745
|
+
const RabettTopBottom = function rabbetTMB(box, thickness, gap = .25, options = {}) {
|
|
2062
1746
|
options = Object.assign({
|
|
2063
1747
|
removableTop: true,
|
|
2064
1748
|
removableBottom: true,
|
|
2065
1749
|
topWidth: -thickness,
|
|
2066
1750
|
bottomWidth: thickness
|
|
2067
1751
|
}, options);
|
|
2068
|
-
debug
|
|
1752
|
+
debug("RabettTopBottom", box, thickness, gap, options);
|
|
2069
1753
|
var group = Group("", {
|
|
2070
1754
|
box
|
|
2071
1755
|
});
|
|
@@ -2091,7 +1775,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2091
1775
|
}
|
|
2092
1776
|
return group;
|
|
2093
1777
|
};
|
|
2094
|
-
|
|
1778
|
+
const CutOut = function cutOut(o, h, box, plug, gap) {
|
|
2095
1779
|
gap = gap || .25;
|
|
2096
1780
|
var s = o.size();
|
|
2097
1781
|
var cutout = o.intersect(box);
|
|
@@ -2109,9 +1793,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2109
1793
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
2110
1794
|
});
|
|
2111
1795
|
};
|
|
2112
|
-
|
|
1796
|
+
const Rectangle = function(size, thickness, cb) {
|
|
2113
1797
|
thickness = thickness || 2;
|
|
2114
|
-
var s = div(xyz2array(size), 2);
|
|
1798
|
+
var s = div$1(xyz2array(size), 2);
|
|
2115
1799
|
var r = add(s, thickness);
|
|
2116
1800
|
var box = CSG.cube({
|
|
2117
1801
|
center: r,
|
|
@@ -2123,7 +1807,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2123
1807
|
if (cb) box = cb(box);
|
|
2124
1808
|
return box;
|
|
2125
1809
|
};
|
|
2126
|
-
|
|
1810
|
+
const Hollow = function(object, thickness, interiorcb, exteriorcb) {
|
|
2127
1811
|
thickness = thickness || 2;
|
|
2128
1812
|
var size = -thickness * 2;
|
|
2129
1813
|
interiorcb = interiorcb || identity;
|
|
@@ -2131,19 +1815,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2131
1815
|
if (exteriorcb) box = exteriorcb(box);
|
|
2132
1816
|
return box;
|
|
2133
1817
|
};
|
|
2134
|
-
|
|
1818
|
+
const BBox = function(o) {
|
|
2135
1819
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
2136
|
-
var s = div(xyz2array(o.size()), 2);
|
|
1820
|
+
var s = div$1(xyz2array(o.size()), 2);
|
|
2137
1821
|
return CSG.cube({
|
|
2138
1822
|
center: s,
|
|
2139
1823
|
radius: s
|
|
2140
1824
|
}).align(o, "xyz");
|
|
2141
1825
|
};
|
|
2142
1826
|
function getRadius(o) {
|
|
2143
|
-
return div(xyz2array(o.size()), 2);
|
|
1827
|
+
return div$1(xyz2array(o.size()), 2);
|
|
2144
1828
|
}
|
|
2145
|
-
function rabbetJoin(box, thickness) {
|
|
2146
|
-
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1829
|
+
function rabbetJoin(box, thickness, gap = .25) {
|
|
2147
1830
|
var r = add(getRadius(box), -thickness / 2);
|
|
2148
1831
|
r[2] = thickness / 2;
|
|
2149
1832
|
var cutter = CSG.cube({
|
|
@@ -2161,16 +1844,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2161
1844
|
}
|
|
2162
1845
|
var Boxes = Object.freeze({
|
|
2163
1846
|
__proto__: null,
|
|
1847
|
+
BBox,
|
|
1848
|
+
CutOut,
|
|
1849
|
+
Hollow,
|
|
2164
1850
|
RabbetJoin,
|
|
2165
|
-
topMiddleBottom,
|
|
2166
1851
|
Rabett,
|
|
2167
1852
|
RabettTopBottom,
|
|
2168
|
-
CutOut,
|
|
2169
1853
|
Rectangle,
|
|
2170
|
-
|
|
2171
|
-
BBox: BBox$1
|
|
1854
|
+
topMiddleBottom
|
|
2172
1855
|
});
|
|
2173
|
-
|
|
1856
|
+
const compatV1 = {
|
|
1857
|
+
...util,
|
|
2174
1858
|
group: Group,
|
|
2175
1859
|
init: init$1,
|
|
2176
1860
|
triangle: triUtils,
|
|
@@ -2178,7 +1862,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2178
1862
|
parts: parts$1,
|
|
2179
1863
|
Boxes,
|
|
2180
1864
|
Debug
|
|
2181
|
-
}
|
|
1865
|
+
};
|
|
2182
1866
|
exports.Boxes = Boxes;
|
|
2183
1867
|
exports.Debug = Debug;
|
|
2184
1868
|
exports.Group = Group;
|