Skip to content

Commit

Permalink
feat: add showerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Aug 5, 2024
1 parent b488884 commit f78823b
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 56 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react-router-dom": "6.22.3"
},
"devDependencies": {
"@bifravst/prettier-config": "1.0.0",
"@bifravst/prettier-config": "^1.0.0",
"commitlint": "19.1.0",
"handlebars": "4.7.8",
"husky": "9.0.11",
Expand Down
2 changes: 1 addition & 1 deletion public/404.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { serialize } from '@jscad/stl-serializer'
import { plantPotInlay } from './models/plantPotInlay.js'
import { showerPlate } from './models/showerPlate.js'
import { renderModel } from './renderModel.js'

const containerElement = document.getElementById('jscad')

const model = plantPotInlay()
const model = showerPlate()

if (containerElement !== null) renderModel({ containerElement, model })

Expand Down
8 changes: 4 additions & 4 deletions src/models/chargerPlate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ export const cone = ({
topRadius,
bottomRadius,
height,
center
center,
}: {
topRadius: number
bottomRadius: number
height: number
center?: [number, number, number]
}) => {
const [cx,cy,cz] = center ?? [0,0,0]
const [cx, cy, cz] = center ?? [0, 0, 0]
return hull(
cylinder({
center: [cx,cy,cz],
center: [cx, cy, cz],
height: 0.1,
radius: bottomRadius,
segments,
}),
cylinder({
center: [cx,cy,cz+height],
center: [cx, cy, cz + height],
height: 0.1,
radius: topRadius,
segments,
Expand Down
94 changes: 50 additions & 44 deletions src/models/plantPotInlay.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
import { subtract, union } from "@jscad/modeling/src/operations/booleans";
import { cuboid, cylinder } from "@jscad/modeling/src/primitives";
import { cone } from "./chargerPlate";
import { rotateZ, translateZ } from "@jscad/modeling/src/operations/transforms";
import { degToRad } from "@jscad/modeling/src/utils";
import { subtract, union } from '@jscad/modeling/src/operations/booleans'
import { cuboid, cylinder } from '@jscad/modeling/src/primitives'
import { cone } from './chargerPlate'
import { rotateZ, translateZ } from '@jscad/modeling/src/operations/transforms'
import { degToRad } from '@jscad/modeling/src/utils'

export const plantPotInlay = () => [
translateZ(20, union(
subtract(
cylinder({
center: [0,0,35/2],
radius: 40,
height: 35,
segments: 64
}),
cylinder({
center: [0,0,35/2],
radius: 38,
height: 35,
segments: 64
}),
),
subtract(
cone({
topRadius: 40,
bottomRadius: 7,
height: 20,
center: [0,0,-20]
}),
cone({
topRadius: 38,
bottomRadius: 5,
height: 20,
center: [0,0,-20]
})
),
cuboid({
center: [0,0,-19.5],
size: [12,1,1]
}),
rotateZ(degToRad(90), cuboid({
center: [0,0,-19.5],
size: [12,1,1]
}))
))
]
translateZ(
20,
union(
subtract(
cylinder({
center: [0, 0, 35 / 2],
radius: 40,
height: 35,
segments: 64,
}),
cylinder({
center: [0, 0, 35 / 2],
radius: 38,
height: 35,
segments: 64,
}),
),
subtract(
cone({
topRadius: 40,
bottomRadius: 7,
height: 20,
center: [0, 0, -20],
}),
cone({
topRadius: 38,
bottomRadius: 5,
height: 20,
center: [0, 0, -20],
}),
),
cuboid({
center: [0, 0, -19.5],
size: [12, 1, 1],
}),
rotateZ(
degToRad(90),
cuboid({
center: [0, 0, -19.5],
size: [12, 1, 1],
}),
),
),
),
]
105 changes: 105 additions & 0 deletions src/models/showerPlate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { colorNameToRgb, colorize, hexToRgb } from '@jscad/modeling/src/colors'
import {
intersect,
subtract,
union,
} from '@jscad/modeling/src/operations/booleans'
import { extrudeLinear } from '@jscad/modeling/src/operations/extrusions'
import {
rotate,
rotateX,
rotateY,
scale,
translate,
} from '@jscad/modeling/src/operations/transforms'
import { cuboid, triangle } from '@jscad/modeling/src/primitives'
import { degToRad } from '@jscad/modeling/src/utils'
import { hexagonGrid } from '../utils/hexagon.js'

const height = 2
const len = 223
const edge = 15
const width = 70

const plate = () =>
union(
cuboid({
size: [len - edge * 2, width, height],
}),
cuboid({
size: [edge, 30, height],
center: [len / 2 - edge / 2, 0, 0],
}),
cuboid({
size: [edge, 30, height],
center: [-(len / 2) + edge / 2, 0, 0],
}),
translate(
[-len / 2, edge, -height / 2],
extrudeLinear(
{ height },
triangle({
type: 'SAS',
values: [edge, degToRad(90), (width - 2 * edge) / 2],
}),
),
),
rotateY(
degToRad(180),
translate(
[-len / 2, edge, -height / 2],
extrudeLinear(
{ height },
triangle({
type: 'SAS',
values: [edge, degToRad(90), (width - 2 * edge) / 2],
}),
),
),
),
rotateX(
degToRad(180),
translate(
[-len / 2, edge, -height / 2],
extrudeLinear(
{ height },
triangle({
type: 'SAS',
values: [edge, degToRad(90), (width - 2 * edge) / 2],
}),
),
),
),
rotate(
[degToRad(180), degToRad(180), 0],
translate(
[-len / 2, edge, -height / 2],
extrudeLinear(
{ height },
triangle({
type: 'SAS',
values: [edge, degToRad(90), (width - 2 * edge) / 2],
}),
),
),
),
)

export const showerPlate = () => [
union(
subtract(plate(), scale([0.985, 0.95, 2], plate())),
intersect(
plate(),
translate(
[-120, -52.5, -height / 2],
hexagonGrid({
cols: 20,
rows: 40,
height,
size: height * 2.01,
wallThickness: height / 4,
}),
),
),
),
]

0 comments on commit f78823b

Please sign in to comment.