-
Notifications
You must be signed in to change notification settings - Fork 1
/
support.jscad
135 lines (120 loc) · 5.84 KB
/
support.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const jscad = require('@jscad/modeling')
const { geom2 } = jscad.geometries
const { mat4 } = jscad.maths
const { circle, cuboid, cylinder } = jscad.primitives
const { mirrorY, rotateX, translate, translateZ } = jscad.transforms
const { union, subtract } = jscad.booleans
const { extrudeFromSlices, extrudeLinear, slice } = jscad.extrusions
const main = () => {
const baseHeight = 3.8
const baseHighYPoints = [
[123.9, 16.2],
[114.75, 16.2],
[113.75, 17.2],
[-1.9, 17.2]
]
const baseLowYPoints = [
[-5.70, -3.25],
[-0.5, -9.3],
[100.4, -9.3],
[101.4, -8.3],
[123.9, -8.3]
]
const baseBottomHighYPoints = baseHighYPoints.map(p => [p[0], p[1] + 2])
baseBottomHighYPoints[3][0] += (baseBottomHighYPoints[3][0] - baseLowYPoints[0][0]) / (baseBottomHighYPoints[3][1] - baseLowYPoints[0][1]) * 2
const baseTop = geom2.fromPoints(baseLowYPoints.concat(baseHighYPoints))
const baseBottom = geom2.fromPoints(baseLowYPoints.concat(baseBottomHighYPoints))
const base = extrudeFromSlices({
callback: (progress, index, base) => {
if (progress == 0) {
return slice.fromSides(geom2.toSides(baseBottom))
} else {
return slice.transform(
mat4.fromTranslation(mat4.create(), [0, 0, baseHeight]),
slice.fromSides(geom2.toSides(baseTop))
)
}
}
}, 0)
const centerHoleSizeX = 113.75
const centerHoleSizeY = 14.8
const centerHole = cuboid({center: [centerHoleSizeX/2, centerHoleSizeY/2, baseHeight/2],
size: [centerHoleSizeX, centerHoleSizeY, baseHeight]})
const slotSizeX = 7
const slotSizeY = 1.6
const slotY = -5.75
const slotCutHeight = 2.4
const slot1 = translate([10.1, slotY, baseHeight/2], rotateX(Math.PI/5, cuboid({
size: [slotSizeX, slotSizeY, 2*baseHeight]})))
const slotCut1 = cuboid({center: [10.1, slotY, 3*slotCutHeight/2],
size: [2*slotSizeX, 15, slotCutHeight]})
const slot2 = translate([59.8, slotY, baseHeight/2], rotateX(Math.PI/5, cuboid({
size: [slotSizeX, slotSizeY, 2*baseHeight]})))
const slotCut2 = cuboid({center: [59.8, slotY, 3*slotCutHeight/2],
size: [2*slotSizeX, 15, slotCutHeight]})
const slot3 = translate([94.8, slotY, baseHeight/2], rotateX(Math.PI/5, cuboid({
size: [slotSizeX, slotSizeY, 2*baseHeight]})))
const slotCut3 = cuboid({center: [94.8, slotY, 3*slotCutHeight/2],
size: [2*slotSizeX, 15, slotCutHeight]})
const screwAnchorOuter = 6
const screwAnchorOuter4 = 5.1
const screwAnchorInner = 2.6
const screwAnchorHeight = 5.5
const screwTaper = extrudeFromSlices({
callback: (progress, index, base) => {
if (progress == 0) {
return slice.transform(
mat4.fromTranslation(mat4.create(), [0, 0, baseHeight]),
slice.fromSides(geom2.toSides(circle({radius: screwAnchorInner/2})))
)
} else {
return slice.transform(
mat4.fromTranslation(mat4.create(), [0, 0, screwAnchorHeight]),
slice.fromSides(geom2.toSides(circle({radius: (screwAnchorInner + 1)/2})))
)
}
}
}, 0)
const screwAnchor1 = cylinder({center: [-1.7, -1.0, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorOuter/2})
const screwHole1 = cylinder({center: [-1.7, -1.0, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorInner/2})
const screwCut1 = translateZ(
baseHeight - 0.001,
extrudeLinear({height: screwAnchorHeight - baseHeight + 0.001},
geom2.fromPoints([[-1.7 + .9 - 10, -1.0 + .8 + 10],
[-1.7 + .9 + 10, -1.0 + .8 - 10],
[-1.7 + .9 + 10, -1.0 + .8 + 10]])))
const screwTaper1 = translate([-1.7, -1.0, 0], screwTaper)
const centerScrewY = -6.2
const screwAnchor2 = cylinder({center: [26.2, centerScrewY, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorOuter/2})
const screwHole2 = cylinder({center: [26.2, centerScrewY, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorInner/2})
const screwCut2 = cuboid({center: [26.2, centerScrewY + screwAnchorInner/2 - .4 + 5, baseHeight + 5],
size: [10, 10, 10]})
const screwTaper2 = translate([26.2, centerScrewY, 0], screwTaper)
const screwAnchor3 = cylinder({center: [78.6, centerScrewY, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorOuter/2})
const screwHole3 = cylinder({center: [78.6, centerScrewY, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorInner/2})
const screwCut3 = cuboid({center: [78.6, centerScrewY + screwAnchorInner/2 - .4 + 5, baseHeight + 5],
size: [10, 10, 10]})
const screwTaper3 = translate([78.6, centerScrewY, 0], screwTaper)
const screwAnchor4 = cylinder({center: [118.8, 0.85, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorOuter4/2})
const screwHole4 = cylinder({center: [118.8, 0.85, screwAnchorHeight/2],
height: screwAnchorHeight, radius: screwAnchorInner/2})
const screwTaper4 = translate([118.8, 0.85, 0], screwTaper)
const rightSupport =
subtract(
union(base, screwAnchor1, screwAnchor2, screwAnchor3, screwAnchor4),
centerHole, slot1, slotCut1, slot2, slotCut2, slot3, slotCut3,
screwHole1, screwCut1, screwTaper1,
screwHole2, screwCut2, screwTaper2,
screwHole3, screwCut3, screwTaper3,
screwHole4, screwTaper4)
const leftSupport = translate([0, -20, 0], mirrorY(rightSupport))
return [rightSupport, leftSupport]
}
module.exports = { main }