@@ -13,7 +13,7 @@ import {
1313 roundedRectangle ,
1414} from "@jscad/modeling/src/primitives"
1515import type {
16- PCBPlatedHole ,
16+ PcbPlatedHole ,
1717 PcbBoard ,
1818 PcbHole ,
1919 PcbPanel ,
@@ -43,7 +43,7 @@ export { arePointsClockwise } from "./pcb-board-cutouts"
4343export interface BoardGeometryOptions {
4444 thickness : number
4545 holes ?: PcbHole [ ]
46- platedHoles ?: PCBPlatedHole [ ]
46+ platedHoles ?: PcbPlatedHole [ ]
4747 cutouts ?: BoardCutout [ ]
4848 drillQuality ?: "high" | "fast"
4949}
@@ -104,7 +104,7 @@ const createPillHoleWithSegments = (
104104 width : number ,
105105 height : number ,
106106 thickness : number ,
107- rotate : boolean ,
107+ rotationRad : number = 0 ,
108108 segments : number = DEFAULT_QUALITY_MODE_SEGMENTS ,
109109) : Geom3 => {
110110 const minDimension = Math . min ( width , height )
@@ -119,8 +119,8 @@ const createPillHoleWithSegments = (
119119 let hole3d = extrudeLinear ( { height : thickness + 1 } , hole2d )
120120 hole3d = translate ( [ 0 , 0 , - ( thickness + 1 ) / 2 ] , hole3d )
121121
122- if ( rotate ) {
123- hole3d = rotateZ ( Math . PI / 2 , hole3d )
122+ if ( rotationRad !== 0 ) {
123+ hole3d = rotateZ ( rotationRad , hole3d )
124124 }
125125
126126 return translate ( [ x , y , 0 ] , hole3d )
@@ -130,7 +130,7 @@ export const createHoleGeoms = (
130130 boardCenter : { x : number ; y : number } ,
131131 thickness : number ,
132132 holes : PcbHole [ ] = [ ] ,
133- platedHoles : PCBPlatedHole [ ] = [ ] ,
133+ platedHoles : PcbPlatedHole [ ] = [ ] ,
134134 segments : number = DEFAULT_QUALITY_MODE_SEGMENTS ,
135135) : Geom3 [ ] => {
136136 const holeGeoms : Geom3 [ ] = [ ]
@@ -156,7 +156,7 @@ export const createHoleGeoms = (
156156 width ,
157157 height ,
158158 thickness ,
159- rotate ,
159+ rotate ? Math . PI / 2 : 0 ,
160160 segments ,
161161 ) ,
162162 )
@@ -170,24 +170,17 @@ export const createHoleGeoms = (
170170
171171 const rotation = getNumberProperty ( holeRecord , "ccw_rotation" ) ?? 0
172172 const rotationRad = - ( rotation * Math . PI ) / 180
173-
174- const minDimension = Math . min ( holeWidth , holeHeight )
175- const maxAllowedRadius = Math . max ( 0 , minDimension / 2 - RADIUS_EPSILON )
176- const roundRadius =
177- maxAllowedRadius <= 0 ? 0 : Math . min ( holeHeight / 2 , maxAllowedRadius )
178-
179- const hole2d = roundedRectangle ( {
180- size : [ holeWidth , holeHeight ] ,
181- roundRadius,
182- segments,
183- } )
184-
185- let hole3d = extrudeLinear ( { height : thickness + 1 } , hole2d )
186- hole3d = translate ( [ 0 , 0 , - ( thickness + 1 ) / 2 ] , hole3d )
187- if ( rotationRad !== 0 ) {
188- hole3d = rotateZ ( rotationRad , hole3d )
189- }
190- holeGeoms . push ( translate ( [ relX , relY , 0 ] , hole3d ) )
173+ holeGeoms . push (
174+ createPillHoleWithSegments (
175+ relX ,
176+ relY ,
177+ holeWidth ,
178+ holeHeight ,
179+ thickness ,
180+ rotationRad ,
181+ segments ,
182+ ) ,
183+ )
191184 continue
192185 }
193186
@@ -219,17 +212,16 @@ export const createHoleGeoms = (
219212 0
220213 if ( ! holeWidth || ! holeHeight ) continue
221214
222- const rotate = holeHeight > holeWidth
223- const width = rotate ? holeHeight : holeWidth
224- const height = rotate ? holeWidth : holeHeight
215+ const rotation = getNumberProperty ( platedRecord , "ccw_rotation" ) ?? 0
216+ const rotationRad = - ( rotation * Math . PI ) / 180
225217 holeGeoms . push (
226218 createPillHoleWithSegments (
227219 relX ,
228220 relY ,
229- width ,
230- height ,
221+ holeWidth ,
222+ holeHeight ,
231223 thickness ,
232- rotate ,
224+ rotationRad ,
233225 segments ,
234226 ) ,
235227 )
0 commit comments