From 1b2df001456b0b39b761197f8a0784dedb41dccf Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Thu, 12 Mar 2026 13:36:56 -0700 Subject: [PATCH] Add cad model board direction and PCB rotation offset --- generated/COMPONENT_TYPES.md | 12 ++++++++++++ generated/PROPS_OVERVIEW.md | 2 ++ lib/common/cadModel.ts | 17 +++++++++++++++++ tests/cadmodel.test.ts | 16 ++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/generated/COMPONENT_TYPES.md b/generated/COMPONENT_TYPES.md index 2387c60..c903e81 100644 --- a/generated/COMPONENT_TYPES.md +++ b/generated/COMPONENT_TYPES.md @@ -10,6 +10,14 @@ export const rotationPoint3 = z.object({ y: z.union([z.number(), z.string()]), z: z.union([z.number(), z.string()]), }) +export const cadModelAxisDirections = [ + "x+", + "x-", + "y+", + "y-", + "z+", + "z-", +] as const export interface CadModelBase { rotationOffset?: | number @@ -21,6 +29,8 @@ export interface CadModelBase { } size?: { x: number | string; y: number | string; z: number | string } modelUnitToMmScale?: Distance + modelBoardNormalDirection?: CadModelAxisDirection + pcbRotationOffset?: number zOffsetFromSurface?: Distance showAsTranslucentModel?: boolean } @@ -29,6 +39,8 @@ export const cadModelBase = z.object({ positionOffset: point3.optional(), size: point3.optional(), modelUnitToMmScale: distance.optional(), + modelBoardNormalDirection: cadModelAxisDirection.optional(), + pcbRotationOffset: z.number().optional(), zOffsetFromSurface: distance.optional(), showAsTranslucentModel: z.boolean().optional(), }) diff --git a/generated/PROPS_OVERVIEW.md b/generated/PROPS_OVERVIEW.md index 65d0f88..0b20cff 100644 --- a/generated/PROPS_OVERVIEW.md +++ b/generated/PROPS_OVERVIEW.md @@ -295,6 +295,8 @@ export interface CadModelBase { } size?: { x: number | string; y: number | string; z: number | string } modelUnitToMmScale?: Distance + modelBoardNormalDirection?: CadModelAxisDirection + pcbRotationOffset?: number zOffsetFromSurface?: Distance showAsTranslucentModel?: boolean } diff --git a/lib/common/cadModel.ts b/lib/common/cadModel.ts index 905fff4..d7f28be 100644 --- a/lib/common/cadModel.ts +++ b/lib/common/cadModel.ts @@ -11,6 +11,19 @@ export const rotationPoint3 = z.object({ z: z.union([z.number(), z.string()]), }) +export const cadModelAxisDirections = [ + "x+", + "x-", + "y+", + "y-", + "z+", + "z-", +] as const + +export type CadModelAxisDirection = (typeof cadModelAxisDirections)[number] + +export const cadModelAxisDirection = z.enum(cadModelAxisDirections) + export interface CadModelBase { rotationOffset?: | number @@ -22,6 +35,8 @@ export interface CadModelBase { } size?: { x: number | string; y: number | string; z: number | string } modelUnitToMmScale?: Distance + modelBoardNormalDirection?: CadModelAxisDirection + pcbRotationOffset?: number zOffsetFromSurface?: Distance showAsTranslucentModel?: boolean } @@ -31,6 +46,8 @@ export const cadModelBase = z.object({ positionOffset: point3.optional(), size: point3.optional(), modelUnitToMmScale: distance.optional(), + modelBoardNormalDirection: cadModelAxisDirection.optional(), + pcbRotationOffset: z.number().optional(), zOffsetFromSurface: distance.optional(), showAsTranslucentModel: z.boolean().optional(), }) diff --git a/tests/cadmodel.test.ts b/tests/cadmodel.test.ts index 7fd48bc..2d8b53e 100644 --- a/tests/cadmodel.test.ts +++ b/tests/cadmodel.test.ts @@ -113,3 +113,19 @@ test("cadmodel accepts showAsTranslucentModel", () => { expect(parsed.showAsTranslucentModel).toBe(true) }) + +test("cadmodel accepts modelBoardNormalDirection and pcbRotationOffset", () => { + const raw: CadModelPropsInput = { + modelUrl: "https://example.com/model.stl", + modelBoardNormalDirection: "z+", + pcbRotationOffset: 90, + } + + const parsed = cadmodelProps.parse(raw) as Exclude< + CadModelPropsInput, + null | string + > + + expect(parsed.modelBoardNormalDirection).toBe("z+") + expect(parsed.pcbRotationOffset).toBe(90) +})