@jwc/jscad-utils 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compat.js +409 -286
- package/dist/examples/bisect.jscad +511 -198
- package/dist/examples/boxes.jscad +511 -198
- package/dist/examples/chamfer.jscad +511 -198
- package/dist/examples/fillet.jscad +511 -198
- package/dist/examples/fit.jscad +511 -198
- package/dist/examples/groups.jscad +511 -198
- package/dist/examples/midlineTo.jscad +511 -198
- package/dist/examples/parts-hexagon.jscad +511 -198
- package/dist/examples/rabett-tb.jscad +511 -198
- package/dist/examples/rabett.jscad +511 -198
- package/dist/examples/rabett2.jscad +511 -198
- package/dist/examples/retraction-test.jscad +511 -198
- package/dist/examples/size.jscad +511 -198
- package/dist/examples/snap.jscad +511 -198
- package/dist/examples/text.jscad +511 -198
- package/dist/examples/wedge.jscad +511 -198
- package/dist/index.js +408 -285
- package/package.json +12 -6
- package/src/boxes.js +1 -1
- package/src/compat.js +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,187 @@
|
|
|
1
1
|
var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
5
|
+
|
|
6
|
+
var jsCadCSG__default = /*#__PURE__*/_interopDefaultLegacy(jsCadCSG);
|
|
7
|
+
var scadApi__default = /*#__PURE__*/_interopDefaultLegacy(scadApi);
|
|
8
|
+
|
|
9
|
+
var util = /*#__PURE__*/Object.freeze({
|
|
10
|
+
__proto__: null,
|
|
11
|
+
get NOZZEL_SIZE () { return NOZZEL_SIZE; },
|
|
12
|
+
get nearest () { return nearest; },
|
|
13
|
+
get identity () { return identity; },
|
|
14
|
+
get result () { return result; },
|
|
15
|
+
get defaults () { return defaults; },
|
|
16
|
+
get isEmpty () { return isEmpty; },
|
|
17
|
+
get isNegative () { return isNegative; },
|
|
18
|
+
get print () { return print; },
|
|
19
|
+
get jscadToString () { return jscadToString; },
|
|
20
|
+
get error () { return error; },
|
|
21
|
+
get depreciated () { return depreciated; },
|
|
22
|
+
get inch () { return inch; },
|
|
23
|
+
get cm () { return cm; },
|
|
24
|
+
get label () { return label; },
|
|
25
|
+
get text () { return text; },
|
|
26
|
+
get unitCube () { return unitCube; },
|
|
27
|
+
get unitAxis () { return unitAxis; },
|
|
28
|
+
get toArray () { return toArray; },
|
|
29
|
+
get ifArray () { return ifArray; },
|
|
30
|
+
get segment () { return segment; },
|
|
31
|
+
get zipObject () { return zipObject; },
|
|
32
|
+
get map () { return map; },
|
|
33
|
+
get mapValues () { return mapValues; },
|
|
34
|
+
get pick () { return pick; },
|
|
35
|
+
get mapPick () { return mapPick; },
|
|
36
|
+
get divA () { return divA; },
|
|
37
|
+
get divxyz () { return divxyz; },
|
|
38
|
+
get div () { return div; },
|
|
39
|
+
get mulxyz () { return mulxyz; },
|
|
40
|
+
get mul () { return mul; },
|
|
41
|
+
get xyz2array () { return xyz2array; },
|
|
42
|
+
get rotationAxes () { return rotationAxes; },
|
|
43
|
+
get size () { return size; },
|
|
44
|
+
get scale () { return scale; },
|
|
45
|
+
get center () { return center; },
|
|
46
|
+
get centerY () { return centerY; },
|
|
47
|
+
get centerX () { return centerX; },
|
|
48
|
+
get enlarge () { return enlarge; },
|
|
49
|
+
get fit () { return fit; },
|
|
50
|
+
get shift () { return shift; },
|
|
51
|
+
get zero () { return zero; },
|
|
52
|
+
get mirrored4 () { return mirrored4; },
|
|
53
|
+
get flushSide () { return flushSide; },
|
|
54
|
+
get calcFlush () { return calcFlush; },
|
|
55
|
+
get calcSnap () { return calcSnap; },
|
|
56
|
+
get snap () { return snap; },
|
|
57
|
+
get flush () { return flush; },
|
|
58
|
+
get axisApply () { return axisApply; },
|
|
59
|
+
get axis2array () { return axis2array; },
|
|
60
|
+
get centroid () { return centroid; },
|
|
61
|
+
get calcmidlineTo () { return calcmidlineTo; },
|
|
62
|
+
get midlineTo () { return midlineTo; },
|
|
63
|
+
get translator () { return translator; },
|
|
64
|
+
get calcCenterWith () { return calcCenterWith; },
|
|
65
|
+
get centerWith () { return centerWith; },
|
|
66
|
+
get getDelta () { return getDelta; },
|
|
67
|
+
get bisect () { return bisect; },
|
|
68
|
+
get slice () { return slice; },
|
|
69
|
+
get wedge () { return wedge; },
|
|
70
|
+
get stretch () { return stretch; },
|
|
71
|
+
get poly2solid () { return poly2solid; },
|
|
72
|
+
get slices2poly () { return slices2poly; },
|
|
73
|
+
get normalVector () { return normalVector; },
|
|
74
|
+
get sliceParams () { return sliceParams; },
|
|
75
|
+
get reShape () { return reShape; },
|
|
76
|
+
get chamfer () { return chamfer; },
|
|
77
|
+
get fillet () { return fillet; },
|
|
78
|
+
get calcRotate () { return calcRotate; },
|
|
79
|
+
get rotateAround () { return rotateAround; },
|
|
80
|
+
get clone () { return clone; },
|
|
81
|
+
get addConnector () { return addConnector; }
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function _arrayLikeToArray(r, a) {
|
|
85
|
+
(null == a || a > r.length) && (a = r.length);
|
|
86
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
87
|
+
return n;
|
|
88
|
+
}
|
|
89
|
+
function _arrayWithHoles(r) {
|
|
90
|
+
if (Array.isArray(r)) return r;
|
|
91
|
+
}
|
|
92
|
+
function _defineProperty(e, r, t) {
|
|
93
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
94
|
+
value: t,
|
|
95
|
+
enumerable: !0,
|
|
96
|
+
configurable: !0,
|
|
97
|
+
writable: !0
|
|
98
|
+
}) : e[r] = t, e;
|
|
99
|
+
}
|
|
100
|
+
function _iterableToArrayLimit(r, l) {
|
|
101
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
102
|
+
if (null != t) {
|
|
103
|
+
var e,
|
|
104
|
+
n,
|
|
105
|
+
i,
|
|
106
|
+
u,
|
|
107
|
+
a = [],
|
|
108
|
+
f = !0,
|
|
109
|
+
o = !1;
|
|
110
|
+
try {
|
|
111
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
112
|
+
if (Object(t) !== t) return;
|
|
113
|
+
f = !1;
|
|
114
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
115
|
+
} catch (r) {
|
|
116
|
+
o = !0, n = r;
|
|
117
|
+
} finally {
|
|
118
|
+
try {
|
|
119
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
120
|
+
} finally {
|
|
121
|
+
if (o) throw n;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return a;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function _nonIterableRest() {
|
|
128
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
129
|
+
}
|
|
130
|
+
function ownKeys(e, r) {
|
|
131
|
+
var t = Object.keys(e);
|
|
132
|
+
if (Object.getOwnPropertySymbols) {
|
|
133
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
134
|
+
r && (o = o.filter(function (r) {
|
|
135
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
136
|
+
})), t.push.apply(t, o);
|
|
137
|
+
}
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
function _objectSpread2(e) {
|
|
141
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
142
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
143
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
144
|
+
_defineProperty(e, r, t[r]);
|
|
145
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
146
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return e;
|
|
150
|
+
}
|
|
151
|
+
function _slicedToArray(r, e) {
|
|
152
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
153
|
+
}
|
|
154
|
+
function _toPrimitive(t, r) {
|
|
155
|
+
if ("object" != typeof t || !t) return t;
|
|
156
|
+
var e = t[Symbol.toPrimitive];
|
|
157
|
+
if (void 0 !== e) {
|
|
158
|
+
var i = e.call(t, r || "default");
|
|
159
|
+
if ("object" != typeof i) return i;
|
|
160
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
161
|
+
}
|
|
162
|
+
return ("string" === r ? String : Number)(t);
|
|
163
|
+
}
|
|
164
|
+
function _toPropertyKey(t) {
|
|
165
|
+
var i = _toPrimitive(t, "string");
|
|
166
|
+
return "symbol" == typeof i ? i : i + "";
|
|
167
|
+
}
|
|
168
|
+
function _typeof(o) {
|
|
169
|
+
"@babel/helpers - typeof";
|
|
170
|
+
|
|
171
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
172
|
+
return typeof o;
|
|
173
|
+
} : function (o) {
|
|
174
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
175
|
+
}, _typeof(o);
|
|
176
|
+
}
|
|
177
|
+
function _unsupportedIterableToArray(r, a) {
|
|
178
|
+
if (r) {
|
|
179
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
180
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
181
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
4
185
|
/** @module triangle */
|
|
5
186
|
|
|
6
187
|
/**
|
|
@@ -8,7 +189,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
8
189
|
* @param {Number} deg value in degrees
|
|
9
190
|
* @return {Number} value in radians
|
|
10
191
|
*/
|
|
11
|
-
|
|
192
|
+
var toRadians = function toRadians(deg) {
|
|
12
193
|
return deg / 180 * Math.PI;
|
|
13
194
|
};
|
|
14
195
|
|
|
@@ -17,7 +198,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
17
198
|
* @param {Number} rad value in radians
|
|
18
199
|
* @return {Number} value in degrees
|
|
19
200
|
*/
|
|
20
|
-
|
|
201
|
+
var toDegrees = function toDegrees(rad) {
|
|
21
202
|
return rad * (180 / Math.PI);
|
|
22
203
|
};
|
|
23
204
|
|
|
@@ -29,7 +210,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
29
210
|
* @param {Number} p2.y Point 2 y coordinate
|
|
30
211
|
* @return {Object} A triangle object {A,B,C,a,b,c}
|
|
31
212
|
*/
|
|
32
|
-
|
|
213
|
+
var solve = function solve(p1, p2) {
|
|
33
214
|
var r = {
|
|
34
215
|
c: 90,
|
|
35
216
|
A: Math.abs(p2.x - p1.x),
|
|
@@ -71,7 +252,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
71
252
|
* @param {Number} r.c Length of side `c`
|
|
72
253
|
* @return {Object} A solved triangle object {A,B,C,a,b,c}
|
|
73
254
|
*/
|
|
74
|
-
|
|
255
|
+
var solve90SA = function solve90SA(r) {
|
|
75
256
|
r = Object.assign(r, {
|
|
76
257
|
C: 90
|
|
77
258
|
});
|
|
@@ -92,7 +273,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
92
273
|
r.b = r.b || r.a / Math.tan(arad);
|
|
93
274
|
return r;
|
|
94
275
|
};
|
|
95
|
-
|
|
276
|
+
var solve90ac = function solve90ac(r) {
|
|
96
277
|
r = Object.assign(r, {
|
|
97
278
|
C: 90
|
|
98
279
|
});
|
|
@@ -149,12 +330,12 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
149
330
|
|
|
150
331
|
var triUtils = /*#__PURE__*/Object.freeze({
|
|
151
332
|
__proto__: null,
|
|
333
|
+
toRadians: toRadians,
|
|
334
|
+
toDegrees: toDegrees,
|
|
152
335
|
solve: solve,
|
|
153
336
|
solve90SA: solve90SA,
|
|
154
337
|
solve90ac: solve90ac,
|
|
155
|
-
solveab: solveab
|
|
156
|
-
toDegrees: toDegrees,
|
|
157
|
-
toRadians: toRadians
|
|
338
|
+
solveab: solveab
|
|
158
339
|
});
|
|
159
340
|
|
|
160
341
|
/**
|
|
@@ -169,7 +350,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
169
350
|
* @param {Number} f
|
|
170
351
|
* @memberof! array
|
|
171
352
|
*/
|
|
172
|
-
|
|
353
|
+
var div$1 = function div(a, f) {
|
|
173
354
|
return a.map(function (e) {
|
|
174
355
|
return e / f;
|
|
175
356
|
});
|
|
@@ -182,7 +363,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
182
363
|
* @param {Number} f A value to add to each element of the original array.
|
|
183
364
|
* @return {Array} A new array with the values added together.
|
|
184
365
|
*/
|
|
185
|
-
|
|
366
|
+
var addValue = function addValue(a, f) {
|
|
186
367
|
return a.map(function (e) {
|
|
187
368
|
return e + f;
|
|
188
369
|
});
|
|
@@ -196,7 +377,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
196
377
|
* @param {Array} f Another array of numbers, if
|
|
197
378
|
* @return {Array} A new array with the two values added together.
|
|
198
379
|
*/
|
|
199
|
-
|
|
380
|
+
var addArray = function addArray(a, f) {
|
|
200
381
|
return a.map(function (e, i) {
|
|
201
382
|
return e + f[i];
|
|
202
383
|
});
|
|
@@ -208,7 +389,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
208
389
|
* @param {Array} a An array of numbers .
|
|
209
390
|
* @return {Array} A new array with the two values added together.
|
|
210
391
|
*/
|
|
211
|
-
|
|
392
|
+
var add = function add(a) {
|
|
212
393
|
return Array.prototype.slice.call(arguments, 1).reduce(function (result, arg) {
|
|
213
394
|
if (Array.isArray(arg)) {
|
|
214
395
|
result = addArray(result, arg);
|
|
@@ -225,10 +406,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
225
406
|
* @function fromxyz
|
|
226
407
|
* @param {Object|Array} object
|
|
227
408
|
*/
|
|
228
|
-
|
|
409
|
+
var fromxyz = function fromxyz(object) {
|
|
229
410
|
return Array.isArray(object) ? object : [object.x, object.y, object.z];
|
|
230
411
|
};
|
|
231
|
-
|
|
412
|
+
var toxyz = function toxyz(a) {
|
|
232
413
|
return {
|
|
233
414
|
x: a[0],
|
|
234
415
|
y: a[1],
|
|
@@ -242,7 +423,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
242
423
|
* @param {Array} a An array of numbers.
|
|
243
424
|
* @return {Number} The value of the first element of the array or undefined.
|
|
244
425
|
*/
|
|
245
|
-
|
|
426
|
+
var first = function first(a) {
|
|
246
427
|
return a ? a[0] : undefined;
|
|
247
428
|
};
|
|
248
429
|
|
|
@@ -251,7 +432,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
251
432
|
* @param {Array} a An array of numbers.
|
|
252
433
|
* @return {Number} The value of the last element of the array or undefined.
|
|
253
434
|
*/
|
|
254
|
-
|
|
435
|
+
var last = function last(a) {
|
|
255
436
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
256
437
|
};
|
|
257
438
|
|
|
@@ -261,7 +442,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
261
442
|
* @param {Array} a An array of numbers.
|
|
262
443
|
* @return {Number} The minimum value in an array of numbers.
|
|
263
444
|
*/
|
|
264
|
-
|
|
445
|
+
var min = function min(a) {
|
|
265
446
|
return a.reduce(function (result, value) {
|
|
266
447
|
return value < result ? value : result;
|
|
267
448
|
}, Number.MAX_VALUE);
|
|
@@ -274,7 +455,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
274
455
|
* @param {Number} b The ending value.
|
|
275
456
|
* @return {Array} An array of values from `a` to `b`.
|
|
276
457
|
*/
|
|
277
|
-
|
|
458
|
+
var range = function range(a, b) {
|
|
278
459
|
var result = [];
|
|
279
460
|
for (var i = a; i < b; i++) {
|
|
280
461
|
result.push(i);
|
|
@@ -284,22 +465,22 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
284
465
|
|
|
285
466
|
var array = /*#__PURE__*/Object.freeze({
|
|
286
467
|
__proto__: null,
|
|
287
|
-
add: add,
|
|
288
|
-
addArray: addArray,
|
|
289
|
-
addValue: addValue,
|
|
290
468
|
div: div$1,
|
|
291
|
-
|
|
469
|
+
addValue: addValue,
|
|
470
|
+
addArray: addArray,
|
|
471
|
+
add: add,
|
|
292
472
|
fromxyz: fromxyz,
|
|
473
|
+
toxyz: toxyz,
|
|
474
|
+
first: first,
|
|
293
475
|
last: last,
|
|
294
476
|
min: min,
|
|
295
|
-
range: range
|
|
296
|
-
toxyz: toxyz
|
|
477
|
+
range: range
|
|
297
478
|
});
|
|
298
479
|
|
|
299
480
|
/* globals jscadUtilsDebug */
|
|
300
481
|
|
|
301
|
-
|
|
302
|
-
|
|
482
|
+
var debugColors = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'];
|
|
483
|
+
var termColors = ['\\033[0;34m', '\\033[0;32m', '\\033[0;36m', '\\033[0;31m', '\\033[0;35m', '\\033[0;33m', '\\033[1;33m', '\\033[0;30m', '\\033[1;34m'];
|
|
303
484
|
var debugCount = 0;
|
|
304
485
|
|
|
305
486
|
/**
|
|
@@ -320,7 +501,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
320
501
|
* @param {String} name The name of the debug function.
|
|
321
502
|
* @return {Function} A debug function if enabled otherwise an empty function.
|
|
322
503
|
*/
|
|
323
|
-
|
|
504
|
+
var Debug = function Debug(name) {
|
|
324
505
|
var checks = Object.assign({
|
|
325
506
|
enabled: [],
|
|
326
507
|
disabled: [],
|
|
@@ -328,17 +509,27 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
328
509
|
browser: true
|
|
329
510
|
}
|
|
330
511
|
}, jscadUtilsDebug || {});
|
|
331
|
-
var style = checks.options.browser ?
|
|
512
|
+
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
332
513
|
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
333
514
|
return check.test(name);
|
|
334
515
|
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
335
516
|
return check.test(name);
|
|
336
517
|
});
|
|
337
|
-
var logger = enabled ? checks.options.browser ? (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
518
|
+
var logger = enabled ? checks.options.browser ? function () {
|
|
519
|
+
var _console;
|
|
520
|
+
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
521
|
+
msg[_key] = arguments[_key];
|
|
522
|
+
}
|
|
523
|
+
(_console = console).log.apply(_console, ['%c%s', style, name].concat(msg));
|
|
524
|
+
} : function () {
|
|
525
|
+
var _console2;
|
|
526
|
+
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
527
|
+
msg[_key2] = arguments[_key2];
|
|
528
|
+
}
|
|
529
|
+
(_console2 = console).log.apply(_console2, ["".concat(name)].concat(msg));
|
|
530
|
+
} : function () {
|
|
531
|
+
return undefined;
|
|
532
|
+
};
|
|
342
533
|
logger.enabled = enabled;
|
|
343
534
|
return logger;
|
|
344
535
|
};
|
|
@@ -361,7 +552,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
361
552
|
*}
|
|
362
553
|
* @type {Record<ColorName, string>}
|
|
363
554
|
*/
|
|
364
|
-
|
|
555
|
+
var nameArray = {
|
|
365
556
|
aliceblue: '#f0f8ff',
|
|
366
557
|
antiquewhite: '#faebd7',
|
|
367
558
|
aqua: '#00ffff',
|
|
@@ -539,7 +730,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
539
730
|
/**
|
|
540
731
|
* @type {Record<ColorName, number[]>}
|
|
541
732
|
*/
|
|
542
|
-
|
|
733
|
+
var _name2rgb = {};
|
|
543
734
|
|
|
544
735
|
/**
|
|
545
736
|
* Converts a css color name to an rgb array.
|
|
@@ -643,7 +834,6 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
643
834
|
* @property {function} getConnector
|
|
644
835
|
*/
|
|
645
836
|
|
|
646
|
-
|
|
647
837
|
/**
|
|
648
838
|
* Initialize `jscad-utils` and add utilities to the `proto` object.
|
|
649
839
|
* @param {CSG} proto The global `proto` object
|
|
@@ -726,14 +916,23 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
726
916
|
proto.prototype.chamfer = function chamfer$1(radius, orientation, options) {
|
|
727
917
|
return chamfer(this, radius, orientation, options);
|
|
728
918
|
};
|
|
729
|
-
proto.prototype.bisect = function bisect$1(
|
|
730
|
-
|
|
919
|
+
proto.prototype.bisect = function bisect$1() {
|
|
920
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
921
|
+
args[_key] = arguments[_key];
|
|
922
|
+
}
|
|
923
|
+
return bisect.apply(util, [this].concat(args));
|
|
731
924
|
};
|
|
732
|
-
proto.prototype.slice = function slice$1(
|
|
733
|
-
|
|
925
|
+
proto.prototype.slice = function slice$1() {
|
|
926
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
927
|
+
args[_key2] = arguments[_key2];
|
|
928
|
+
}
|
|
929
|
+
return slice.apply(util, [this].concat(args));
|
|
734
930
|
};
|
|
735
|
-
proto.prototype.wedge = function wedge$1(
|
|
736
|
-
|
|
931
|
+
proto.prototype.wedge = function wedge$1() {
|
|
932
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
933
|
+
args[_key3] = arguments[_key3];
|
|
934
|
+
}
|
|
935
|
+
return wedge.apply(util, [this].concat(args));
|
|
737
936
|
};
|
|
738
937
|
proto.prototype.stretch = function stretch$1(axis, distance, offset) {
|
|
739
938
|
return stretch(this, axis, distance, offset);
|
|
@@ -759,7 +958,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
759
958
|
} else {
|
|
760
959
|
var t = Array.prototype.slice.call(arguments, 0).reduce(function (result, arg) {
|
|
761
960
|
// console.log('arg', arg);
|
|
762
|
-
result = undefined
|
|
961
|
+
result = undefined(result, arg);
|
|
763
962
|
return result;
|
|
764
963
|
}, [0, 0, 0]);
|
|
765
964
|
|
|
@@ -770,8 +969,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
770
969
|
proto.prototype.addConnector = function addConnector$1(name, point, axis, normal) {
|
|
771
970
|
return addConnector(this, name, point, axis, normal);
|
|
772
971
|
};
|
|
773
|
-
proto.prototype.connect = function connectTo(myConnectorName, otherConnector
|
|
774
|
-
var
|
|
972
|
+
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
973
|
+
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
974
|
+
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
975
|
+
var myConnector = myConnectorName.split('.').reduce(function (a, v) {
|
|
775
976
|
return a[v];
|
|
776
977
|
}, this.properties);
|
|
777
978
|
|
|
@@ -779,7 +980,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
779
980
|
* Check for missing property.
|
|
780
981
|
*/
|
|
781
982
|
if (!myConnector) {
|
|
782
|
-
error(
|
|
983
|
+
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(','), "]"), 'Missing connector property');
|
|
783
984
|
}
|
|
784
985
|
return this.connectTo(myConnector, otherConnector, mirror, normalrotation);
|
|
785
986
|
};
|
|
@@ -790,26 +991,19 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
790
991
|
|
|
791
992
|
var init$1 = /*#__PURE__*/Object.freeze({
|
|
792
993
|
__proto__: null,
|
|
793
|
-
default: init
|
|
994
|
+
'default': init
|
|
794
995
|
});
|
|
795
996
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
const {
|
|
804
|
-
vector_text,
|
|
805
|
-
vector_char
|
|
806
|
-
} = scadApi.text;
|
|
807
|
-
const {
|
|
808
|
-
union
|
|
809
|
-
} = scadApi.booleanOps;
|
|
997
|
+
var CSG = jsCadCSG__default["default"].CSG,
|
|
998
|
+
CAG = jsCadCSG__default["default"].CAG;
|
|
999
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
1000
|
+
var _scadApi$text = scadApi__default["default"].text,
|
|
1001
|
+
vector_text = _scadApi$text.vector_text,
|
|
1002
|
+
vector_char = _scadApi$text.vector_char;
|
|
1003
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
810
1004
|
init(CSG);
|
|
811
1005
|
|
|
812
|
-
|
|
1006
|
+
var debug$3 = Debug('jscadUtils:group');
|
|
813
1007
|
|
|
814
1008
|
/**
|
|
815
1009
|
* @function JsCadUtilsGroup
|
|
@@ -818,7 +1012,10 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
818
1012
|
* @param {CSG[]} holes An array of CSG objects that will be subtracted after combination.
|
|
819
1013
|
* @namespace JsCadUtilsGroup
|
|
820
1014
|
*/
|
|
821
|
-
function JsCadUtilsGroup(
|
|
1015
|
+
function JsCadUtilsGroup() {
|
|
1016
|
+
var names = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1017
|
+
var parts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1018
|
+
var holes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
822
1019
|
this.name = '';
|
|
823
1020
|
this.names = names;
|
|
824
1021
|
this.parts = parts;
|
|
@@ -866,7 +1063,11 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
866
1063
|
* @param {Function} map A function that is run before unioning the parts together.
|
|
867
1064
|
* @return {CSG} A single `CSG` object of the unioned parts.
|
|
868
1065
|
*/
|
|
869
|
-
JsCadUtilsGroup.prototype.combine = function (pieces
|
|
1066
|
+
JsCadUtilsGroup.prototype.combine = function (pieces) {
|
|
1067
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1068
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) {
|
|
1069
|
+
return x;
|
|
1070
|
+
};
|
|
870
1071
|
try {
|
|
871
1072
|
var self = this;
|
|
872
1073
|
options = Object.assign({
|
|
@@ -874,7 +1075,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
874
1075
|
}, options);
|
|
875
1076
|
pieces = pieces ? pieces.split(',') : self.names;
|
|
876
1077
|
if (pieces.length === 0) {
|
|
877
|
-
throw new Error(
|
|
1078
|
+
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
878
1079
|
}
|
|
879
1080
|
debug$3('combine', self.names, self.parts);
|
|
880
1081
|
var g = union(mapPick(self.parts, pieces, function (value, key, index, object) {
|
|
@@ -884,12 +1085,7 @@ var jscadUtils = (function (exports, jsCadCSG, scadApi) {
|
|
|
884
1085
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
885
1086
|
} catch (err) {
|
|
886
1087
|
debug$3('combine error', this, pieces, options, err);
|
|
887
|
-
throw error(
|
|
888
|
-
this: ${this}
|
|
889
|
-
pieces: "${pieces}"
|
|
890
|
-
options: ${JSON.stringify(options, null, 2)}
|
|
891
|
-
stack: ${err.stack}
|
|
892
|
-
`, 'JSCAD_UTILS_GROUP_ERROR');
|
|
1088
|
+
throw error("group::combine error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npieces: \"").concat(pieces, "\"\noptions: ").concat(JSON.stringify(options, null, 2), "\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
|
|
893
1089
|
}
|
|
894
1090
|
};
|
|
895
1091
|
|
|
@@ -902,7 +1098,9 @@ stack: ${err.stack}
|
|
|
902
1098
|
*/
|
|
903
1099
|
JsCadUtilsGroup.prototype.map = function (cb) {
|
|
904
1100
|
var self = this;
|
|
905
|
-
self.parts = Object.keys(self.parts).filter(
|
|
1101
|
+
self.parts = Object.keys(self.parts).filter(function (k) {
|
|
1102
|
+
return k !== 'holes';
|
|
1103
|
+
}).reduce(function (result, key) {
|
|
906
1104
|
result[key] = cb(self.parts[key], key);
|
|
907
1105
|
return result;
|
|
908
1106
|
}, {});
|
|
@@ -926,7 +1124,7 @@ stack: ${err.stack}
|
|
|
926
1124
|
* @return {JsCadUtilsGroup} The new group.
|
|
927
1125
|
*/
|
|
928
1126
|
JsCadUtilsGroup.prototype.clone = function (name, map) {
|
|
929
|
-
debug$3('clone', name,
|
|
1127
|
+
debug$3('clone', name, _typeof(name), map);
|
|
930
1128
|
var self = this;
|
|
931
1129
|
/**
|
|
932
1130
|
* For backwards compatibility
|
|
@@ -1013,15 +1211,7 @@ stack: ${err.stack}
|
|
|
1013
1211
|
return self;
|
|
1014
1212
|
} catch (err) {
|
|
1015
1213
|
debug$3('snap error', this, part, to, axis, delta, err);
|
|
1016
|
-
throw error(
|
|
1017
|
-
this: ${this}
|
|
1018
|
-
part: "${part}"
|
|
1019
|
-
to: ${to}
|
|
1020
|
-
axis: "${axis}"
|
|
1021
|
-
orientation: "${orientation}"
|
|
1022
|
-
delta: "${delta}"
|
|
1023
|
-
stack: ${err.stack}
|
|
1024
|
-
`, 'JSCAD_UTILS_GROUP_ERROR');
|
|
1214
|
+
throw error("group::snap error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npart: \"").concat(part, "\"\nto: ").concat(to, "\naxis: \"").concat(axis, "\"\norientation: \"").concat(orientation, "\"\ndelta: \"").concat(delta, "\"\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
|
|
1025
1215
|
}
|
|
1026
1216
|
};
|
|
1027
1217
|
|
|
@@ -1053,14 +1243,7 @@ stack: ${err.stack}
|
|
|
1053
1243
|
return self;
|
|
1054
1244
|
} catch (err) {
|
|
1055
1245
|
debug$3('align error', this, part, to, axis, delta, err);
|
|
1056
|
-
throw error(
|
|
1057
|
-
this: ${this}
|
|
1058
|
-
part: "${part}"
|
|
1059
|
-
to: ${to}
|
|
1060
|
-
axis: "${axis}"
|
|
1061
|
-
delta: "${delta}"
|
|
1062
|
-
stack: ${err.stack}
|
|
1063
|
-
`, 'JSCAD_UTILS_GROUP_ERROR');
|
|
1246
|
+
throw error("group::align error \"".concat(err.message || err.toString(), "\"\nthis: ").concat(this, "\npart: \"").concat(part, "\"\nto: ").concat(to, "\naxis: \"").concat(axis, "\"\ndelta: \"").concat(delta, "\"\nstack: ").concat(err.stack, "\n"), 'JSCAD_UTILS_GROUP_ERROR');
|
|
1064
1247
|
}
|
|
1065
1248
|
};
|
|
1066
1249
|
JsCadUtilsGroup.prototype.center = function center(part) {
|
|
@@ -1072,21 +1255,23 @@ stack: ${err.stack}
|
|
|
1072
1255
|
var bounds = self.parts[part].getBounds();
|
|
1073
1256
|
return self.translate([0, 0, -bounds[0].z]);
|
|
1074
1257
|
};
|
|
1075
|
-
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName
|
|
1258
|
+
JsCadUtilsGroup.prototype.connectTo = function connectTo(partName, connectorName, to, toConnectorName) {
|
|
1259
|
+
var mirror = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1260
|
+
var normalrotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
1076
1261
|
debug$3('connectTo', {
|
|
1077
|
-
partName,
|
|
1078
|
-
connectorName,
|
|
1079
|
-
to,
|
|
1080
|
-
toConnectorName,
|
|
1081
|
-
mirror,
|
|
1082
|
-
normalrotation
|
|
1262
|
+
partName: partName,
|
|
1263
|
+
connectorName: connectorName,
|
|
1264
|
+
to: to,
|
|
1265
|
+
toConnectorName: toConnectorName,
|
|
1266
|
+
mirror: mirror,
|
|
1267
|
+
normalrotation: normalrotation
|
|
1083
1268
|
});
|
|
1084
1269
|
var self = this;
|
|
1085
|
-
var myConnector = connectorName.split('.').reduce((a, v)
|
|
1270
|
+
var myConnector = connectorName.split('.').reduce(function (a, v) {
|
|
1086
1271
|
return a[v];
|
|
1087
1272
|
}, self.parts[partName].properties);
|
|
1088
1273
|
debug$3('toConnector', to instanceof CSG.Connector);
|
|
1089
|
-
var toConnector = toConnectorName.split('.').reduce((a, v)
|
|
1274
|
+
var toConnector = toConnectorName.split('.').reduce(function (a, v) {
|
|
1090
1275
|
return a[v];
|
|
1091
1276
|
}, to.properties);
|
|
1092
1277
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
@@ -1174,18 +1359,16 @@ stack: ${err.stack}
|
|
|
1174
1359
|
* @return {Array} An array of `CSG` objects
|
|
1175
1360
|
*/
|
|
1176
1361
|
JsCadUtilsGroup.prototype.array = function (parts, map) {
|
|
1362
|
+
var _this = this;
|
|
1177
1363
|
var self = this;
|
|
1178
1364
|
// try {
|
|
1179
1365
|
var p = parts && parts.length > 0 && parts.split(',') || self.names;
|
|
1180
1366
|
if (!map) map = identity;
|
|
1181
1367
|
var a = [];
|
|
1182
|
-
p.forEach(name
|
|
1368
|
+
p.forEach(function (name) {
|
|
1183
1369
|
if (!self.parts[name]) {
|
|
1184
|
-
debug$3('array error',
|
|
1185
|
-
throw error(
|
|
1186
|
-
this: ${this}
|
|
1187
|
-
parts: "${parts}"
|
|
1188
|
-
`, 'JSCAD_UTILS_GROUP_ERROR');
|
|
1370
|
+
debug$3('array error', _this, parts);
|
|
1371
|
+
throw error("group::array error \"".concat(name, "\" not found.\nthis: ").concat(_this, "\nparts: \"").concat(parts, "\"\n"), 'JSCAD_UTILS_GROUP_ERROR');
|
|
1189
1372
|
}
|
|
1190
1373
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
1191
1374
|
});
|
|
@@ -1215,17 +1398,12 @@ parts: "${parts}"
|
|
|
1215
1398
|
var self = this;
|
|
1216
1399
|
var piecesArray = pieces ? pieces.split(',') : self.names;
|
|
1217
1400
|
return piecesArray.map(function (piece) {
|
|
1218
|
-
if (!self.parts[piece]) console.error(
|
|
1401
|
+
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
1219
1402
|
return self.parts[piece];
|
|
1220
1403
|
});
|
|
1221
1404
|
};
|
|
1222
1405
|
JsCadUtilsGroup.prototype.toString = function () {
|
|
1223
|
-
return
|
|
1224
|
-
name: "${this.name}",
|
|
1225
|
-
names: "${this.names.join(',')}",
|
|
1226
|
-
parts: "${Object.keys(this.parts)}",
|
|
1227
|
-
holes: ${Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0}
|
|
1228
|
-
}`;
|
|
1406
|
+
return "{\n name: \"".concat(this.name, "\",\n names: \"").concat(this.names.join(','), "\", \n parts: \"").concat(Object.keys(this.parts), "\",\n holes: ").concat(Array.isArray(this.holes) ? this.holes.length : this.holes ? 1 : 0, "\n}");
|
|
1229
1407
|
};
|
|
1230
1408
|
JsCadUtilsGroup.prototype.setName = function (name) {
|
|
1231
1409
|
this.name = name;
|
|
@@ -1274,7 +1452,9 @@ parts: "${parts}"
|
|
|
1274
1452
|
self.name = objectNames;
|
|
1275
1453
|
} else {
|
|
1276
1454
|
var objects = objectNames; // eslint-disable-line no-redeclare
|
|
1277
|
-
self.names = Object.keys(objects).filter(
|
|
1455
|
+
self.names = Object.keys(objects).filter(function (k) {
|
|
1456
|
+
return k !== 'holes';
|
|
1457
|
+
});
|
|
1278
1458
|
self.parts = Object.assign({}, objects);
|
|
1279
1459
|
self.holes = objects.holes;
|
|
1280
1460
|
}
|
|
@@ -1283,15 +1463,13 @@ parts: "${parts}"
|
|
|
1283
1463
|
return new JsCadUtilsGroup(self.names, self.parts, self.holes);
|
|
1284
1464
|
}
|
|
1285
1465
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
const debug$2 = Debug('jscadUtils:util');
|
|
1466
|
+
var debug$2 = Debug('jscadUtils:util');
|
|
1289
1467
|
// import utilInit from '../src/add-prototype';
|
|
1290
1468
|
// utilInit(CSG);
|
|
1291
1469
|
// console.trace('CSG', CSG.prototype);
|
|
1292
1470
|
|
|
1293
1471
|
var NOZZEL_SIZE = 0.4;
|
|
1294
|
-
|
|
1472
|
+
var nearest = {
|
|
1295
1473
|
/**
|
|
1296
1474
|
* Return the largest number that is a multiple of the
|
|
1297
1475
|
* nozzel size.
|
|
@@ -1300,7 +1478,9 @@ parts: "${parts}"
|
|
|
1300
1478
|
* @param {Number} [nozzie=0] Number of nozzel sizes to add to the value
|
|
1301
1479
|
* @return {Number} Multiple of nozzel size
|
|
1302
1480
|
*/
|
|
1303
|
-
under: function (desired
|
|
1481
|
+
under: function under(desired) {
|
|
1482
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1483
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1304
1484
|
return (Math.floor(desired / nozzel) + nozzie) * nozzel;
|
|
1305
1485
|
},
|
|
1306
1486
|
/**
|
|
@@ -1311,7 +1491,9 @@ parts: "${parts}"
|
|
|
1311
1491
|
* @param {Number} [nozzie=0] Number of nozzel sizes to add to the value
|
|
1312
1492
|
* @return {Number} Multiple of nozzel size
|
|
1313
1493
|
*/
|
|
1314
|
-
over: function (desired
|
|
1494
|
+
over: function over(desired) {
|
|
1495
|
+
var nozzel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NOZZEL_SIZE;
|
|
1496
|
+
var nozzie = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1315
1497
|
return (Math.ceil(desired / nozzel) + nozzie) * nozzel;
|
|
1316
1498
|
}
|
|
1317
1499
|
};
|
|
@@ -1377,14 +1559,10 @@ parts: "${parts}"
|
|
|
1377
1559
|
debug$2(msg, JSON.stringify(o.getBounds()), JSON.stringify(this.size(o.getBounds())));
|
|
1378
1560
|
}
|
|
1379
1561
|
function jscadToString(o) {
|
|
1380
|
-
if (
|
|
1562
|
+
if (_typeof(o) == 'object') {
|
|
1381
1563
|
if (o.polygons) {
|
|
1382
1564
|
// is this CSG like?
|
|
1383
|
-
return
|
|
1384
|
-
polygons: ${o.polygons.length},
|
|
1385
|
-
properties: "${Object.keys(o.properties)}"
|
|
1386
|
-
}
|
|
1387
|
-
`;
|
|
1565
|
+
return "{\npolygons: ".concat(o.polygons.length, ",\nproperties: \"").concat(Object.keys(o.properties), "\"\n}\n");
|
|
1388
1566
|
}
|
|
1389
1567
|
} else {
|
|
1390
1568
|
return o.toString();
|
|
@@ -1453,13 +1631,13 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1453
1631
|
}
|
|
1454
1632
|
function text(text) {
|
|
1455
1633
|
var l = vector_char(0, 0, text); // l contains a list of polylines to draw
|
|
1456
|
-
var
|
|
1634
|
+
var _char = l.segments.reduce(function (result, segment) {
|
|
1457
1635
|
var path = new CSG.Path2D(segment);
|
|
1458
1636
|
var cag = path.expandToCAG(2);
|
|
1459
1637
|
// debug('reduce', result, segment, path, cag);
|
|
1460
1638
|
return result ? result.union(cag) : cag;
|
|
1461
1639
|
}, undefined);
|
|
1462
|
-
return
|
|
1640
|
+
return _char;
|
|
1463
1641
|
}
|
|
1464
1642
|
function unitCube(length, radius) {
|
|
1465
1643
|
radius = radius || 0.5;
|
|
@@ -1532,7 +1710,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1532
1710
|
function mapPick(o, names, f, options) {
|
|
1533
1711
|
return names.reduce(function (result, name, index) {
|
|
1534
1712
|
if (!o[name]) {
|
|
1535
|
-
throw new Error(
|
|
1713
|
+
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(',')));
|
|
1536
1714
|
}
|
|
1537
1715
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
1538
1716
|
return result;
|
|
@@ -1564,7 +1742,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1564
1742
|
function xyz2array(size) {
|
|
1565
1743
|
return [size.x, size.y, size.z];
|
|
1566
1744
|
}
|
|
1567
|
-
|
|
1745
|
+
var rotationAxes = {
|
|
1568
1746
|
x: [1, 0, 0],
|
|
1569
1747
|
y: [0, 1, 0],
|
|
1570
1748
|
z: [0, 0, 1]
|
|
@@ -1685,7 +1863,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1685
1863
|
function mirrored4(x) {
|
|
1686
1864
|
return x.union([x.mirroredY(90), x.mirroredX(90), x.mirroredY(90).mirroredX(90)]);
|
|
1687
1865
|
}
|
|
1688
|
-
|
|
1866
|
+
var flushSide = {
|
|
1689
1867
|
'above-outside': [1, 0],
|
|
1690
1868
|
'above-inside': [1, 1],
|
|
1691
1869
|
'below-outside': [0, 1],
|
|
@@ -1718,7 +1896,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1718
1896
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1719
1897
|
});
|
|
1720
1898
|
}
|
|
1721
|
-
function calcSnap(moveobj, withobj, axes, orientation
|
|
1899
|
+
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1900
|
+
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
1722
1901
|
var side = flushSide[orientation];
|
|
1723
1902
|
if (!side) {
|
|
1724
1903
|
var fix = {
|
|
@@ -1796,7 +1975,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1796
1975
|
objectSize = objectSize || size(bounds);
|
|
1797
1976
|
return bounds[0].plus(objectSize.dividedBy(2));
|
|
1798
1977
|
} catch (err) {
|
|
1799
|
-
error(
|
|
1978
|
+
error("centroid error o:".concat(jscadToString(o), " objectSize: ").concat(objectSize), undefined, err);
|
|
1800
1979
|
}
|
|
1801
1980
|
}
|
|
1802
1981
|
|
|
@@ -1829,7 +2008,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1829
2008
|
});
|
|
1830
2009
|
return t;
|
|
1831
2010
|
}
|
|
1832
|
-
function calcCenterWith(o, axes, withObj
|
|
2011
|
+
function calcCenterWith(o, axes, withObj) {
|
|
2012
|
+
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1833
2013
|
var objectCentroid = centroid(o);
|
|
1834
2014
|
var withCentroid = centroid(withObj);
|
|
1835
2015
|
var t = axisApply(axes, function (i, axis) {
|
|
@@ -1891,7 +2071,10 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1891
2071
|
* @param {CSG.Vector3D} [options.rotationCenter]
|
|
1892
2072
|
* @return {JsCadUtilsGroup} Returns a group object with a parts object.
|
|
1893
2073
|
*/
|
|
1894
|
-
function bisect(
|
|
2074
|
+
function bisect() {
|
|
2075
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2076
|
+
args[_key] = arguments[_key];
|
|
2077
|
+
}
|
|
1895
2078
|
if (args.length < 2) {
|
|
1896
2079
|
error('bisect requires an object and an axis', 'JSCAD_UTILS_INVALID_ARGS');
|
|
1897
2080
|
}
|
|
@@ -1961,16 +2144,16 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1961
2144
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
1962
2145
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
|
|
1963
2146
|
debug$2('bisect', debug$2.enabled && {
|
|
1964
|
-
axis,
|
|
1965
|
-
offset,
|
|
1966
|
-
angle,
|
|
1967
|
-
rotateaxis,
|
|
1968
|
-
cutDelta,
|
|
1969
|
-
rotateOffsetAxis,
|
|
1970
|
-
rotationCenter,
|
|
1971
|
-
theRotationAxis,
|
|
1972
|
-
cutplane,
|
|
1973
|
-
options
|
|
2147
|
+
axis: axis,
|
|
2148
|
+
offset: offset,
|
|
2149
|
+
angle: angle,
|
|
2150
|
+
rotateaxis: rotateaxis,
|
|
2151
|
+
cutDelta: cutDelta,
|
|
2152
|
+
rotateOffsetAxis: rotateOffsetAxis,
|
|
2153
|
+
rotationCenter: rotationCenter,
|
|
2154
|
+
theRotationAxis: theRotationAxis,
|
|
2155
|
+
cutplane: cutplane,
|
|
2156
|
+
options: options
|
|
1974
2157
|
});
|
|
1975
2158
|
var g = Group('negative,positive', [object.cutByPlane(cutplane.plane).color(options.color && 'red'), object.cutByPlane(cutplane.plane.flipped()).color(options.color && 'blue')]);
|
|
1976
2159
|
if (options.addRotationCenter) g.add(unitAxis(objectSize.length() + 10, 0.1, rotationCenter), 'rotationCenter');
|
|
@@ -1988,10 +2171,14 @@ properties: "${Object.keys(o.properties)}"
|
|
|
1988
2171
|
* @param {CSG.Vector3D} [options.rotationCenter] The location of the rotation center, defaults to [0,0,0].
|
|
1989
2172
|
* @return {JsCadUtilsGroup} A group with a positive and negative CSG object.
|
|
1990
2173
|
*/
|
|
1991
|
-
function slice(object
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2174
|
+
function slice(object) {
|
|
2175
|
+
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15;
|
|
2176
|
+
var axis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'x';
|
|
2177
|
+
var rotateaxis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'z';
|
|
2178
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
2179
|
+
color: true,
|
|
2180
|
+
addRotationCenter: true
|
|
2181
|
+
};
|
|
1995
2182
|
var info = normalVector(axis);
|
|
1996
2183
|
var rotationCenter = options.rotationCenter || new CSG.Vector3D(0, 0, 0);
|
|
1997
2184
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
@@ -2288,19 +2475,21 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2288
2475
|
var rotationCenter = solid.centroid();
|
|
2289
2476
|
var rotationAxis = axes[axis];
|
|
2290
2477
|
return {
|
|
2291
|
-
rotationCenter,
|
|
2292
|
-
rotationAxis
|
|
2478
|
+
rotationCenter: rotationCenter,
|
|
2479
|
+
rotationAxis: rotationAxis
|
|
2293
2480
|
};
|
|
2294
2481
|
}
|
|
2295
2482
|
function rotateAround(part, solid, axis, angle) {
|
|
2296
|
-
var
|
|
2297
|
-
rotationCenter,
|
|
2298
|
-
rotationAxis
|
|
2299
|
-
} = calcRotate(part, solid, axis);
|
|
2483
|
+
var _calcRotate = calcRotate(part, solid, axis),
|
|
2484
|
+
rotationCenter = _calcRotate.rotationCenter,
|
|
2485
|
+
rotationAxis = _calcRotate.rotationAxis;
|
|
2300
2486
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
2301
2487
|
}
|
|
2302
|
-
function cloneProperties(from, to
|
|
2303
|
-
return Object.entries(from).reduce((props,
|
|
2488
|
+
function cloneProperties(from, to) {
|
|
2489
|
+
return Object.entries(from).reduce(function (props, _ref) {
|
|
2490
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2491
|
+
key = _ref2[0],
|
|
2492
|
+
value = _ref2[1];
|
|
2304
2493
|
props[key] = value;
|
|
2305
2494
|
return props;
|
|
2306
2495
|
}, to);
|
|
@@ -2321,93 +2510,21 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2321
2510
|
* @param {Array} point=[0,0,0] a 3 axis array direction vector somewhat perpendicular to axis; this defines the “12 o'clock” orientation of the connection.
|
|
2322
2511
|
* @return {CSG} The CSG object with the new connector added.
|
|
2323
2512
|
*/
|
|
2324
|
-
function addConnector(object, name
|
|
2513
|
+
function addConnector(object, name) {
|
|
2514
|
+
var point = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0];
|
|
2515
|
+
var axis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [1, 0, 0];
|
|
2516
|
+
var normal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [0, 0, 1];
|
|
2325
2517
|
object.properties[name] = new CSG.Connector(point, axis, normal);
|
|
2326
2518
|
return object;
|
|
2327
2519
|
}
|
|
2328
2520
|
|
|
2329
|
-
var
|
|
2330
|
-
__proto__: null,
|
|
2331
|
-
NOZZEL_SIZE: NOZZEL_SIZE,
|
|
2332
|
-
addConnector: addConnector,
|
|
2333
|
-
axis2array: axis2array,
|
|
2334
|
-
axisApply: axisApply,
|
|
2335
|
-
bisect: bisect,
|
|
2336
|
-
calcCenterWith: calcCenterWith,
|
|
2337
|
-
calcFlush: calcFlush,
|
|
2338
|
-
calcRotate: calcRotate,
|
|
2339
|
-
calcSnap: calcSnap,
|
|
2340
|
-
calcmidlineTo: calcmidlineTo,
|
|
2341
|
-
center: center,
|
|
2342
|
-
centerWith: centerWith,
|
|
2343
|
-
centerX: centerX,
|
|
2344
|
-
centerY: centerY,
|
|
2345
|
-
centroid: centroid,
|
|
2346
|
-
chamfer: chamfer,
|
|
2347
|
-
clone: clone,
|
|
2348
|
-
cm: cm,
|
|
2349
|
-
defaults: defaults,
|
|
2350
|
-
depreciated: depreciated,
|
|
2351
|
-
div: div,
|
|
2352
|
-
divA: divA,
|
|
2353
|
-
divxyz: divxyz,
|
|
2354
|
-
enlarge: enlarge,
|
|
2355
|
-
error: error,
|
|
2356
|
-
fillet: fillet,
|
|
2357
|
-
fit: fit,
|
|
2358
|
-
flush: flush,
|
|
2359
|
-
flushSide: flushSide,
|
|
2360
|
-
getDelta: getDelta,
|
|
2361
|
-
identity: identity,
|
|
2362
|
-
ifArray: ifArray,
|
|
2363
|
-
inch: inch,
|
|
2364
|
-
isEmpty: isEmpty,
|
|
2365
|
-
isNegative: isNegative,
|
|
2366
|
-
jscadToString: jscadToString,
|
|
2367
|
-
label: label,
|
|
2368
|
-
map: map,
|
|
2369
|
-
mapPick: mapPick,
|
|
2370
|
-
mapValues: mapValues,
|
|
2371
|
-
midlineTo: midlineTo,
|
|
2372
|
-
mirrored4: mirrored4,
|
|
2373
|
-
mul: mul,
|
|
2374
|
-
mulxyz: mulxyz,
|
|
2375
|
-
nearest: nearest,
|
|
2376
|
-
normalVector: normalVector,
|
|
2377
|
-
pick: pick,
|
|
2378
|
-
poly2solid: poly2solid,
|
|
2379
|
-
print: print,
|
|
2380
|
-
reShape: reShape,
|
|
2381
|
-
result: result,
|
|
2382
|
-
rotateAround: rotateAround,
|
|
2383
|
-
rotationAxes: rotationAxes,
|
|
2384
|
-
scale: scale,
|
|
2385
|
-
segment: segment,
|
|
2386
|
-
shift: shift,
|
|
2387
|
-
size: size,
|
|
2388
|
-
slice: slice,
|
|
2389
|
-
sliceParams: sliceParams,
|
|
2390
|
-
slices2poly: slices2poly,
|
|
2391
|
-
snap: snap,
|
|
2392
|
-
stretch: stretch,
|
|
2393
|
-
text: text,
|
|
2394
|
-
toArray: toArray,
|
|
2395
|
-
translator: translator,
|
|
2396
|
-
unitAxis: unitAxis,
|
|
2397
|
-
unitCube: unitCube,
|
|
2398
|
-
wedge: wedge,
|
|
2399
|
-
xyz2array: xyz2array,
|
|
2400
|
-
zero: zero,
|
|
2401
|
-
zipObject: zipObject
|
|
2402
|
-
});
|
|
2403
|
-
|
|
2404
|
-
const debug$1 = Debug('jscadUtils:parts');
|
|
2521
|
+
var debug$1 = Debug('jscadUtils:parts');
|
|
2405
2522
|
var parts = {
|
|
2406
2523
|
BBox: BBox$1,
|
|
2407
|
-
Cube,
|
|
2408
|
-
RoundedCube,
|
|
2409
|
-
Cylinder,
|
|
2410
|
-
Cone
|
|
2524
|
+
Cube: Cube,
|
|
2525
|
+
RoundedCube: RoundedCube,
|
|
2526
|
+
Cylinder: Cylinder,
|
|
2527
|
+
Cone: Cone
|
|
2411
2528
|
};
|
|
2412
2529
|
|
|
2413
2530
|
/**
|
|
@@ -2417,13 +2534,16 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2417
2534
|
* @param {CSG} ...objects Any number of CSG objects to create a bounding box for.
|
|
2418
2535
|
* @return {CSG} A box with the size of the extents of all of the passed in objects
|
|
2419
2536
|
*/
|
|
2420
|
-
function BBox$1(
|
|
2537
|
+
function BBox$1() {
|
|
2421
2538
|
function box(object) {
|
|
2422
2539
|
return CSG.cube({
|
|
2423
2540
|
center: object.centroid(),
|
|
2424
2541
|
radius: object.size().dividedBy(2)
|
|
2425
2542
|
});
|
|
2426
2543
|
}
|
|
2544
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2545
|
+
objects[_key] = arguments[_key];
|
|
2546
|
+
}
|
|
2427
2547
|
return objects.reduce(function (bbox, part) {
|
|
2428
2548
|
var object = bbox ? union([bbox, box(part)]) : part;
|
|
2429
2549
|
return box(object);
|
|
@@ -2483,7 +2603,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2483
2603
|
* @param {number} [options.resolution] The number of segments to create in 360 degrees of rotation.
|
|
2484
2604
|
* @return {CSG} A CSG Cylinder
|
|
2485
2605
|
*/
|
|
2486
|
-
function Cylinder(diameter, height
|
|
2606
|
+
function Cylinder(diameter, height) {
|
|
2607
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2487
2608
|
debug$1('parts.Cylinder', diameter, height, options);
|
|
2488
2609
|
options = Object.assign({
|
|
2489
2610
|
start: [0, 0, 0],
|
|
@@ -2503,7 +2624,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2503
2624
|
* @param {Object} options Additional options passed to `CSG.cylinder`.
|
|
2504
2625
|
* @return {CSG} A CSG cone object.
|
|
2505
2626
|
*/
|
|
2506
|
-
function Cone(diameter1, diameter2, height
|
|
2627
|
+
function Cone(diameter1, diameter2, height) {
|
|
2628
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2507
2629
|
debug$1('parts.Cone', diameter1, diameter2, height, options);
|
|
2508
2630
|
return CSG.cylinder(Object.assign({
|
|
2509
2631
|
start: [0, 0, 0],
|
|
@@ -2564,12 +2686,14 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2564
2686
|
* @param {Number} width
|
|
2565
2687
|
* @param {Number} height
|
|
2566
2688
|
*/
|
|
2567
|
-
function Anchor(
|
|
2689
|
+
function Anchor() {
|
|
2690
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
2691
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
2568
2692
|
var hole = Cylinder(width, height).Center().color('red');
|
|
2569
2693
|
var post = Cylinder(height / 2, width * 0.66).rotateX(90).align(hole, 'xz').snap(hole, 'y', 'inside-').translate([0, 0, -height / 6]).color('purple');
|
|
2570
2694
|
return Group({
|
|
2571
|
-
post,
|
|
2572
|
-
hole
|
|
2695
|
+
post: post,
|
|
2696
|
+
hole: hole
|
|
2573
2697
|
});
|
|
2574
2698
|
}
|
|
2575
2699
|
function Board(width, height, corner_radius, thickness) {
|
|
@@ -2584,7 +2708,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2584
2708
|
});
|
|
2585
2709
|
return board;
|
|
2586
2710
|
}
|
|
2587
|
-
|
|
2711
|
+
var Hardware = {
|
|
2588
2712
|
Orientation: {
|
|
2589
2713
|
up: {
|
|
2590
2714
|
head: 'outside-',
|
|
@@ -2595,7 +2719,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2595
2719
|
clear: 'inside-'
|
|
2596
2720
|
}
|
|
2597
2721
|
},
|
|
2598
|
-
Screw: function (head, thread, headClearSpace, options) {
|
|
2722
|
+
Screw: function Screw(head, thread, headClearSpace, options) {
|
|
2599
2723
|
depreciated('Screw', false, 'Use the jscad-hardware screw methods instead');
|
|
2600
2724
|
options = Object.assign(options, {
|
|
2601
2725
|
orientation: 'up',
|
|
@@ -2620,7 +2744,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2620
2744
|
* @param {number} clearLength Length of the clearance section of the head.
|
|
2621
2745
|
* @param {object} options Screw options include orientation and clerance scale.
|
|
2622
2746
|
*/
|
|
2623
|
-
PanHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2747
|
+
PanHeadScrew: function PanHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2624
2748
|
depreciated('PanHeadScrew', false, 'Use the jscad-hardware screw methods instead');
|
|
2625
2749
|
var head = Cylinder(headDiameter, headLength);
|
|
2626
2750
|
var thread = Cylinder(diameter, length);
|
|
@@ -2638,7 +2762,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2638
2762
|
* @param {number} clearLength Length of the clearance section of the head.
|
|
2639
2763
|
* @param {object} options Screw options include orientation and clerance scale.
|
|
2640
2764
|
*/
|
|
2641
|
-
HexHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2765
|
+
HexHeadScrew: function HexHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2642
2766
|
depreciated('HexHeadScrew', false, 'Use the jscad-hardware screw methods instead');
|
|
2643
2767
|
var head = Hexagon(headDiameter, headLength);
|
|
2644
2768
|
var thread = Cylinder(diameter, length);
|
|
@@ -2656,7 +2780,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2656
2780
|
* @param {number} clearLength clearance length
|
|
2657
2781
|
* @param {object} options options
|
|
2658
2782
|
*/
|
|
2659
|
-
FlatHeadScrew: function (headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2783
|
+
FlatHeadScrew: function FlatHeadScrew(headDiameter, headLength, diameter, length, clearLength, options) {
|
|
2660
2784
|
depreciated('FlatHeadScrew', false, 'Use the jscad-hardware screw methods instead');
|
|
2661
2785
|
var head = Cone(headDiameter, diameter, headLength);
|
|
2662
2786
|
// var head = Cylinder(headDiameter, headLength);
|
|
@@ -2670,21 +2794,21 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2670
2794
|
|
|
2671
2795
|
var parts$1 = /*#__PURE__*/Object.freeze({
|
|
2672
2796
|
__proto__: null,
|
|
2673
|
-
|
|
2797
|
+
'default': parts,
|
|
2674
2798
|
BBox: BBox$1,
|
|
2675
|
-
Board: Board,
|
|
2676
|
-
Cone: Cone,
|
|
2677
2799
|
Cube: Cube,
|
|
2800
|
+
RoundedCube: RoundedCube,
|
|
2678
2801
|
Cylinder: Cylinder,
|
|
2679
|
-
|
|
2802
|
+
Cone: Cone,
|
|
2680
2803
|
Hexagon: Hexagon,
|
|
2681
|
-
RoundedCube: RoundedCube,
|
|
2682
2804
|
Triangle: Triangle,
|
|
2683
2805
|
Tube: Tube,
|
|
2684
|
-
|
|
2806
|
+
Anchor: Anchor,
|
|
2807
|
+
Board: Board,
|
|
2808
|
+
Hardware: Hardware
|
|
2685
2809
|
});
|
|
2686
2810
|
|
|
2687
|
-
|
|
2811
|
+
var debug = Debug('jscadUtils:boxes');
|
|
2688
2812
|
|
|
2689
2813
|
/** @typedef {import("./group").JsCadUtilsGroup} JsCadUtilsGroup */
|
|
2690
2814
|
|
|
@@ -2756,7 +2880,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2756
2880
|
* @param {Number} face Size of the join face.
|
|
2757
2881
|
* @return {JsCadUtilsGroup} A group object with `positive`, `negative` parts.
|
|
2758
2882
|
*/
|
|
2759
|
-
function Rabett(box, thickness, gap, height, face
|
|
2883
|
+
function Rabett(box, thickness, gap, height, face) {
|
|
2884
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
2760
2885
|
debug('Rabett', 'thickness', thickness, 'gap', gap, 'height', height, 'face', face);
|
|
2761
2886
|
gap = gap || 0.25;
|
|
2762
2887
|
var inside = thickness - gap;
|
|
@@ -2765,18 +2890,16 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2765
2890
|
debug('inside', inside, 'outside', outside);
|
|
2766
2891
|
var group = Group();
|
|
2767
2892
|
// debug('Rabbet top height:', height, 'options:', options);
|
|
2768
|
-
var
|
|
2769
|
-
positive
|
|
2770
|
-
negative
|
|
2771
|
-
} = box.bisect('z', height, options).parts;
|
|
2893
|
+
var _box$bisect$parts = box.bisect('z', height, options).parts,
|
|
2894
|
+
top = _box$bisect$parts.positive,
|
|
2895
|
+
lower2_3rd = _box$bisect$parts.negative;
|
|
2772
2896
|
|
|
2773
2897
|
// debug('face', face, 'height', height);
|
|
2774
2898
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
2775
2899
|
// debug('Rabbet bottom height:', lowerBisectHeight, 'options:', options);
|
|
2776
|
-
var
|
|
2777
|
-
positive
|
|
2778
|
-
negative
|
|
2779
|
-
} = lower2_3rd.bisect('z', lowerBisectHeight, options).parts;
|
|
2900
|
+
var _lower2_3rd$bisect$pa = lower2_3rd.bisect('z', lowerBisectHeight, options).parts,
|
|
2901
|
+
middle = _lower2_3rd$bisect$pa.positive,
|
|
2902
|
+
bottom = _lower2_3rd$bisect$pa.negative;
|
|
2780
2903
|
var middleTop = middle.color('yellow').subtract(middle.color('darkred').enlarge([outside, outside, 0]));
|
|
2781
2904
|
group.add(top
|
|
2782
2905
|
// .color('blue')
|
|
@@ -2820,7 +2943,9 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2820
2943
|
* @return {JsCadUtilsGroup} An A hollow version of the original object..
|
|
2821
2944
|
* @memberof module:Boxes
|
|
2822
2945
|
*/
|
|
2823
|
-
|
|
2946
|
+
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
2947
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
|
|
2948
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2824
2949
|
options = Object.assign({
|
|
2825
2950
|
removableTop: true,
|
|
2826
2951
|
removableBottom: true,
|
|
@@ -2853,7 +2978,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2853
2978
|
}
|
|
2854
2979
|
return group;
|
|
2855
2980
|
};
|
|
2856
|
-
|
|
2981
|
+
var CutOut = function cutOut(o, h, box, plug, gap) {
|
|
2857
2982
|
gap = gap || 0.25;
|
|
2858
2983
|
// console.log('cutOut', o.size(), h, b.size());
|
|
2859
2984
|
// var r = getRadius(o);
|
|
@@ -2873,7 +2998,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2873
2998
|
insert: union([o, top]).intersect(box).subtract(o).enlarge([-gap, 0, 0]).union(clip.subtract(plug).enlarge(-gap, -gap, 0)).color('blue')
|
|
2874
2999
|
});
|
|
2875
3000
|
};
|
|
2876
|
-
|
|
3001
|
+
var Rectangle = function Rectangle(size, thickness, cb) {
|
|
2877
3002
|
thickness = thickness || 2;
|
|
2878
3003
|
var s = div$1(xyz2array(size), 2);
|
|
2879
3004
|
var r = add(s, thickness);
|
|
@@ -2904,7 +3029,7 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2904
3029
|
* @return {CSG} An A hollow version of the original object..
|
|
2905
3030
|
* @memberof module:Boxes
|
|
2906
3031
|
*/
|
|
2907
|
-
|
|
3032
|
+
var Hollow = function Hollow(object, thickness, interiorcb, exteriorcb) {
|
|
2908
3033
|
thickness = thickness || 2;
|
|
2909
3034
|
var size = -thickness * 2;
|
|
2910
3035
|
interiorcb = interiorcb || identity;
|
|
@@ -2914,13 +3039,13 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2914
3039
|
};
|
|
2915
3040
|
|
|
2916
3041
|
/**
|
|
2917
|
-
* Create a box that
|
|
3042
|
+
* Create a box that surrounds the object.
|
|
2918
3043
|
* @param {CSG} o The object to create a bounding box for.
|
|
2919
3044
|
* @return {CSG} The bounding box aligned with the object.
|
|
2920
3045
|
* @deprecated use parts.BBox
|
|
2921
3046
|
* @memberof module:Boxes
|
|
2922
3047
|
*/
|
|
2923
|
-
|
|
3048
|
+
var BBox = function BBox(o) {
|
|
2924
3049
|
depreciated('BBox', true, "Use 'parts.BBox' instead");
|
|
2925
3050
|
var s = div$1(xyz2array(o.size()), 2);
|
|
2926
3051
|
return CSG.cube({
|
|
@@ -2931,7 +3056,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2931
3056
|
function getRadius(o) {
|
|
2932
3057
|
return div$1(xyz2array(o.size()), 2);
|
|
2933
3058
|
}
|
|
2934
|
-
function rabbetJoin(box, thickness
|
|
3059
|
+
function rabbetJoin(box, thickness) {
|
|
3060
|
+
var gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.25;
|
|
2935
3061
|
var r = add(getRadius(box), -thickness / 2);
|
|
2936
3062
|
r[2] = thickness / 2;
|
|
2937
3063
|
var cutter = CSG.cube({
|
|
@@ -2950,30 +3076,25 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2950
3076
|
|
|
2951
3077
|
var Boxes = /*#__PURE__*/Object.freeze({
|
|
2952
3078
|
__proto__: null,
|
|
2953
|
-
BBox: BBox,
|
|
2954
|
-
CutOut: CutOut,
|
|
2955
|
-
Hollow: Hollow,
|
|
2956
3079
|
RabbetJoin: RabbetJoin,
|
|
3080
|
+
topMiddleBottom: topMiddleBottom,
|
|
2957
3081
|
Rabett: Rabett,
|
|
2958
3082
|
RabettTopBottom: RabettTopBottom,
|
|
3083
|
+
CutOut: CutOut,
|
|
2959
3084
|
Rectangle: Rectangle,
|
|
2960
|
-
|
|
3085
|
+
Hollow: Hollow,
|
|
3086
|
+
BBox: BBox
|
|
2961
3087
|
});
|
|
2962
3088
|
|
|
2963
|
-
|
|
2964
|
-
* JsCad Utilities es6
|
|
2965
|
-
*/
|
|
2966
|
-
|
|
2967
|
-
const compatV1 = {
|
|
2968
|
-
...util,
|
|
3089
|
+
var compatV1 = _objectSpread2(_objectSpread2({}, util), {}, {
|
|
2969
3090
|
group: Group,
|
|
2970
3091
|
init: init$1,
|
|
2971
3092
|
triangle: triUtils,
|
|
2972
|
-
array,
|
|
3093
|
+
array: array,
|
|
2973
3094
|
parts: parts$1,
|
|
2974
|
-
Boxes,
|
|
2975
|
-
Debug
|
|
2976
|
-
};
|
|
3095
|
+
Boxes: Boxes,
|
|
3096
|
+
Debug: Debug
|
|
3097
|
+
});
|
|
2977
3098
|
|
|
2978
3099
|
exports.Boxes = Boxes;
|
|
2979
3100
|
exports.Debug = Debug;
|
|
@@ -2985,6 +3106,8 @@ properties: "${Object.keys(o.properties)}"
|
|
|
2985
3106
|
exports.triUtils = triUtils;
|
|
2986
3107
|
exports.util = util;
|
|
2987
3108
|
|
|
3109
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3110
|
+
|
|
2988
3111
|
return exports;
|
|
2989
3112
|
|
|
2990
3113
|
})({}, jsCadCSG, scadApi);
|