Skip to content

Commit 5658e43

Browse files
committed
fix(led-panel): print only side
1 parent 04464e7 commit 5658e43

File tree

2 files changed

+119
-44
lines changed

2 files changed

+119
-44
lines changed

src/models/ledPanelBox.ts

Lines changed: 118 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { colorize, hexToRgb } from '@jscad/modeling/src/colors'
2-
import { subtract, union } from '@jscad/modeling/src/operations/booleans'
31
import {
2+
intersect,
3+
subtract,
4+
union,
5+
} from '@jscad/modeling/src/operations/booleans'
6+
import {
7+
rotate,
48
rotateX,
59
rotateZ,
610
translate,
@@ -9,8 +13,8 @@ import {
913
import { cuboid, cylinder } from '@jscad/modeling/src/primitives'
1014
import { degToRad } from '@jscad/modeling/src/utils'
1115

12-
const panelWidth = 120
13-
const panelLength = 282
16+
const panelWidth = 100
17+
const panelLength = 279
1418
const boxHeight = 150
1519
const thickness = 4
1620

@@ -46,14 +50,63 @@ const side = ({
4650
const padding = 15
4751
const radius = 20
4852
const segments = 64
53+
const sideCutsLeft = []
54+
const sideCutsRight = []
55+
for (let i = 0; i < height / (radius + padding / 2); i++) {
56+
sideCutsLeft.push(
57+
translate(
58+
[length / 2, 0, i * (radius + padding / 2) - height / 2 - 25],
59+
rotateX(
60+
degToRad(90),
61+
cylinder({
62+
segments,
63+
radius: radius / 2,
64+
height: padding,
65+
}),
66+
),
67+
),
68+
)
69+
sideCutsRight.push(
70+
translate(
71+
[-length / 2, 0, i * (radius + padding / 2) - height / 2 - 25],
72+
rotateX(
73+
degToRad(90),
74+
cylinder({
75+
segments,
76+
radius: radius / 2,
77+
height: padding,
78+
}),
79+
),
80+
),
81+
)
82+
}
4983
return union(
5084
// Plate
5185
subtract(
52-
cuboid({ size: [length, thickness, height] }),
86+
union(
87+
// Base plate
88+
cuboid({ size: [length, thickness, height] }),
89+
// Inner support ridge
90+
subtract(
91+
cuboid({
92+
size: [length - 2 * radius, 6, 10],
93+
center: [0, -5, height / 2 - 5],
94+
}),
95+
rotate(
96+
[degToRad(90), 0, degToRad(90)], // Ridge
97+
cylinder({
98+
segments: 32,
99+
height: length - 2 * radius,
100+
radius: 15,
101+
center: [-15, height / 2 - 17, 0],
102+
}),
103+
),
104+
),
105+
),
53106
// ridge for LED panel
54107
cuboid({
55-
size: [length, thickness, thickness],
56-
center: [0, -thickness / 2, height / 2],
108+
size: [length, 50, thickness],
109+
center: [0, -25, height / 2],
57110
}),
58111
// Cut out circle 1
59112
translate(
@@ -114,52 +167,74 @@ const side = ({
114167
}),
115168
),
116169
),
170+
...sideCutsLeft,
171+
...sideCutsRight,
117172
),
118173
)
119174
}
120175

121176
export const ledPanelBox = () => [
177+
/*
122178
colorize(
123179
hexToRgb('#6a97bf'),
124180
translateZ(boxHeight, rotateX(degToRad(180), ledPanel())),
125181
),
126-
union(
127-
translate(
128-
[0, panelWidth / 2, boxHeight / 2],
129-
side({ height: boxHeight, length: panelLength + thickness, thickness }),
130-
),
131-
translate(
132-
[0, -panelWidth / 2, boxHeight / 2],
133-
rotateZ(
134-
degToRad(180),
135-
side({
136-
height: boxHeight,
137-
length: panelLength + thickness,
138-
thickness,
139-
}),
140-
),
141-
),
142-
translate(
143-
[-panelLength / 2, 0, boxHeight / 2],
144-
rotateZ(
145-
degToRad(90),
146-
side({
147-
height: boxHeight,
148-
length: panelWidth + thickness,
149-
thickness,
150-
}),
151-
),
152-
),
153-
translate(
154-
[panelLength / 2, 0, boxHeight / 2],
155-
rotateZ(
156-
degToRad(-90),
157-
side({
158-
height: boxHeight,
159-
length: panelWidth + thickness,
160-
thickness,
161-
}),
182+
*/
183+
// Only print sides
184+
intersect(
185+
subtract(
186+
union(
187+
translate(
188+
[0, panelWidth / 2, boxHeight / 2],
189+
side({
190+
height: boxHeight,
191+
length: panelLength + thickness,
192+
thickness,
193+
}),
194+
),
195+
translate(
196+
[0, -panelWidth / 2, boxHeight / 2],
197+
rotateZ(
198+
degToRad(180),
199+
side({
200+
height: boxHeight,
201+
length: panelLength + thickness,
202+
thickness,
203+
}),
204+
),
205+
),
206+
translate(
207+
[-panelLength / 2, 0, boxHeight / 2],
208+
rotateZ(
209+
degToRad(90),
210+
side({
211+
height: boxHeight,
212+
length: panelWidth + thickness,
213+
thickness,
214+
}),
215+
),
216+
),
217+
translate(
218+
[panelLength / 2, 0, boxHeight / 2],
219+
rotateZ(
220+
degToRad(-90),
221+
side({
222+
height: boxHeight,
223+
length: panelWidth + thickness,
224+
thickness,
225+
}),
226+
),
227+
),
162228
),
229+
// Cut-out for cable fastener
230+
cuboid({
231+
size: [10, panelWidth * 1.1, 2.5],
232+
center: [panelLength / 2 - 40, 0, boxHeight - 10],
233+
}),
163234
),
235+
cuboid({
236+
size: [50, 200, boxHeight],
237+
center: [(panelLength + thickness) / 2 - 25, 0, boxHeight / 2],
238+
}),
164239
),
165240
]

src/renderModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const renderModel = ({
2727
// prepare the camera
2828
state.camera = Object.assign({}, perspectiveCamera.defaults, {
2929
//position: [450, 550, 700],
30-
position: [450, 550, 700],
30+
position: [1500, 2000, 2000],
3131
fov: Math.PI / 32,
3232
})
3333
perspectiveCamera.setProjection(state.camera, state.camera, { width, height })

0 commit comments

Comments
 (0)