-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.jscad
77 lines (55 loc) · 1.89 KB
/
lib.jscad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// title : Finger Mechanism Holder
// author : Gino Tubaro
// license : MIT License
// description: Conector inferior x1 (bottom)
// file : xbottom.jscad
include('lodash.js');
include("node_modules/jscad-utils/jscad-utils.jscad");
include("node_modules/jscad-utils/jscad-utils-color.jscad");
include('node_modules/jscad-utils/jscad-utils-parts.jscad');
include('node_modules/jscad-utils/jscad-boxes.jscad');
function getParameterDefinitions() {
return [
{ name: 'x', type: 'float', initial: 80, caption: "x:" },
{ name: 'y', type: 'float', initial: 30, caption: "y:" },
{ name: 'z', type: 'float', initial: 8, caption: "z:" },
{ name: 'altopata', type: 'float', initial: 20, caption: "altopata" },
{ name: 'colors', type: 'choice', caption: "Colores", values:["red", "blue", "black"], captions:["Rojo", "Azul", "Negro"], initial: "Rojo" },
];
}
var r = [], y = [], t = [];
var result,xbottom,cono, ext, int, flat;
var pi = 180;
function main(params) {
util.init(CSG);
cacas=screw();
//var test=caca.union(cube({size: [10,10,10], center: [true, true, true]}))
caca=cube({size: [100, 10, 1], center: [true, true, true]})
return cacas;
}
function screw(params) {
util.init(CSG);
var vueltas = 4;
var espacio = 10;
var radius = 5;
var vagrados = vueltas *360;
var sqrt3 = Math.sqrt(3) / 2;
var hex = CSG.Polygon.createFromPoints([
[radius, 0, 0],
[radius / 2, radius * sqrt3, 0],
[-radius / 2, radius * sqrt3, 0],
[-radius, 0, 0],
[-radius / 2, -radius * sqrt3, 0],
[radius / 2, -radius * sqrt3, 0]
]);
return hex.solidFromSlices({
numslices: vagrados,
callback: function(t, slice) {
return this.translate([radius * espacio* t, t, 0]).rotate(
[0,40,0], //ancho
[1, 0, 0], //-1 cambia el sentido de rosca
slice //z
);
}
});
}