-
Notifications
You must be signed in to change notification settings - Fork 1
/
shelf-pin.jscad
97 lines (89 loc) · 2.28 KB
/
shelf-pin.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Pin holding shelve
//
//include ('jscad-utils.jscad')
//include ('jscad-utils-color.jscad')
function getParameterDefinitions() {
return [{
name: 'resolution',
type: 'choice',
values: [0, 1, 2, 3, 4, 5],
captions: ['very low (6,16)', 'low (8,24)', 'normal (12,32)', 'high (24,64)', 'very high (48,128)',
'ultra high (96,256)'],
initial: 2,
caption: 'Resolution:'
}, {
name: 'part',
type: 'choice',
values: ['piece', 'flat_piece'],
captions: ['piece', 'piece with larger hold'],
initial: 'flat_piece',
caption: 'Part:'
}];
}
function main(params) {
var resolutions = [
[6, 16],
[8, 24],
[12, 32],
[24, 64],
[48, 128],
[96, 256]
];
CSG.defaultResolution3D = resolutions[params.resolution][0];
CSG.defaultResolution2D = resolutions[params.resolution][1];
//util.init(CSG);
// Radius of small pin
var small_r = 4.92/2;
// Length of pin
var small_height = 7.92;
// Radius of part outside
var large_r = 7.92/2;
// Length of outside part
var total_height = 15.92;
// dimensions of tooth holding the shelve
var fillet_r = 1;
tooth_x = small_r*2;
tooth_y = 10;
tooth_z = 15;
var fillet = CSG.cylinder({
start: [0,0,0],
end: [0, 0, fillet_r],
radius: small_r+fillet_r
}).subtract(torus({ ro: small_r+fillet_r, ri: (fillet_r) }).translate([0, 0, fillet_r]));
var small_cyl = CSG.cylinder({
start: [0,0,0],
end: [0, 0, small_height],
radius: small_r
}).union(fillet).rotateX(180).translate([0, 0, small_height]);
var large_cyl = CSG.cylinder({
start: [0,0,small_height],
end: [0, 0, total_height-large_r],
radius: large_r
});
var half_dome = CSG.sphere({
center: [0, 0, total_height-large_r],
radius: large_r
});
var tooth = CSG.cube({
center: [0,0,small_height+tooth_z/2],
radius: [tooth_x/2,tooth_y/2,tooth_z/2]
});
//
// Render
//
//return fillet;
//return small_cyl;
switch (params.part) {
case 'piece':
return union(large_cyl, small_cyl, half_dome);
case 'flat_piece':
return union(small_cyl, tooth).
rotateY(90)
.intersect(CSG.cube({
center: [0,0,small_height+tooth_z/2],
radius: [tooth_x/2,tooth_y/2,tooth_z/2+small_height]})
.rotateY(90)
);
}
}