Skip to content

Commit

Permalink
✨ feat(enclosure): add button geometry to section design
Browse files Browse the repository at this point in the history
- incorporate cylinders for button placements
- update button and section dimensions for improved design

♻️ refactor(enclosure): restructure button handling and dimensions

- adjust button properties and positioning logic
- separate button geometry into a dedicated function
  • Loading branch information
isfopo committed Nov 28, 2024
1 parent da1b7da commit 8b9c5b2
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions hardware/enclosure/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { arc, circle, line } from "@jscad/modeling/src/primitives";
import { arc, circle, cylinder, line } from "@jscad/modeling/src/primitives";
import { extrudeLinear } from "@jscad/modeling/src/operations/extrusions";
import { expand } from "@jscad/modeling/src/operations/expansions";
import { union } from "@jscad/modeling/src/operations/booleans";
import { subtract, union } from "@jscad/modeling/src/operations/booleans";
import { rotate, translate } from "@jscad/modeling/src/operations/transforms";
import convert from "convert";

interface SectionOptions {
Expand All @@ -23,14 +24,14 @@ const section = {

const buttons = {
diameter: convert(1 / 2, "in").to("mm"),
count: 8,
countPerSection: 2,
};

const dimensions = {
face: convert(3, "in").to("mm"),
back: convert(3 / 2, "in").to("mm"),
face: convert(4, "in").to("mm"),
back: convert(2, "in").to("mm"),
angle: convert(80, "deg").to("rad"),
thickness: convert(1 / 16, "in").to("mm"),
thickness: convert(3 / 32, "in").to("mm"),
};

const sectionGeo = ({ isEndSection }: SectionOptions) => {
Expand All @@ -56,9 +57,38 @@ const sectionGeo = ({ isEndSection }: SectionOptions) => {
[0, -(rod.diameter / 2 + dimensions.thickness / 2)],
]);

return extrudeLinear(
{ height: section.width(isEndSection) },
expand({ delta: dimensions.thickness }, ...shafts, face, back)
const buttonGeo = (i: number) =>
cylinder({
radius: buttons.diameter / 2,
height: dimensions.thickness * 2,
center: [
i * (section.width(isEndSection) / buttons.countPerSection),
dimensions.face / 2,
0,
],
});

const buttonsGeo = rotate(
[0, -Math.PI / 2, 0],
translate(
[
-section.width(isEndSection) / buttons.countPerSection / 2,
0,
-(rod.diameter / 2 + dimensions.thickness / 2),
],
buttonGeo(1),
buttonGeo(2)
)
);

return subtract(
union(
extrudeLinear(
{ height: section.width(isEndSection) },
expand({ delta: dimensions.thickness }, ...shafts, face, back)
)
),
buttonsGeo
);
};

Expand Down

0 comments on commit 8b9c5b2

Please sign in to comment.