@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
|
@@ -74,335 +74,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
74
74
|
});
|
|
75
75
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
76
76
|
"use strict";
|
|
77
|
-
function
|
|
78
|
-
return e && typeof e === "object" && "default" in e ? e : {
|
|
79
|
-
default: e
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
83
|
-
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
84
|
-
var util = Object.freeze({
|
|
85
|
-
__proto__: null,
|
|
86
|
-
get NOZZEL_SIZE() {
|
|
87
|
-
return NOZZEL_SIZE;
|
|
88
|
-
},
|
|
89
|
-
get nearest() {
|
|
90
|
-
return nearest;
|
|
91
|
-
},
|
|
92
|
-
get identity() {
|
|
93
|
-
return identity;
|
|
94
|
-
},
|
|
95
|
-
get result() {
|
|
96
|
-
return result;
|
|
97
|
-
},
|
|
98
|
-
get defaults() {
|
|
99
|
-
return defaults;
|
|
100
|
-
},
|
|
101
|
-
get isEmpty() {
|
|
102
|
-
return isEmpty;
|
|
103
|
-
},
|
|
104
|
-
get isNegative() {
|
|
105
|
-
return isNegative;
|
|
106
|
-
},
|
|
107
|
-
get print() {
|
|
108
|
-
return print;
|
|
109
|
-
},
|
|
110
|
-
get jscadToString() {
|
|
111
|
-
return jscadToString;
|
|
112
|
-
},
|
|
113
|
-
get error() {
|
|
114
|
-
return error;
|
|
115
|
-
},
|
|
116
|
-
get depreciated() {
|
|
117
|
-
return depreciated;
|
|
118
|
-
},
|
|
119
|
-
get inch() {
|
|
120
|
-
return inch;
|
|
121
|
-
},
|
|
122
|
-
get cm() {
|
|
123
|
-
return cm;
|
|
124
|
-
},
|
|
125
|
-
get label() {
|
|
126
|
-
return label;
|
|
127
|
-
},
|
|
128
|
-
get text() {
|
|
129
|
-
return text;
|
|
130
|
-
},
|
|
131
|
-
get unitCube() {
|
|
132
|
-
return unitCube;
|
|
133
|
-
},
|
|
134
|
-
get unitAxis() {
|
|
135
|
-
return unitAxis;
|
|
136
|
-
},
|
|
137
|
-
get toArray() {
|
|
138
|
-
return toArray;
|
|
139
|
-
},
|
|
140
|
-
get ifArray() {
|
|
141
|
-
return ifArray;
|
|
142
|
-
},
|
|
143
|
-
get segment() {
|
|
144
|
-
return segment;
|
|
145
|
-
},
|
|
146
|
-
get zipObject() {
|
|
147
|
-
return zipObject;
|
|
148
|
-
},
|
|
149
|
-
get map() {
|
|
150
|
-
return map;
|
|
151
|
-
},
|
|
152
|
-
get mapValues() {
|
|
153
|
-
return mapValues;
|
|
154
|
-
},
|
|
155
|
-
get pick() {
|
|
156
|
-
return pick;
|
|
157
|
-
},
|
|
158
|
-
get mapPick() {
|
|
159
|
-
return mapPick;
|
|
160
|
-
},
|
|
161
|
-
get divA() {
|
|
162
|
-
return divA;
|
|
163
|
-
},
|
|
164
|
-
get divxyz() {
|
|
165
|
-
return divxyz;
|
|
166
|
-
},
|
|
167
|
-
get div() {
|
|
168
|
-
return div$1;
|
|
169
|
-
},
|
|
170
|
-
get mulxyz() {
|
|
171
|
-
return mulxyz;
|
|
172
|
-
},
|
|
173
|
-
get mul() {
|
|
174
|
-
return mul;
|
|
175
|
-
},
|
|
176
|
-
get xyz2array() {
|
|
177
|
-
return xyz2array;
|
|
178
|
-
},
|
|
179
|
-
get rotationAxes() {
|
|
180
|
-
return rotationAxes;
|
|
181
|
-
},
|
|
182
|
-
get size() {
|
|
183
|
-
return size;
|
|
184
|
-
},
|
|
185
|
-
get scale() {
|
|
186
|
-
return scale;
|
|
187
|
-
},
|
|
188
|
-
get center() {
|
|
189
|
-
return center;
|
|
190
|
-
},
|
|
191
|
-
get centerY() {
|
|
192
|
-
return centerY;
|
|
193
|
-
},
|
|
194
|
-
get centerX() {
|
|
195
|
-
return centerX;
|
|
196
|
-
},
|
|
197
|
-
get enlarge() {
|
|
198
|
-
return enlarge;
|
|
199
|
-
},
|
|
200
|
-
get fit() {
|
|
201
|
-
return fit;
|
|
202
|
-
},
|
|
203
|
-
get shift() {
|
|
204
|
-
return shift;
|
|
205
|
-
},
|
|
206
|
-
get zero() {
|
|
207
|
-
return zero;
|
|
208
|
-
},
|
|
209
|
-
get mirrored4() {
|
|
210
|
-
return mirrored4;
|
|
211
|
-
},
|
|
212
|
-
get flushSide() {
|
|
213
|
-
return flushSide;
|
|
214
|
-
},
|
|
215
|
-
get calcFlush() {
|
|
216
|
-
return calcFlush;
|
|
217
|
-
},
|
|
218
|
-
get calcSnap() {
|
|
219
|
-
return calcSnap;
|
|
220
|
-
},
|
|
221
|
-
get snap() {
|
|
222
|
-
return snap;
|
|
223
|
-
},
|
|
224
|
-
get flush() {
|
|
225
|
-
return flush;
|
|
226
|
-
},
|
|
227
|
-
get axisApply() {
|
|
228
|
-
return axisApply;
|
|
229
|
-
},
|
|
230
|
-
get axis2array() {
|
|
231
|
-
return axis2array;
|
|
232
|
-
},
|
|
233
|
-
get centroid() {
|
|
234
|
-
return centroid;
|
|
235
|
-
},
|
|
236
|
-
get calcmidlineTo() {
|
|
237
|
-
return calcmidlineTo;
|
|
238
|
-
},
|
|
239
|
-
get midlineTo() {
|
|
240
|
-
return midlineTo;
|
|
241
|
-
},
|
|
242
|
-
get translator() {
|
|
243
|
-
return translator;
|
|
244
|
-
},
|
|
245
|
-
get calcCenterWith() {
|
|
246
|
-
return calcCenterWith;
|
|
247
|
-
},
|
|
248
|
-
get centerWith() {
|
|
249
|
-
return centerWith;
|
|
250
|
-
},
|
|
251
|
-
get getDelta() {
|
|
252
|
-
return getDelta;
|
|
253
|
-
},
|
|
254
|
-
get bisect() {
|
|
255
|
-
return bisect;
|
|
256
|
-
},
|
|
257
|
-
get slice() {
|
|
258
|
-
return slice;
|
|
259
|
-
},
|
|
260
|
-
get wedge() {
|
|
261
|
-
return wedge;
|
|
262
|
-
},
|
|
263
|
-
get stretch() {
|
|
264
|
-
return stretch;
|
|
265
|
-
},
|
|
266
|
-
get poly2solid() {
|
|
267
|
-
return poly2solid;
|
|
268
|
-
},
|
|
269
|
-
get slices2poly() {
|
|
270
|
-
return slices2poly;
|
|
271
|
-
},
|
|
272
|
-
get normalVector() {
|
|
273
|
-
return normalVector;
|
|
274
|
-
},
|
|
275
|
-
get sliceParams() {
|
|
276
|
-
return sliceParams;
|
|
277
|
-
},
|
|
278
|
-
get reShape() {
|
|
279
|
-
return reShape;
|
|
280
|
-
},
|
|
281
|
-
get chamfer() {
|
|
282
|
-
return chamfer;
|
|
283
|
-
},
|
|
284
|
-
get fillet() {
|
|
285
|
-
return fillet;
|
|
286
|
-
},
|
|
287
|
-
get calcRotate() {
|
|
288
|
-
return calcRotate;
|
|
289
|
-
},
|
|
290
|
-
get rotateAround() {
|
|
291
|
-
return rotateAround;
|
|
292
|
-
},
|
|
293
|
-
get clone() {
|
|
294
|
-
return clone;
|
|
295
|
-
},
|
|
296
|
-
get addConnector() {
|
|
297
|
-
return addConnector;
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
function _typeof(obj) {
|
|
301
|
-
"@babel/helpers - typeof";
|
|
302
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
303
|
-
_typeof = function(obj) {
|
|
304
|
-
return typeof obj;
|
|
305
|
-
};
|
|
306
|
-
} else {
|
|
307
|
-
_typeof = function(obj) {
|
|
308
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
return _typeof(obj);
|
|
312
|
-
}
|
|
313
|
-
function _defineProperty(obj, key, value) {
|
|
314
|
-
if (key in obj) {
|
|
315
|
-
Object.defineProperty(obj, key, {
|
|
316
|
-
value,
|
|
317
|
-
enumerable: true,
|
|
318
|
-
configurable: true,
|
|
319
|
-
writable: true
|
|
320
|
-
});
|
|
321
|
-
} else {
|
|
322
|
-
obj[key] = value;
|
|
323
|
-
}
|
|
324
|
-
return obj;
|
|
325
|
-
}
|
|
326
|
-
function ownKeys(object, enumerableOnly) {
|
|
327
|
-
var keys = Object.keys(object);
|
|
328
|
-
if (Object.getOwnPropertySymbols) {
|
|
329
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
330
|
-
if (enumerableOnly) symbols = symbols.filter((function(sym) {
|
|
331
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
332
|
-
}));
|
|
333
|
-
keys.push.apply(keys, symbols);
|
|
334
|
-
}
|
|
335
|
-
return keys;
|
|
336
|
-
}
|
|
337
|
-
function _objectSpread2(target) {
|
|
338
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
339
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
340
|
-
if (i % 2) {
|
|
341
|
-
ownKeys(Object(source), true).forEach((function(key) {
|
|
342
|
-
_defineProperty(target, key, source[key]);
|
|
343
|
-
}));
|
|
344
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
345
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
346
|
-
} else {
|
|
347
|
-
ownKeys(Object(source)).forEach((function(key) {
|
|
348
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
349
|
-
}));
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return target;
|
|
353
|
-
}
|
|
354
|
-
function _slicedToArray(arr, i) {
|
|
355
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
356
|
-
}
|
|
357
|
-
function _arrayWithHoles(arr) {
|
|
358
|
-
if (Array.isArray(arr)) return arr;
|
|
359
|
-
}
|
|
360
|
-
function _iterableToArrayLimit(arr, i) {
|
|
361
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
362
|
-
var _arr = [];
|
|
363
|
-
var _n = true;
|
|
364
|
-
var _d = false;
|
|
365
|
-
var _e = undefined;
|
|
366
|
-
try {
|
|
367
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
368
|
-
_arr.push(_s.value);
|
|
369
|
-
if (i && _arr.length === i) break;
|
|
370
|
-
}
|
|
371
|
-
} catch (err) {
|
|
372
|
-
_d = true;
|
|
373
|
-
_e = err;
|
|
374
|
-
} finally {
|
|
375
|
-
try {
|
|
376
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
377
|
-
} finally {
|
|
378
|
-
if (_d) throw _e;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return _arr;
|
|
382
|
-
}
|
|
383
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
384
|
-
if (!o) return;
|
|
385
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
386
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
387
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
388
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
389
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
390
|
-
}
|
|
391
|
-
function _arrayLikeToArray(arr, len) {
|
|
392
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
393
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
394
|
-
return arr2;
|
|
395
|
-
}
|
|
396
|
-
function _nonIterableRest() {
|
|
397
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
398
|
-
}
|
|
399
|
-
var toRadians = function toRadians(deg) {
|
|
77
|
+
const toRadians = function toRadians(deg) {
|
|
400
78
|
return deg / 180 * Math.PI;
|
|
401
79
|
};
|
|
402
|
-
|
|
80
|
+
const toDegrees = function toDegrees(rad) {
|
|
403
81
|
return rad * (180 / Math.PI);
|
|
404
82
|
};
|
|
405
|
-
|
|
83
|
+
const solve = function(p1, p2) {
|
|
406
84
|
var r = {
|
|
407
85
|
c: 90,
|
|
408
86
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -414,7 +92,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
414
92
|
r.a = 90 - r.b;
|
|
415
93
|
return r;
|
|
416
94
|
};
|
|
417
|
-
|
|
95
|
+
const solve90SA = function(r) {
|
|
418
96
|
r = Object.assign(r, {
|
|
419
97
|
C: 90
|
|
420
98
|
});
|
|
@@ -426,7 +104,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
426
104
|
r.b = r.b || r.a / Math.tan(arad);
|
|
427
105
|
return r;
|
|
428
106
|
};
|
|
429
|
-
|
|
107
|
+
const solve90ac = function(r) {
|
|
430
108
|
r = Object.assign(r, {
|
|
431
109
|
C: 90
|
|
432
110
|
});
|
|
@@ -447,60 +125,60 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
447
125
|
}
|
|
448
126
|
var triUtils = Object.freeze({
|
|
449
127
|
__proto__: null,
|
|
450
|
-
toRadians,
|
|
451
|
-
toDegrees,
|
|
452
128
|
solve,
|
|
453
129
|
solve90SA,
|
|
454
130
|
solve90ac,
|
|
455
|
-
solveab
|
|
131
|
+
solveab,
|
|
132
|
+
toDegrees,
|
|
133
|
+
toRadians
|
|
456
134
|
});
|
|
457
|
-
|
|
458
|
-
return a.map(
|
|
135
|
+
const div$1 = function(a, f) {
|
|
136
|
+
return a.map(function(e) {
|
|
459
137
|
return e / f;
|
|
460
|
-
})
|
|
138
|
+
});
|
|
461
139
|
};
|
|
462
|
-
|
|
463
|
-
return a.map(
|
|
140
|
+
const addValue = function(a, f) {
|
|
141
|
+
return a.map(function(e) {
|
|
464
142
|
return e + f;
|
|
465
|
-
})
|
|
143
|
+
});
|
|
466
144
|
};
|
|
467
|
-
|
|
468
|
-
return a.map(
|
|
145
|
+
const addArray = function(a, f) {
|
|
146
|
+
return a.map(function(e, i) {
|
|
469
147
|
return e + f[i];
|
|
470
|
-
})
|
|
148
|
+
});
|
|
471
149
|
};
|
|
472
|
-
|
|
473
|
-
return Array.prototype.slice.call(arguments, 1).reduce(
|
|
150
|
+
const add = function(a) {
|
|
151
|
+
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
474
152
|
if (Array.isArray(arg)) {
|
|
475
153
|
result = addArray(result, arg);
|
|
476
154
|
} else {
|
|
477
155
|
result = addValue(result, arg);
|
|
478
156
|
}
|
|
479
157
|
return result;
|
|
480
|
-
}
|
|
158
|
+
}, a);
|
|
481
159
|
};
|
|
482
|
-
|
|
160
|
+
const fromxyz = function(object) {
|
|
483
161
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
484
162
|
};
|
|
485
|
-
|
|
163
|
+
const toxyz = function(a) {
|
|
486
164
|
return {
|
|
487
165
|
x: a[0],
|
|
488
166
|
y: a[1],
|
|
489
167
|
z: a[2]
|
|
490
168
|
};
|
|
491
169
|
};
|
|
492
|
-
|
|
170
|
+
const first = function(a) {
|
|
493
171
|
return a ? a[0] : undefined;
|
|
494
172
|
};
|
|
495
|
-
|
|
173
|
+
const last = function(a) {
|
|
496
174
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
497
175
|
};
|
|
498
|
-
|
|
499
|
-
return a.reduce(
|
|
176
|
+
const min = function(a) {
|
|
177
|
+
return a.reduce(function(result, value) {
|
|
500
178
|
return value < result ? value : result;
|
|
501
|
-
}
|
|
179
|
+
}, Number.MAX_VALUE);
|
|
502
180
|
};
|
|
503
|
-
|
|
181
|
+
const range = function(a, b) {
|
|
504
182
|
var result = [];
|
|
505
183
|
for (var i = a; i < b; i++) {
|
|
506
184
|
result.push(i);
|
|
@@ -509,21 +187,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
509
187
|
};
|
|
510
188
|
var array = Object.freeze({
|
|
511
189
|
__proto__: null,
|
|
512
|
-
div,
|
|
513
|
-
addValue,
|
|
514
|
-
addArray,
|
|
515
190
|
add,
|
|
516
|
-
|
|
517
|
-
|
|
191
|
+
addArray,
|
|
192
|
+
addValue,
|
|
193
|
+
div: div$1,
|
|
518
194
|
first,
|
|
195
|
+
fromxyz,
|
|
519
196
|
last,
|
|
520
197
|
min,
|
|
521
|
-
range
|
|
198
|
+
range,
|
|
199
|
+
toxyz
|
|
522
200
|
});
|
|
523
|
-
|
|
524
|
-
|
|
201
|
+
const debugColors = [ "#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999" ];
|
|
202
|
+
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" ];
|
|
525
203
|
var debugCount = 0;
|
|
526
|
-
|
|
204
|
+
const Debug = function(name) {
|
|
527
205
|
var checks = Object.assign({
|
|
528
206
|
enabled: [],
|
|
529
207
|
disabled: [],
|
|
@@ -531,31 +209,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
531
209
|
browser: true
|
|
532
210
|
}
|
|
533
211
|
}, jscadUtilsDebug || {});
|
|
534
|
-
var style = checks.options.browser ?
|
|
535
|
-
var enabled = checks.enabled.some(
|
|
212
|
+
var style = checks.options.browser ? `color:${debugColors[debugCount++ % debugColors.length]}` : `${termColors[debugCount++ % termColors.length]}`;
|
|
213
|
+
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
536
214
|
return check.test(name);
|
|
537
|
-
})
|
|
215
|
+
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
538
216
|
return check.test(name);
|
|
539
|
-
})
|
|
540
|
-
var logger = enabled ? checks.options.browser ?
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
(_console = console).log.apply(_console, [ "%c%s", style, name ].concat(msg));
|
|
546
|
-
} : function() {
|
|
547
|
-
var _console2;
|
|
548
|
-
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
549
|
-
msg[_key2] = arguments[_key2];
|
|
550
|
-
}
|
|
551
|
-
(_console2 = console).log.apply(_console2, [ "".concat(name) ].concat(msg));
|
|
552
|
-
} : function() {
|
|
553
|
-
return undefined;
|
|
554
|
-
};
|
|
217
|
+
});
|
|
218
|
+
var logger = enabled ? checks.options.browser ? (...msg) => {
|
|
219
|
+
console.log("%c%s", style, name, ...msg);
|
|
220
|
+
} : (...msg) => {
|
|
221
|
+
console.log(`${name}`, ...msg);
|
|
222
|
+
} : () => undefined;
|
|
555
223
|
logger.enabled = enabled;
|
|
556
224
|
return logger;
|
|
557
225
|
};
|
|
558
|
-
|
|
226
|
+
const nameArray = {
|
|
559
227
|
aliceblue: "#f0f8ff",
|
|
560
228
|
antiquewhite: "#faebd7",
|
|
561
229
|
aqua: "#00ffff",
|
|
@@ -713,9 +381,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
713
381
|
h = h.replace(/^\#/, "");
|
|
714
382
|
if (h.length === 6) {
|
|
715
383
|
return [ parseInt(h.substr(0, 2), 16), parseInt(h.substr(2, 2), 16), parseInt(h.substr(4, 2), 16) ];
|
|
384
|
+
} else {
|
|
385
|
+
return [ 0, 0, 0 ];
|
|
716
386
|
}
|
|
717
387
|
}
|
|
718
|
-
|
|
388
|
+
const _name2rgb = {};
|
|
719
389
|
function name2rgb(n) {
|
|
720
390
|
if (!_name2rgb[n]) _name2rgb[n] = hex2rgb(name2hex(n));
|
|
721
391
|
return _name2rgb[n];
|
|
@@ -723,9 +393,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
723
393
|
function color(o, r, g, b, a) {
|
|
724
394
|
if (typeof r !== "string") return o.setColor(r, g, b, a);
|
|
725
395
|
if (r === "") return o;
|
|
726
|
-
var c = name2rgb(r).map(
|
|
396
|
+
var c = name2rgb(r).map(function(x) {
|
|
727
397
|
return x / 255;
|
|
728
|
-
})
|
|
398
|
+
});
|
|
729
399
|
c[3] = g || 1;
|
|
730
400
|
return o.setColor(c);
|
|
731
401
|
}
|
|
@@ -795,23 +465,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
795
465
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
796
466
|
return chamfer(this, radius, orientation, options);
|
|
797
467
|
};
|
|
798
|
-
proto.prototype.bisect = function bisect$1() {
|
|
799
|
-
|
|
800
|
-
args[_key] = arguments[_key];
|
|
801
|
-
}
|
|
802
|
-
return bisect.apply(util, [ this ].concat(args));
|
|
468
|
+
proto.prototype.bisect = function bisect$1(...args) {
|
|
469
|
+
return bisect(this, ...args);
|
|
803
470
|
};
|
|
804
|
-
proto.prototype.slice = function slice$1() {
|
|
805
|
-
|
|
806
|
-
args[_key2] = arguments[_key2];
|
|
807
|
-
}
|
|
808
|
-
return slice.apply(util, [ this ].concat(args));
|
|
471
|
+
proto.prototype.slice = function slice$1(...args) {
|
|
472
|
+
return slice(this, ...args);
|
|
809
473
|
};
|
|
810
|
-
proto.prototype.wedge = function wedge$1() {
|
|
811
|
-
|
|
812
|
-
args[_key3] = arguments[_key3];
|
|
813
|
-
}
|
|
814
|
-
return wedge.apply(util, [ this ].concat(args));
|
|
474
|
+
proto.prototype.wedge = function wedge$1(...args) {
|
|
475
|
+
return wedge(this, ...args);
|
|
815
476
|
};
|
|
816
477
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
817
478
|
return stretch(this, axis, distance, offset);
|
|
@@ -827,24 +488,20 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
827
488
|
if (arguments.length === 1) {
|
|
828
489
|
return this._translate(arguments[0]);
|
|
829
490
|
} else {
|
|
830
|
-
var t = Array.prototype.slice.call(arguments, 0).reduce(
|
|
831
|
-
result = undefined(result, arg);
|
|
491
|
+
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
492
|
+
result = undefined.addArray(result, arg);
|
|
832
493
|
return result;
|
|
833
|
-
}
|
|
494
|
+
}, [ 0, 0, 0 ]);
|
|
834
495
|
return this._translate(t);
|
|
835
496
|
}
|
|
836
497
|
};
|
|
837
498
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
838
499
|
return addConnector(this, name, point, axis, normal);
|
|
839
500
|
};
|
|
840
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
841
|
-
var
|
|
842
|
-
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
843
|
-
var myConnector = myConnectorName.split(".").reduce((function(a, v) {
|
|
844
|
-
return a[v];
|
|
845
|
-
}), this.properties);
|
|
501
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector, mirror = false, normalrotation = 0) {
|
|
502
|
+
var myConnector = myConnectorName.split(".").reduce((a, v) => a[v], this.properties);
|
|
846
503
|
if (!myConnector) {
|
|
847
|
-
error(
|
|
504
|
+
error(`The connector '${myConnectorName}' does not exist on the object [${Object.keys(this.properties).join(",")}]`, "Missing connector property");
|
|
848
505
|
}
|
|
849
506
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
850
507
|
};
|
|
@@ -854,32 +511,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
854
511
|
__proto__: null,
|
|
855
512
|
default: init
|
|
856
513
|
});
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
514
|
+
const {CSG, CAG} = jsCadCSG;
|
|
515
|
+
const {rectangular_extrude} = scadApi.extrusions;
|
|
516
|
+
const {vector_text, vector_char} = scadApi.text;
|
|
517
|
+
const {union} = scadApi.booleanOps;
|
|
861
518
|
init(CSG);
|
|
862
|
-
|
|
863
|
-
function JsCadUtilsGroup() {
|
|
864
|
-
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
865
|
-
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
866
|
-
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
519
|
+
const debug$3 = Debug("jscadUtils:group");
|
|
520
|
+
function JsCadUtilsGroup(names = [], parts = {}, holes = []) {
|
|
867
521
|
this.name = "";
|
|
868
522
|
this.names = names;
|
|
869
523
|
this.parts = parts;
|
|
870
524
|
this.holes = holes;
|
|
871
525
|
}
|
|
872
526
|
JsCadUtilsGroup.prototype.add = function(object, name, hidden, subparts, parts) {
|
|
873
|
-
debug("add", object, name, hidden, subparts, parts);
|
|
527
|
+
debug$3("add", object, name, hidden, subparts, parts);
|
|
874
528
|
var self = this;
|
|
875
529
|
if (object.parts) {
|
|
876
530
|
if (name) {
|
|
877
531
|
if (!hidden) self.names.push(name);
|
|
878
532
|
self.parts[name] = object.combine(parts);
|
|
879
533
|
if (subparts) {
|
|
880
|
-
Object.keys(object.parts).forEach(
|
|
534
|
+
Object.keys(object.parts).forEach(function(key) {
|
|
881
535
|
self.parts[subparts + key] = object.parts[key];
|
|
882
|
-
})
|
|
536
|
+
});
|
|
883
537
|
}
|
|
884
538
|
} else {
|
|
885
539
|
Object.assign(self.parts, object.parts);
|
|
@@ -891,11 +545,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
891
545
|
}
|
|
892
546
|
return self;
|
|
893
547
|
};
|
|
894
|
-
JsCadUtilsGroup.prototype.combine = function(pieces) {
|
|
895
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
896
|
-
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function(x) {
|
|
897
|
-
return x;
|
|
898
|
-
};
|
|
548
|
+
JsCadUtilsGroup.prototype.combine = function(pieces, options = {}, map = x => x) {
|
|
899
549
|
try {
|
|
900
550
|
var self = this;
|
|
901
551
|
options = Object.assign({
|
|
@@ -903,31 +553,30 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
903
553
|
}, options);
|
|
904
554
|
pieces = pieces ? pieces.split(",") : self.names;
|
|
905
555
|
if (pieces.length === 0) {
|
|
906
|
-
throw new Error(
|
|
556
|
+
throw new Error(`no pieces found in ${self.name} pieces: ${pieces} parts: ${Object.keys(self.parts)} names: ${self.names}`);
|
|
907
557
|
}
|
|
908
|
-
debug("combine", self.names, self.parts);
|
|
909
|
-
var g = union(mapPick(self.parts, pieces,
|
|
558
|
+
debug$3("combine", self.names, self.parts);
|
|
559
|
+
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
560
|
+
debug$3("combine mapPick", value, key, object);
|
|
910
561
|
return map ? map(value, key, index, object) : identity(value);
|
|
911
|
-
}
|
|
562
|
+
}, self.name));
|
|
912
563
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
913
564
|
} catch (err) {
|
|
914
|
-
debug("combine error", this, pieces, options, err);
|
|
915
|
-
throw error(
|
|
565
|
+
debug$3("combine error", this, pieces, options, err);
|
|
566
|
+
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");
|
|
916
567
|
}
|
|
917
568
|
};
|
|
918
569
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
919
570
|
var self = this;
|
|
920
|
-
self.parts = Object.keys(self.parts).filter((function(
|
|
921
|
-
return k !== "holes";
|
|
922
|
-
})).reduce((function(result, key) {
|
|
571
|
+
self.parts = Object.keys(self.parts).filter(k => k !== "holes").reduce(function(result, key) {
|
|
923
572
|
result[key] = cb(self.parts[key], key);
|
|
924
573
|
return result;
|
|
925
|
-
}
|
|
574
|
+
}, {});
|
|
926
575
|
if (self.holes) {
|
|
927
576
|
if (Array.isArray(self.holes)) {
|
|
928
|
-
self.holes = self.holes.map(
|
|
577
|
+
self.holes = self.holes.map(function(hole, idx) {
|
|
929
578
|
return cb(hole, idx);
|
|
930
|
-
})
|
|
579
|
+
});
|
|
931
580
|
} else {
|
|
932
581
|
self.holes = cb(self.holes, "holes");
|
|
933
582
|
}
|
|
@@ -935,7 +584,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
935
584
|
return self;
|
|
936
585
|
};
|
|
937
586
|
JsCadUtilsGroup.prototype.clone = function(name, map) {
|
|
938
|
-
debug("clone", name,
|
|
587
|
+
debug$3("clone", name, typeof name, map);
|
|
939
588
|
var self = this;
|
|
940
589
|
if (typeof name == "function") {
|
|
941
590
|
map = name;
|
|
@@ -943,15 +592,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
943
592
|
}
|
|
944
593
|
if (!map) map = identity;
|
|
945
594
|
var group = Group(name);
|
|
946
|
-
Object.keys(self.parts).forEach(
|
|
595
|
+
Object.keys(self.parts).forEach(function(key) {
|
|
947
596
|
var part = self.parts[key];
|
|
948
597
|
var hidden = self.names.indexOf(key) == -1;
|
|
949
598
|
group.add(map(clone(part)), key, hidden);
|
|
950
|
-
})
|
|
599
|
+
});
|
|
951
600
|
if (self.holes) {
|
|
952
|
-
group.holes = toArray(self.holes).map(
|
|
601
|
+
group.holes = toArray(self.holes).map(function(part) {
|
|
953
602
|
return map(CSG.fromPolygons(part.toPolygons()), "holes");
|
|
954
|
-
})
|
|
603
|
+
});
|
|
955
604
|
}
|
|
956
605
|
return group;
|
|
957
606
|
};
|
|
@@ -968,9 +617,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
968
617
|
}
|
|
969
618
|
var rotationCenter = solid.centroid();
|
|
970
619
|
var rotationAxis = axes[axis];
|
|
971
|
-
self.map(
|
|
620
|
+
self.map(function(part) {
|
|
972
621
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
973
|
-
})
|
|
622
|
+
});
|
|
974
623
|
return self;
|
|
975
624
|
};
|
|
976
625
|
JsCadUtilsGroup.prototype.combineAll = function(options, map) {
|
|
@@ -981,13 +630,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
981
630
|
try {
|
|
982
631
|
var self = this;
|
|
983
632
|
var t = calcSnap(self.combine(part), to, axis, orientation, delta);
|
|
984
|
-
self.map(
|
|
633
|
+
self.map(function(part) {
|
|
985
634
|
return part.translate(t);
|
|
986
|
-
})
|
|
635
|
+
});
|
|
987
636
|
return self;
|
|
988
637
|
} catch (err) {
|
|
989
|
-
debug("snap error", this, part, to, axis, delta, err);
|
|
990
|
-
throw error(
|
|
638
|
+
debug$3("snap error", this, part, to, axis, delta, err);
|
|
639
|
+
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");
|
|
991
640
|
}
|
|
992
641
|
};
|
|
993
642
|
JsCadUtilsGroup.prototype.align = function align(part, to, axis, delta) {
|
|
@@ -996,13 +645,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
996
645
|
var t = calcCenterWith(self.combine(part, {
|
|
997
646
|
noholes: true
|
|
998
647
|
}), axis, to, delta);
|
|
999
|
-
self.map(
|
|
648
|
+
self.map(function(part) {
|
|
1000
649
|
return part.translate(t);
|
|
1001
|
-
})
|
|
650
|
+
});
|
|
1002
651
|
return self;
|
|
1003
652
|
} catch (err) {
|
|
1004
|
-
debug("align error", this, part, to, axis, delta, err);
|
|
1005
|
-
throw error(
|
|
653
|
+
debug$3("align error", this, part, to, axis, delta, err);
|
|
654
|
+
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");
|
|
1006
655
|
}
|
|
1007
656
|
};
|
|
1008
657
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -1014,10 +663,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1014
663
|
var bounds = self.parts[part].getBounds();
|
|
1015
664
|
return self.translate([ 0, 0, -bounds[0].z ]);
|
|
1016
665
|
};
|
|
1017
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
1018
|
-
|
|
1019
|
-
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
1020
|
-
debug("connectTo", {
|
|
666
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName, mirror = true, normalrotation = 0) {
|
|
667
|
+
debug$3("connectTo", {
|
|
1021
668
|
partName,
|
|
1022
669
|
connectorName,
|
|
1023
670
|
to,
|
|
@@ -1026,38 +673,34 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1026
673
|
normalrotation
|
|
1027
674
|
});
|
|
1028
675
|
var self = this;
|
|
1029
|
-
var myConnector = connectorName.split(".").reduce((
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
debug("toConnector", to instanceof CSG.Connector);
|
|
1033
|
-
var toConnector = toConnectorName.split(".").reduce((function(a, v) {
|
|
1034
|
-
return a[v];
|
|
1035
|
-
}), to.properties);
|
|
676
|
+
var myConnector = connectorName.split(".").reduce((a, v) => a[v], self.parts[partName].properties);
|
|
677
|
+
debug$3("toConnector", to instanceof CSG.Connector);
|
|
678
|
+
var toConnector = toConnectorName.split(".").reduce((a, v) => a[v], to.properties);
|
|
1036
679
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
1037
|
-
debug("connectTo", matrix);
|
|
1038
|
-
self.map(
|
|
680
|
+
debug$3("connectTo", matrix);
|
|
681
|
+
self.map(function(part) {
|
|
1039
682
|
return part.transform(matrix);
|
|
1040
|
-
})
|
|
683
|
+
});
|
|
1041
684
|
return self;
|
|
1042
685
|
};
|
|
1043
686
|
JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
|
|
1044
687
|
var self = this;
|
|
1045
688
|
var size = self.combine(part).size();
|
|
1046
|
-
var t = axisApply(axis,
|
|
689
|
+
var t = axisApply(axis, function(i, a) {
|
|
1047
690
|
return to - size[a] / 2;
|
|
1048
|
-
})
|
|
1049
|
-
self.map(
|
|
691
|
+
});
|
|
692
|
+
self.map(function(part) {
|
|
1050
693
|
return part.translate(t);
|
|
1051
|
-
})
|
|
694
|
+
});
|
|
1052
695
|
return self;
|
|
1053
696
|
};
|
|
1054
697
|
JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
|
|
1055
698
|
var self = this;
|
|
1056
699
|
var t = Array.isArray(x) ? x : [ x, y, z ];
|
|
1057
|
-
debug("translate", t);
|
|
1058
|
-
self.map(
|
|
700
|
+
debug$3("translate", t);
|
|
701
|
+
self.map(function(part) {
|
|
1059
702
|
return part.translate(t);
|
|
1060
|
-
})
|
|
703
|
+
});
|
|
1061
704
|
return self;
|
|
1062
705
|
};
|
|
1063
706
|
JsCadUtilsGroup.prototype.pick = function(parts, map) {
|
|
@@ -1065,43 +708,42 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1065
708
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1066
709
|
if (!map) map = identity;
|
|
1067
710
|
var g = Group();
|
|
1068
|
-
p.forEach(
|
|
711
|
+
p.forEach(function(name) {
|
|
1069
712
|
g.add(map(CSG.fromPolygons(self.parts[name].toPolygons()), name), name);
|
|
1070
|
-
})
|
|
713
|
+
});
|
|
1071
714
|
return g;
|
|
1072
715
|
};
|
|
1073
716
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
1074
|
-
var _this = this;
|
|
1075
717
|
var self = this;
|
|
1076
718
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1077
719
|
if (!map) map = identity;
|
|
1078
720
|
var a = [];
|
|
1079
|
-
p.forEach(
|
|
721
|
+
p.forEach(name => {
|
|
1080
722
|
if (!self.parts[name]) {
|
|
1081
|
-
debug("array error",
|
|
1082
|
-
throw error(
|
|
723
|
+
debug$3("array error", this, parts);
|
|
724
|
+
throw error(`group::array error "${name}" not found.\nthis: ${this}\nparts: "${parts}"\n`, "JSCAD_UTILS_GROUP_ERROR");
|
|
1083
725
|
}
|
|
1084
726
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
1085
|
-
})
|
|
727
|
+
});
|
|
1086
728
|
return a;
|
|
1087
729
|
};
|
|
1088
730
|
JsCadUtilsGroup.prototype.toArray = function(pieces) {
|
|
1089
731
|
var self = this;
|
|
1090
732
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
1091
|
-
return piecesArray.map(
|
|
1092
|
-
if (!self.parts[piece]) console.error(
|
|
733
|
+
return piecesArray.map(function(piece) {
|
|
734
|
+
if (!self.parts[piece]) console.error(`Cannot find ${piece} in ${self.names}`);
|
|
1093
735
|
return self.parts[piece];
|
|
1094
|
-
})
|
|
736
|
+
});
|
|
1095
737
|
};
|
|
1096
738
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
1097
|
-
return
|
|
739
|
+
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}`;
|
|
1098
740
|
};
|
|
1099
741
|
JsCadUtilsGroup.prototype.setName = function(name) {
|
|
1100
742
|
this.name = name;
|
|
1101
743
|
return this;
|
|
1102
744
|
};
|
|
1103
745
|
function Group(objectNames, addObjects) {
|
|
1104
|
-
debug("Group", objectNames, addObjects);
|
|
746
|
+
debug$3("Group", objectNames, addObjects);
|
|
1105
747
|
var self = {
|
|
1106
748
|
name: "",
|
|
1107
749
|
names: [],
|
|
@@ -1124,9 +766,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1124
766
|
self.name = objectNames;
|
|
1125
767
|
} else {
|
|
1126
768
|
var objects = objectNames;
|
|
1127
|
-
self.names = Object.keys(objects).filter(
|
|
1128
|
-
return k !== "holes";
|
|
1129
|
-
}));
|
|
769
|
+
self.names = Object.keys(objects).filter(k => k !== "holes");
|
|
1130
770
|
self.parts = Object.assign({}, objects);
|
|
1131
771
|
self.holes = objects.holes;
|
|
1132
772
|
}
|
|
@@ -1134,17 +774,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1134
774
|
}
|
|
1135
775
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
1136
776
|
}
|
|
1137
|
-
|
|
777
|
+
const debug$2 = Debug("jscadUtils:util");
|
|
1138
778
|
var NOZZEL_SIZE = .4;
|
|
1139
|
-
|
|
1140
|
-
under: function
|
|
1141
|
-
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1142
|
-
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
779
|
+
const nearest = {
|
|
780
|
+
under: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
|
|
1143
781
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
1144
782
|
},
|
|
1145
|
-
over: function
|
|
1146
|
-
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1147
|
-
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
783
|
+
over: function(desired, nozzel = NOZZEL_SIZE, nozzie = 0) {
|
|
1148
784
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
1149
785
|
}
|
|
1150
786
|
};
|
|
@@ -1169,12 +805,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1169
805
|
return ((n = +n) || 1 / n) < 0;
|
|
1170
806
|
}
|
|
1171
807
|
function print(msg, o) {
|
|
1172
|
-
debug$
|
|
808
|
+
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
1173
809
|
}
|
|
1174
810
|
function jscadToString(o) {
|
|
1175
|
-
if (
|
|
811
|
+
if (typeof o == "object") {
|
|
1176
812
|
if (o.polygons) {
|
|
1177
|
-
return
|
|
813
|
+
return `{\npolygons: ${o.polygons.length},\nproperties: "${Object.keys(o.properties)}"\n}\n`;
|
|
1178
814
|
}
|
|
1179
815
|
} else {
|
|
1180
816
|
return o.toString();
|
|
@@ -1205,22 +841,22 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1205
841
|
function label(text, x, y, width, height) {
|
|
1206
842
|
var l = vector_text(x || 0, y || 0, text);
|
|
1207
843
|
var o = [];
|
|
1208
|
-
l.forEach(
|
|
844
|
+
l.forEach(function(pl) {
|
|
1209
845
|
o.push(rectangular_extrude(pl, {
|
|
1210
846
|
w: width || 2,
|
|
1211
847
|
h: height || 2
|
|
1212
848
|
}));
|
|
1213
|
-
})
|
|
849
|
+
});
|
|
1214
850
|
return center(union(o));
|
|
1215
851
|
}
|
|
1216
852
|
function text(text) {
|
|
1217
853
|
var l = vector_char(0, 0, text);
|
|
1218
|
-
var
|
|
854
|
+
var char = l.segments.reduce(function(result, segment) {
|
|
1219
855
|
var path = new CSG.Path2D(segment);
|
|
1220
856
|
var cag = path.expandToCAG(2);
|
|
1221
857
|
return result ? result.union(cag) : cag;
|
|
1222
|
-
}
|
|
1223
|
-
return
|
|
858
|
+
}, undefined);
|
|
859
|
+
return char;
|
|
1224
860
|
}
|
|
1225
861
|
function unitCube(length, radius) {
|
|
1226
862
|
radius = radius || .5;
|
|
@@ -1230,7 +866,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1230
866
|
});
|
|
1231
867
|
}
|
|
1232
868
|
function unitAxis(length, radius, centroid) {
|
|
1233
|
-
debug$
|
|
869
|
+
debug$2("unitAxis", length, radius, centroid);
|
|
1234
870
|
centroid = centroid || [ 0, 0, 0 ];
|
|
1235
871
|
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) ]);
|
|
1236
872
|
unitaxis.properties.origin = new CSG.Connector([ 0, 0, 0 ], [ 1, 0, 0 ], [ 0, 1, 0 ]);
|
|
@@ -1252,38 +888,38 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1252
888
|
return result;
|
|
1253
889
|
}
|
|
1254
890
|
function zipObject(names, values) {
|
|
1255
|
-
return names.reduce(
|
|
891
|
+
return names.reduce(function(result, value, idx) {
|
|
1256
892
|
result[value] = values[idx];
|
|
1257
893
|
return result;
|
|
1258
|
-
}
|
|
894
|
+
}, {});
|
|
1259
895
|
}
|
|
1260
896
|
function map(o, f) {
|
|
1261
|
-
return Object.keys(o).map(
|
|
897
|
+
return Object.keys(o).map(function(key) {
|
|
1262
898
|
return f(o[key], key, o);
|
|
1263
|
-
})
|
|
899
|
+
});
|
|
1264
900
|
}
|
|
1265
901
|
function mapValues(o, f) {
|
|
1266
|
-
return Object.keys(o).map(
|
|
902
|
+
return Object.keys(o).map(function(key) {
|
|
1267
903
|
return f(o[key], key);
|
|
1268
|
-
})
|
|
904
|
+
});
|
|
1269
905
|
}
|
|
1270
906
|
function pick(o, names) {
|
|
1271
|
-
return names.reduce(
|
|
907
|
+
return names.reduce(function(result, name) {
|
|
1272
908
|
result[name] = o[name];
|
|
1273
909
|
return result;
|
|
1274
|
-
}
|
|
910
|
+
}, {});
|
|
1275
911
|
}
|
|
1276
912
|
function mapPick(o, names, f, options) {
|
|
1277
|
-
return names.reduce(
|
|
913
|
+
return names.reduce(function(result, name, index) {
|
|
1278
914
|
if (!o[name]) {
|
|
1279
|
-
throw new Error(
|
|
915
|
+
throw new Error(`${name} not found in ${options.name}: ${Object.keys(o).join(",")}`);
|
|
1280
916
|
}
|
|
1281
917
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
1282
918
|
return result;
|
|
1283
|
-
}
|
|
919
|
+
}, []);
|
|
1284
920
|
}
|
|
1285
921
|
function divA(a, f) {
|
|
1286
|
-
return div(a, f);
|
|
922
|
+
return div$1(a, f);
|
|
1287
923
|
}
|
|
1288
924
|
function divxyz(size, x, y, z) {
|
|
1289
925
|
return {
|
|
@@ -1292,7 +928,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1292
928
|
z: size.z / z
|
|
1293
929
|
};
|
|
1294
930
|
}
|
|
1295
|
-
function div
|
|
931
|
+
function div(size, d) {
|
|
1296
932
|
return this.divxyz(size, d, d, d);
|
|
1297
933
|
}
|
|
1298
934
|
function mulxyz(size, x, y, z) {
|
|
@@ -1308,7 +944,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1308
944
|
function xyz2array(size) {
|
|
1309
945
|
return [ size.x, size.y, size.z ];
|
|
1310
946
|
}
|
|
1311
|
-
|
|
947
|
+
const rotationAxes = {
|
|
1312
948
|
x: [ 1, 0, 0 ],
|
|
1313
949
|
y: [ 0, 1, 0 ],
|
|
1314
950
|
z: [ 0, 0, 1 ]
|
|
@@ -1344,9 +980,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1344
980
|
var objectSize = size(object);
|
|
1345
981
|
var objectCentroid = centroid(object, objectSize);
|
|
1346
982
|
var idx = 0;
|
|
1347
|
-
var t = map(objectSize,
|
|
983
|
+
var t = map(objectSize, function(i) {
|
|
1348
984
|
return scale(i, a[idx++]);
|
|
1349
|
-
})
|
|
985
|
+
});
|
|
1350
986
|
var new_object = object.scale(t);
|
|
1351
987
|
var new_centroid = centroid(new_object);
|
|
1352
988
|
var delta = new_centroid.minus(objectCentroid).times(-1);
|
|
@@ -1370,10 +1006,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1370
1006
|
}
|
|
1371
1007
|
var s = [ scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z) ];
|
|
1372
1008
|
var min$1 = min(s);
|
|
1373
|
-
return centerWith(object.scale(s.map(
|
|
1009
|
+
return centerWith(object.scale(s.map(function(d, i) {
|
|
1374
1010
|
if (a[i] === 0) return 1;
|
|
1375
1011
|
return keep_aspect_ratio ? min$1 : d;
|
|
1376
|
-
}))
|
|
1012
|
+
})), "xyz", object);
|
|
1377
1013
|
}
|
|
1378
1014
|
function shift(object, x, y, z) {
|
|
1379
1015
|
var hsize = this.div(this.size(object.getBounds()), 2);
|
|
@@ -1386,7 +1022,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1386
1022
|
function mirrored4(x) {
|
|
1387
1023
|
return x.union([ x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90) ]);
|
|
1388
1024
|
}
|
|
1389
|
-
|
|
1025
|
+
const flushSide = {
|
|
1390
1026
|
"above-outside": [ 1, 0 ],
|
|
1391
1027
|
"above-inside": [ 1, 1 ],
|
|
1392
1028
|
"below-outside": [ 0, 1 ],
|
|
@@ -1412,12 +1048,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1412
1048
|
if (side[0] === -1) {
|
|
1413
1049
|
w[-1] = toxyz(withobj.centroid());
|
|
1414
1050
|
}
|
|
1415
|
-
return this.axisApply(axes,
|
|
1051
|
+
return this.axisApply(axes, function(i, axis) {
|
|
1416
1052
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1417
|
-
})
|
|
1053
|
+
});
|
|
1418
1054
|
}
|
|
1419
|
-
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1420
|
-
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1055
|
+
function calcSnap(moveobj, withobj, axes, orientation, delta = 0) {
|
|
1421
1056
|
var side = flushSide[orientation];
|
|
1422
1057
|
if (!side) {
|
|
1423
1058
|
var fix = {
|
|
@@ -1435,15 +1070,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1435
1070
|
if (side[0] === -1) {
|
|
1436
1071
|
w[-1] = withobj.centroid();
|
|
1437
1072
|
}
|
|
1438
|
-
var t = axisApply(axes,
|
|
1073
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1439
1074
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1440
|
-
})
|
|
1441
|
-
return delta ? axisApply(axes,
|
|
1075
|
+
});
|
|
1076
|
+
return delta ? axisApply(axes, function(i) {
|
|
1442
1077
|
return t[i] + delta;
|
|
1443
|
-
})
|
|
1078
|
+
}) : t;
|
|
1444
1079
|
}
|
|
1445
1080
|
function snap(moveobj, withobj, axis, orientation, delta) {
|
|
1446
|
-
debug$
|
|
1081
|
+
debug$2("snap", moveobj, withobj, axis, orientation, delta);
|
|
1447
1082
|
var t = calcSnap(moveobj, withobj, axis, orientation, delta);
|
|
1448
1083
|
return moveobj.translate(t);
|
|
1449
1084
|
}
|
|
@@ -1451,16 +1086,16 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1451
1086
|
return moveobj.translate(calcFlush(moveobj, withobj, axis, mside, wside));
|
|
1452
1087
|
}
|
|
1453
1088
|
function axisApply(axes, valfun, a) {
|
|
1454
|
-
debug$
|
|
1089
|
+
debug$2("axisApply", axes, valfun, a);
|
|
1455
1090
|
var retval = a || [ 0, 0, 0 ];
|
|
1456
1091
|
var lookup = {
|
|
1457
1092
|
x: 0,
|
|
1458
1093
|
y: 1,
|
|
1459
1094
|
z: 2
|
|
1460
1095
|
};
|
|
1461
|
-
axes.split("").forEach(
|
|
1096
|
+
axes.split("").forEach(function(axis) {
|
|
1462
1097
|
retval[lookup[axis]] = valfun(lookup[axis], axis);
|
|
1463
|
-
})
|
|
1098
|
+
});
|
|
1464
1099
|
return retval;
|
|
1465
1100
|
}
|
|
1466
1101
|
function axis2array(axes, valfun) {
|
|
@@ -1471,10 +1106,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1471
1106
|
y: 1,
|
|
1472
1107
|
z: 2
|
|
1473
1108
|
};
|
|
1474
|
-
axes.split("").forEach(
|
|
1109
|
+
axes.split("").forEach(function(axis) {
|
|
1475
1110
|
var i = lookup[axis];
|
|
1476
1111
|
a[i] = valfun(i, axis);
|
|
1477
|
-
})
|
|
1112
|
+
});
|
|
1478
1113
|
return a;
|
|
1479
1114
|
}
|
|
1480
1115
|
function centroid(o, objectSize) {
|
|
@@ -1483,15 +1118,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1483
1118
|
objectSize = objectSize || size(bounds);
|
|
1484
1119
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1485
1120
|
} catch (err) {
|
|
1486
|
-
error(
|
|
1121
|
+
error(`centroid error o:${jscadToString(o)} objectSize: ${objectSize}`, undefined, err);
|
|
1487
1122
|
}
|
|
1488
1123
|
}
|
|
1489
1124
|
function calcmidlineTo(o, axis, to) {
|
|
1490
1125
|
var bounds = o.getBounds();
|
|
1491
1126
|
var objectSize = size(bounds);
|
|
1492
|
-
return axisApply(axis,
|
|
1127
|
+
return axisApply(axis, function(i, a) {
|
|
1493
1128
|
return to - objectSize[a] / 2;
|
|
1494
|
-
})
|
|
1129
|
+
});
|
|
1495
1130
|
}
|
|
1496
1131
|
function midlineTo(o, axis, to) {
|
|
1497
1132
|
return o.translate(calcmidlineTo(o, axis, to));
|
|
@@ -1499,18 +1134,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1499
1134
|
function translator(o, axis, withObj) {
|
|
1500
1135
|
var objectCentroid = centroid(o);
|
|
1501
1136
|
var withCentroid = centroid(withObj);
|
|
1502
|
-
var t = axisApply(axis,
|
|
1137
|
+
var t = axisApply(axis, function(i) {
|
|
1503
1138
|
return withCentroid[i] - objectCentroid[i];
|
|
1504
|
-
})
|
|
1139
|
+
});
|
|
1505
1140
|
return t;
|
|
1506
1141
|
}
|
|
1507
|
-
function calcCenterWith(o, axes, withObj) {
|
|
1508
|
-
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1142
|
+
function calcCenterWith(o, axes, withObj, delta = 0) {
|
|
1509
1143
|
var objectCentroid = centroid(o);
|
|
1510
1144
|
var withCentroid = centroid(withObj);
|
|
1511
|
-
var t = axisApply(axes,
|
|
1145
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1512
1146
|
return withCentroid[axis] - objectCentroid[axis];
|
|
1513
|
-
})
|
|
1147
|
+
});
|
|
1514
1148
|
return delta ? add(t, delta) : t;
|
|
1515
1149
|
}
|
|
1516
1150
|
function centerWith(o, axis, withObj) {
|
|
@@ -1523,16 +1157,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1523
1157
|
}
|
|
1524
1158
|
}
|
|
1525
1159
|
var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
|
|
1526
|
-
return axisApply(axis,
|
|
1160
|
+
return axisApply(axis, function(i, a) {
|
|
1527
1161
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1528
|
-
})
|
|
1162
|
+
});
|
|
1529
1163
|
}
|
|
1530
|
-
function bisect() {
|
|
1531
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1532
|
-
args[_key] = arguments[_key];
|
|
1533
|
-
}
|
|
1164
|
+
function bisect(...args) {
|
|
1534
1165
|
if (args.length < 2) {
|
|
1535
|
-
error("bisect
|
|
1166
|
+
error("bisect requires an object and an axis", "JSCAD_UTILS_INVALID_ARGS");
|
|
1536
1167
|
}
|
|
1537
1168
|
var object = args[0];
|
|
1538
1169
|
var axis = args[1];
|
|
@@ -1588,14 +1219,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1588
1219
|
}[[ axis, rotateaxis ].sort().join("")];
|
|
1589
1220
|
var centroid = object.centroid();
|
|
1590
1221
|
var rotateDelta = getDelta(objectSize, bounds, rotateOffsetAxis, rotateoffset);
|
|
1591
|
-
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz",
|
|
1222
|
+
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", function(i, a) {
|
|
1592
1223
|
if (a == axis) return cutDelta[i];
|
|
1593
1224
|
if (a == rotateOffsetAxis) return rotateDelta[i];
|
|
1594
1225
|
return centroid[a];
|
|
1595
|
-
}))
|
|
1226
|
+
}));
|
|
1596
1227
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
1597
1228
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
|
|
1598
|
-
debug$
|
|
1229
|
+
debug$2("bisect", debug$2.enabled && {
|
|
1599
1230
|
axis,
|
|
1600
1231
|
offset,
|
|
1601
1232
|
angle,
|
|
@@ -1611,14 +1242,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1611
1242
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, .1, rotationCenter), "rotationCenter");
|
|
1612
1243
|
return g;
|
|
1613
1244
|
}
|
|
1614
|
-
function slice(object
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
1619
|
-
color: true,
|
|
1620
|
-
addRotationCenter: true
|
|
1621
|
-
};
|
|
1245
|
+
function slice(object, angle = 15, axis = "x", rotateaxis = "z", options = {
|
|
1246
|
+
color: true,
|
|
1247
|
+
addRotationCenter: true
|
|
1248
|
+
}) {
|
|
1622
1249
|
var info = normalVector(axis);
|
|
1623
1250
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1624
1251
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -1676,21 +1303,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1676
1303
|
return CSG.fromPolygons(polygons);
|
|
1677
1304
|
}
|
|
1678
1305
|
function slices2poly(slices, options, axis) {
|
|
1679
|
-
debug$
|
|
1306
|
+
debug$2("slices2poly", slices, options, axis);
|
|
1680
1307
|
options = Object.assign({
|
|
1681
1308
|
twistangle: 0,
|
|
1682
1309
|
twiststeps: 0
|
|
1683
1310
|
}, options);
|
|
1684
1311
|
var twistangle = options && parseFloat(options.twistangle) || 0;
|
|
1685
|
-
|
|
1686
|
-
if (twistangle == 0 || twiststeps < 1) {
|
|
1687
|
-
twiststeps = 1;
|
|
1688
|
-
}
|
|
1312
|
+
options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
|
|
1689
1313
|
var normalVector = options.si.normalVector;
|
|
1690
1314
|
var polygons = [];
|
|
1691
1315
|
var first$1 = first(slices);
|
|
1692
1316
|
var last$1 = last(slices);
|
|
1693
|
-
debug$
|
|
1317
|
+
debug$2("slices2poly first", first$1, first$1.offset, "last", last$1);
|
|
1694
1318
|
var up = first$1.offset[axis] > last$1.offset[axis];
|
|
1695
1319
|
polygons = polygons.concat(first$1.poly._toPlanePolygons({
|
|
1696
1320
|
translation: first$1.offset,
|
|
@@ -1709,7 +1333,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1709
1333
|
return v[rotateAxis](angle * percent);
|
|
1710
1334
|
};
|
|
1711
1335
|
var connectorAxis = last$1.offset.minus(first$1.offset).abs();
|
|
1712
|
-
slices.forEach(
|
|
1336
|
+
slices.forEach(function(slice, idx) {
|
|
1713
1337
|
if (idx < slices.length - 1) {
|
|
1714
1338
|
var nextidx = idx + 1;
|
|
1715
1339
|
var top = !up ? slices[nextidx] : slice;
|
|
@@ -1722,7 +1346,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1722
1346
|
toConnector2: c2
|
|
1723
1347
|
}));
|
|
1724
1348
|
}
|
|
1725
|
-
})
|
|
1349
|
+
});
|
|
1726
1350
|
return CSG.fromPolygons(polygons);
|
|
1727
1351
|
}
|
|
1728
1352
|
function normalVector(axis) {
|
|
@@ -1763,12 +1387,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1763
1387
|
var info = dirInfo["dir" + direction];
|
|
1764
1388
|
return Object.assign({
|
|
1765
1389
|
axis,
|
|
1766
|
-
cutDelta: axisApply(axis,
|
|
1390
|
+
cutDelta: axisApply(axis, function(i, a) {
|
|
1767
1391
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.sizeDir;
|
|
1768
|
-
})
|
|
1769
|
-
moveDelta: axisApply(axis,
|
|
1392
|
+
}),
|
|
1393
|
+
moveDelta: axisApply(axis, function(i, a) {
|
|
1770
1394
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
|
|
1771
|
-
})
|
|
1395
|
+
})
|
|
1772
1396
|
}, info, normalVector(axis));
|
|
1773
1397
|
}
|
|
1774
1398
|
function reShape(object, radius, orientation, options, slicer) {
|
|
@@ -1776,18 +1400,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1776
1400
|
var b = object.getBounds();
|
|
1777
1401
|
var absoluteRadius = Math.abs(radius);
|
|
1778
1402
|
var si = sliceParams(orientation, radius, b);
|
|
1779
|
-
debug$
|
|
1780
|
-
if (si.axis !== "z") throw new Error('reShape error: CAG.
|
|
1403
|
+
debug$2("reShape", absoluteRadius, si);
|
|
1404
|
+
if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolygons only uses the "z" axis. You must use the "z" axis for now.');
|
|
1781
1405
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
|
|
1782
1406
|
var slice = object.sectionCut(cutplane);
|
|
1783
|
-
var first = axisApply(si.axis,
|
|
1407
|
+
var first = axisApply(si.axis, function() {
|
|
1784
1408
|
return si.positive ? 0 : absoluteRadius;
|
|
1785
|
-
})
|
|
1786
|
-
var last = axisApply(si.axis,
|
|
1409
|
+
});
|
|
1410
|
+
var last = axisApply(si.axis, function() {
|
|
1787
1411
|
return si.positive ? absoluteRadius : 0;
|
|
1788
|
-
})
|
|
1412
|
+
});
|
|
1789
1413
|
var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
|
|
1790
|
-
debug$
|
|
1414
|
+
debug$2("reShape first/last", first, last);
|
|
1791
1415
|
var slices = slicer(first, last, slice, radius);
|
|
1792
1416
|
var delta = slices2poly(slices, Object.assign(options, {
|
|
1793
1417
|
si
|
|
@@ -1796,7 +1420,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1796
1420
|
return union([ options.unionOriginal ? object : remainder, delta.translate(si.moveDelta) ]);
|
|
1797
1421
|
}
|
|
1798
1422
|
function chamfer(object, radius, orientation, options) {
|
|
1799
|
-
return reShape(object, radius, orientation, options,
|
|
1423
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1800
1424
|
return [ {
|
|
1801
1425
|
poly: slice,
|
|
1802
1426
|
offset: new CSG.Vector3D(first)
|
|
@@ -1804,15 +1428,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1804
1428
|
poly: enlarge(slice, [ -radius * 2, -radius * 2 ]),
|
|
1805
1429
|
offset: new CSG.Vector3D(last)
|
|
1806
1430
|
} ];
|
|
1807
|
-
})
|
|
1431
|
+
});
|
|
1808
1432
|
}
|
|
1809
1433
|
function fillet(object, radius, orientation, options) {
|
|
1810
1434
|
options = options || {};
|
|
1811
|
-
return reShape(object, radius, orientation, options,
|
|
1435
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1812
1436
|
var v1 = new CSG.Vector3D(first);
|
|
1813
1437
|
var v2 = new CSG.Vector3D(last);
|
|
1814
1438
|
var res = options.resolution || CSG.defaultResolution3D;
|
|
1815
|
-
var slices = range(0, res).map(
|
|
1439
|
+
var slices = range(0, res).map(function(i) {
|
|
1816
1440
|
var p = i > 0 ? i / (res - 1) : 0;
|
|
1817
1441
|
var v = v1.lerp(v2, p);
|
|
1818
1442
|
var size = -radius * 2 - Math.cos(Math.asin(p)) * (-radius * 2);
|
|
@@ -1820,9 +1444,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1820
1444
|
poly: enlarge(slice, [ size, size ]),
|
|
1821
1445
|
offset: v
|
|
1822
1446
|
};
|
|
1823
|
-
})
|
|
1447
|
+
});
|
|
1824
1448
|
return slices;
|
|
1825
|
-
})
|
|
1449
|
+
});
|
|
1826
1450
|
}
|
|
1827
1451
|
function calcRotate(part, solid, axis) {
|
|
1828
1452
|
var axes = {
|
|
@@ -1838,54 +1462,121 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1838
1462
|
};
|
|
1839
1463
|
}
|
|
1840
1464
|
function rotateAround(part, solid, axis, angle) {
|
|
1841
|
-
var
|
|
1465
|
+
var {rotationCenter, rotationAxis} = calcRotate(part, solid, axis);
|
|
1842
1466
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1843
1467
|
}
|
|
1844
|
-
function cloneProperties(from, to) {
|
|
1845
|
-
return Object.entries(from).reduce((
|
|
1846
|
-
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1468
|
+
function cloneProperties(from, to, depth = 0) {
|
|
1469
|
+
return Object.entries(from).reduce((props, [key, value]) => {
|
|
1847
1470
|
props[key] = value;
|
|
1848
1471
|
return props;
|
|
1849
|
-
}
|
|
1472
|
+
}, to);
|
|
1850
1473
|
}
|
|
1851
1474
|
function clone(o) {
|
|
1852
1475
|
var c = CSG.fromPolygons(o.toPolygons());
|
|
1853
1476
|
cloneProperties(o, c);
|
|
1854
|
-
debug$
|
|
1477
|
+
debug$2("clone", o, c, CSG);
|
|
1855
1478
|
return c;
|
|
1856
1479
|
}
|
|
1857
|
-
function addConnector(object, name) {
|
|
1858
|
-
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [ 0, 0, 0 ];
|
|
1859
|
-
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [ 1, 0, 0 ];
|
|
1860
|
-
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [ 0, 0, 1 ];
|
|
1480
|
+
function addConnector(object, name, point = [ 0, 0, 0 ], axis = [ 1, 0, 0 ], normal = [ 0, 0, 1 ]) {
|
|
1861
1481
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
1862
1482
|
return object;
|
|
1863
1483
|
}
|
|
1864
|
-
var
|
|
1484
|
+
var util = Object.freeze({
|
|
1485
|
+
__proto__: null,
|
|
1486
|
+
NOZZEL_SIZE,
|
|
1487
|
+
addConnector,
|
|
1488
|
+
axis2array,
|
|
1489
|
+
axisApply,
|
|
1490
|
+
bisect,
|
|
1491
|
+
calcCenterWith,
|
|
1492
|
+
calcFlush,
|
|
1493
|
+
calcRotate,
|
|
1494
|
+
calcSnap,
|
|
1495
|
+
calcmidlineTo,
|
|
1496
|
+
center,
|
|
1497
|
+
centerWith,
|
|
1498
|
+
centerX,
|
|
1499
|
+
centerY,
|
|
1500
|
+
centroid,
|
|
1501
|
+
chamfer,
|
|
1502
|
+
clone,
|
|
1503
|
+
cm,
|
|
1504
|
+
defaults,
|
|
1505
|
+
depreciated,
|
|
1506
|
+
div,
|
|
1507
|
+
divA,
|
|
1508
|
+
divxyz,
|
|
1509
|
+
enlarge,
|
|
1510
|
+
error,
|
|
1511
|
+
fillet,
|
|
1512
|
+
fit,
|
|
1513
|
+
flush,
|
|
1514
|
+
flushSide,
|
|
1515
|
+
getDelta,
|
|
1516
|
+
identity,
|
|
1517
|
+
ifArray,
|
|
1518
|
+
inch,
|
|
1519
|
+
isEmpty,
|
|
1520
|
+
isNegative,
|
|
1521
|
+
jscadToString,
|
|
1522
|
+
label,
|
|
1523
|
+
map,
|
|
1524
|
+
mapPick,
|
|
1525
|
+
mapValues,
|
|
1526
|
+
midlineTo,
|
|
1527
|
+
mirrored4,
|
|
1528
|
+
mul,
|
|
1529
|
+
mulxyz,
|
|
1530
|
+
nearest,
|
|
1531
|
+
normalVector,
|
|
1532
|
+
pick,
|
|
1533
|
+
poly2solid,
|
|
1534
|
+
print,
|
|
1535
|
+
reShape,
|
|
1536
|
+
result,
|
|
1537
|
+
rotateAround,
|
|
1538
|
+
rotationAxes,
|
|
1539
|
+
scale,
|
|
1540
|
+
segment,
|
|
1541
|
+
shift,
|
|
1542
|
+
size,
|
|
1543
|
+
slice,
|
|
1544
|
+
sliceParams,
|
|
1545
|
+
slices2poly,
|
|
1546
|
+
snap,
|
|
1547
|
+
stretch,
|
|
1548
|
+
text,
|
|
1549
|
+
toArray,
|
|
1550
|
+
translator,
|
|
1551
|
+
unitAxis,
|
|
1552
|
+
unitCube,
|
|
1553
|
+
wedge,
|
|
1554
|
+
xyz2array,
|
|
1555
|
+
zero,
|
|
1556
|
+
zipObject
|
|
1557
|
+
});
|
|
1558
|
+
const debug$1 = Debug("jscadUtils:parts");
|
|
1865
1559
|
var parts = {
|
|
1866
|
-
BBox,
|
|
1560
|
+
BBox: BBox$1,
|
|
1867
1561
|
Cube,
|
|
1868
1562
|
RoundedCube,
|
|
1869
1563
|
Cylinder,
|
|
1870
1564
|
Cone
|
|
1871
1565
|
};
|
|
1872
|
-
function BBox() {
|
|
1566
|
+
function BBox$1(...objects) {
|
|
1873
1567
|
function box(object) {
|
|
1874
1568
|
return CSG.cube({
|
|
1875
1569
|
center: object.centroid(),
|
|
1876
1570
|
radius: object.size().dividedBy(2)
|
|
1877
1571
|
});
|
|
1878
1572
|
}
|
|
1879
|
-
|
|
1880
|
-
objects[_key] = arguments[_key];
|
|
1881
|
-
}
|
|
1882
|
-
return objects.reduce((function(bbox, part) {
|
|
1573
|
+
return objects.reduce(function(bbox, part) {
|
|
1883
1574
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1884
1575
|
return box(object);
|
|
1885
|
-
}
|
|
1576
|
+
}, undefined);
|
|
1886
1577
|
}
|
|
1887
1578
|
function Cube(width) {
|
|
1888
|
-
var r = div(fromxyz(width), 2);
|
|
1579
|
+
var r = div$1(fromxyz(width), 2);
|
|
1889
1580
|
return CSG.cube({
|
|
1890
1581
|
center: r,
|
|
1891
1582
|
radius: r
|
|
@@ -1900,7 +1591,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1900
1591
|
} else {
|
|
1901
1592
|
var r = [ x / 2, y / 2 ];
|
|
1902
1593
|
}
|
|
1903
|
-
debug$
|
|
1594
|
+
debug$1("RoundedCube", size$1, r, thickness, corner_radius);
|
|
1904
1595
|
var roundedcube = CAG.roundedRectangle({
|
|
1905
1596
|
center: [ r[0], r[1], 0 ],
|
|
1906
1597
|
radius: r,
|
|
@@ -1911,9 +1602,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1911
1602
|
});
|
|
1912
1603
|
return roundedcube;
|
|
1913
1604
|
}
|
|
1914
|
-
function Cylinder(diameter, height) {
|
|
1915
|
-
|
|
1916
|
-
debug$2("parts.Cylinder", diameter, height, options);
|
|
1605
|
+
function Cylinder(diameter, height, options = {}) {
|
|
1606
|
+
debug$1("parts.Cylinder", diameter, height, options);
|
|
1917
1607
|
options = Object.assign({
|
|
1918
1608
|
start: [ 0, 0, 0 ],
|
|
1919
1609
|
end: [ 0, 0, height ],
|
|
@@ -1922,9 +1612,8 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1922
1612
|
}, options);
|
|
1923
1613
|
return CSG.cylinder(options);
|
|
1924
1614
|
}
|
|
1925
|
-
function Cone(diameter1, diameter2, height) {
|
|
1926
|
-
|
|
1927
|
-
debug$2("parts.Cone", diameter1, diameter2, height, options);
|
|
1615
|
+
function Cone(diameter1, diameter2, height, options = {}) {
|
|
1616
|
+
debug$1("parts.Cone", diameter1, diameter2, height, options);
|
|
1928
1617
|
return CSG.cylinder(Object.assign({
|
|
1929
1618
|
start: [ 0, 0, 0 ],
|
|
1930
1619
|
end: [ 0, 0, height ],
|
|
@@ -1934,7 +1623,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1934
1623
|
}, options));
|
|
1935
1624
|
}
|
|
1936
1625
|
function Hexagon(diameter, height) {
|
|
1937
|
-
debug$
|
|
1626
|
+
debug$1("hexagon", diameter, height);
|
|
1938
1627
|
var radius = diameter / 2;
|
|
1939
1628
|
var sqrt3 = Math.sqrt(3) / 2;
|
|
1940
1629
|
var hex = CAG.fromPoints([ [ radius, 0 ], [ radius / 2, radius * sqrt3 ], [ -radius / 2, radius * sqrt3 ], [ -radius, 0 ], [ -radius / 2, -radius * sqrt3 ], [ radius / 2, -radius * sqrt3 ] ]);
|
|
@@ -1952,9 +1641,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1952
1641
|
function Tube(outsideDiameter, insideDiameter, height, outsideOptions, insideOptions) {
|
|
1953
1642
|
return Cylinder(outsideDiameter, height, outsideOptions).subtract(Cylinder(insideDiameter, height, insideOptions || outsideOptions));
|
|
1954
1643
|
}
|
|
1955
|
-
function Anchor() {
|
|
1956
|
-
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1957
|
-
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1644
|
+
function Anchor(width = 10, height = 10) {
|
|
1958
1645
|
var hole = Cylinder(width, height).Center().color("red");
|
|
1959
1646
|
var post = Cylinder(height / 2, width * .66).rotateX(90).align(hole, "xz").snap(hole, "y", "inside-").translate([ 0, 0, -height / 6 ]).color("purple");
|
|
1960
1647
|
return Group({
|
|
@@ -1974,7 +1661,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1974
1661
|
});
|
|
1975
1662
|
return board;
|
|
1976
1663
|
}
|
|
1977
|
-
|
|
1664
|
+
const Hardware = {
|
|
1978
1665
|
Orientation: {
|
|
1979
1666
|
up: {
|
|
1980
1667
|
head: "outside-",
|
|
@@ -1985,7 +1672,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1985
1672
|
clear: "inside-"
|
|
1986
1673
|
}
|
|
1987
1674
|
},
|
|
1988
|
-
Screw: function
|
|
1675
|
+
Screw: function(head, thread, headClearSpace, options) {
|
|
1989
1676
|
depreciated("Screw", false, "Use the jscad-hardware screw methods instead");
|
|
1990
1677
|
options = Object.assign(options, {
|
|
1991
1678
|
orientation: "up",
|
|
@@ -2001,7 +1688,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2001
1688
|
}
|
|
2002
1689
|
return group;
|
|
2003
1690
|
},
|
|
2004
|
-
PanHeadScrew: function
|
|
1691
|
+
PanHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2005
1692
|
depreciated("PanHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
2006
1693
|
var head = Cylinder(headDiameter, headLength);
|
|
2007
1694
|
var thread = Cylinder(diameter, length);
|
|
@@ -2010,7 +1697,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2010
1697
|
}
|
|
2011
1698
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
2012
1699
|
},
|
|
2013
|
-
HexHeadScrew: function
|
|
1700
|
+
HexHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2014
1701
|
depreciated("HexHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
2015
1702
|
var head = Hexagon(headDiameter, headLength);
|
|
2016
1703
|
var thread = Cylinder(diameter, length);
|
|
@@ -2019,7 +1706,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2019
1706
|
}
|
|
2020
1707
|
return Hardware.Screw(head, thread, headClearSpace, options);
|
|
2021
1708
|
},
|
|
2022
|
-
FlatHeadScrew: function
|
|
1709
|
+
FlatHeadScrew: function(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2023
1710
|
depreciated("FlatHeadScrew", false, "Use the jscad-hardware screw methods instead");
|
|
2024
1711
|
var head = Cone(headDiameter, diameter, headLength);
|
|
2025
1712
|
var thread = Cylinder(diameter, length);
|
|
@@ -2031,43 +1718,42 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2031
1718
|
};
|
|
2032
1719
|
var parts$1 = Object.freeze({
|
|
2033
1720
|
__proto__: null,
|
|
2034
|
-
|
|
2035
|
-
BBox,
|
|
1721
|
+
Anchor,
|
|
1722
|
+
BBox: BBox$1,
|
|
1723
|
+
Board,
|
|
1724
|
+
Cone,
|
|
2036
1725
|
Cube,
|
|
2037
|
-
RoundedCube,
|
|
2038
1726
|
Cylinder,
|
|
2039
|
-
|
|
1727
|
+
Hardware,
|
|
2040
1728
|
Hexagon,
|
|
1729
|
+
RoundedCube,
|
|
2041
1730
|
Triangle,
|
|
2042
1731
|
Tube,
|
|
2043
|
-
|
|
2044
|
-
Board,
|
|
2045
|
-
Hardware
|
|
1732
|
+
default: parts
|
|
2046
1733
|
});
|
|
2047
|
-
|
|
1734
|
+
const debug = Debug("jscadUtils:boxes");
|
|
2048
1735
|
function RabbetJoin(box, thickness, cutHeight) {
|
|
2049
1736
|
depreciated("RabbetJoin", true, "Use 'Rabbet' instead");
|
|
2050
1737
|
return rabbetJoin(box, thickness, cutHeight);
|
|
2051
1738
|
}
|
|
2052
1739
|
function topMiddleBottom(box, thickness) {
|
|
2053
|
-
debug
|
|
1740
|
+
debug("TopMiddleBottom", box, thickness);
|
|
2054
1741
|
var bottom = box.bisect("z", thickness, {
|
|
2055
1742
|
color: true
|
|
2056
1743
|
});
|
|
2057
1744
|
var top = bottom.parts.positive.bisect("z", -thickness);
|
|
2058
1745
|
return Group("top,middle,bottom", [ top.parts.positive, top.parts.negative.color("green"), bottom.parts.negative ]);
|
|
2059
1746
|
}
|
|
2060
|
-
function Rabett(box, thickness, gap, height, face) {
|
|
2061
|
-
|
|
2062
|
-
debug$3("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
1747
|
+
function Rabett(box, thickness, gap, height, face, options = {}) {
|
|
1748
|
+
debug("Rabett", "thickness", thickness, "gap", gap, "height", height, "face", face);
|
|
2063
1749
|
gap = gap || .25;
|
|
2064
1750
|
var inside = thickness - gap;
|
|
2065
1751
|
var outside = -thickness + gap;
|
|
2066
|
-
debug
|
|
1752
|
+
debug("inside", inside, "outside", outside);
|
|
2067
1753
|
var group = Group();
|
|
2068
|
-
var
|
|
1754
|
+
var {positive: top, negative: lower2_3rd} = box.bisect("z", height, options).parts;
|
|
2069
1755
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
2070
|
-
var
|
|
1756
|
+
var {positive: middle, negative: bottom} = lower2_3rd.bisect("z", lowerBisectHeight, options).parts;
|
|
2071
1757
|
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
2072
1758
|
group.add(top.union(middleTop), "top");
|
|
2073
1759
|
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
@@ -2076,16 +1762,14 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2076
1762
|
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
2077
1763
|
return group;
|
|
2078
1764
|
}
|
|
2079
|
-
|
|
2080
|
-
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
2081
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1765
|
+
const RabettTopBottom = function rabbetTMB(box, thickness, gap = .25, options = {}) {
|
|
2082
1766
|
options = Object.assign({
|
|
2083
1767
|
removableTop: true,
|
|
2084
1768
|
removableBottom: true,
|
|
2085
1769
|
topWidth: -thickness,
|
|
2086
1770
|
bottomWidth: thickness
|
|
2087
1771
|
}, options);
|
|
2088
|
-
debug
|
|
1772
|
+
debug("RabettTopBottom", box, thickness, gap, options);
|
|
2089
1773
|
var group = Group("", {
|
|
2090
1774
|
box
|
|
2091
1775
|
});
|
|
@@ -2111,7 +1795,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2111
1795
|
}
|
|
2112
1796
|
return group;
|
|
2113
1797
|
};
|
|
2114
|
-
|
|
1798
|
+
const CutOut = function cutOut(o, h, box, plug, gap) {
|
|
2115
1799
|
gap = gap || .25;
|
|
2116
1800
|
var s = o.size();
|
|
2117
1801
|
var cutout = o.intersect(box);
|
|
@@ -2129,9 +1813,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2129
1813
|
insert: union([ o, top ]).intersect(box).subtract(o).enlarge([ -gap, 0, 0 ]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color("blue")
|
|
2130
1814
|
});
|
|
2131
1815
|
};
|
|
2132
|
-
|
|
1816
|
+
const Rectangle = function(size, thickness, cb) {
|
|
2133
1817
|
thickness = thickness || 2;
|
|
2134
|
-
var s = div(xyz2array(size), 2);
|
|
1818
|
+
var s = div$1(xyz2array(size), 2);
|
|
2135
1819
|
var r = add(s, thickness);
|
|
2136
1820
|
var box = CSG.cube({
|
|
2137
1821
|
center: r,
|
|
@@ -2143,7 +1827,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2143
1827
|
if (cb) box = cb(box);
|
|
2144
1828
|
return box;
|
|
2145
1829
|
};
|
|
2146
|
-
|
|
1830
|
+
const Hollow = function(object, thickness, interiorcb, exteriorcb) {
|
|
2147
1831
|
thickness = thickness || 2;
|
|
2148
1832
|
var size = -thickness * 2;
|
|
2149
1833
|
interiorcb = interiorcb || identity;
|
|
@@ -2151,19 +1835,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2151
1835
|
if (exteriorcb) box = exteriorcb(box);
|
|
2152
1836
|
return box;
|
|
2153
1837
|
};
|
|
2154
|
-
|
|
1838
|
+
const BBox = function(o) {
|
|
2155
1839
|
depreciated("BBox", true, "Use 'parts.BBox' instead");
|
|
2156
|
-
var s = div(xyz2array(o.size()), 2);
|
|
1840
|
+
var s = div$1(xyz2array(o.size()), 2);
|
|
2157
1841
|
return CSG.cube({
|
|
2158
1842
|
center: s,
|
|
2159
1843
|
radius: s
|
|
2160
1844
|
}).align(o, "xyz");
|
|
2161
1845
|
};
|
|
2162
1846
|
function getRadius(o) {
|
|
2163
|
-
return div(xyz2array(o.size()), 2);
|
|
1847
|
+
return div$1(xyz2array(o.size()), 2);
|
|
2164
1848
|
}
|
|
2165
|
-
function rabbetJoin(box, thickness) {
|
|
2166
|
-
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .25;
|
|
1849
|
+
function rabbetJoin(box, thickness, gap = .25) {
|
|
2167
1850
|
var r = add(getRadius(box), -thickness / 2);
|
|
2168
1851
|
r[2] = thickness / 2;
|
|
2169
1852
|
var cutter = CSG.cube({
|
|
@@ -2181,16 +1864,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2181
1864
|
}
|
|
2182
1865
|
var Boxes = Object.freeze({
|
|
2183
1866
|
__proto__: null,
|
|
1867
|
+
BBox,
|
|
1868
|
+
CutOut,
|
|
1869
|
+
Hollow,
|
|
2184
1870
|
RabbetJoin,
|
|
2185
|
-
topMiddleBottom,
|
|
2186
1871
|
Rabett,
|
|
2187
1872
|
RabettTopBottom,
|
|
2188
|
-
CutOut,
|
|
2189
1873
|
Rectangle,
|
|
2190
|
-
|
|
2191
|
-
BBox: BBox$1
|
|
1874
|
+
topMiddleBottom
|
|
2192
1875
|
});
|
|
2193
|
-
|
|
1876
|
+
const compatV1 = {
|
|
1877
|
+
...util,
|
|
2194
1878
|
group: Group,
|
|
2195
1879
|
init: init$1,
|
|
2196
1880
|
triangle: triUtils,
|
|
@@ -2198,7 +1882,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2198
1882
|
parts: parts$1,
|
|
2199
1883
|
Boxes,
|
|
2200
1884
|
Debug
|
|
2201
|
-
}
|
|
1885
|
+
};
|
|
2202
1886
|
exports.Boxes = Boxes;
|
|
2203
1887
|
exports.Debug = Debug;
|
|
2204
1888
|
exports.Group = Group;
|