@jwc/jscad-raspberrypi 3.1.0 → 3.2.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/.vscode/settings.json +22 -0
- package/README.md +0 -12
- package/dist/examples/active-cooling-fan.jscad +2742 -0
- package/dist/examples/bplus.jscad +223 -202
- package/dist/examples/bplus3.jscad +223 -202
- package/dist/examples/camera-module-v1.jscad +223 -202
- package/dist/examples/camera-module-v2.jscad +223 -202
- package/dist/examples/example.jscad +239 -211
- package/dist/examples/hat-standoff.jscad +223 -202
- package/dist/examples/hat.jscad +223 -202
- package/dist/examples/hq_camera-module.jscad +2742 -0
- package/dist/examples/miniPiTFT.jscad +2742 -0
- package/dist/examples/pi-tft22.jscad +223 -202
- package/dist/examples/pi-tft24.jscad +223 -202
- package/dist/examples/pi4.jscad +2742 -0
- package/dist/examples/pi5.jscad +2752 -0
- package/dist/examples/spacer.jscad +223 -202
- package/dist/index.js +191 -102
- package/dist/v1compat.js +191 -102
- package/examples/active-cooling-fan.jscad +10 -0
- package/examples/example.jscad +16 -9
- package/examples/hq_camera-module.jscad +10 -0
- package/examples/miniPiTFT.jscad +10 -0
- package/examples/pi4.jscad +10 -0
- package/examples/pi5.jscad +20 -0
- package/gulpfile.js +4 -4
- package/package.json +31 -39
- package/src/active-cooling-fan.js +160 -0
- package/src/bplus.js +38 -2
- package/src/index.js +6 -9
|
@@ -51,8 +51,13 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
51
51
|
});
|
|
52
52
|
var jscadUtils = function(exports, jsCadCSG, scadApi) {
|
|
53
53
|
"use strict";
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
function _interopDefaultLegacy(e) {
|
|
55
|
+
return e && typeof e === "object" && "default" in e ? e : {
|
|
56
|
+
default: e
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var jsCadCSG__default = _interopDefaultLegacy(jsCadCSG);
|
|
60
|
+
var scadApi__default = _interopDefaultLegacy(scadApi);
|
|
56
61
|
var util = Object.freeze({
|
|
57
62
|
__proto__: null,
|
|
58
63
|
get NOZZEL_SIZE() {
|
|
@@ -299,9 +304,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
299
304
|
var keys = Object.keys(object);
|
|
300
305
|
if (Object.getOwnPropertySymbols) {
|
|
301
306
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
302
|
-
if (enumerableOnly) symbols = symbols.filter(
|
|
307
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
303
308
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
304
|
-
})
|
|
309
|
+
});
|
|
305
310
|
keys.push.apply(keys, symbols);
|
|
306
311
|
}
|
|
307
312
|
return keys;
|
|
@@ -310,15 +315,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
310
315
|
for (var i = 1; i < arguments.length; i++) {
|
|
311
316
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
312
317
|
if (i % 2) {
|
|
313
|
-
ownKeys(Object(source), true).forEach(
|
|
318
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
314
319
|
_defineProperty(target, key, source[key]);
|
|
315
|
-
})
|
|
320
|
+
});
|
|
316
321
|
} else if (Object.getOwnPropertyDescriptors) {
|
|
317
322
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
318
323
|
} else {
|
|
319
|
-
ownKeys(Object(source)).forEach(
|
|
324
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
320
325
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
321
|
-
})
|
|
326
|
+
});
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
329
|
return target;
|
|
@@ -427,29 +432,29 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
427
432
|
solveab
|
|
428
433
|
});
|
|
429
434
|
var div = function div(a, f) {
|
|
430
|
-
return a.map(
|
|
435
|
+
return a.map(function(e) {
|
|
431
436
|
return e / f;
|
|
432
|
-
})
|
|
437
|
+
});
|
|
433
438
|
};
|
|
434
439
|
var addValue = function addValue(a, f) {
|
|
435
|
-
return a.map(
|
|
440
|
+
return a.map(function(e) {
|
|
436
441
|
return e + f;
|
|
437
|
-
})
|
|
442
|
+
});
|
|
438
443
|
};
|
|
439
444
|
var addArray = function addArray(a, f) {
|
|
440
|
-
return a.map(
|
|
445
|
+
return a.map(function(e, i) {
|
|
441
446
|
return e + f[i];
|
|
442
|
-
})
|
|
447
|
+
});
|
|
443
448
|
};
|
|
444
449
|
var add = function add(a) {
|
|
445
|
-
return Array.prototype.slice.call(arguments, 1).reduce(
|
|
450
|
+
return Array.prototype.slice.call(arguments, 1).reduce(function(result, arg) {
|
|
446
451
|
if (Array.isArray(arg)) {
|
|
447
452
|
result = addArray(result, arg);
|
|
448
453
|
} else {
|
|
449
454
|
result = addValue(result, arg);
|
|
450
455
|
}
|
|
451
456
|
return result;
|
|
452
|
-
}
|
|
457
|
+
}, a);
|
|
453
458
|
};
|
|
454
459
|
var fromxyz = function fromxyz(object) {
|
|
455
460
|
return Array.isArray(object) ? object : [ object.x, object.y, object.z ];
|
|
@@ -468,9 +473,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
468
473
|
return a && a.length > 0 ? a[a.length - 1] : undefined;
|
|
469
474
|
};
|
|
470
475
|
var min = function min(a) {
|
|
471
|
-
return a.reduce(
|
|
476
|
+
return a.reduce(function(result, value) {
|
|
472
477
|
return value < result ? value : result;
|
|
473
|
-
}
|
|
478
|
+
}, Number.MAX_VALUE);
|
|
474
479
|
};
|
|
475
480
|
var range = function range(a, b) {
|
|
476
481
|
var result = [];
|
|
@@ -504,11 +509,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
504
509
|
}
|
|
505
510
|
}, jscadUtilsDebug || {});
|
|
506
511
|
var style = checks.options.browser ? "color:".concat(debugColors[debugCount++ % debugColors.length]) : "".concat(termColors[debugCount++ % termColors.length]);
|
|
507
|
-
var enabled = checks.enabled.some(
|
|
512
|
+
var enabled = checks.enabled.some(function checkEnabled(check) {
|
|
508
513
|
return check.test(name);
|
|
509
|
-
})
|
|
514
|
+
}) && !checks.disabled.some(function checkEnabled(check) {
|
|
510
515
|
return check.test(name);
|
|
511
|
-
})
|
|
516
|
+
});
|
|
512
517
|
var logger = enabled ? checks.options.browser ? function() {
|
|
513
518
|
var _console;
|
|
514
519
|
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -695,9 +700,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
695
700
|
function color(o, r, g, b, a) {
|
|
696
701
|
if (typeof r !== "string") return o.setColor(r, g, b, a);
|
|
697
702
|
if (r === "") return o;
|
|
698
|
-
var c = name2rgb(r).map(
|
|
703
|
+
var c = name2rgb(r).map(function(x) {
|
|
699
704
|
return x / 255;
|
|
700
|
-
})
|
|
705
|
+
});
|
|
701
706
|
c[3] = g || 1;
|
|
702
707
|
return o.setColor(c);
|
|
703
708
|
}
|
|
@@ -799,10 +804,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
799
804
|
if (arguments.length === 1) {
|
|
800
805
|
return this._translate(arguments[0]);
|
|
801
806
|
} else {
|
|
802
|
-
var t = Array.prototype.slice.call(arguments, 0).reduce(
|
|
807
|
+
var t = Array.prototype.slice.call(arguments, 0).reduce(function(result, arg) {
|
|
803
808
|
result = undefined(result, arg);
|
|
804
809
|
return result;
|
|
805
|
-
}
|
|
810
|
+
}, [ 0, 0, 0 ]);
|
|
806
811
|
return this._translate(t);
|
|
807
812
|
}
|
|
808
813
|
};
|
|
@@ -812,9 +817,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
812
817
|
proto.prototype.connect = function connectTo(myConnectorName, otherConnector) {
|
|
813
818
|
var mirror = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
814
819
|
var normalrotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
815
|
-
var myConnector = myConnectorName.split(".").reduce(
|
|
820
|
+
var myConnector = myConnectorName.split(".").reduce(function(a, v) {
|
|
816
821
|
return a[v];
|
|
817
|
-
}
|
|
822
|
+
}, this.properties);
|
|
818
823
|
if (!myConnector) {
|
|
819
824
|
error("The connector '".concat(myConnectorName, "' does not exist on the object [").concat(Object.keys(this.properties).join(","), "]"), "Missing connector property");
|
|
820
825
|
}
|
|
@@ -826,10 +831,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
826
831
|
__proto__: null,
|
|
827
832
|
default: init
|
|
828
833
|
});
|
|
829
|
-
var CSG =
|
|
830
|
-
var rectangular_extrude =
|
|
831
|
-
var _scadApi$text =
|
|
832
|
-
var union =
|
|
834
|
+
var CSG = jsCadCSG__default["default"].CSG, CAG = jsCadCSG__default["default"].CAG;
|
|
835
|
+
var rectangular_extrude = scadApi__default["default"].extrusions.rectangular_extrude;
|
|
836
|
+
var _scadApi$text = scadApi__default["default"].text, vector_text = _scadApi$text.vector_text, vector_char = _scadApi$text.vector_char;
|
|
837
|
+
var union = scadApi__default["default"].booleanOps.union;
|
|
833
838
|
init(CSG);
|
|
834
839
|
var debug = Debug("jscadUtils:group");
|
|
835
840
|
function JsCadUtilsGroup() {
|
|
@@ -849,9 +854,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
849
854
|
if (!hidden) self.names.push(name);
|
|
850
855
|
self.parts[name] = object.combine(parts);
|
|
851
856
|
if (subparts) {
|
|
852
|
-
Object.keys(object.parts).forEach(
|
|
857
|
+
Object.keys(object.parts).forEach(function(key) {
|
|
853
858
|
self.parts[subparts + key] = object.parts[key];
|
|
854
|
-
})
|
|
859
|
+
});
|
|
855
860
|
}
|
|
856
861
|
} else {
|
|
857
862
|
Object.assign(self.parts, object.parts);
|
|
@@ -878,9 +883,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
878
883
|
throw new Error("no pieces found in ".concat(self.name, " pieces: ").concat(pieces, " parts: ").concat(Object.keys(self.parts), " names: ").concat(self.names));
|
|
879
884
|
}
|
|
880
885
|
debug("combine", self.names, self.parts);
|
|
881
|
-
var g = union(mapPick(self.parts, pieces,
|
|
886
|
+
var g = union(mapPick(self.parts, pieces, function(value, key, index, object) {
|
|
882
887
|
return map ? map(value, key, index, object) : identity(value);
|
|
883
|
-
}
|
|
888
|
+
}, self.name));
|
|
884
889
|
return g.subtractIf(self.holes && Array.isArray(self.holes) ? union(self.holes) : self.holes, self.holes && !options.noholes);
|
|
885
890
|
} catch (err) {
|
|
886
891
|
debug("combine error", this, pieces, options, err);
|
|
@@ -889,17 +894,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
889
894
|
};
|
|
890
895
|
JsCadUtilsGroup.prototype.map = function(cb) {
|
|
891
896
|
var self = this;
|
|
892
|
-
self.parts = Object.keys(self.parts).filter(
|
|
897
|
+
self.parts = Object.keys(self.parts).filter(function(k) {
|
|
893
898
|
return k !== "holes";
|
|
894
|
-
})
|
|
899
|
+
}).reduce(function(result, key) {
|
|
895
900
|
result[key] = cb(self.parts[key], key);
|
|
896
901
|
return result;
|
|
897
|
-
}
|
|
902
|
+
}, {});
|
|
898
903
|
if (self.holes) {
|
|
899
904
|
if (Array.isArray(self.holes)) {
|
|
900
|
-
self.holes = self.holes.map(
|
|
905
|
+
self.holes = self.holes.map(function(hole, idx) {
|
|
901
906
|
return cb(hole, idx);
|
|
902
|
-
})
|
|
907
|
+
});
|
|
903
908
|
} else {
|
|
904
909
|
self.holes = cb(self.holes, "holes");
|
|
905
910
|
}
|
|
@@ -915,15 +920,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
915
920
|
}
|
|
916
921
|
if (!map) map = identity;
|
|
917
922
|
var group = Group(name);
|
|
918
|
-
Object.keys(self.parts).forEach(
|
|
923
|
+
Object.keys(self.parts).forEach(function(key) {
|
|
919
924
|
var part = self.parts[key];
|
|
920
925
|
var hidden = self.names.indexOf(key) == -1;
|
|
921
926
|
group.add(map(clone(part)), key, hidden);
|
|
922
|
-
})
|
|
927
|
+
});
|
|
923
928
|
if (self.holes) {
|
|
924
|
-
group.holes = toArray(self.holes).map(
|
|
929
|
+
group.holes = toArray(self.holes).map(function(part) {
|
|
925
930
|
return map(CSG.fromPolygons(part.toPolygons()), "holes");
|
|
926
|
-
})
|
|
931
|
+
});
|
|
927
932
|
}
|
|
928
933
|
return group;
|
|
929
934
|
};
|
|
@@ -940,9 +945,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
940
945
|
}
|
|
941
946
|
var rotationCenter = solid.centroid();
|
|
942
947
|
var rotationAxis = axes[axis];
|
|
943
|
-
self.map(
|
|
948
|
+
self.map(function(part) {
|
|
944
949
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
945
|
-
})
|
|
950
|
+
});
|
|
946
951
|
return self;
|
|
947
952
|
};
|
|
948
953
|
JsCadUtilsGroup.prototype.combineAll = function(options, map) {
|
|
@@ -953,9 +958,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
953
958
|
try {
|
|
954
959
|
var self = this;
|
|
955
960
|
var t = calcSnap(self.combine(part), to, axis, orientation, delta);
|
|
956
|
-
self.map(
|
|
961
|
+
self.map(function(part) {
|
|
957
962
|
return part.translate(t);
|
|
958
|
-
})
|
|
963
|
+
});
|
|
959
964
|
return self;
|
|
960
965
|
} catch (err) {
|
|
961
966
|
debug("snap error", this, part, to, axis, delta, err);
|
|
@@ -968,9 +973,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
968
973
|
var t = calcCenterWith(self.combine(part, {
|
|
969
974
|
noholes: true
|
|
970
975
|
}), axis, to, delta);
|
|
971
|
-
self.map(
|
|
976
|
+
self.map(function(part) {
|
|
972
977
|
return part.translate(t);
|
|
973
|
-
})
|
|
978
|
+
});
|
|
974
979
|
return self;
|
|
975
980
|
} catch (err) {
|
|
976
981
|
debug("align error", this, part, to, axis, delta, err);
|
|
@@ -998,38 +1003,38 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
998
1003
|
normalrotation
|
|
999
1004
|
});
|
|
1000
1005
|
var self = this;
|
|
1001
|
-
var myConnector = connectorName.split(".").reduce(
|
|
1006
|
+
var myConnector = connectorName.split(".").reduce(function(a, v) {
|
|
1002
1007
|
return a[v];
|
|
1003
|
-
}
|
|
1008
|
+
}, self.parts[partName].properties);
|
|
1004
1009
|
debug("toConnector", to instanceof CSG.Connector);
|
|
1005
|
-
var toConnector = toConnectorName.split(".").reduce(
|
|
1010
|
+
var toConnector = toConnectorName.split(".").reduce(function(a, v) {
|
|
1006
1011
|
return a[v];
|
|
1007
|
-
}
|
|
1012
|
+
}, to.properties);
|
|
1008
1013
|
var matrix = myConnector.getTransformationTo(toConnector, mirror, normalrotation);
|
|
1009
1014
|
debug("connectTo", matrix);
|
|
1010
|
-
self.map(
|
|
1015
|
+
self.map(function(part) {
|
|
1011
1016
|
return part.transform(matrix);
|
|
1012
|
-
})
|
|
1017
|
+
});
|
|
1013
1018
|
return self;
|
|
1014
1019
|
};
|
|
1015
1020
|
JsCadUtilsGroup.prototype.midlineTo = function midlineTo(part, axis, to) {
|
|
1016
1021
|
var self = this;
|
|
1017
1022
|
var size = self.combine(part).size();
|
|
1018
|
-
var t = axisApply(axis,
|
|
1023
|
+
var t = axisApply(axis, function(i, a) {
|
|
1019
1024
|
return to - size[a] / 2;
|
|
1020
|
-
})
|
|
1021
|
-
self.map(
|
|
1025
|
+
});
|
|
1026
|
+
self.map(function(part) {
|
|
1022
1027
|
return part.translate(t);
|
|
1023
|
-
})
|
|
1028
|
+
});
|
|
1024
1029
|
return self;
|
|
1025
1030
|
};
|
|
1026
1031
|
JsCadUtilsGroup.prototype.translate = function translate(x, y, z) {
|
|
1027
1032
|
var self = this;
|
|
1028
1033
|
var t = Array.isArray(x) ? x : [ x, y, z ];
|
|
1029
1034
|
debug("translate", t);
|
|
1030
|
-
self.map(
|
|
1035
|
+
self.map(function(part) {
|
|
1031
1036
|
return part.translate(t);
|
|
1032
|
-
})
|
|
1037
|
+
});
|
|
1033
1038
|
return self;
|
|
1034
1039
|
};
|
|
1035
1040
|
JsCadUtilsGroup.prototype.pick = function(parts, map) {
|
|
@@ -1037,9 +1042,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1037
1042
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1038
1043
|
if (!map) map = identity;
|
|
1039
1044
|
var g = Group();
|
|
1040
|
-
p.forEach(
|
|
1045
|
+
p.forEach(function(name) {
|
|
1041
1046
|
g.add(map(CSG.fromPolygons(self.parts[name].toPolygons()), name), name);
|
|
1042
|
-
})
|
|
1047
|
+
});
|
|
1043
1048
|
return g;
|
|
1044
1049
|
};
|
|
1045
1050
|
JsCadUtilsGroup.prototype.array = function(parts, map) {
|
|
@@ -1048,22 +1053,22 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1048
1053
|
var p = parts && parts.length > 0 && parts.split(",") || self.names;
|
|
1049
1054
|
if (!map) map = identity;
|
|
1050
1055
|
var a = [];
|
|
1051
|
-
p.forEach(
|
|
1056
|
+
p.forEach(function(name) {
|
|
1052
1057
|
if (!self.parts[name]) {
|
|
1053
1058
|
debug("array error", _this, parts);
|
|
1054
1059
|
throw error('group::array error "'.concat(name, '" not found.\nthis: ').concat(_this, '\nparts: "').concat(parts, '"\n'), "JSCAD_UTILS_GROUP_ERROR");
|
|
1055
1060
|
}
|
|
1056
1061
|
a.push(map(CSG.fromPolygons(self.parts[name].toPolygons()), name));
|
|
1057
|
-
})
|
|
1062
|
+
});
|
|
1058
1063
|
return a;
|
|
1059
1064
|
};
|
|
1060
1065
|
JsCadUtilsGroup.prototype.toArray = function(pieces) {
|
|
1061
1066
|
var self = this;
|
|
1062
1067
|
var piecesArray = pieces ? pieces.split(",") : self.names;
|
|
1063
|
-
return piecesArray.map(
|
|
1068
|
+
return piecesArray.map(function(piece) {
|
|
1064
1069
|
if (!self.parts[piece]) console.error("Cannot find ".concat(piece, " in ").concat(self.names));
|
|
1065
1070
|
return self.parts[piece];
|
|
1066
|
-
})
|
|
1071
|
+
});
|
|
1067
1072
|
};
|
|
1068
1073
|
JsCadUtilsGroup.prototype.toString = function() {
|
|
1069
1074
|
return '{\n name: "'.concat(this.name, '",\n names: "').concat(this.names.join(","), '", \n parts: "').concat(Object.keys(this.parts), '",\n holes: "').concat(this.holes, '"\n}');
|
|
@@ -1096,9 +1101,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1096
1101
|
self.name = objectNames;
|
|
1097
1102
|
} else {
|
|
1098
1103
|
var objects = objectNames;
|
|
1099
|
-
self.names = Object.keys(objects).filter(
|
|
1104
|
+
self.names = Object.keys(objects).filter(function(k) {
|
|
1100
1105
|
return k !== "holes";
|
|
1101
|
-
})
|
|
1106
|
+
});
|
|
1102
1107
|
self.parts = Object.assign({}, objects);
|
|
1103
1108
|
self.holes = objects.holes;
|
|
1104
1109
|
}
|
|
@@ -1177,21 +1182,21 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1177
1182
|
function label(text, x, y, width, height) {
|
|
1178
1183
|
var l = vector_text(x || 0, y || 0, text);
|
|
1179
1184
|
var o = [];
|
|
1180
|
-
l.forEach(
|
|
1185
|
+
l.forEach(function(pl) {
|
|
1181
1186
|
o.push(rectangular_extrude(pl, {
|
|
1182
1187
|
w: width || 2,
|
|
1183
1188
|
h: height || 2
|
|
1184
1189
|
}));
|
|
1185
|
-
})
|
|
1190
|
+
});
|
|
1186
1191
|
return center(union(o));
|
|
1187
1192
|
}
|
|
1188
1193
|
function text(text) {
|
|
1189
1194
|
var l = vector_char(0, 0, text);
|
|
1190
|
-
var _char = l.segments.reduce(
|
|
1195
|
+
var _char = l.segments.reduce(function(result, segment) {
|
|
1191
1196
|
var path = new CSG.Path2D(segment);
|
|
1192
1197
|
var cag = path.expandToCAG(2);
|
|
1193
1198
|
return result ? result.union(cag) : cag;
|
|
1194
|
-
}
|
|
1199
|
+
}, undefined);
|
|
1195
1200
|
return _char;
|
|
1196
1201
|
}
|
|
1197
1202
|
function unitCube(length, radius) {
|
|
@@ -1224,35 +1229,35 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1224
1229
|
return result;
|
|
1225
1230
|
}
|
|
1226
1231
|
function zipObject(names, values) {
|
|
1227
|
-
return names.reduce(
|
|
1232
|
+
return names.reduce(function(result, value, idx) {
|
|
1228
1233
|
result[value] = values[idx];
|
|
1229
1234
|
return result;
|
|
1230
|
-
}
|
|
1235
|
+
}, {});
|
|
1231
1236
|
}
|
|
1232
1237
|
function map(o, f) {
|
|
1233
|
-
return Object.keys(o).map(
|
|
1238
|
+
return Object.keys(o).map(function(key) {
|
|
1234
1239
|
return f(o[key], key, o);
|
|
1235
|
-
})
|
|
1240
|
+
});
|
|
1236
1241
|
}
|
|
1237
1242
|
function mapValues(o, f) {
|
|
1238
|
-
return Object.keys(o).map(
|
|
1243
|
+
return Object.keys(o).map(function(key) {
|
|
1239
1244
|
return f(o[key], key);
|
|
1240
|
-
})
|
|
1245
|
+
});
|
|
1241
1246
|
}
|
|
1242
1247
|
function pick(o, names) {
|
|
1243
|
-
return names.reduce(
|
|
1248
|
+
return names.reduce(function(result, name) {
|
|
1244
1249
|
result[name] = o[name];
|
|
1245
1250
|
return result;
|
|
1246
|
-
}
|
|
1251
|
+
}, {});
|
|
1247
1252
|
}
|
|
1248
1253
|
function mapPick(o, names, f, options) {
|
|
1249
|
-
return names.reduce(
|
|
1254
|
+
return names.reduce(function(result, name, index) {
|
|
1250
1255
|
if (!o[name]) {
|
|
1251
1256
|
throw new Error("".concat(name, " not found in ").concat(options.name, ": ").concat(Object.keys(o).join(",")));
|
|
1252
1257
|
}
|
|
1253
1258
|
result.push(f ? f(o[name], name, index, o) : o[name]);
|
|
1254
1259
|
return result;
|
|
1255
|
-
}
|
|
1260
|
+
}, []);
|
|
1256
1261
|
}
|
|
1257
1262
|
function divA(a, f) {
|
|
1258
1263
|
return div(a, f);
|
|
@@ -1316,9 +1321,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1316
1321
|
var objectSize = size(object);
|
|
1317
1322
|
var objectCentroid = centroid(object, objectSize);
|
|
1318
1323
|
var idx = 0;
|
|
1319
|
-
var t = map(objectSize,
|
|
1324
|
+
var t = map(objectSize, function(i) {
|
|
1320
1325
|
return scale(i, a[idx++]);
|
|
1321
|
-
})
|
|
1326
|
+
});
|
|
1322
1327
|
var new_object = object.scale(t);
|
|
1323
1328
|
var new_centroid = centroid(new_object);
|
|
1324
1329
|
var delta = new_centroid.minus(objectCentroid).times(-1);
|
|
@@ -1342,10 +1347,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1342
1347
|
}
|
|
1343
1348
|
var s = [ scale(objectSize.x, x), scale(objectSize.y, y), scale(objectSize.z, z) ];
|
|
1344
1349
|
var min$1 = min(s);
|
|
1345
|
-
return centerWith(object.scale(s.map(
|
|
1350
|
+
return centerWith(object.scale(s.map(function(d, i) {
|
|
1346
1351
|
if (a[i] === 0) return 1;
|
|
1347
1352
|
return keep_aspect_ratio ? min$1 : d;
|
|
1348
|
-
}))
|
|
1353
|
+
})), "xyz", object);
|
|
1349
1354
|
}
|
|
1350
1355
|
function shift(object, x, y, z) {
|
|
1351
1356
|
var hsize = this.div(this.size(object.getBounds()), 2);
|
|
@@ -1384,9 +1389,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1384
1389
|
if (side[0] === -1) {
|
|
1385
1390
|
w[-1] = toxyz(withobj.centroid());
|
|
1386
1391
|
}
|
|
1387
|
-
return this.axisApply(axes,
|
|
1392
|
+
return this.axisApply(axes, function(i, axis) {
|
|
1388
1393
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1389
|
-
})
|
|
1394
|
+
});
|
|
1390
1395
|
}
|
|
1391
1396
|
function calcSnap(moveobj, withobj, axes, orientation) {
|
|
1392
1397
|
var delta = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
@@ -1407,12 +1412,12 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1407
1412
|
if (side[0] === -1) {
|
|
1408
1413
|
w[-1] = withobj.centroid();
|
|
1409
1414
|
}
|
|
1410
|
-
var t = axisApply(axes,
|
|
1415
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1411
1416
|
return w[side[0]][axis] - m[side[1]][axis];
|
|
1412
|
-
})
|
|
1413
|
-
return delta ? axisApply(axes,
|
|
1417
|
+
});
|
|
1418
|
+
return delta ? axisApply(axes, function(i) {
|
|
1414
1419
|
return t[i] + delta;
|
|
1415
|
-
})
|
|
1420
|
+
}) : t;
|
|
1416
1421
|
}
|
|
1417
1422
|
function snap(moveobj, withobj, axis, orientation, delta) {
|
|
1418
1423
|
debug$1("snap", moveobj, withobj, axis, orientation, delta);
|
|
@@ -1430,9 +1435,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1430
1435
|
y: 1,
|
|
1431
1436
|
z: 2
|
|
1432
1437
|
};
|
|
1433
|
-
axes.split("").forEach(
|
|
1438
|
+
axes.split("").forEach(function(axis) {
|
|
1434
1439
|
retval[lookup[axis]] = valfun(lookup[axis], axis);
|
|
1435
|
-
})
|
|
1440
|
+
});
|
|
1436
1441
|
return retval;
|
|
1437
1442
|
}
|
|
1438
1443
|
function axis2array(axes, valfun) {
|
|
@@ -1443,10 +1448,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1443
1448
|
y: 1,
|
|
1444
1449
|
z: 2
|
|
1445
1450
|
};
|
|
1446
|
-
axes.split("").forEach(
|
|
1451
|
+
axes.split("").forEach(function(axis) {
|
|
1447
1452
|
var i = lookup[axis];
|
|
1448
1453
|
a[i] = valfun(i, axis);
|
|
1449
|
-
})
|
|
1454
|
+
});
|
|
1450
1455
|
return a;
|
|
1451
1456
|
}
|
|
1452
1457
|
function centroid(o, objectSize) {
|
|
@@ -1461,9 +1466,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1461
1466
|
function calcmidlineTo(o, axis, to) {
|
|
1462
1467
|
var bounds = o.getBounds();
|
|
1463
1468
|
var objectSize = size(bounds);
|
|
1464
|
-
return axisApply(axis,
|
|
1469
|
+
return axisApply(axis, function(i, a) {
|
|
1465
1470
|
return to - objectSize[a] / 2;
|
|
1466
|
-
})
|
|
1471
|
+
});
|
|
1467
1472
|
}
|
|
1468
1473
|
function midlineTo(o, axis, to) {
|
|
1469
1474
|
return o.translate(calcmidlineTo(o, axis, to));
|
|
@@ -1471,18 +1476,18 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1471
1476
|
function translator(o, axis, withObj) {
|
|
1472
1477
|
var objectCentroid = centroid(o);
|
|
1473
1478
|
var withCentroid = centroid(withObj);
|
|
1474
|
-
var t = axisApply(axis,
|
|
1479
|
+
var t = axisApply(axis, function(i) {
|
|
1475
1480
|
return withCentroid[i] - objectCentroid[i];
|
|
1476
|
-
})
|
|
1481
|
+
});
|
|
1477
1482
|
return t;
|
|
1478
1483
|
}
|
|
1479
1484
|
function calcCenterWith(o, axes, withObj) {
|
|
1480
1485
|
var delta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1481
1486
|
var objectCentroid = centroid(o);
|
|
1482
1487
|
var withCentroid = centroid(withObj);
|
|
1483
|
-
var t = axisApply(axes,
|
|
1488
|
+
var t = axisApply(axes, function(i, axis) {
|
|
1484
1489
|
return withCentroid[axis] - objectCentroid[axis];
|
|
1485
|
-
})
|
|
1490
|
+
});
|
|
1486
1491
|
return delta ? add(t, delta) : t;
|
|
1487
1492
|
}
|
|
1488
1493
|
function centerWith(o, axis, withObj) {
|
|
@@ -1495,9 +1500,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1495
1500
|
}
|
|
1496
1501
|
}
|
|
1497
1502
|
var dist = isNegative(offset) ? offset = size[axis] + offset : offset;
|
|
1498
|
-
return axisApply(axis,
|
|
1503
|
+
return axisApply(axis, function(i, a) {
|
|
1499
1504
|
return bounds[0][a] + (isEmpty(dist) ? size[axis] / 2 : dist);
|
|
1500
|
-
})
|
|
1505
|
+
});
|
|
1501
1506
|
}
|
|
1502
1507
|
function bisect() {
|
|
1503
1508
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1560,11 +1565,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1560
1565
|
}[[ axis, rotateaxis ].sort().join("")];
|
|
1561
1566
|
var centroid = object.centroid();
|
|
1562
1567
|
var rotateDelta = getDelta(objectSize, bounds, rotateOffsetAxis, rotateoffset);
|
|
1563
|
-
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz",
|
|
1568
|
+
var rotationCenter = options.rotationCenter || new CSG.Vector3D(axisApply("xyz", function(i, a) {
|
|
1564
1569
|
if (a == axis) return cutDelta[i];
|
|
1565
1570
|
if (a == rotateOffsetAxis) return rotateDelta[i];
|
|
1566
1571
|
return centroid[a];
|
|
1567
|
-
}))
|
|
1572
|
+
}));
|
|
1568
1573
|
var theRotationAxis = rotationAxes[rotateaxis];
|
|
1569
1574
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(info.orthoNormalCartesian[0], info.orthoNormalCartesian[1]).translate(cutDelta).rotate(rotationCenter, theRotationAxis, angle);
|
|
1570
1575
|
debug$1("bisect", debug$1.enabled && {
|
|
@@ -1648,6 +1653,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1648
1653
|
return CSG.fromPolygons(polygons);
|
|
1649
1654
|
}
|
|
1650
1655
|
function slices2poly(slices, options, axis) {
|
|
1656
|
+
debug$1("slices2poly", slices, options, axis);
|
|
1657
|
+
options = Object.assign({
|
|
1658
|
+
twistangle: 0,
|
|
1659
|
+
twiststeps: 0
|
|
1660
|
+
}, options);
|
|
1651
1661
|
var twistangle = options && parseFloat(options.twistangle) || 0;
|
|
1652
1662
|
var twiststeps = options && parseInt(options.twiststeps) || CSG.defaultResolution3D;
|
|
1653
1663
|
if (twistangle == 0 || twiststeps < 1) {
|
|
@@ -1657,6 +1667,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1657
1667
|
var polygons = [];
|
|
1658
1668
|
var first$1 = first(slices);
|
|
1659
1669
|
var last$1 = last(slices);
|
|
1670
|
+
debug$1("slices2poly first", first$1, first$1.offset, "last", last$1);
|
|
1660
1671
|
var up = first$1.offset[axis] > last$1.offset[axis];
|
|
1661
1672
|
polygons = polygons.concat(first$1.poly._toPlanePolygons({
|
|
1662
1673
|
translation: first$1.offset,
|
|
@@ -1675,7 +1686,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1675
1686
|
return v[rotateAxis](angle * percent);
|
|
1676
1687
|
};
|
|
1677
1688
|
var connectorAxis = last$1.offset.minus(first$1.offset).abs();
|
|
1678
|
-
slices.forEach(
|
|
1689
|
+
slices.forEach(function(slice, idx) {
|
|
1679
1690
|
if (idx < slices.length - 1) {
|
|
1680
1691
|
var nextidx = idx + 1;
|
|
1681
1692
|
var top = !up ? slices[nextidx] : slice;
|
|
@@ -1688,7 +1699,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1688
1699
|
toConnector2: c2
|
|
1689
1700
|
}));
|
|
1690
1701
|
}
|
|
1691
|
-
})
|
|
1702
|
+
});
|
|
1692
1703
|
return CSG.fromPolygons(polygons);
|
|
1693
1704
|
}
|
|
1694
1705
|
function normalVector(axis) {
|
|
@@ -1729,30 +1740,32 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1729
1740
|
var info = dirInfo["dir" + direction];
|
|
1730
1741
|
return Object.assign({
|
|
1731
1742
|
axis,
|
|
1732
|
-
cutDelta: axisApply(axis,
|
|
1743
|
+
cutDelta: axisApply(axis, function(i, a) {
|
|
1733
1744
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.sizeDir;
|
|
1734
|
-
})
|
|
1735
|
-
moveDelta: axisApply(axis,
|
|
1745
|
+
}),
|
|
1746
|
+
moveDelta: axisApply(axis, function(i, a) {
|
|
1736
1747
|
return bounds[info.sizeIdx][a] + Math.abs(radius) * info.moveDir;
|
|
1737
|
-
})
|
|
1748
|
+
})
|
|
1738
1749
|
}, info, normalVector(axis));
|
|
1739
1750
|
}
|
|
1740
1751
|
function reShape(object, radius, orientation, options, slicer) {
|
|
1741
1752
|
options = options || {};
|
|
1742
1753
|
var b = object.getBounds();
|
|
1743
|
-
var
|
|
1754
|
+
var absoluteRadius = Math.abs(radius);
|
|
1744
1755
|
var si = sliceParams(orientation, radius, b);
|
|
1756
|
+
debug$1("reShape", absoluteRadius, si);
|
|
1745
1757
|
if (si.axis !== "z") throw new Error('reShape error: CAG._toPlanePolytons only uses the "z" axis. You must use the "z" axis for now.');
|
|
1746
1758
|
var cutplane = CSG.OrthoNormalBasis.GetCartesian(si.orthoNormalCartesian[0], si.orthoNormalCartesian[1]).translate(si.cutDelta);
|
|
1747
1759
|
var slice = object.sectionCut(cutplane);
|
|
1748
|
-
var first = axisApply(si.axis,
|
|
1749
|
-
return si.positive ? 0 :
|
|
1750
|
-
})
|
|
1751
|
-
var last = axisApply(si.axis,
|
|
1752
|
-
return si.positive ?
|
|
1753
|
-
})
|
|
1760
|
+
var first = axisApply(si.axis, function() {
|
|
1761
|
+
return si.positive ? 0 : absoluteRadius;
|
|
1762
|
+
});
|
|
1763
|
+
var last = axisApply(si.axis, function() {
|
|
1764
|
+
return si.positive ? absoluteRadius : 0;
|
|
1765
|
+
});
|
|
1754
1766
|
var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();
|
|
1755
|
-
|
|
1767
|
+
debug$1("reShape first/last", first, last);
|
|
1768
|
+
var slices = slicer(first, last, slice, radius);
|
|
1756
1769
|
var delta = slices2poly(slices, Object.assign(options, {
|
|
1757
1770
|
si
|
|
1758
1771
|
}), si.axis).color(options.color);
|
|
@@ -1760,7 +1773,7 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1760
1773
|
return union([ options.unionOriginal ? object : remainder, delta.translate(si.moveDelta) ]);
|
|
1761
1774
|
}
|
|
1762
1775
|
function chamfer(object, radius, orientation, options) {
|
|
1763
|
-
return reShape(object, radius, orientation, options,
|
|
1776
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1764
1777
|
return [ {
|
|
1765
1778
|
poly: slice,
|
|
1766
1779
|
offset: new CSG.Vector3D(first)
|
|
@@ -1768,15 +1781,15 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1768
1781
|
poly: enlarge(slice, [ -radius * 2, -radius * 2 ]),
|
|
1769
1782
|
offset: new CSG.Vector3D(last)
|
|
1770
1783
|
} ];
|
|
1771
|
-
})
|
|
1784
|
+
});
|
|
1772
1785
|
}
|
|
1773
1786
|
function fillet(object, radius, orientation, options) {
|
|
1774
1787
|
options = options || {};
|
|
1775
|
-
return reShape(object, radius, orientation, options,
|
|
1788
|
+
return reShape(object, radius, orientation, options, function(first, last, slice) {
|
|
1776
1789
|
var v1 = new CSG.Vector3D(first);
|
|
1777
1790
|
var v2 = new CSG.Vector3D(last);
|
|
1778
1791
|
var res = options.resolution || CSG.defaultResolution3D;
|
|
1779
|
-
var slices = range(0, res).map(
|
|
1792
|
+
var slices = range(0, res).map(function(i) {
|
|
1780
1793
|
var p = i > 0 ? i / (res - 1) : 0;
|
|
1781
1794
|
var v = v1.lerp(v2, p);
|
|
1782
1795
|
var size = -radius * 2 - Math.cos(Math.asin(p)) * (-radius * 2);
|
|
@@ -1784,9 +1797,9 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1784
1797
|
poly: enlarge(slice, [ size, size ]),
|
|
1785
1798
|
offset: v
|
|
1786
1799
|
};
|
|
1787
|
-
})
|
|
1800
|
+
});
|
|
1788
1801
|
return slices;
|
|
1789
|
-
})
|
|
1802
|
+
});
|
|
1790
1803
|
}
|
|
1791
1804
|
function calcRotate(part, solid, axis) {
|
|
1792
1805
|
var axes = {
|
|
@@ -1806,11 +1819,11 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1806
1819
|
return part.rotate(rotationCenter, rotationAxis, angle);
|
|
1807
1820
|
}
|
|
1808
1821
|
function cloneProperties(from, to) {
|
|
1809
|
-
return Object.entries(from).reduce(
|
|
1822
|
+
return Object.entries(from).reduce(function(props, _ref) {
|
|
1810
1823
|
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
1811
1824
|
props[key] = value;
|
|
1812
1825
|
return props;
|
|
1813
|
-
}
|
|
1826
|
+
}, to);
|
|
1814
1827
|
}
|
|
1815
1828
|
function clone(o) {
|
|
1816
1829
|
var c = CSG.fromPolygons(o.toPolygons());
|
|
@@ -1843,10 +1856,10 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
1843
1856
|
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1844
1857
|
objects[_key] = arguments[_key];
|
|
1845
1858
|
}
|
|
1846
|
-
return objects.reduce(
|
|
1859
|
+
return objects.reduce(function(bbox, part) {
|
|
1847
1860
|
var object = bbox ? union([ bbox, box(part) ]) : part;
|
|
1848
1861
|
return box(object);
|
|
1849
|
-
}
|
|
1862
|
+
}, undefined);
|
|
1850
1863
|
}
|
|
1851
1864
|
function Cube(width) {
|
|
1852
1865
|
var r = div(fromxyz(width), 2);
|
|
@@ -2027,16 +2040,17 @@ function initJscadutils(_CSG, options = {}) {
|
|
|
2027
2040
|
gap = gap || .25;
|
|
2028
2041
|
var inside = thickness - gap;
|
|
2029
2042
|
var outside = -thickness + gap;
|
|
2030
|
-
|
|
2043
|
+
debug$3("inside", inside, "outside", outside);
|
|
2031
2044
|
var group = Group();
|
|
2032
|
-
debug$3("Rabbet top height:", height, "options:", options);
|
|
2033
2045
|
var _box$bisect$parts = box.bisect("z", height, options).parts, top = _box$bisect$parts.positive, lower2_3rd = _box$bisect$parts.negative;
|
|
2034
|
-
debug$3("face", face, "height", height);
|
|
2035
2046
|
var lowerBisectHeight = Math.sign(height) < 0 ? face * Math.sign(height) : height - face;
|
|
2036
|
-
debug$3("Rabbet bottom height:", lowerBisectHeight, "options:", options);
|
|
2037
2047
|
var _lower2_3rd$bisect$pa = lower2_3rd.bisect("z", lowerBisectHeight, options).parts, middle = _lower2_3rd$bisect$pa.positive, bottom = _lower2_3rd$bisect$pa.negative;
|
|
2038
|
-
|
|
2039
|
-
group.add(
|
|
2048
|
+
var middleTop = middle.color("yellow").subtract(middle.color("darkred").enlarge([ outside, outside, 0 ]));
|
|
2049
|
+
group.add(top.union(middleTop), "top");
|
|
2050
|
+
var bottomOutline = middle.color("yellow").subtract(middle.color("orange").enlarge([ outside, outside, 0 ])).enlarge([ outside, outside, 0 ]);
|
|
2051
|
+
group.add(bottomOutline, "middle-top", true);
|
|
2052
|
+
group.add(middle.color("green").subtract(middle.color("pink").enlarge([ inside, inside, 0 ])), "middle-bottom", true);
|
|
2053
|
+
group.add(bottom.color("orange").union(middle.color("green").subtract(middle.color("red").enlarge([ inside, inside, 0 ])).subtract(middleTop)), "bottom");
|
|
2040
2054
|
return group;
|
|
2041
2055
|
}
|
|
2042
2056
|
var RabettTopBottom = function rabbetTMB(box, thickness) {
|
|
@@ -2236,15 +2250,14 @@ function initJscadRPi() {
|
|
|
2236
2250
|
};
|
|
2237
2251
|
var jscadRPi = function(exports, jscadUtils, jsCadCSG, scadApi) {
|
|
2238
2252
|
"use strict";
|
|
2239
|
-
function
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2253
|
+
function activeCoolingFan() {
|
|
2254
|
+
var g = jscadUtils.Group("ActiveCoolingFan");
|
|
2255
|
+
var board = jscadUtils.parts.Cube([ 64, 42.5, 1 ]).subtract(jscadUtils.parts.Cube([ 64 - 58, 31.3, 1 ]).translate([ 0, 42.5 - 31.3, 0 ]).color("orange").union(jscadUtils.parts.Cube([ 28, 42.5 - 31.3, 1 ]).translate([ 64 - 28, 0, 0 ]).color("blue"))).union(jscadUtils.parts.Cube([ 19, 40, 9 ]).translate([ 64 - 58, 2.5, 0 ])).color("silver").union(jscadUtils.parts.Cube([ 30, 30, 9 ]).translate([ 64 - 58 + 19, 42.5 - 31.3, 0 ]).color("black"));
|
|
2256
|
+
g.add(board, "board");
|
|
2257
|
+
return g;
|
|
2243
2258
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
var CSG$1 = jsCadCSG__default["default"].CSG;
|
|
2247
|
-
var union = scadApi__default["default"].booleanOps.union;
|
|
2259
|
+
jsCadCSG.CSG;
|
|
2260
|
+
scadApi.booleanOps.union;
|
|
2248
2261
|
function RightSide(o, mb) {
|
|
2249
2262
|
return o.translate(jscadUtils.array.add(o.calcSnap(mb, "z", "outside-"), o.calcSnap(mb, "x", "inside+"), o.calcSnap(mb, "y", "inside-"), [ 2, 0, 0 ]));
|
|
2250
2263
|
}
|
|
@@ -2309,13 +2322,13 @@ function initJscadRPi() {
|
|
|
2309
2322
|
function BoardLed() {
|
|
2310
2323
|
return jscadUtils.parts.Cube([ 1, 2, .7 ]);
|
|
2311
2324
|
}
|
|
2312
|
-
var debug = jscadUtils.Debug("jscadRPi:BPlusMounting");
|
|
2325
|
+
var debug$2 = jscadUtils.Debug("jscadRPi:BPlusMounting");
|
|
2313
2326
|
function holes(mb) {
|
|
2314
2327
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2315
2328
|
options = Object.assign(options, {
|
|
2316
2329
|
height: 8
|
|
2317
2330
|
});
|
|
2318
|
-
debug("holes", mb, options);
|
|
2331
|
+
debug$2("holes", mb, options);
|
|
2319
2332
|
var hole = MountingHole(options.diameter || 3.25, options.height).snap(mb, "xy", "inside-").align(mb, "z");
|
|
2320
2333
|
var holes = [ hole.midlineTo("x", 3.5).midlineTo("y", 3.5), hole.midlineTo("x", 61.5).midlineTo("y", 3.5), hole.midlineTo("x", 3.5).midlineTo("y", 52.5), hole.midlineTo("x", 61.5).midlineTo("y", 52.5) ];
|
|
2321
2334
|
return jscadUtils.Group("hole1,hole2,hole3,hole4", holes);
|
|
@@ -2360,6 +2373,8 @@ function initJscadRPi() {
|
|
|
2360
2373
|
group.add(BoardLed().snap(mb, "z", "outside-").midlineTo("x", 1.1).midlineTo("y", 12).color("red"), "powerled");
|
|
2361
2374
|
}
|
|
2362
2375
|
function pi5(group, clearance, mb) {
|
|
2376
|
+
group.add(jscadUtils.parts.Cube([ 12, 12, 3 ]).color("lightgray").translate([ 24, 15, 2 ]), "cpu");
|
|
2377
|
+
group.add(jscadUtils.parts.Cube([ 12, 12, clearance ]).color("red").translate([ 24, 15, 2 ]), "clearance-cpu", true, "clearance");
|
|
2363
2378
|
group.add(RightSide(jscadUtils.parts.Cube([ 21.5, 16.5, 13.5 ]).color("lightgray"), mb).translate([ 2, 0, 0 ]).midlineTo("y", 10.2), "ethernet");
|
|
2364
2379
|
group.add(jscadUtils.parts.Cube([ clearance, 16.5, 13.5 ]).align(group.parts.ethernet, "yz").snap(group.parts.ethernet, "x", "outside-").color("red"), "clearance-ethernet", true, "clearance");
|
|
2365
2380
|
var usb = jscadUtils.Group();
|
|
@@ -2425,9 +2440,15 @@ function initJscadRPi() {
|
|
|
2425
2440
|
group.add(group.holes[1], "hole2", true);
|
|
2426
2441
|
group.add(group.holes[2], "hole3", true);
|
|
2427
2442
|
group.add(group.holes[3], "hole4", true);
|
|
2443
|
+
if (model >= 5) {
|
|
2444
|
+
group.holes.push(MountingHole(3.25, 8).snap(mb, "xy", "inside-").align(mb, "z").midlineTo("x", 3.5).midlineTo("y", 6 + 3.5));
|
|
2445
|
+
group.add(group.holes[4], "fan1hole", true);
|
|
2446
|
+
group.holes.push(MountingHole(3.25, 8).snap(mb, "xy", "inside-").align(mb, "z").midlineTo("x", 3.5 + 58).midlineTo("y", 52.5 - 6));
|
|
2447
|
+
group.add(group.holes[5], "fan2hole", true);
|
|
2448
|
+
}
|
|
2428
2449
|
return group;
|
|
2429
2450
|
}
|
|
2430
|
-
function CameraModuleV1() {
|
|
2451
|
+
function CameraModuleV1$1() {
|
|
2431
2452
|
var t = 1.1;
|
|
2432
2453
|
var height = {
|
|
2433
2454
|
sensor: 5.9 - t,
|
|
@@ -2440,27 +2461,27 @@ function initJscadRPi() {
|
|
|
2440
2461
|
}
|
|
2441
2462
|
g.holes = [ Hole(2, 2).color("yellow"), Hole(2, 23), Hole(12.5 + 2, 2), Hole(12.5 + 2, 23) ];
|
|
2442
2463
|
g.add(jscadUtils.Group("hole0,hole1,hole2,hole3", g.holes), "hole", false, "holes");
|
|
2443
|
-
var mounts = g.holes.reduce(
|
|
2464
|
+
var mounts = g.holes.reduce(function(m, h, i) {
|
|
2444
2465
|
m["mount".concat(i)] = jscadUtils.parts.Cylinder(4, 2).align(h, "xy").snap(g.parts.board, "z", "outside-");
|
|
2445
2466
|
return m;
|
|
2446
|
-
}
|
|
2467
|
+
}, {});
|
|
2447
2468
|
g.add(jscadUtils.Group(mounts), "mounts", true, "mounts");
|
|
2448
|
-
var pins = g.holes.reduce(
|
|
2469
|
+
var pins = g.holes.reduce(function(m, h, i) {
|
|
2449
2470
|
m["pin".concat(i)] = jscadUtils.parts.Cylinder(jscadUtils.util.nearest.under(1.5), height.board).align(h, "xy").align(g.parts.board, "z");
|
|
2450
2471
|
return m;
|
|
2451
|
-
}
|
|
2472
|
+
}, {});
|
|
2452
2473
|
g.add(jscadUtils.Group(pins), "pins", true, "pins");
|
|
2453
2474
|
g.add(jscadUtils.parts.Cube([ 8.5, 8.5, 2 ]).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside-").midlineTo("x", 12.5 + 2).midlineTo("y", 8.5 + 4).color("black"), "sensor");
|
|
2454
2475
|
g.add(jscadUtils.parts.Cube([ 8.5, 8.5, height.sensor - 2 ]).align(g.parts.sensor, "xy").snap(g.parts.sensor, "z", "outside-").color("gray"), "lense");
|
|
2455
2476
|
g.add(jscadUtils.parts.Cube([ 7.56, 10, 2.65 - t ]).snap(g.parts.board, "z", "outside-").align(g.parts.lense, "y", "inside-").snap(g.parts.lense, "x", "outside+", -1).color("gray"), "lenseribbon");
|
|
2456
2477
|
g.add(jscadUtils.parts.Cube([ 5.5, 17, 3 ]).snap(g.parts.board, "x", "inside+").snap(g.parts.board, "y", "inside-").snap(g.parts.board, "z", "outside+").midlineTo("y", 12.5), "ribbon");
|
|
2457
|
-
g.add(jscadUtils.parts.RoundedCube(24 - 5.5, 25, 2.5 - t, 2).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside+").subtract(g.holes.map(
|
|
2478
|
+
g.add(jscadUtils.parts.RoundedCube(24 - 5.5, 25, 2.5 - t, 2).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside+").subtract(g.holes.map(function(hole) {
|
|
2458
2479
|
return hole.enlarge(3, 3, 5);
|
|
2459
|
-
}))
|
|
2480
|
+
})).color("red"), "bottom-nogo");
|
|
2460
2481
|
g.add(g.parts.ribbon.enlarge(2, -1, -1).snap(g.parts.ribbon, "x", "outside-").color("red"), "ribbon-nogo");
|
|
2461
2482
|
return g;
|
|
2462
2483
|
}
|
|
2463
|
-
function CameraModuleV1
|
|
2484
|
+
function CameraModuleV1() {
|
|
2464
2485
|
var t = 1.1;
|
|
2465
2486
|
var height = {
|
|
2466
2487
|
sensor: 4 - t,
|
|
@@ -2473,23 +2494,23 @@ function initJscadRPi() {
|
|
|
2473
2494
|
}
|
|
2474
2495
|
g.holes = [ Hole(2, 2).color("yellow"), Hole(2, 23), Hole(14.5, 2), Hole(14.5, 23) ];
|
|
2475
2496
|
g.add(jscadUtils.Group("hole0,hole1,hole2,hole3", g.holes), "hole", false, "holes");
|
|
2476
|
-
var mounts = g.holes.reduce(
|
|
2497
|
+
var mounts = g.holes.reduce(function(m, h, i) {
|
|
2477
2498
|
m["mount".concat(i)] = jscadUtils.parts.Cylinder(4, height.sensor).align(h, "xy").snap(g.parts.board, "z", "outside-");
|
|
2478
2499
|
return m;
|
|
2479
|
-
}
|
|
2500
|
+
}, {});
|
|
2480
2501
|
g.add(jscadUtils.Group(mounts), "mounts", true, "mounts");
|
|
2481
|
-
var pins = g.holes.reduce(
|
|
2502
|
+
var pins = g.holes.reduce(function(m, h, i) {
|
|
2482
2503
|
m["pin".concat(i)] = jscadUtils.parts.Cylinder(jscadUtils.util.nearest.under(1.5), height.board).align(h, "xy").align(g.parts.board, "z");
|
|
2483
2504
|
return m;
|
|
2484
|
-
}
|
|
2505
|
+
}, {});
|
|
2485
2506
|
g.add(jscadUtils.Group(pins), "pins", true, "pins");
|
|
2486
2507
|
g.add(jscadUtils.parts.Cube([ 8.5, 8.5, height.sensor ]).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside-").midlineTo("x", 14.5).midlineTo("y", 12.5).color("black"), "sensor");
|
|
2487
2508
|
g.add(jscadUtils.parts.Cylinder(7.3, 1.6).align(g.parts.sensor, "xy").snap(g.parts.sensor, "z", "outside-").color("gray"), "lense");
|
|
2488
2509
|
g.add(jscadUtils.parts.Cube([ 4, 9, 2.65 - t ]).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside-").midlineTo("x", 4.7).midlineTo("y", 13.8).stretch("x", 4).color("gray"), "lenseribbon");
|
|
2489
2510
|
g.add(jscadUtils.parts.Cube([ 5.5, 20.8, 3.55 - t ]).snap(g.parts.board, "x", "inside+").snap(g.parts.board, "y", "inside-").snap(g.parts.board, "z", "outside+").midlineTo("y", 12.5), "ribbon");
|
|
2490
|
-
g.add(jscadUtils.parts.RoundedCube(23.862 - 5.5, 25, 2.5 - t, 2).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside+").subtract(g.holes.map(
|
|
2511
|
+
g.add(jscadUtils.parts.RoundedCube(23.862 - 5.5, 25, 2.5 - t, 2).snap(g.parts.board, "xy", "inside-").snap(g.parts.board, "z", "outside+").subtract(g.holes.map(function(hole) {
|
|
2491
2512
|
return hole.enlarge(3, 3, 5);
|
|
2492
|
-
}))
|
|
2513
|
+
})).color("red"), "bottom-nogo");
|
|
2493
2514
|
g.add(g.parts.ribbon.enlarge(2, -1, -1).snap(g.parts.ribbon, "x", "outside-").color("red"), "ribbon-nogo");
|
|
2494
2515
|
return g;
|
|
2495
2516
|
}
|
|
@@ -2515,31 +2536,30 @@ function initJscadRPi() {
|
|
|
2515
2536
|
var peg = MountingHole(null, options.height + 3);
|
|
2516
2537
|
return standoff.union(peg);
|
|
2517
2538
|
}
|
|
2518
|
-
function
|
|
2519
|
-
|
|
2539
|
+
function _arrayLikeToArray(r, a) {
|
|
2540
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2541
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2542
|
+
return n;
|
|
2520
2543
|
}
|
|
2521
|
-
function _arrayWithoutHoles(
|
|
2522
|
-
if (Array.isArray(
|
|
2544
|
+
function _arrayWithoutHoles(r) {
|
|
2545
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
2523
2546
|
}
|
|
2524
|
-
function _iterableToArray(
|
|
2525
|
-
if (typeof Symbol
|
|
2526
|
-
}
|
|
2527
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
2528
|
-
if (!o) return;
|
|
2529
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
2530
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2531
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2532
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
2533
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
2534
|
-
}
|
|
2535
|
-
function _arrayLikeToArray(arr, len) {
|
|
2536
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
2537
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
2538
|
-
return arr2;
|
|
2547
|
+
function _iterableToArray(r) {
|
|
2548
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
2539
2549
|
}
|
|
2540
2550
|
function _nonIterableSpread() {
|
|
2541
2551
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2542
2552
|
}
|
|
2553
|
+
function _toConsumableArray(r) {
|
|
2554
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
2555
|
+
}
|
|
2556
|
+
function _unsupportedIterableToArray(r, a) {
|
|
2557
|
+
if (r) {
|
|
2558
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
2559
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2560
|
+
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;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2543
2563
|
function HQCameraModule() {
|
|
2544
2564
|
var _camera$holes;
|
|
2545
2565
|
var t = 1.1;
|
|
@@ -2610,8 +2630,8 @@ function initJscadRPi() {
|
|
|
2610
2630
|
group.add(buttons[3], "button4");
|
|
2611
2631
|
return group;
|
|
2612
2632
|
}
|
|
2613
|
-
var union
|
|
2614
|
-
var debug
|
|
2633
|
+
var union = scadApi.booleanOps.union;
|
|
2634
|
+
var debug = jscadUtils.Debug("jscadRPi:PiTFT24");
|
|
2615
2635
|
function PiTFT24() {
|
|
2616
2636
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2617
2637
|
var pi = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -2622,7 +2642,7 @@ function initJscadRPi() {
|
|
|
2622
2642
|
buttonWireYOffset: 5,
|
|
2623
2643
|
clearance: .9
|
|
2624
2644
|
});
|
|
2625
|
-
debug
|
|
2645
|
+
debug("PiTFT24", options);
|
|
2626
2646
|
var hat = Hat(pi);
|
|
2627
2647
|
var mb = hat.parts.mb;
|
|
2628
2648
|
var group = jscadUtils.Group();
|
|
@@ -2636,36 +2656,36 @@ function initJscadRPi() {
|
|
|
2636
2656
|
group.add(lcdbevel.translate(lcdbevel.calcSnap(mb, "xy", "inside-")).translate(lcdbevel.calcSnap(mb, "z", "outside-")).translate([ 4.5, 7, 0 ]), "lcdbevel");
|
|
2637
2657
|
var buttonBase = jscadUtils.parts.Cube([ 6.1, 3.5, 3.55 ]).color("beige").snap(mb, "z", "outside-").snap(mb, "xy", "inside-").midlineTo("y", 2.5);
|
|
2638
2658
|
var button = buttonBase.union(jscadUtils.parts.Cube([ 3, 1.5, .5 ]).color("white").snap(buttonBase, "z", "outside-").align(buttonBase, "xy"));
|
|
2639
|
-
var buttons = [ 12.39, 12.39 + 10, 12.39 + 20, 12.39 + 30, 12.39 + 40 ].map(
|
|
2659
|
+
var buttons = [ 12.39, 12.39 + 10, 12.39 + 20, 12.39 + 30, 12.39 + 40 ].map(function(midpoint) {
|
|
2640
2660
|
return button.midlineTo("x", midpoint);
|
|
2641
|
-
})
|
|
2661
|
+
});
|
|
2642
2662
|
group.add(jscadUtils.Group("1,2,3,4,5", buttons), "buttons", false, "button");
|
|
2643
2663
|
var capBaseHeight = options.capBaseHeight;
|
|
2644
2664
|
var buttonCapBase = jscadUtils.parts.Cube([ 6.6, 4, capBaseHeight ]).color("blue");
|
|
2645
2665
|
var buttonCapTop = jscadUtils.parts.Cube([ 6.1, 3.5, options.buttonCapHeight - capBaseHeight ]).snap(buttonCapBase, "z", "outside-").align(buttonCapBase, "xy").fillet(1, "z+").color("deepskyblue");
|
|
2646
|
-
var buttonCaps = buttons.map(
|
|
2647
|
-
return union
|
|
2648
|
-
})
|
|
2649
|
-
group.add(union
|
|
2650
|
-
group.add(union
|
|
2651
|
-
return union
|
|
2652
|
-
}))
|
|
2666
|
+
var buttonCaps = buttons.map(function(button) {
|
|
2667
|
+
return union([ buttonCapBase, buttonCapTop ]).snap(button, "z", "outside-").align(button, "xy");
|
|
2668
|
+
});
|
|
2669
|
+
group.add(union(buttonCaps), "buttonCaps", hiddenPart);
|
|
2670
|
+
group.add(union(buttonCaps.map(function(button) {
|
|
2671
|
+
return union([ buttonCapBase.align(button, "xy").snap(button, "z", "inside-").enlarge([ options.clearance, options.clearance, 1 ]), jscadUtils.parts.Cube([ 6.1, 3.5, options.buttonCapHeight - capBaseHeight ]).align(button, "xy").snap(button, "z", "inside-").enlarge([ options.clearance, options.clearance, 1 ]) ]);
|
|
2672
|
+
})), "buttonCapClearance", hiddenPart);
|
|
2653
2673
|
var bwthickness = options.capBaseHeight;
|
|
2654
2674
|
var connector = LeftSide(jscadUtils.parts.Cube([ bwthickness, options.buttonWireYOffset, bwthickness ]), mb).snap(buttonCaps[0], "z", "inside-").snap(buttonCaps[0], "y", "outside+").color("blue");
|
|
2655
2675
|
var buttonWire = jscadUtils.parts.Cube([ 40, bwthickness, bwthickness ]).snap(buttonCaps[0], "x", "center-").snap(buttonCaps[0], "z", "inside-").snap(connector, "y", "inside-").color("blue");
|
|
2656
|
-
group.add(union
|
|
2657
|
-
var buttonWireConnector = buttonCaps.map(
|
|
2676
|
+
group.add(union(buttonWire), "buttonWire", hiddenPart);
|
|
2677
|
+
var buttonWireConnector = buttonCaps.map(function(buttonCap) {
|
|
2658
2678
|
return connector.align(buttonCap, "x");
|
|
2659
|
-
})
|
|
2660
|
-
group.add(union
|
|
2661
|
-
var buttonWireClearance = union
|
|
2679
|
+
});
|
|
2680
|
+
group.add(union(buttonWireConnector), "buttonWireConnector", hiddenPart);
|
|
2681
|
+
var buttonWireClearance = union(buttonWireConnector.map(function(connector) {
|
|
2662
2682
|
return connector.enlarge([ options.clearance, options.clearance, options.buttonCapHeight ]);
|
|
2663
|
-
}))
|
|
2683
|
+
})).union(buttonWire.enlarge([ options.clearance, options.clearance, options.buttonCapHeight ])).snap(buttonWire, "z", "inside+").color("red");
|
|
2664
2684
|
group.add(buttonWireClearance, "buttonWireClearance", hiddenPart);
|
|
2665
2685
|
group.add(jscadUtils.parts.Cube([ 15, 33, 7 ]).snap(mb, "x", "inside-").snap(mb, "z", "outside+").align(mb, "y").color("red"), "gpio2", hiddenPart);
|
|
2666
2686
|
return group;
|
|
2667
2687
|
}
|
|
2668
|
-
|
|
2688
|
+
jscadUtils.Debug("jscadRPi:Spacer");
|
|
2669
2689
|
function Spacer() {
|
|
2670
2690
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2671
2691
|
var mb = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -2701,9 +2721,10 @@ function initJscadRPi() {
|
|
|
2701
2721
|
var assembly = spacers.union(gusset.unionIf(cross, !options.hollow).translate([ 0, 0, -options.offset ])).subtractIf(gpio.enlarge([ 1, 1, 0 ]), options.gpio);
|
|
2702
2722
|
return assembly.color("yellow");
|
|
2703
2723
|
}
|
|
2724
|
+
exports.ActiveCoolingFan = activeCoolingFan;
|
|
2704
2725
|
exports.BPlus = BPlus;
|
|
2705
|
-
exports.CameraModuleV1 = CameraModuleV1;
|
|
2706
|
-
exports.CameraModuleV2 = CameraModuleV1
|
|
2726
|
+
exports.CameraModuleV1 = CameraModuleV1$1;
|
|
2727
|
+
exports.CameraModuleV2 = CameraModuleV1;
|
|
2707
2728
|
exports.HQCameraModule = HQCameraModule;
|
|
2708
2729
|
exports.Hat = Hat;
|
|
2709
2730
|
exports.HatStandoff = HatStandoff;
|